Skip to content

Commit 56b7432

Browse files
mbrost05rodrigovivi
authored andcommitted
drm/xe: Avoid memory allocations in xe_device_declare_wedged()
xe_device_declare_wedged() runs in the DMA-fence signaling path, where GFP_KERNEL memory allocations are not allowed. However, registering xe_device_wedged_fini via drmm_add_action_or_reset() triggers a GFP_KERNEL allocation. Fix this by deferring the registration of xe_device_wedged_fini until late in the driver load sequence. Additionally, drop the wedged PM reference only if the device is actually wedged in xe_device_wedged_fini. Fixes: 452bca0 ("drm/xe: Don't suspend device upon wedge") Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patch.msgid.link/20260326210116.202585-2-matthew.brost@intel.com (cherry picked from commit b08ceb4) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent bce7cd6 commit 56b7432

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

drivers/gpu/drm/xe/xe_device.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,14 @@ static void detect_preproduction_hw(struct xe_device *xe)
837837
}
838838
}
839839

840+
static void xe_device_wedged_fini(struct drm_device *drm, void *arg)
841+
{
842+
struct xe_device *xe = arg;
843+
844+
if (atomic_read(&xe->wedged.flag))
845+
xe_pm_runtime_put(xe);
846+
}
847+
840848
int xe_device_probe(struct xe_device *xe)
841849
{
842850
struct xe_tile *tile;
@@ -1013,6 +1021,10 @@ int xe_device_probe(struct xe_device *xe)
10131021

10141022
detect_preproduction_hw(xe);
10151023

1024+
err = drmm_add_action_or_reset(&xe->drm, xe_device_wedged_fini, xe);
1025+
if (err)
1026+
goto err_unregister_display;
1027+
10161028
return devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe);
10171029

10181030
err_unregister_display:
@@ -1216,13 +1228,6 @@ u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address)
12161228
return address & GENMASK_ULL(xe->info.va_bits - 1, 0);
12171229
}
12181230

1219-
static void xe_device_wedged_fini(struct drm_device *drm, void *arg)
1220-
{
1221-
struct xe_device *xe = arg;
1222-
1223-
xe_pm_runtime_put(xe);
1224-
}
1225-
12261231
/**
12271232
* DOC: Xe Device Wedging
12281233
*
@@ -1300,15 +1305,9 @@ void xe_device_declare_wedged(struct xe_device *xe)
13001305
return;
13011306
}
13021307

1303-
xe_pm_runtime_get_noresume(xe);
1304-
1305-
if (drmm_add_action_or_reset(&xe->drm, xe_device_wedged_fini, xe)) {
1306-
drm_err(&xe->drm, "Failed to register xe_device_wedged_fini clean-up. Although device is wedged.\n");
1307-
return;
1308-
}
1309-
13101308
if (!atomic_xchg(&xe->wedged.flag, 1)) {
13111309
xe->needs_flr_on_fini = true;
1310+
xe_pm_runtime_get_noresume(xe);
13121311
drm_err(&xe->drm,
13131312
"CRITICAL: Xe has declared device %s as wedged.\n"
13141313
"IOCTLs and executions are blocked. Only a rebind may clear the failure\n"

0 commit comments

Comments
 (0)