Lines Matching +full:0 +full:xe
49 * @xe: xe device
55 bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe) in xe_ttm_stolen_cpu_access_needs_ggtt() argument
57 return GRAPHICS_VERx100(xe) < 1270 && !IS_DGFX(xe); in xe_ttm_stolen_cpu_access_needs_ggtt()
60 static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr) in detect_bar2_dgfx() argument
62 struct xe_tile *tile = xe_device_get_root_tile(xe); in detect_bar2_dgfx()
63 struct xe_gt *mmio = xe_root_mmio_gt(xe); in detect_bar2_dgfx()
64 struct pci_dev *pdev = to_pci_dev(xe->drm.dev); in detect_bar2_dgfx()
69 tile_offset = tile->mem.vram.io_start - xe->mem.vram.io_start; in detect_bar2_dgfx()
74 if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base)) in detect_bar2_dgfx()
75 return 0; in detect_bar2_dgfx()
92 static u32 get_wopcm_size(struct xe_device *xe) in get_wopcm_size() argument
97 val = xe_mmio_read64_2x32(xe_root_mmio_gt(xe), STOLEN_RESERVED); in get_wopcm_size()
101 case 0x5 ... 0x6: in get_wopcm_size()
104 case 0x0 ... 0x3: in get_wopcm_size()
109 wopcm_size = 0; in get_wopcm_size()
115 static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr) in detect_bar2_integrated() argument
117 struct pci_dev *pdev = to_pci_dev(xe->drm.dev); in detect_bar2_integrated()
118 struct xe_gt *media_gt = xe_device_get_root_tile(xe)->media_gt; in detect_bar2_integrated()
122 ggc = xe_mmio_read32(xe_root_mmio_gt(xe), GGC); in detect_bar2_integrated()
125 * Check GGMS: it should be fixed 0x3 (8MB), which corresponds to the in detect_bar2_integrated()
128 if (drm_WARN_ON(&xe->drm, (ggc & GGMS_MASK) != GGMS_MASK)) in detect_bar2_integrated()
129 return 0; in detect_bar2_integrated()
144 case 0x0 ... 0x04: in detect_bar2_integrated()
147 case 0xf0 ... 0xfe: in detect_bar2_integrated()
148 stolen_size = (gms - 0xf0 + 1) * 4 * SZ_1M; in detect_bar2_integrated()
151 return 0; in detect_bar2_integrated()
155 wopcm_size = get_wopcm_size(xe); in detect_bar2_integrated()
156 if (drm_WARN_ON(&xe->drm, !wopcm_size)) in detect_bar2_integrated()
157 return 0; in detect_bar2_integrated()
163 & ~GENMASK_ULL(5, 0); in detect_bar2_integrated()
182 if (drm_WARN_ON(&xe->drm, stolen_size + SZ_8M > pci_resource_len(pdev, 2))) in detect_bar2_integrated()
183 return 0; in detect_bar2_integrated()
190 static u64 detect_stolen(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr) in detect_stolen() argument
194 mgr->io_base = pci_resource_start(to_pci_dev(xe->drm.dev), 2); in detect_stolen()
200 return 0; in detect_stolen()
204 void xe_ttm_stolen_mgr_init(struct xe_device *xe) in xe_ttm_stolen_mgr_init() argument
206 struct xe_ttm_stolen_mgr *mgr = drmm_kzalloc(&xe->drm, sizeof(*mgr), GFP_KERNEL); in xe_ttm_stolen_mgr_init()
207 struct pci_dev *pdev = to_pci_dev(xe->drm.dev); in xe_ttm_stolen_mgr_init()
212 drm_dbg_kms(&xe->drm, "Stolen mgr init failed\n"); in xe_ttm_stolen_mgr_init()
216 if (IS_SRIOV_VF(xe)) in xe_ttm_stolen_mgr_init()
217 stolen_size = 0; in xe_ttm_stolen_mgr_init()
218 else if (IS_DGFX(xe)) in xe_ttm_stolen_mgr_init()
219 stolen_size = detect_bar2_dgfx(xe, mgr); in xe_ttm_stolen_mgr_init()
220 else if (GRAPHICS_VERx100(xe) >= 1270) in xe_ttm_stolen_mgr_init()
221 stolen_size = detect_bar2_integrated(xe, mgr); in xe_ttm_stolen_mgr_init()
223 stolen_size = detect_stolen(xe, mgr); in xe_ttm_stolen_mgr_init()
226 drm_dbg_kms(&xe->drm, "No stolen memory support\n"); in xe_ttm_stolen_mgr_init()
235 io_size = 0; in xe_ttm_stolen_mgr_init()
236 if (mgr->io_base && !xe_ttm_stolen_cpu_access_needs_ggtt(xe)) in xe_ttm_stolen_mgr_init()
239 err = __xe_ttm_vram_mgr_init(xe, &mgr->base, XE_PL_STOLEN, stolen_size, in xe_ttm_stolen_mgr_init()
242 drm_dbg_kms(&xe->drm, "Stolen mgr init failed: %i\n", err); in xe_ttm_stolen_mgr_init()
246 drm_dbg_kms(&xe->drm, "Initialized stolen memory support with %llu bytes\n", in xe_ttm_stolen_mgr_init()
255 struct xe_device *xe = xe_bo_device(bo); in xe_ttm_stolen_io_offset() local
256 struct ttm_resource_manager *ttm_mgr = ttm_manager_type(&xe->ttm, XE_PL_STOLEN); in xe_ttm_stolen_io_offset()
262 if (xe_ttm_stolen_cpu_access_needs_ggtt(xe)) in xe_ttm_stolen_io_offset()
269 static int __xe_ttm_stolen_io_mem_reserve_bar2(struct xe_device *xe, in __xe_ttm_stolen_io_mem_reserve_bar2() argument
278 xe_res_first(mem, 0, 4096, &cur); in __xe_ttm_stolen_io_mem_reserve_bar2()
281 drm_WARN_ON(&xe->drm, !(mem->placement & TTM_PL_FLAG_CONTIGUOUS)); in __xe_ttm_stolen_io_mem_reserve_bar2()
290 return 0; in __xe_ttm_stolen_io_mem_reserve_bar2()
293 static int __xe_ttm_stolen_io_mem_reserve_stolen(struct xe_device *xe, in __xe_ttm_stolen_io_mem_reserve_stolen() argument
300 XE_WARN_ON(IS_DGFX(xe)); in __xe_ttm_stolen_io_mem_reserve_stolen()
303 if (drm_WARN_ON(&xe->drm, !(bo->flags & XE_BO_FLAG_GGTT))) in __xe_ttm_stolen_io_mem_reserve_stolen()
312 return 0; in __xe_ttm_stolen_io_mem_reserve_stolen()
315 drm_WARN_ON(&xe->drm, 1); in __xe_ttm_stolen_io_mem_reserve_stolen()
320 int xe_ttm_stolen_io_mem_reserve(struct xe_device *xe, struct ttm_resource *mem) in xe_ttm_stolen_io_mem_reserve() argument
322 struct ttm_resource_manager *ttm_mgr = ttm_manager_type(&xe->ttm, XE_PL_STOLEN); in xe_ttm_stolen_io_mem_reserve()
328 if (xe_ttm_stolen_cpu_access_needs_ggtt(xe)) in xe_ttm_stolen_io_mem_reserve()
329 return __xe_ttm_stolen_io_mem_reserve_stolen(xe, mgr, mem); in xe_ttm_stolen_io_mem_reserve()
331 return __xe_ttm_stolen_io_mem_reserve_bar2(xe, mgr, mem); in xe_ttm_stolen_io_mem_reserve()
334 u64 xe_ttm_stolen_gpu_offset(struct xe_device *xe) in xe_ttm_stolen_gpu_offset() argument
337 to_stolen_mgr(ttm_manager_type(&xe->ttm, XE_PL_STOLEN)); in xe_ttm_stolen_gpu_offset()