Skip to content

Commit 1e1981b

Browse files
committed
drm/xe: Fix taking invalid lock on wedge
If device wedges on e.g. GuC upload, the submission is not yet enabled and the state is not even initialized. Protect the wedge call so it does nothing in this case. It fixes the following splat: [] xe 0000:bf:00.0: [drm] device wedged, needs recovery [] ------------[ cut here ]------------ [] DEBUG_LOCKS_WARN_ON(lock->magic != lock) [] WARNING: CPU: 48 PID: 312 at kernel/locking/mutex.c:564 __mutex_lock+0x8a1/0xe60 ... [] RIP: 0010:__mutex_lock+0x8a1/0xe60 [] mutex_lock_nested+0x1b/0x30 [] xe_guc_submit_wedge+0x80/0x2b0 [xe] Reviewed-by: Balasubramani Vivekanandan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent f350747 commit 1e1981b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ int xe_guc_submit_init(struct xe_guc *guc, unsigned int num_ids)
300300

301301
primelockdep(guc);
302302

303+
guc->submission_state.initialized = true;
304+
303305
return drmm_add_action_or_reset(&xe->drm, guc_submit_fini, guc);
304306
}
305307

@@ -834,6 +836,13 @@ void xe_guc_submit_wedge(struct xe_guc *guc)
834836

835837
xe_gt_assert(guc_to_gt(guc), guc_to_xe(guc)->wedged.mode);
836838

839+
/*
840+
* If device is being wedged even before submission_state is
841+
* initialized, there's nothing to do here.
842+
*/
843+
if (!guc->submission_state.initialized)
844+
return;
845+
837846
err = devm_add_action_or_reset(guc_to_xe(guc)->drm.dev,
838847
guc_submit_wedged_fini, guc);
839848
if (err) {

drivers/gpu/drm/xe/xe_guc_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ struct xe_guc {
8989
struct mutex lock;
9090
/** @submission_state.enabled: submission is enabled */
9191
bool enabled;
92+
/**
93+
* @submission_state.initialized: mark when submission state is
94+
* even initialized - before that not even the lock is valid
95+
*/
96+
bool initialized;
9297
/** @submission_state.fini_wq: submit fini wait queue */
9398
wait_queue_head_t fini_wq;
9499
} submission_state;

0 commit comments

Comments
 (0)