From: Arvind Yadav <arvind.yadav@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: rodrigo.vivi@intel.com, matthew.brost@intel.com,
himal.prasad.ghimiray@intel.com,
thomas.hellstrom@linux.intel.com, sanjay.kumar.yadav@intel.com
Subject: [PATCH v2 1/4] drm/xe: Hold a device reference across deferred VM destruction
Date: Wed, 28 Oct 2026 17:51:22 +0530 [thread overview]
Message-ID: <20261028122125.3772832-2-arvind.yadav@intel.com> (raw)
In-Reply-To: <20261028122125.3772832-1-arvind.yadav@intel.com>
xe_vm_free() is the drm_gpuvm vm_free callback. It hands the final
teardown to vm_destroy_work_func() on a workqueue and returns.
drm_gpuvm_free() drops its device reference immediately after the
callback returns:
gpuvm->ops->vm_free(gpuvm);
drm_dev_put(drm);
vm_destroy_work_func() then keeps using device state: xe_pm_runtime_put()
for an LR mode VM, ttm_lru_bulk_move_fini() on xe->ttm, and the tile
iteration. If the freed VM held the last device reference, the work runs
against a released xe_device.
Take a device reference in xe_vm_free() and drop it once
vm_destroy_work_func() has finished using the device.
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Assisted-by: LLM
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
---
drivers/gpu/drm/xe/xe_vm.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 823e264319a1..a1a4eaf3165f 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2108,6 +2108,8 @@ static void vm_destroy_work_func(struct work_struct *w)
xe_file_put(vm->xef);
kfree(vm);
+
+ drm_dev_put(&xe->drm);
}
static void xe_vm_free(struct drm_gpuvm *gpuvm)
@@ -2115,10 +2117,13 @@ static void xe_vm_free(struct drm_gpuvm *gpuvm)
struct xe_vm *vm = container_of(gpuvm, struct xe_vm, gpuvm);
/*
- * To destroy the VM we need to be able to sleep.
- * drm_gpuvm keeps at least one device reference at this
- * point so xe->destroy_wq must still be alive.
+ * drm_gpuvm drops its device reference as soon as this callback
+ * returns, but vm_destroy_work_func() still uses device state. Hold a
+ * reference across the deferred work.
*/
+ drm_dev_get(&vm->xe->drm);
+
+ /* To destroy the VM we need to be able to sleep */
queue_work(vm->xe->destroy_wq, &vm->destroy_work);
}
--
2.43.0
next prev parent reply other threads:[~2026-10-28 12:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 12:21 [PATCH v2 0/4] drm/xe: Fix VM teardown and migration queue recovery Arvind Yadav
2026-10-28 12:21 ` Arvind Yadav [this message]
2026-10-28 13:59 ` [PATCH v2 1/4] drm/xe: Hold a device reference across deferred VM destruction Yadav, Sanjay Kumar
2026-10-28 12:21 ` [PATCH v2 2/4] drm/xe: Disable scheduling early on FD close to avoid CAT error cascade Arvind Yadav
2026-10-28 12:21 ` [PATCH v2 3/4] drm/xe: Mark VMs as closing before queue cleanup Arvind Yadav
2026-10-28 14:00 ` Yadav, Sanjay Kumar
2026-10-28 12:21 ` [PATCH v2 4/4] drm/xe: Defer VM teardown until exec queue cleanup completes Arvind Yadav
2026-10-28 14:01 ` Yadav, Sanjay Kumar
2026-10-28 12:30 ` ✓ CI.KUnit: success for drm/xe: Fix VM teardown and migration queue recovery (rev2) Patchwork
2026-10-28 13:07 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-28 22: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=20261028122125.3772832-2-arvind.yadav@intel.com \
--to=arvind.yadav@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=sanjay.kumar.yadav@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.