1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2022-2023 Intel Corporation
6 #ifndef _XE_DEVICE_TYPES_H_
7 #define _XE_DEVICE_TYPES_H_
11 #include <drm/drm_device.h>
12 #include <drm/drm_file.h>
13 #include <drm/ttm/ttm_device.h>
15 #include "xe_devcoredump_types.h"
16 #include "xe_gt_types.h"
17 #include "xe_platform_types.h"
18 #include "xe_step_types.h"
22 #define XE_BO_INVALID_OFFSET LONG_MAX
24 #define GRAPHICS_VER(xe) ((xe)->info.graphics_verx100 / 100)
25 #define MEDIA_VER(xe) ((xe)->info.media_verx100 / 100)
26 #define GRAPHICS_VERx100(xe) ((xe)->info.graphics_verx100)
27 #define MEDIA_VERx100(xe) ((xe)->info.media_verx100)
28 #define IS_DGFX(xe) ((xe)->info.is_dgfx)
30 #define XE_VRAM_FLAGS_NEED64K BIT(0)
34 #define XE_MAX_TILES_PER_DEVICE (XE_GT1 + 1)
36 #define XE_MAX_ASID (BIT(20))
38 #define IS_PLATFORM_STEP(_xe, _platform, min_step, max_step) \
39 ((_xe)->info.platform == (_platform) && \
40 (_xe)->info.step.graphics >= (min_step) && \
41 (_xe)->info.step.graphics < (max_step))
42 #define IS_SUBPLATFORM_STEP(_xe, _platform, sub, min_step, max_step) \
43 ((_xe)->info.platform == (_platform) && \
44 (_xe)->info.subplatform == (sub) && \
45 (_xe)->info.step.graphics >= (min_step) && \
46 (_xe)->info.step.graphics < (max_step))
48 #define tile_to_xe(tile__) \
50 const struct xe_tile *: (const struct xe_device *)((tile__)->xe), \
51 struct xe_tile *: (tile__)->xe)
54 * struct xe_tile - hardware tile structure
56 * From a driver perspective, a "tile" is effectively a complete GPU, containing
57 * an SGunit, 1-2 GTs, and (for discrete platforms) VRAM.
59 * Multi-tile platforms effectively bundle multiple GPUs behind a single PCI
60 * device and designate one "root" tile as being responsible for external PCI
61 * communication. PCI BAR0 exposes the GGTT and MMIO register space for each
62 * tile in a stacked layout, and PCI BAR2 exposes the local memory associated
63 * with each tile similarly. Device-wide interrupts can be enabled/disabled
64 * at the root tile, and the MSTR_TILE_INTR register will report which tiles
65 * have interrupts that need servicing.
68 /** @xe: Backpointer to tile's PCI device */
71 /** @id: ID of the tile */
75 * @primary_gt: Primary GT
77 struct xe_gt primary_gt;
79 /* TODO: Add media GT here */
82 * @mmio: MMIO info for a tile.
84 * Each tile has its own 16MB space in BAR0, laid out as:
87 * * 8MB-16MB: global GTT
90 /** @size: size of tile's MMIO space */
93 /** @regs: pointer to tile's MMIO space (starting with registers) */
97 /** @mem: memory management info for tile */
100 * @vram: VRAM info for tile.
102 * Although VRAM is associated with a specific tile, it can
103 * still be accessed by all tiles' GTs.
106 /** @io_start: IO start address of this VRAM instance */
107 resource_size_t io_start;
109 * @io_size: IO size of this VRAM instance
111 * This represents how much of this VRAM we can access
112 * via the CPU through the VRAM BAR. This can be smaller
113 * than @size, in which case only part of VRAM is CPU
114 * accessible (typically the first 256M). This
115 * configuration is known as small-bar.
117 resource_size_t io_size;
118 /** @base: offset of VRAM starting base */
119 resource_size_t base;
120 /** @size: size of VRAM. */
121 resource_size_t size;
122 /** @mapping: pointer to VRAM mappable space */
123 void *__iomem mapping;
126 /** @vram_mgr: VRAM TTM manager */
127 struct xe_ttm_vram_mgr *vram_mgr;
129 /** @ggtt: Global graphics translation table */
130 struct xe_ggtt *ggtt;
133 * @kernel_bb_pool: Pool from which batchbuffers are allocated.
135 * Media GT shares a pool with its primary GT.
137 struct xe_sa_manager *kernel_bb_pool;
140 /** @migrate: Migration helper for vram blits and clearing */
141 struct xe_migrate *migrate;
145 * struct xe_device - Top level struct of XE device
148 /** @drm: drm device */
149 struct drm_device drm;
151 /** @devcoredump: device coredump */
152 struct xe_devcoredump devcoredump;
154 /** @info: device info */
155 struct intel_device_info {
156 /** @graphics_name: graphics IP name */
157 const char *graphics_name;
158 /** @media_name: media IP name */
159 const char *media_name;
160 /** @graphics_verx100: graphics IP version */
161 u32 graphics_verx100;
162 /** @media_verx100: media IP version */
164 /** @mem_region_mask: mask of valid memory regions */
166 /** @platform: XE platform enum */
167 enum xe_platform platform;
168 /** @subplatform: XE subplatform enum */
169 enum xe_subplatform subplatform;
170 /** @devid: device ID */
172 /** @revid: device revision */
174 /** @step: stepping information for each IP */
175 struct xe_step_info step;
176 /** @dma_mask_size: DMA address bits */
178 /** @vram_flags: Vram flags */
180 /** @tile_count: Number of tiles */
182 /** @vm_max_level: Max VM level */
185 /** @is_dgfx: is discrete device */
187 /** @supports_usm: Supports unified shared memory */
189 /** @has_asid: Has address space ID */
191 /** @enable_guc: GuC submission enabled */
193 /** @has_flat_ccs: Whether flat CCS metadata is used */
195 /** @has_4tile: Whether tile-4 tiling is supported */
197 /** @has_llc: Device has a shared CPU+GPU last level cache */
199 /** @has_range_tlb_invalidation: Has range based TLB invalidations */
200 u8 has_range_tlb_invalidation:1;
201 /** @has_link_copy_engines: Whether the platform has link copy engines */
202 u8 has_link_copy_engine:1;
205 /** @irq: device interrupt state */
207 /** @lock: lock for processing irq's on this device */
210 /** @enabled: interrupts enabled on this device */
214 /** @ttm: ttm device */
215 struct ttm_device ttm;
217 /** @mmio: mmio info for device */
219 /** @size: size of MMIO space for device */
221 /** @regs: pointer to MMIO space for device */
225 /** @mem: memory info for device */
227 /** @vram: VRAM info for device */
229 /** @io_start: IO start address of VRAM */
230 resource_size_t io_start;
232 * @io_size: IO size of VRAM.
234 * This represents how much of VRAM the CPU can access
236 * On systems that do not support large BAR IO space,
237 * this can be smaller than the actual memory size, in
238 * which case only part of VRAM is CPU accessible
239 * (typically the first 256M). This configuration is
240 * known as small-bar.
242 resource_size_t io_size;
243 /** @size: Total size of VRAM */
244 resource_size_t size;
245 /** @base: Offset to apply for Device Physical Address control */
246 resource_size_t base;
247 /** @mapping: pointer to VRAM mappable space */
248 void *__iomem mapping;
250 /** @sys_mgr: system TTM manager */
251 struct ttm_resource_manager sys_mgr;
254 /** @usm: unified memory state */
256 /** @asid: convert a ASID to VM */
257 struct xarray asid_to_vm;
258 /** @next_asid: next ASID, used to cyclical alloc asids */
260 /** @num_vm_in_fault_mode: number of VM in fault mode */
261 u32 num_vm_in_fault_mode;
262 /** @num_vm_in_non_fault_mode: number of VM in non-fault mode */
263 u32 num_vm_in_non_fault_mode;
264 /** @lock: protects UM state */
268 /** @persistent_engines: engines that are closed but still running */
270 /** @lock: protects persistent engines */
272 /** @list: list of persistent engines */
273 struct list_head list;
274 } persistent_engines;
276 /** @pinned: pinned BO state */
278 /** @lock: protected pinned BO list state */
280 /** @evicted: pinned kernel BO that are present */
281 struct list_head kernel_bo_present;
282 /** @evicted: pinned BO that have been evicted */
283 struct list_head evicted;
284 /** @external_vram: pinned external BO in vram*/
285 struct list_head external_vram;
288 /** @ufence_wq: user fence wait queue */
289 wait_queue_head_t ufence_wq;
291 /** @ordered_wq: used to serialize compute mode resume */
292 struct workqueue_struct *ordered_wq;
294 /** @tiles: device tiles */
295 struct xe_tile tiles[XE_MAX_TILES_PER_DEVICE];
298 * @mem_access: keep track of memory access in the device, possibly
299 * triggering additional actions when they occur.
302 /** @ref: ref count of memory accesses */
304 /** @hold_rpm: need to put rpm ref back at the end */
308 /** @d3cold_allowed: Indicates if d3cold is a valid device state */
312 struct mutex sb_lock;
314 u32 enabled_irq_mask;
318 * struct xe_file - file handle for XE driver
321 /** @drm: base DRM file */
322 struct drm_file *drm;
324 /** @vm: VM state for file */
326 /** @xe: xarray to store VMs */
328 /** @lock: protects file VM state */
332 /** @engine: Submission engine state for file */
334 /** @xe: xarray to store engines */
336 /** @lock: protects file engine state */