Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sanjay Yadav <sanjay.kumar.yadav@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [PATCH 0/2] drm/xe/bo: Fix async BO free teardown deadlock
Date: Mon, 23 Nov 2026 10:26:53 +0530	[thread overview]
Message-ID: <20261123045652.3575516-4-sanjay.kumar.yadav@intel.com> (raw)

The async BO free worker can drop the last drm_device reference when
freeing a page-table BO (BO -> VM -> drm_gpuvm_free() -> drm_dev_put()).
Device teardown then runs from the worker and xe_bo_dev_fini() flushes
the work it is running on, deadlocking.

  WARNING: possible recursive locking detected
  kworker/7:0/50249 is trying to acquire lock:
  ((work_completion)(&bo_dev->async_free)), at: __flush_work+0x25d/0x640
  but task is already holding lock:
  ((work_completion)(&bo_dev->async_free)), at: process_one_work+0x26d/0x890
  ...
  Workqueue: events xe_bo_dev_work_func [xe]
  Call Trace:
   flush_work+0x2d/0x40
   xe_bo_dev_fini+0xe/0x20 [xe]
   xe_device_destroy+0x19/0xa0 [xe]
   drm_managed_release+0x8b/0x170
   drm_dev_put+0x69/0x90
   drm_gpuvm_free+0xc2/0x2e0 [drm_gpuvm]
   drm_gpuvm_put+0x48/0x80 [drm_gpuvm]
   xe_ttm_bo_destroy+0xfa/0x320 [xe]
   ttm_bo_release+0x70/0x310 [ttm]
   ttm_bo_fini+0x3c/0x70 [ttm]
   xe_gem_object_free+0x1a/0x30 [xe]
   drm_gem_object_free+0x1d/0x40
   xe_bo_dev_work_func+0x3a/0x60 [xe]
   process_one_work+0x2ad/0x890
   worker_thread+0x200/0x3f0

Patch 1 fixes the deadlock by holding a device reference in the worker
and not self-flushing from xe_bo_dev_fini().

Patch 2 moves the work to the module-lifetime xe_destroy_wq, so module
unload cannot free the xe text while the worker is still finishing a
teardown it triggered.

Sanjay Yadav (2):
  drm/xe/bo: Fix self-flush deadlock in async BO free
  drm/xe/bo: Queue async BO free on the module-lifetime destroy wq

 drivers/gpu/drm/xe/xe_bo.c     | 20 +++++++++++++++++++-
 drivers/gpu/drm/xe/xe_bo.h     |  3 ++-
 drivers/gpu/drm/xe/xe_module.c |  5 +++--
 drivers/gpu/drm/xe/xe_pt.c     |  2 +-
 4 files changed, 25 insertions(+), 5 deletions(-)

-- 
2.52.0


             reply	other threads:[~2026-11-23  5:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  4:56 Sanjay Yadav [this message]
2026-11-23  4:56 ` [PATCH 1/2] drm/xe/bo: Fix self-flush deadlock in async BO free Sanjay Yadav
2026-11-23  5:41   ` sashiko-bot
2026-11-23  4:56 ` [PATCH 2/2] drm/xe/bo: Queue async BO free on the module-lifetime destroy wq Sanjay Yadav
2026-11-23  5:20 ` ✗ CI.KUnit: failure for drm/xe/bo: Fix async BO free teardown deadlock (rev2) 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=20261123045652.3575516-4-sanjay.kumar.yadav@intel.com \
    --to=sanjay.kumar.yadav@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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