Skip to content

Commit 919c2b5

Browse files
illevilucasdemarchi
authored andcommitted
drm/xe: Use managed BO in memirq
When probe has an error, the current scheme causes a page fault during resource unwinding. This happens because GTTMMADR_BAR gets unmapped before the allocated BO is released via drmm. Switching to a managed BO that is released via devm solves this ordering issue. Signed-off-by: Ilia Levi <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 7cbd0f7 commit 919c2b5

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

drivers/gpu/drm/xe/xe_memirq.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,6 @@ static const char *guc_name(struct xe_guc *guc)
155155
*
156156
*/
157157

158-
static void __release_xe_bo(struct drm_device *drm, void *arg)
159-
{
160-
struct xe_bo *bo = arg;
161-
162-
xe_bo_unpin_map_no_vm(bo);
163-
}
164-
165158
static inline bool hw_reports_to_instance_zero(struct xe_memirq *memirq)
166159
{
167160
/*
@@ -184,14 +177,12 @@ static int memirq_alloc_pages(struct xe_memirq *memirq)
184177
BUILD_BUG_ON(!IS_ALIGNED(XE_MEMIRQ_SOURCE_OFFSET(0), SZ_64));
185178
BUILD_BUG_ON(!IS_ALIGNED(XE_MEMIRQ_STATUS_OFFSET(0), SZ_4K));
186179

187-
/* XXX: convert to managed bo */
188-
bo = xe_bo_create_pin_map(xe, tile, NULL, bo_size,
189-
ttm_bo_type_kernel,
190-
XE_BO_FLAG_SYSTEM |
191-
XE_BO_FLAG_GGTT |
192-
XE_BO_FLAG_GGTT_INVALIDATE |
193-
XE_BO_FLAG_NEEDS_UC |
194-
XE_BO_FLAG_NEEDS_CPU_ACCESS);
180+
bo = xe_managed_bo_create_pin_map(xe, tile, bo_size,
181+
XE_BO_FLAG_SYSTEM |
182+
XE_BO_FLAG_GGTT |
183+
XE_BO_FLAG_GGTT_INVALIDATE |
184+
XE_BO_FLAG_NEEDS_UC |
185+
XE_BO_FLAG_NEEDS_CPU_ACCESS);
195186
if (IS_ERR(bo)) {
196187
err = PTR_ERR(bo);
197188
goto out;
@@ -215,7 +206,7 @@ static int memirq_alloc_pages(struct xe_memirq *memirq)
215206
xe_bo_ggtt_addr(bo), bo_size, XE_MEMIRQ_SOURCE_OFFSET(0),
216207
XE_MEMIRQ_STATUS_OFFSET(0));
217208

218-
return drmm_add_action_or_reset(&xe->drm, __release_xe_bo, memirq->bo);
209+
return 0;
219210

220211
out:
221212
memirq_err(memirq, "Failed to allocate memirq page (%pe)\n", ERR_PTR(err));

0 commit comments

Comments
 (0)