From: Brian Nguyen <brian3.nguyen@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Brian Nguyen" <brian3.nguyen@intel.com>,
"Maciej Patelczyk" <maciej.patelczyk@intel.com>,
"Mika Kuoppala" <mika.kuoppala@linux.intel.com>,
"Stuart Summers" <stuart.summers@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [PATCH] drm/xe/xe_exec: Avoid potential lockdep cycle with xe_pm_block_map
Date: Tue, 28 Apr 2026 16:13:48 +0000 [thread overview]
Message-ID: <20260428161347.848905-2-brian3.nguyen@intel.com> (raw)
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
next reply other threads:[~2026-04-28 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 16:13 Brian Nguyen [this message]
2026-04-28 17:44 ` ✓ CI.KUnit: success for drm/xe/xe_exec: Avoid potential lockdep cycle with xe_pm_block_map Patchwork
2026-04-28 19:06 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-29 7:09 ` ✗ Xe.CI.FULL: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260428161347.848905-2-brian3.nguyen@intel.com \
--to=brian3.nguyen@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=maciej.patelczyk@intel.com \
--cc=mika.kuoppala@linux.intel.com \
--cc=stuart.summers@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox