Skip to content

Commit 04485cc

Browse files
committed
Merge tag 'drm-xe-fixes-2025-02-13' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
- Remove bo->clients out of bos_lock area (Tejas) - Carve out wopcm portion from the stolen memory (Nirmoy) Signed-off-by: Dave Airlie <[email protected]> From: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents d70c6ae + e977499 commit 04485cc

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

drivers/gpu/drm/xe/xe_drm_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ void xe_drm_client_add_bo(struct xe_drm_client *client,
135135
XE_WARN_ON(bo->client);
136136
XE_WARN_ON(!list_empty(&bo->client_link));
137137

138-
spin_lock(&client->bos_lock);
139138
bo->client = xe_drm_client_get(client);
139+
spin_lock(&client->bos_lock);
140140
list_add_tail(&bo->client_link, &client->bos_list);
141141
spin_unlock(&client->bos_lock);
142142
}

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_tile_mmio(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_mmio *mmio = xe_root_tile_mmio(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_tile_mmio(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)