Skip to content

Commit 480b358

Browse files
committed
drm/xe: Do not wake device during a GT reset
Waking the device during a GT reset can lead to unintended memory allocation, which is not allowed since GT resets occur in the reclaim path. Prevent this by holding a PM reference while a reset is in flight. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: stable@vger.kernel.org Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://lore.kernel.org/r/20251022005538.828980-3-matthew.brost@intel.com
1 parent 1f1314e commit 480b358

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -818,17 +818,19 @@ static int gt_reset(struct xe_gt *gt)
818818
unsigned int fw_ref;
819819
int err;
820820

821-
if (xe_device_wedged(gt_to_xe(gt)))
822-
return -ECANCELED;
821+
if (xe_device_wedged(gt_to_xe(gt))) {
822+
err = -ECANCELED;
823+
goto err_pm_put;
824+
}
823825

824826
/* We only support GT resets with GuC submission */
825-
if (!xe_device_uc_enabled(gt_to_xe(gt)))
826-
return -ENODEV;
827+
if (!xe_device_uc_enabled(gt_to_xe(gt))) {
828+
err = -ENODEV;
829+
goto err_pm_put;
830+
}
827831

828832
xe_gt_info(gt, "reset started\n");
829833

830-
xe_pm_runtime_get(gt_to_xe(gt));
831-
832834
if (xe_fault_inject_gt_reset()) {
833835
err = -ECANCELED;
834836
goto err_fail;
@@ -875,6 +877,7 @@ static int gt_reset(struct xe_gt *gt)
875877
xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err));
876878

877879
xe_device_declare_wedged(gt_to_xe(gt));
880+
err_pm_put:
878881
xe_pm_runtime_put(gt_to_xe(gt));
879882

880883
return err;
@@ -896,7 +899,9 @@ void xe_gt_reset_async(struct xe_gt *gt)
896899
return;
897900

898901
xe_gt_info(gt, "reset queued\n");
899-
queue_work(gt->ordered_wq, &gt->reset.worker);
902+
xe_pm_runtime_get_noresume(gt_to_xe(gt));
903+
if (!queue_work(gt->ordered_wq, &gt->reset.worker))
904+
xe_pm_runtime_put(gt_to_xe(gt));
900905
}
901906

902907
void xe_gt_suspend_prepare(struct xe_gt *gt)

0 commit comments

Comments
 (0)