Lines Matching +full:0 +full:xe
49 * @xe: xe device
55 bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe)
57 return GRAPHICS_VERx100(xe) < 1270 && !IS_DGFX(xe);
60 static u32 get_wopcm_size(struct xe_device *xe)
65 val = xe_mmio_read64_2x32(xe_root_tile_mmio(xe), STOLEN_RESERVED);
69 case 0x5 ... 0x6:
72 case 0x0 ... 0x3:
77 wopcm_size = 0;
83 static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
85 struct xe_tile *tile = xe_device_get_root_tile(xe);
86 struct xe_mmio *mmio = xe_root_tile_mmio(xe);
87 struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
92 tile_offset = tile->mem.vram.io_start - xe->mem.vram.io_start;
97 if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base))
98 return 0;
101 wopcm_size = get_wopcm_size(xe);
102 if (drm_WARN_ON(&xe->drm, !wopcm_size))
103 return 0;
121 static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
123 struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
124 struct xe_gt *media_gt = xe_device_get_root_tile(xe)->media_gt;
128 ggc = xe_mmio_read32(xe_root_tile_mmio(xe), GGC);
131 * Check GGMS: it should be fixed 0x3 (8MB), which corresponds to the
134 if (drm_WARN_ON(&xe->drm, (ggc & GGMS_MASK) != GGMS_MASK))
135 return 0;
150 case 0x0 ... 0x04:
153 case 0xf0 ... 0xfe:
154 stolen_size = (gms - 0xf0 + 1) * 4 * SZ_1M;
157 return 0;
161 wopcm_size = get_wopcm_size(xe);
162 if (drm_WARN_ON(&xe->drm, !wopcm_size))
163 return 0;
169 & ~GENMASK_ULL(5, 0);
188 if (drm_WARN_ON(&xe->drm, stolen_size + SZ_8M > pci_resource_len(pdev, 2)))
189 return 0;
196 static u64 detect_stolen(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
200 mgr->io_base = pci_resource_start(to_pci_dev(xe->drm.dev), 2);
206 return 0;
210 int xe_ttm_stolen_mgr_init(struct xe_device *xe)
212 struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
217 mgr = drmm_kzalloc(&xe->drm, sizeof(*mgr), GFP_KERNEL);
221 if (IS_SRIOV_VF(xe))
222 stolen_size = 0;
223 else if (IS_DGFX(xe))
224 stolen_size = detect_bar2_dgfx(xe, mgr);
225 else if (GRAPHICS_VERx100(xe) >= 1270)
226 stolen_size = detect_bar2_integrated(xe, mgr);
228 stolen_size = detect_stolen(xe, mgr);
231 drm_dbg_kms(&xe->drm, "No stolen memory support\n");
232 return 0;
240 io_size = 0;
241 if (mgr->io_base && !xe_ttm_stolen_cpu_access_needs_ggtt(xe))
244 err = __xe_ttm_vram_mgr_init(xe, &mgr->base, XE_PL_STOLEN, stolen_size,
247 drm_dbg_kms(&xe->drm, "Stolen mgr init failed: %i\n", err);
251 drm_dbg_kms(&xe->drm, "Initialized stolen memory support with %llu bytes\n",
257 return 0;
262 struct xe_device *xe = xe_bo_device(bo);
263 struct ttm_resource_manager *ttm_mgr = ttm_manager_type(&xe->ttm, XE_PL_STOLEN);
269 if (xe_ttm_stolen_cpu_access_needs_ggtt(xe))
276 static int __xe_ttm_stolen_io_mem_reserve_bar2(struct xe_device *xe,
285 xe_res_first(mem, 0, 4096, &cur);
288 drm_WARN_ON(&xe->drm, !(mem->placement & TTM_PL_FLAG_CONTIGUOUS));
297 return 0;
300 static int __xe_ttm_stolen_io_mem_reserve_stolen(struct xe_device *xe,
307 XE_WARN_ON(IS_DGFX(xe));
310 if (drm_WARN_ON(&xe->drm, !(bo->flags & XE_BO_FLAG_GGTT)))
319 return 0;
322 drm_WARN_ON(&xe->drm, 1);
327 int xe_ttm_stolen_io_mem_reserve(struct xe_device *xe, struct ttm_resource *mem)
329 struct ttm_resource_manager *ttm_mgr = ttm_manager_type(&xe->ttm, XE_PL_STOLEN);
335 if (xe_ttm_stolen_cpu_access_needs_ggtt(xe))
336 return __xe_ttm_stolen_io_mem_reserve_stolen(xe, mgr, mem);
338 return __xe_ttm_stolen_io_mem_reserve_bar2(xe, mgr, mem);
341 u64 xe_ttm_stolen_gpu_offset(struct xe_device *xe)
344 to_stolen_mgr(ttm_manager_type(&xe->ttm, XE_PL_STOLEN));