Skip to content
Snippets Groups Projects
Unverified Commit e9774998 authored by Nirmoy Das's avatar Nirmoy Das Committed by Rodrigo Vivi
Browse files

drm/xe: Carve out wopcm portion from the stolen memory


The top of stolen memory is WOPCM, which shouldn't be accessed. Remove
this portion from the stolen memory region for discrete platforms.
This was already done for integrated, but was missing for discrete
platforms.

This also moves get_wopcm_size() so detect_bar2_dgfx() and
detect_bar2_integrated can use the same function.

v2: Improve commit message and suitable stable version tag(Lucas)

Fixes: d8b52a02 ("drm/xe: Implement stolen memory.")
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: stable@vger.kernel.org # v6.11+
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250210143654.2076747-1-nirmoy.das@intel.com


Signed-off-by: default avatarNirmoy Das <nirmoy.das@intel.com>
(cherry picked from commit 2c7f45cc)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent fc876c95
No related branches found
No related tags found
No related merge requests found
......@@ -57,12 +57,35 @@ bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe)
return GRAPHICS_VERx100(xe) < 1270 && !IS_DGFX(xe);
}
static u32 get_wopcm_size(struct xe_device *xe)
{
u32 wopcm_size;
u64 val;
val = xe_mmio_read64_2x32(xe_root_tile_mmio(xe), STOLEN_RESERVED);
val = REG_FIELD_GET64(WOPCM_SIZE_MASK, val);
switch (val) {
case 0x5 ... 0x6:
val--;
fallthrough;
case 0x0 ... 0x3:
wopcm_size = (1U << val) * SZ_1M;
break;
default:
WARN(1, "Missing case wopcm_size=%llx\n", val);
wopcm_size = 0;
}
return wopcm_size;
}
static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
{
struct xe_tile *tile = xe_device_get_root_tile(xe);
struct xe_mmio *mmio = xe_root_tile_mmio(xe);
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
u64 stolen_size;
u64 stolen_size, wopcm_size;
u64 tile_offset;
u64 tile_size;
......@@ -74,7 +97,13 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base))
return 0;
/* Carve out the top of DSM as it contains the reserved WOPCM region */
wopcm_size = get_wopcm_size(xe);
if (drm_WARN_ON(&xe->drm, !wopcm_size))
return 0;
stolen_size = tile_size - mgr->stolen_base;
stolen_size -= wopcm_size;
/* Verify usage fits in the actual resource available */
if (mgr->stolen_base + stolen_size <= pci_resource_len(pdev, LMEM_BAR))
......@@ -89,29 +118,6 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
return ALIGN_DOWN(stolen_size, SZ_1M);
}
static u32 get_wopcm_size(struct xe_device *xe)
{
u32 wopcm_size;
u64 val;
val = xe_mmio_read64_2x32(xe_root_tile_mmio(xe), STOLEN_RESERVED);
val = REG_FIELD_GET64(WOPCM_SIZE_MASK, val);
switch (val) {
case 0x5 ... 0x6:
val--;
fallthrough;
case 0x0 ... 0x3:
wopcm_size = (1U << val) * SZ_1M;
break;
default:
WARN(1, "Missing case wopcm_size=%llx\n", val);
wopcm_size = 0;
}
return wopcm_size;
}
static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
{
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment