~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/imagination/vulkan/winsys/pvrsrvkm/fw-api/pvr_rogue_fwif_shared.h

  • Committer: mmach
  • Date: 2022-09-22 19:58:36 UTC
  • Revision ID: netbit73@gmail.com-20220922195836-9nl9joew85y8d25o
2022-07-04 12:44:28

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2022 Imagination Technologies Ltd.
 
3
 *
 
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
5
 * of this software and associated documentation files (the "Software"), to deal
 
6
 * in the Software without restriction, including without limitation the rights
 
7
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
8
 * copies of the Software, and to permit persons to whom the Software is
 
9
 * furnished to do so, subject to the following conditions:
 
10
 *
 
11
 * The above copyright notice and this permission notice (including the next
 
12
 * paragraph) shall be included in all copies or substantial portions of the
 
13
 * Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
21
 * SOFTWARE.
 
22
 */
 
23
 
 
24
#ifndef PVR_ROGUE_FWIF_SHARED_H
 
25
#define PVR_ROGUE_FWIF_SHARED_H
 
26
 
 
27
#include <stdbool.h>
 
28
#include <stdint.h>
 
29
 
 
30
#define ALIGN(x) __attribute__((aligned(x)))
 
31
 
 
32
/**
 
33
 * Maximum number of UFOs in a CCB command.
 
34
 * The number is based on having 32 sync prims (as originally), plus 32 sync
 
35
 * checkpoints.
 
36
 * Once the use of sync prims is no longer supported, we will retain
 
37
 * the same total (64) as the number of sync checkpoints which may be
 
38
 * supporting a fence is not visible to the client driver and has to
 
39
 * allow for the number of different timelines involved in fence merges.
 
40
 */
 
41
#define ROGUE_FWIF_CCB_CMD_MAX_UFOS (32U + 32U)
 
42
 
 
43
/**
 
44
 * This is a generic limit imposed on any DM (TA,3D,CDM,TDM,2D,TRANSFER)
 
45
 * command passed through the bridge.
 
46
 * Just across the bridge in the server, any incoming kick command size is
 
47
 * checked against this maximum limit.
 
48
 * In case the incoming command size is larger than the specified limit,
 
49
 * the bridge call is retired with error.
 
50
 */
 
51
#define ROGUE_FWIF_DM_INDEPENDENT_KICK_CMD_SIZE (1024U)
 
52
 
 
53
#define ROGUE_FWIF_PRBUFFER_START (0)
 
54
#define ROGUE_FWIF_PRBUFFER_ZSBUFFER (0)
 
55
#define ROGUE_FWIF_PRBUFFER_MSAABUFFER (1)
 
56
#define ROGUE_FWIF_PRBUFFER_MAXSUPPORTED (2)
 
57
 
 
58
struct rogue_fwif_dev_addr {
 
59
   uint32_t addr;
 
60
};
 
61
 
 
62
struct rogue_fwif_dma_addr {
 
63
   uint64_t ALIGN(8) dev_vaddr;
 
64
   struct rogue_fwif_dev_addr fw_addr;
 
65
} ALIGN(8);
 
66
 
 
67
struct rogue_fwif_ufo {
 
68
   struct rogue_fwif_dev_addr ufo_addr;
 
69
   uint32_t value;
 
70
};
 
71
 
 
72
struct rogue_fwif_cleanup_ctl {
 
73
   /** Number of commands received by the FW. */
 
74
   uint32_t submitted_cmds;
 
75
 
 
76
   /** Number of commands executed by the FW. */
 
77
   uint32_t executed_cmds;
 
78
} ALIGN(8);
 
79
 
 
80
/**
 
81
 * Used to share frame numbers across UM-KM-FW,
 
82
 * frame number is set in UM,
 
83
 * frame number is required in both KM for HTB and FW for FW trace.
 
84
 *
 
85
 * May be used to house Kick flags in the future.
 
86
 */
 
87
struct rogue_fwif_cmd_common {
 
88
   /** Associated frame number. */
 
89
   uint32_t frame_num;
 
90
};
 
91
 
 
92
/**
 
93
 * TA and 3D commands require set of firmware addresses that are stored in the
 
94
 * Kernel. Client has handle(s) to Kernel containers storing these addresses,
 
95
 * instead of raw addresses. We have to patch/write these addresses in KM to
 
96
 * prevent UM from controlling FW addresses directly.
 
97
 * Structures for TA and 3D commands are shared between Client and Firmware
 
98
 * (both single-BVNC). Kernel is implemented in a multi-BVNC manner, so it can't
 
99
 * use TA|3D CMD type definitions directly. Therefore we have a SHARED block
 
100
 * that is shared between UM-KM-FW across all BVNC configurations.
 
101
 */
 
102
struct rogue_fwif_cmd_ta_3d_shared {
 
103
   /** Common command attributes. */
 
104
   struct rogue_fwif_cmd_common cmn;
 
105
 
 
106
   /**
 
107
    * RTData associated with this command, this is used for context
 
108
    * selection and for storing out HW-context, when TA is switched out for
 
109
    * continuing later.
 
110
    */
 
111
   struct rogue_fwif_dev_addr hw_rt_data;
 
112
 
 
113
   /** Supported PR Buffers like Z/S/MSAA Scratch. */
 
114
   struct rogue_fwif_dev_addr pr_buffers[ROGUE_FWIF_PRBUFFER_MAXSUPPORTED];
 
115
};
 
116
 
 
117
/**
 
118
 * Client Circular Command Buffer (CCCB) control structure.
 
119
 * This is shared between the KM driver and the Firmware and holds byte offsets
 
120
 * into the CCCB as well as the wrapping mask to aid wrap around. A given
 
121
 * snapshot of this queue with Cmd 1 running on the GPU might be:
 
122
 *
 
123
 *          Roff                           Doff                 Woff
 
124
 * [..........|-1----------|=2===|=3===|=4===|~5~~~~|~6~~~~|~7~~~~|..........]
 
125
 *            <      runnable commands       ><   !ready to run   >
 
126
 *
 
127
 * Cmd 1    : Currently executing on the GPU data master.
 
128
 * Cmd 2,3,4: Fence dependencies met, commands runnable.
 
129
 * Cmd 5... : Fence dependency not met yet.
 
130
 */
 
131
struct rogue_fwif_cccb_ctl {
 
132
   /** Host write offset into CCB. This must be aligned to 16 bytes. */
 
133
   uint32_t write_offset;
 
134
 
 
135
   /**
 
136
    * Firmware read offset into CCB. Points to the command that is runnable
 
137
    * on GPU, if R!=W.
 
138
    */
 
139
   uint32_t read_offset;
 
140
 
 
141
   /**
 
142
    * Firmware fence dependency offset. Points to commands not ready, i.e.
 
143
    * fence dependencies are not met.
 
144
    */
 
145
   uint32_t dep_offset;
 
146
 
 
147
   /** Offset wrapping mask, total capacity in bytes of the CCB-1. */
 
148
   uint32_t wrap_mask;
 
149
} ALIGN(8);
 
150
 
 
151
#define ROGUE_FW_LOCAL_FREELIST 0U
 
152
#define ROGUE_FW_GLOBAL_FREELIST 1U
 
153
#define ROGUE_FW_FREELIST_TYPE_LAST ROGUE_FW_GLOBAL_FREELIST
 
154
#define ROGUE_FW_MAX_FREELISTS (ROGUE_FW_FREELIST_TYPE_LAST + 1U)
 
155
 
 
156
struct rogue_fwif_ta_regs_cswitch {
 
157
   uint64_t vdm_context_state_base_addr;
 
158
   uint64_t vdm_context_state_resume_addr;
 
159
   uint64_t ta_context_state_base_addr;
 
160
 
 
161
   struct {
 
162
      uint64_t vdm_context_store_task0;
 
163
      uint64_t vdm_context_store_task1;
 
164
      uint64_t vdm_context_store_task2;
 
165
 
 
166
      /* VDM resume state update controls. */
 
167
      uint64_t vdm_context_resume_task0;
 
168
      uint64_t vdm_context_resume_task1;
 
169
      uint64_t vdm_context_resume_task2;
 
170
 
 
171
      uint64_t vdm_context_store_task3;
 
172
      uint64_t vdm_context_store_task4;
 
173
 
 
174
      uint64_t vdm_context_resume_task3;
 
175
      uint64_t vdm_context_resume_task4;
 
176
   } ta_state[2];
 
177
};
 
178
 
 
179
#define ROGUE_FWIF_TAREGISTERS_CSWITCH_SIZE \
 
180
   sizeof(struct rogue_fwif_taregisters_cswitch)
 
181
 
 
182
struct rogue_fwif_cdm_regs_cswitch {
 
183
   uint64_t cdm_context_state_base_addr;
 
184
   uint64_t cdm_context_pds0;
 
185
   uint64_t cdm_context_pds1;
 
186
   uint64_t cdm_terminate_pds;
 
187
   uint64_t cdm_terminate_pds1;
 
188
 
 
189
   /* CDM resume controls. */
 
190
   uint64_t cdm_resume_pds0;
 
191
   uint64_t cdm_context_pds0_b;
 
192
   uint64_t cdm_resume_pds0_b;
 
193
};
 
194
 
 
195
struct rogue_fwif_static_rendercontext_state {
 
196
   /** Geom registers for ctx switch. */
 
197
   struct rogue_fwif_ta_regs_cswitch ALIGN(8) ctx_switch_regs;
 
198
};
 
199
 
 
200
#define ROGUE_FWIF_STATIC_RENDERCONTEXT_SIZE \
 
201
   sizeof(struct rogue_fwif_static_rendercontext_state)
 
202
 
 
203
struct rogue_fwif_static_computecontext_state {
 
204
   /** CDM registers for ctx switch. */
 
205
   struct rogue_fwif_cdm_regs_cswitch ALIGN(8) ctx_switch_regs;
 
206
};
 
207
 
 
208
#define ROGUE_FWIF_STATIC_COMPUTECONTEXT_SIZE \
 
209
   sizeof(struct rogue_fwif_static_computecontext_state)
 
210
 
 
211
enum rogue_fwif_prbuffer_state {
 
212
   ROGUE_FWIF_PRBUFFER_UNBACKED = 0,
 
213
   ROGUE_FWIF_PRBUFFER_BACKED,
 
214
   ROGUE_FWIF_PRBUFFER_BACKING_PENDING,
 
215
   ROGUE_FWIF_PRBUFFER_UNBACKING_PENDING,
 
216
};
 
217
 
 
218
struct rogue_fwif_prbuffer {
 
219
   /** Buffer ID. */
 
220
   uint32_t buffer_id;
 
221
   /** Needs On-demand Z/S/MSAA Buffer allocation. */
 
222
   bool ALIGN(4) on_demand;
 
223
   /** Z/S/MSAA -Buffer state. */
 
224
   enum rogue_fwif_prbuffer_state state;
 
225
   /** Cleanup state. */
 
226
   struct rogue_fwif_cleanup_ctl cleanup_state;
 
227
   /** Compatibility and other flags. */
 
228
   uint32_t pr_buffer_flags;
 
229
} ALIGN(8);
 
230
 
 
231
/* Last reset reason for a context. */
 
232
enum rogue_context_reset_reason {
 
233
   /** No reset reason recorded. */
 
234
   ROGUE_CONTEXT_RESET_REASON_NONE = 0,
 
235
   /** Caused a reset due to locking up. */
 
236
   ROGUE_CONTEXT_RESET_REASON_GUILTY_LOCKUP = 1,
 
237
   /** Affected by another context locking up. */
 
238
   ROGUE_CONTEXT_RESET_REASON_INNOCENT_LOCKUP = 2,
 
239
   /** Overran the global deadline. */
 
240
   ROGUE_CONTEXT_RESET_REASON_GUILTY_OVERRUNING = 3,
 
241
   /** Affected by another context overrunning. */
 
242
   ROGUE_CONTEXT_RESET_REASON_INNOCENT_OVERRUNING = 4,
 
243
   /** Forced reset to ensure scheduling requirements. */
 
244
   ROGUE_CONTEXT_RESET_REASON_HARD_CONTEXT_SWITCH = 5,
 
245
};
 
246
 
 
247
struct rogue_context_reset_reason_data {
 
248
   enum rogue_context_reset_reason reset_reason;
 
249
   uint32_t reset_ext_job_ref;
 
250
};
 
251
 
 
252
#endif /* PVR_ROGUE_FWIF_SHARED_H */