Skip to content

Commit ab64e42

Browse files
Sasha Levingregkh
authored andcommitted
drm/xe: Carve out wopcm portion from the stolen memory
[ Upstream commit e977499 ] 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: d8b52a0 ("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: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250210143654.2076747-1-nirmoy.das@intel.com Signed-off-by: Nirmoy Das <nirmoy.das@intel.com> (cherry picked from commit 2c7f45c) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b2d2be7 commit ab64e42

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,35 @@ bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe)
5757
return GRAPHICS_VERx100(xe) < 1270 && !IS_DGFX(xe);
5858
}
5959

60+
static u32 get_wopcm_size(struct xe_device *xe)
61+
{
62+
u32 wopcm_size;
63+
u64 val;
64+
65+
val = xe_mmio_read64_2x32(xe_root_mmio_gt(xe), STOLEN_RESERVED);
66+
val = REG_FIELD_GET64(WOPCM_SIZE_MASK, val);
67+
68+
switch (val) {
69+
case 0x5 ... 0x6:
70+
val--;
71+
fallthrough;
72+
case 0x0 ... 0x3:
73+
wopcm_size = (1U << val) * SZ_1M;
74+
break;
75+
default:
76+
WARN(1, "Missing case wopcm_size=%llx\n", val);
77+
wopcm_size = 0;
78+
}
79+
80+
return wopcm_size;
81+
}
82+
6083
static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
6184
{
6285
struct xe_tile *tile = xe_device_get_root_tile(xe);
6386
struct xe_gt *mmio = xe_root_mmio_gt(xe);
6487
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
65-
u64 stolen_size;
88+
u64 stolen_size, wopcm_size;
6689
u64 tile_offset;
6790
u64 tile_size;
6891

@@ -74,7 +97,13 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
7497
if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base))
7598
return 0;
7699

100+
/* Carve out the top of DSM as it contains the reserved WOPCM region */
101+
wopcm_size = get_wopcm_size(xe);
102+
if (drm_WARN_ON(&xe->drm, !wopcm_size))
103+
return 0;
104+
77105
stolen_size = tile_size - mgr->stolen_base;
106+
stolen_size -= wopcm_size;
78107

79108
/* Verify usage fits in the actual resource available */
80109
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)
89118
return ALIGN_DOWN(stolen_size, SZ_1M);
90119
}
91120

92-
static u32 get_wopcm_size(struct xe_device *xe)
93-
{
94-
u32 wopcm_size;
95-
u64 val;
96-
97-
val = xe_mmio_read64_2x32(xe_root_mmio_gt(xe), STOLEN_RESERVED);
98-
val = REG_FIELD_GET64(WOPCM_SIZE_MASK, val);
99-
100-
switch (val) {
101-
case 0x5 ... 0x6:
102-
val--;
103-
fallthrough;
104-
case 0x0 ... 0x3:
105-
wopcm_size = (1U << val) * SZ_1M;
106-
break;
107-
default:
108-
WARN(1, "Missing case wopcm_size=%llx\n", val);
109-
wopcm_size = 0;
110-
}
111-
112-
return wopcm_size;
113-
}
114-
115121
static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
116122
{
117123
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);

0 commit comments

Comments
 (0)