Lines Matching +full:mem +full:- +full:base

1 // SPDX-License-Identifier: MIT
3 * Copyright © 2021-2023 Intel Corporation
4 * Copyright (C) 2021-2002 Red Hat
30 struct xe_ttm_vram_mgr base; member
32 /* PCI base offset */
34 /* GPU base offset */
43 return container_of(man, struct xe_ttm_stolen_mgr, base.manager); in to_stolen_mgr()
47 * xe_ttm_stolen_cpu_access_needs_ggtt() - If we can't directly CPU access
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()
70 tile_size = tile->mem.vram.actual_physical_size; in detect_bar2_dgfx()
72 /* Use DSM base address instead for stolen memory */ in detect_bar2_dgfx()
73 mgr->stolen_base = (xe_mmio_read64_2x32(mmio, DSMBASE) & BDSM_MASK) - tile_offset; in detect_bar2_dgfx()
74 if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base)) in detect_bar2_dgfx()
77 stolen_size = tile_size - mgr->stolen_base; in detect_bar2_dgfx()
80 if (mgr->stolen_base + stolen_size <= pci_resource_len(pdev, LMEM_BAR)) in detect_bar2_dgfx()
81 mgr->io_base = tile->mem.vram.io_start + mgr->stolen_base; in detect_bar2_dgfx()
102 val--; in get_wopcm_size()
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()
128 if (drm_WARN_ON(&xe->drm, (ggc & GGMS_MASK) != GGMS_MASK)) in detect_bar2_integrated()
138 mgr->stolen_base = SZ_8M; in detect_bar2_integrated()
139 mgr->io_base = pci_resource_start(pdev, 2) + mgr->stolen_base; in detect_bar2_integrated()
141 /* return valid GMS value, -EIO if invalid */ in detect_bar2_integrated()
148 stolen_size = (gms - 0xf0 + 1) * 4 * SZ_1M; in detect_bar2_integrated()
156 if (drm_WARN_ON(&xe->drm, !wopcm_size)) in detect_bar2_integrated()
159 stolen_size -= wopcm_size; in detect_bar2_integrated()
173 if (gscpsmi_base >= mgr->io_base && in detect_bar2_integrated()
174 gscpsmi_base < mgr->io_base + stolen_size) { in detect_bar2_integrated()
177 mgr->io_base + stolen_size - gscpsmi_base); in detect_bar2_integrated()
178 stolen_size = gscpsmi_base - mgr->io_base; in detect_bar2_integrated()
182 if (drm_WARN_ON(&xe->drm, stolen_size + SZ_8M > pci_resource_len(pdev, 2))) in detect_bar2_integrated()
194 mgr->io_base = pci_resource_start(to_pci_dev(xe->drm.dev), 2); in detect_stolen()
197 mgr->stolen_base = intel_graphics_stolen_res.start; in detect_stolen()
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()
226 drm_dbg_kms(&xe->drm, "No stolen memory support\n"); in xe_ttm_stolen_mgr_init()
233 * much always 256M, with small-bar. 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()
250 mgr->mapping = devm_ioremap_wc(&pdev->dev, mgr->io_base, io_size); in xe_ttm_stolen_mgr_init()
256 struct ttm_resource_manager *ttm_mgr = ttm_manager_type(&xe->ttm, XE_PL_STOLEN); in xe_ttm_stolen_io_offset()
260 XE_WARN_ON(!mgr->io_base); in xe_ttm_stolen_io_offset()
263 return mgr->io_base + xe_bo_ggtt_addr(bo) + offset; in xe_ttm_stolen_io_offset()
265 xe_res_first(bo->ttm.resource, offset, 4096, &cur); in xe_ttm_stolen_io_offset()
266 return mgr->io_base + cur.start; in xe_ttm_stolen_io_offset()
271 struct ttm_resource *mem) in __xe_ttm_stolen_io_mem_reserve_bar2() argument
275 if (!mgr->io_base) in __xe_ttm_stolen_io_mem_reserve_bar2()
276 return -EIO; in __xe_ttm_stolen_io_mem_reserve_bar2()
278 xe_res_first(mem, 0, 4096, &cur); in __xe_ttm_stolen_io_mem_reserve_bar2()
279 mem->bus.offset = cur.start; 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()
283 if (mem->placement & TTM_PL_FLAG_CONTIGUOUS && mgr->mapping) in __xe_ttm_stolen_io_mem_reserve_bar2()
284 mem->bus.addr = (u8 __force *)mgr->mapping + mem->bus.offset; in __xe_ttm_stolen_io_mem_reserve_bar2()
286 mem->bus.offset += mgr->io_base; in __xe_ttm_stolen_io_mem_reserve_bar2()
287 mem->bus.is_iomem = true; in __xe_ttm_stolen_io_mem_reserve_bar2()
288 mem->bus.caching = ttm_write_combined; in __xe_ttm_stolen_io_mem_reserve_bar2()
295 struct ttm_resource *mem) in __xe_ttm_stolen_io_mem_reserve_stolen() argument
298 struct xe_bo *bo = ttm_to_xe_bo(mem->bo); 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()
304 return -EIO; in __xe_ttm_stolen_io_mem_reserve_stolen()
307 mem->bus.offset = xe_bo_ggtt_addr(bo) + mgr->io_base; in __xe_ttm_stolen_io_mem_reserve_stolen()
309 mem->bus.is_iomem = true; in __xe_ttm_stolen_io_mem_reserve_stolen()
310 mem->bus.caching = ttm_write_combined; in __xe_ttm_stolen_io_mem_reserve_stolen()
315 drm_WARN_ON(&xe->drm, 1); in __xe_ttm_stolen_io_mem_reserve_stolen()
316 return -EIO; 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()
325 if (!mgr || !mgr->io_base) in xe_ttm_stolen_io_mem_reserve()
326 return -EIO; 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()
337 to_stolen_mgr(ttm_manager_type(&xe->ttm, XE_PL_STOLEN)); in xe_ttm_stolen_gpu_offset()
339 return mgr->stolen_base; in xe_ttm_stolen_gpu_offset()