drm/xe: Document nested struct members according to guidelines
[linux-2.6-microblaze.git] / drivers / gpu / drm / xe / xe_gt_types.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022-2023 Intel Corporation
4  */
5
6 #ifndef _XE_GT_TYPES_H_
7 #define _XE_GT_TYPES_H_
8
9 #include "xe_force_wake_types.h"
10 #include "xe_gt_idle_types.h"
11 #include "xe_hw_engine_types.h"
12 #include "xe_hw_fence_types.h"
13 #include "xe_reg_sr_types.h"
14 #include "xe_sa_types.h"
15 #include "xe_uc_types.h"
16
17 struct xe_exec_queue_ops;
18 struct xe_migrate;
19 struct xe_ring_ops;
20
21 enum xe_gt_type {
22         XE_GT_TYPE_UNINITIALIZED,
23         XE_GT_TYPE_MAIN,
24         XE_GT_TYPE_MEDIA,
25 };
26
27 #define XE_MAX_DSS_FUSE_REGS    3
28 #define XE_MAX_EU_FUSE_REGS     1
29
30 typedef unsigned long xe_dss_mask_t[BITS_TO_LONGS(32 * XE_MAX_DSS_FUSE_REGS)];
31 typedef unsigned long xe_eu_mask_t[BITS_TO_LONGS(32 * XE_MAX_EU_FUSE_REGS)];
32
33 struct xe_mmio_range {
34         u32 start;
35         u32 end;
36 };
37
38 /*
39  * The hardware has multiple kinds of multicast register ranges that need
40  * special register steering (and future platforms are expected to add
41  * additional types).
42  *
43  * During driver startup, we initialize the steering control register to
44  * direct reads to a slice/subslice that are valid for the 'subslice' class
45  * of multicast registers.  If another type of steering does not have any
46  * overlap in valid steering targets with 'subslice' style registers, we will
47  * need to explicitly re-steer reads of registers of the other type.
48  *
49  * Only the replication types that may need additional non-default steering
50  * are listed here.
51  */
52 enum xe_steering_type {
53         L3BANK,
54         MSLICE,
55         LNCF,
56         DSS,
57         OADDRM,
58         SQIDI_PSMI,
59
60         /*
61          * On some platforms there are multiple types of MCR registers that
62          * will always return a non-terminated value at instance (0, 0).  We'll
63          * lump those all into a single category to keep things simple.
64          */
65         INSTANCE0,
66
67         /*
68          * Register ranges that don't need special steering for each register:
69          * it's sufficient to keep the HW-default for the selector, or only
70          * change it once, on GT initialization. This needs to be the last
71          * steering type.
72          */
73         IMPLICIT_STEERING,
74         NUM_STEERING_TYPES
75 };
76
77 #define gt_to_tile(gt__)                                                        \
78         _Generic(gt__,                                                          \
79                  const struct xe_gt * : (const struct xe_tile *)((gt__)->tile), \
80                  struct xe_gt * : (gt__)->tile)
81
82 #define gt_to_xe(gt__)                                                                          \
83         _Generic(gt__,                                                                          \
84                  const struct xe_gt * : (const struct xe_device *)(gt_to_tile(gt__)->xe),       \
85                  struct xe_gt * : gt_to_tile(gt__)->xe)
86
87 /**
88  * struct xe_gt - A "Graphics Technology" unit of the GPU
89  *
90  * A GT ("Graphics Technology") is the subset of a GPU primarily responsible
91  * for implementing the graphics, compute, and/or media IP.  It encapsulates
92  * the hardware engines, programmable execution units, and GuC.   Each GT has
93  * its own handling of power management (RC6+forcewake) and multicast register
94  * steering.
95  *
96  * A GPU/tile may have a single GT that supplies all graphics, compute, and
97  * media functionality, or the graphics/compute and media may be split into
98  * separate GTs within a tile.
99  */
100 struct xe_gt {
101         /** @tile: Backpointer to GT's tile */
102         struct xe_tile *tile;
103
104         /** @info: GT info */
105         struct {
106                 /** @info.type: type of GT */
107                 enum xe_gt_type type;
108                 /** @info.id: Unique ID of this GT within the PCI Device */
109                 u8 id;
110                 /** @info.reference_clock: clock frequency */
111                 u32 reference_clock;
112                 /** @info.engine_mask: mask of engines present on GT */
113                 u64 engine_mask;
114                 /**
115                  * @info.__engine_mask: mask of engines present on GT read from
116                  * xe_pci.c, used to fake reading the engine_mask from the
117                  * hwconfig blob.
118                  */
119                 u64 __engine_mask;
120         } info;
121
122         /**
123          * @mmio: mmio info for GT.  All GTs within a tile share the same
124          * register space, but have their own copy of GSI registers at a
125          * specific offset, as well as their own forcewake handling.
126          */
127         struct {
128                 /** @mmio.fw: force wake for GT */
129                 struct xe_force_wake fw;
130                 /**
131                  * @mmio.adj_limit: adjust MMIO address if address is below this
132                  * value
133                  */
134                 u32 adj_limit;
135                 /** @mmio.adj_offset: offect to add to MMIO address when adjusting */
136                 u32 adj_offset;
137         } mmio;
138
139         /**
140          * @reg_sr: table with registers to be restored on GT init/resume/reset
141          */
142         struct xe_reg_sr reg_sr;
143
144         /** @reset: state for GT resets */
145         struct {
146                 /**
147                  * @reset.worker: work so GT resets can done async allowing to reset
148                  * code to safely flush all code paths
149                  */
150                 struct work_struct worker;
151         } reset;
152
153         /** @tlb_invalidation: TLB invalidation state */
154         struct {
155                 /** @tlb_invalidation.seqno: TLB invalidation seqno, protected by CT lock */
156 #define TLB_INVALIDATION_SEQNO_MAX      0x100000
157                 int seqno;
158                 /**
159                  * @tlb_invalidation.seqno_recv: last received TLB invalidation seqno,
160                  * protected by CT lock
161                  */
162                 int seqno_recv;
163                 /**
164                  * @tlb_invalidation.pending_fences: list of pending fences waiting TLB
165                  * invaliations, protected by CT lock
166                  */
167                 struct list_head pending_fences;
168                 /**
169                  * @tlb_invalidation.pending_lock: protects @tlb_invalidation.pending_fences
170                  * and updating @tlb_invalidation.seqno_recv.
171                  */
172                 spinlock_t pending_lock;
173                 /**
174                  * @tlb_invalidation.fence_tdr: schedules a delayed call to
175                  * xe_gt_tlb_fence_timeout after the timeut interval is over.
176                  */
177                 struct delayed_work fence_tdr;
178                 /** @tlb_invalidation.fence_context: context for TLB invalidation fences */
179                 u64 fence_context;
180                 /**
181                  * @tlb_invalidation.fence_seqno: seqno to TLB invalidation fences, protected by
182                  * tlb_invalidation.lock
183                  */
184                 u32 fence_seqno;
185                 /** @tlb_invalidation.lock: protects TLB invalidation fences */
186                 spinlock_t lock;
187         } tlb_invalidation;
188
189         /**
190          * @ccs_mode: Number of compute engines enabled.
191          * Allows fixed mapping of available compute slices to compute engines.
192          * By default only the first available compute engine is enabled and all
193          * available compute slices are allocated to it.
194          */
195         u32 ccs_mode;
196
197         /** @usm: unified shared memory state */
198         struct {
199                 /**
200                  * @usm.bb_pool: Pool from which batchbuffers, for USM operations
201                  * (e.g. migrations, fixing page tables), are allocated.
202                  * Dedicated pool needed so USM operations to not get blocked
203                  * behind any user operations which may have resulted in a
204                  * fault.
205                  */
206                 struct xe_sa_manager *bb_pool;
207                 /**
208                  * @usm.reserved_bcs_instance: reserved BCS instance used for USM
209                  * operations (e.g. mmigrations, fixing page tables)
210                  */
211                 u16 reserved_bcs_instance;
212                 /** @usm.pf_wq: page fault work queue, unbound, high priority */
213                 struct workqueue_struct *pf_wq;
214                 /** @usm.acc_wq: access counter work queue, unbound, high priority */
215                 struct workqueue_struct *acc_wq;
216                 /**
217                  * @usm.pf_queue: Page fault queue used to sync faults so faults can
218                  * be processed not under the GuC CT lock. The queue is sized so
219                  * it can sync all possible faults (1 per physical engine).
220                  * Multiple queues exists for page faults from different VMs are
221                  * be processed in parallel.
222                  */
223                 struct pf_queue {
224                         /** @usm.pf_queue.gt: back pointer to GT */
225                         struct xe_gt *gt;
226 #define PF_QUEUE_NUM_DW 128
227                         /** @usm.pf_queue.data: data in the page fault queue */
228                         u32 data[PF_QUEUE_NUM_DW];
229                         /**
230                          * @usm.pf_queue.tail: tail pointer in DWs for page fault queue,
231                          * moved by worker which processes faults (consumer).
232                          */
233                         u16 tail;
234                         /**
235                          * @usm.pf_queue.head: head pointer in DWs for page fault queue,
236                          * moved by G2H handler (producer).
237                          */
238                         u16 head;
239                         /** @usm.pf_queue.lock: protects page fault queue */
240                         spinlock_t lock;
241                         /** @usm.pf_queue.worker: to process page faults */
242                         struct work_struct worker;
243 #define NUM_PF_QUEUE    4
244                 } pf_queue[NUM_PF_QUEUE];
245                 /**
246                  * @usm.acc_queue: Same as page fault queue, cannot process access
247                  * counters under CT lock.
248                  */
249                 struct acc_queue {
250                         /** @usm.acc_queue.gt: back pointer to GT */
251                         struct xe_gt *gt;
252 #define ACC_QUEUE_NUM_DW        128
253                         /** @usm.acc_queue.data: data in the page fault queue */
254                         u32 data[ACC_QUEUE_NUM_DW];
255                         /**
256                          * @usm.acc_queue.tail: tail pointer in DWs for access counter queue,
257                          * moved by worker which processes counters
258                          * (consumer).
259                          */
260                         u16 tail;
261                         /**
262                          * @usm.acc_queue.head: head pointer in DWs for access counter queue,
263                          * moved by G2H handler (producer).
264                          */
265                         u16 head;
266                         /** @usm.acc_queue.lock: protects page fault queue */
267                         spinlock_t lock;
268                         /** @usm.acc_queue.worker: to process access counters */
269                         struct work_struct worker;
270 #define NUM_ACC_QUEUE   4
271                 } acc_queue[NUM_ACC_QUEUE];
272         } usm;
273
274         /** @ordered_wq: used to serialize GT resets and TDRs */
275         struct workqueue_struct *ordered_wq;
276
277         /** @uc: micro controllers on the GT */
278         struct xe_uc uc;
279
280         /** @gtidle: idle properties of GT */
281         struct xe_gt_idle gtidle;
282
283         /** @exec_queue_ops: submission backend exec queue operations */
284         const struct xe_exec_queue_ops *exec_queue_ops;
285
286         /**
287          * @ring_ops: ring operations for this hw engine (1 per engine class)
288          */
289         const struct xe_ring_ops *ring_ops[XE_ENGINE_CLASS_MAX];
290
291         /** @fence_irq: fence IRQs (1 per engine class) */
292         struct xe_hw_fence_irq fence_irq[XE_ENGINE_CLASS_MAX];
293
294         /** @default_lrc: default LRC state */
295         void *default_lrc[XE_ENGINE_CLASS_MAX];
296
297         /** @hw_engines: hardware engines on the GT */
298         struct xe_hw_engine hw_engines[XE_NUM_HW_ENGINES];
299
300         /** @eclass: per hardware engine class interface on the GT */
301         struct xe_hw_engine_class_intf  eclass[XE_ENGINE_CLASS_MAX];
302
303         /** @pcode: GT's PCODE */
304         struct {
305                 /** @pcode.lock: protecting GT's PCODE mailbox data */
306                 struct mutex lock;
307         } pcode;
308
309         /** @sysfs: sysfs' kobj used by xe_gt_sysfs */
310         struct kobject *sysfs;
311
312         /** @freq: Main GT freq sysfs control */
313         struct kobject *freq;
314
315         /** @mocs: info */
316         struct {
317                 /** @mocs.uc_index: UC index */
318                 u8 uc_index;
319                 /** @mocs.wb_index: WB index, only used on L3_CCS platforms */
320                 u8 wb_index;
321         } mocs;
322
323         /** @fuse_topo: GT topology reported by fuse registers */
324         struct {
325                 /** @fuse_topo.g_dss_mask: dual-subslices usable by geometry */
326                 xe_dss_mask_t g_dss_mask;
327
328                 /** @fuse_topo.c_dss_mask: dual-subslices usable by compute */
329                 xe_dss_mask_t c_dss_mask;
330
331                 /** @fuse_topo.eu_mask_per_dss: EU mask per DSS*/
332                 xe_eu_mask_t eu_mask_per_dss;
333         } fuse_topo;
334
335         /** @steering: register steering for individual HW units */
336         struct {
337                 /** @steering.ranges: register ranges used for this steering type */
338                 const struct xe_mmio_range *ranges;
339
340                 /** @steering.group_target: target to steer accesses to */
341                 u16 group_target;
342                 /** @steering.instance_target: instance to steer accesses to */
343                 u16 instance_target;
344         } steering[NUM_STEERING_TYPES];
345
346         /**
347          * @mcr_lock: protects the MCR_SELECTOR register for the duration
348          *    of a steered operation
349          */
350         spinlock_t mcr_lock;
351
352         /** @wa_active: keep track of active workarounds */
353         struct {
354                 /** @wa_active.gt: bitmap with active GT workarounds */
355                 unsigned long *gt;
356                 /** @wa_active.engine: bitmap with active engine workarounds */
357                 unsigned long *engine;
358                 /** @wa_active.lrc: bitmap with active LRC workarounds */
359                 unsigned long *lrc;
360                 /** @wa_active.oob: bitmap with active OOB workaroudns */
361                 unsigned long *oob;
362         } wa_active;
363 };
364
365 #endif