2
* Copyright © 2022 Imagination Technologies Ltd.
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:
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
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
24
#ifndef PVR_ROGUE_FWIF_SHARED_H
25
#define PVR_ROGUE_FWIF_SHARED_H
30
#define ALIGN(x) __attribute__((aligned(x)))
33
* Maximum number of UFOs in a CCB command.
34
* The number is based on having 32 sync prims (as originally), plus 32 sync
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.
41
#define ROGUE_FWIF_CCB_CMD_MAX_UFOS (32U + 32U)
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.
51
#define ROGUE_FWIF_DM_INDEPENDENT_KICK_CMD_SIZE (1024U)
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)
58
struct rogue_fwif_dev_addr {
62
struct rogue_fwif_dma_addr {
63
uint64_t ALIGN(8) dev_vaddr;
64
struct rogue_fwif_dev_addr fw_addr;
67
struct rogue_fwif_ufo {
68
struct rogue_fwif_dev_addr ufo_addr;
72
struct rogue_fwif_cleanup_ctl {
73
/** Number of commands received by the FW. */
74
uint32_t submitted_cmds;
76
/** Number of commands executed by the FW. */
77
uint32_t executed_cmds;
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.
85
* May be used to house Kick flags in the future.
87
struct rogue_fwif_cmd_common {
88
/** Associated frame number. */
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.
102
struct rogue_fwif_cmd_ta_3d_shared {
103
/** Common command attributes. */
104
struct rogue_fwif_cmd_common cmn;
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
111
struct rogue_fwif_dev_addr hw_rt_data;
113
/** Supported PR Buffers like Z/S/MSAA Scratch. */
114
struct rogue_fwif_dev_addr pr_buffers[ROGUE_FWIF_PRBUFFER_MAXSUPPORTED];
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:
124
* [..........|-1----------|=2===|=3===|=4===|~5~~~~|~6~~~~|~7~~~~|..........]
125
* < runnable commands >< !ready to run >
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.
131
struct rogue_fwif_cccb_ctl {
132
/** Host write offset into CCB. This must be aligned to 16 bytes. */
133
uint32_t write_offset;
136
* Firmware read offset into CCB. Points to the command that is runnable
139
uint32_t read_offset;
142
* Firmware fence dependency offset. Points to commands not ready, i.e.
143
* fence dependencies are not met.
147
/** Offset wrapping mask, total capacity in bytes of the CCB-1. */
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)
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;
162
uint64_t vdm_context_store_task0;
163
uint64_t vdm_context_store_task1;
164
uint64_t vdm_context_store_task2;
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;
171
uint64_t vdm_context_store_task3;
172
uint64_t vdm_context_store_task4;
174
uint64_t vdm_context_resume_task3;
175
uint64_t vdm_context_resume_task4;
179
#define ROGUE_FWIF_TAREGISTERS_CSWITCH_SIZE \
180
sizeof(struct rogue_fwif_taregisters_cswitch)
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;
189
/* CDM resume controls. */
190
uint64_t cdm_resume_pds0;
191
uint64_t cdm_context_pds0_b;
192
uint64_t cdm_resume_pds0_b;
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;
200
#define ROGUE_FWIF_STATIC_RENDERCONTEXT_SIZE \
201
sizeof(struct rogue_fwif_static_rendercontext_state)
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;
208
#define ROGUE_FWIF_STATIC_COMPUTECONTEXT_SIZE \
209
sizeof(struct rogue_fwif_static_computecontext_state)
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,
218
struct rogue_fwif_prbuffer {
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;
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,
247
struct rogue_context_reset_reason_data {
248
enum rogue_context_reset_reason reset_reason;
249
uint32_t reset_ext_job_ref;
252
#endif /* PVR_ROGUE_FWIF_SHARED_H */