1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2022-2023 Intel Corporation
6 #ifndef _XE_GT_TYPES_H_
7 #define _XE_GT_TYPES_H_
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"
17 struct xe_exec_queue_ops;
22 XE_GT_TYPE_UNINITIALIZED,
27 #define XE_MAX_DSS_FUSE_REGS 3
28 #define XE_MAX_EU_FUSE_REGS 1
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)];
33 struct xe_mmio_range {
39 * The hardware has multiple kinds of multicast register ranges that need
40 * special register steering (and future platforms are expected to add
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.
49 * Only the replication types that may need additional non-default steering
52 enum xe_steering_type {
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.
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
77 #define gt_to_tile(gt__) \
79 const struct xe_gt * : (const struct xe_tile *)((gt__)->tile), \
80 struct xe_gt * : (gt__)->tile)
82 #define gt_to_xe(gt__) \
84 const struct xe_gt * : (const struct xe_device *)(gt_to_tile(gt__)->xe), \
85 struct xe_gt * : gt_to_tile(gt__)->xe)
88 * struct xe_gt - A "Graphics Technology" unit of the GPU
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
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.
101 /** @tile: Backpointer to GT's tile */
102 struct xe_tile *tile;
104 /** @info: GT info */
106 /** @info.type: type of GT */
107 enum xe_gt_type type;
108 /** @info.id: Unique ID of this GT within the PCI Device */
110 /** @info.reference_clock: clock frequency */
112 /** @info.engine_mask: mask of engines present on GT */
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
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.
128 /** @mmio.fw: force wake for GT */
129 struct xe_force_wake fw;
131 * @mmio.adj_limit: adjust MMIO address if address is below this
135 /** @mmio.adj_offset: offect to add to MMIO address when adjusting */
140 * @reg_sr: table with registers to be restored on GT init/resume/reset
142 struct xe_reg_sr reg_sr;
144 /** @reset: state for GT resets */
147 * @reset.worker: work so GT resets can done async allowing to reset
148 * code to safely flush all code paths
150 struct work_struct worker;
153 /** @tlb_invalidation: TLB invalidation state */
155 /** @tlb_invalidation.seqno: TLB invalidation seqno, protected by CT lock */
156 #define TLB_INVALIDATION_SEQNO_MAX 0x100000
159 * @tlb_invalidation.seqno_recv: last received TLB invalidation seqno,
160 * protected by CT lock
164 * @tlb_invalidation.pending_fences: list of pending fences waiting TLB
165 * invaliations, protected by CT lock
167 struct list_head pending_fences;
169 * @tlb_invalidation.pending_lock: protects @tlb_invalidation.pending_fences
170 * and updating @tlb_invalidation.seqno_recv.
172 spinlock_t pending_lock;
174 * @tlb_invalidation.fence_tdr: schedules a delayed call to
175 * xe_gt_tlb_fence_timeout after the timeut interval is over.
177 struct delayed_work fence_tdr;
178 /** @tlb_invalidation.fence_context: context for TLB invalidation fences */
181 * @tlb_invalidation.fence_seqno: seqno to TLB invalidation fences, protected by
182 * tlb_invalidation.lock
185 /** @tlb_invalidation.lock: protects TLB invalidation fences */
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.
197 /** @usm: unified shared memory state */
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
206 struct xe_sa_manager *bb_pool;
208 * @usm.reserved_bcs_instance: reserved BCS instance used for USM
209 * operations (e.g. mmigrations, fixing page tables)
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;
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.
224 /** @usm.pf_queue.gt: back pointer to 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];
230 * @usm.pf_queue.tail: tail pointer in DWs for page fault queue,
231 * moved by worker which processes faults (consumer).
235 * @usm.pf_queue.head: head pointer in DWs for page fault queue,
236 * moved by G2H handler (producer).
239 /** @usm.pf_queue.lock: protects page fault queue */
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];
246 * @usm.acc_queue: Same as page fault queue, cannot process access
247 * counters under CT lock.
250 /** @usm.acc_queue.gt: back pointer to 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];
256 * @usm.acc_queue.tail: tail pointer in DWs for access counter queue,
257 * moved by worker which processes counters
262 * @usm.acc_queue.head: head pointer in DWs for access counter queue,
263 * moved by G2H handler (producer).
266 /** @usm.acc_queue.lock: protects page fault queue */
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];
274 /** @ordered_wq: used to serialize GT resets and TDRs */
275 struct workqueue_struct *ordered_wq;
277 /** @uc: micro controllers on the GT */
280 /** @gtidle: idle properties of GT */
281 struct xe_gt_idle gtidle;
283 /** @exec_queue_ops: submission backend exec queue operations */
284 const struct xe_exec_queue_ops *exec_queue_ops;
287 * @ring_ops: ring operations for this hw engine (1 per engine class)
289 const struct xe_ring_ops *ring_ops[XE_ENGINE_CLASS_MAX];
291 /** @fence_irq: fence IRQs (1 per engine class) */
292 struct xe_hw_fence_irq fence_irq[XE_ENGINE_CLASS_MAX];
294 /** @default_lrc: default LRC state */
295 void *default_lrc[XE_ENGINE_CLASS_MAX];
297 /** @hw_engines: hardware engines on the GT */
298 struct xe_hw_engine hw_engines[XE_NUM_HW_ENGINES];
300 /** @eclass: per hardware engine class interface on the GT */
301 struct xe_hw_engine_class_intf eclass[XE_ENGINE_CLASS_MAX];
303 /** @pcode: GT's PCODE */
305 /** @pcode.lock: protecting GT's PCODE mailbox data */
309 /** @sysfs: sysfs' kobj used by xe_gt_sysfs */
310 struct kobject *sysfs;
312 /** @freq: Main GT freq sysfs control */
313 struct kobject *freq;
317 /** @mocs.uc_index: UC index */
319 /** @mocs.wb_index: WB index, only used on L3_CCS platforms */
323 /** @fuse_topo: GT topology reported by fuse registers */
325 /** @fuse_topo.g_dss_mask: dual-subslices usable by geometry */
326 xe_dss_mask_t g_dss_mask;
328 /** @fuse_topo.c_dss_mask: dual-subslices usable by compute */
329 xe_dss_mask_t c_dss_mask;
331 /** @fuse_topo.eu_mask_per_dss: EU mask per DSS*/
332 xe_eu_mask_t eu_mask_per_dss;
335 /** @steering: register steering for individual HW units */
337 /** @steering.ranges: register ranges used for this steering type */
338 const struct xe_mmio_range *ranges;
340 /** @steering.group_target: target to steer accesses to */
342 /** @steering.instance_target: instance to steer accesses to */
344 } steering[NUM_STEERING_TYPES];
347 * @mcr_lock: protects the MCR_SELECTOR register for the duration
348 * of a steered operation
352 /** @wa_active: keep track of active workarounds */
354 /** @wa_active.gt: bitmap with active GT workarounds */
356 /** @wa_active.engine: bitmap with active engine workarounds */
357 unsigned long *engine;
358 /** @wa_active.lrc: bitmap with active LRC workarounds */
360 /** @wa_active.oob: bitmap with active OOB workaroudns */