Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/xe_exec: Avoid potential lockdep cycle with xe_pm_block_map
@ 2026-04-28 16:13 Brian Nguyen
  2026-04-28 17:44 ` ✓ CI.KUnit: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Brian Nguyen @ 2026-04-28 16:13 UTC (permalink / raw)
  To: intel-xe
  Cc: Brian Nguyen, Maciej Patelczyk, Mika Kuoppala, Stuart Summers,
	Thomas Hellström

With the EUDEBUG patch series [1], lockdep will report multiple
circular locking dependencies originating from xe_exec_ioctl that
close through discovery_lock.

The vm->lock -> xe_pm_block_map comes from calling
xe_pm_block_on_suspend() inside of the vm->lock critical section. The
xe_pm_block_map annotation was added by commit f73f6dd312a5
("drm/xe/pm: Add lockdep annotation for the pm_block completion") and
made existing lockdep ordering visible.

Some lockdep cycle variants are observed through the preempt rebind
worker, SVM garbage collector worker, and the mode_sem lock in xe_exec.

To prevent problematic ordering, probe for pending suspend and if the
block is needed, drop held locks before blocking, removing the common
ordering between all 3 cycles (vm->lock -> xe_pm_block_map) and prevent
another possible cycle (mode_sem -> xe_pm_block_map) from forming.

As reference, the cycles closed by inclusion of the discovery_lock are:

Cycle A: discovery_lock -> mode_sem -> vm->lock -> xe_pm_block_map ->
clientlist_mutex -> discovery_lock

Cycle B: discovery_lock -> work_completion(rebind_work) -> vm->lock ->
xe_pm_block_map -> clientlist_mutex -> discovery_lock

Cycle C: discovery_lock -> work_completion(garbage_collector.work) ->
vm->lock -> xe_pm_block_map -> clientlist_mutex -> discovery_lock

[1] https://patchwork.freedesktop.org/series/161979/

Signed-off-by: Brian Nguyen <brian3.nguyen@intel.com>
Cc: Maciej Patelczyk <maciej.patelczyk@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Stuart Summers <stuart.summers@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_exec.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
index e05dabfcd43c..0717bf0c0d31 100644
--- a/drivers/gpu/drm/xe/xe_exec.c
+++ b/drivers/gpu/drm/xe/xe_exec.c
@@ -257,13 +257,19 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 	}
 
 	/*
-	 * It's OK to block interruptible here with the vm lock held, since
-	 * on task freezing during suspend / hibernate, the call will
-	 * return -ERESTARTSYS and the IOCTL will be rerun.
+	 * If suspend is pending, drop held locks then perform the
+	 * block on suspend, avoiding potential lockdep cycle.
+	 * On task freezing the wait itself returns -ERESTARTSYS via the freezer
+	 * signal path; either way the caller is restarted.
 	 */
-	err = xe_pm_block_on_suspend(xe);
-	if (err)
-		goto err_unlock_list;
+	if (!try_wait_for_completion(&xe->pm_block)) {
+		up_read(&vm->lock);
+		if (mode == EXEC_MODE_DMA_FENCE)
+			xe_hw_engine_group_put(group);
+		xe_pm_block_on_suspend(xe);
+		err = -ERESTARTSYS;
+		goto err_syncs;
+	}
 
 	if (!xe_vm_in_lr_mode(vm)) {
 		vm_exec.vm = &vm->gpuvm;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-29  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 16:13 [PATCH] drm/xe/xe_exec: Avoid potential lockdep cycle with xe_pm_block_map Brian Nguyen
2026-04-28 17:44 ` ✓ CI.KUnit: success for " Patchwork
2026-04-28 19:06 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-29  7:09 ` ✗ Xe.CI.FULL: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox