Exec queue destruction is asynchronous, and user queues can outlive
the VM handle. Closing the VM before those queues finish cleanup can
remove mappings that are still in use.

This series marks the VM as closing to reject new work, then keeps
its mappings until the tracked queues are freed. It also holds a
device reference across final VM destruction.

File close keeps the existing synchronous scheduling-disable wait.
There is no additional wait for the queue count to reach zero.
If tracked queues remain, VM close is deferred until their cleanup
completes.

User bind jobs are allowed to drain during file close and queue
destroy. The VM-owned bind queue is not counted and remains alive
until xe_vm_close() has waited for pending BOOKKEEP fences.

This series is based on the FD close cleanup changes in [1].

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

Changes in v2:
- Reduce the series to four patches following review.
- Run deferred VM close and final VM destruction on the
  module-lifetime destroy workqueue.
- Use a shared queue-wait budget during file close and defer teardown
  when queues remain.

Changes in v3:
- Rebase on the "FD close cleanup for XE" series and reduce this series
  to three patches.
- Move the module-lifetime workqueue change into patch 1 to avoid
  self-deadlock when the worker drops the last device reference.
- Check VM state before acknowledging cached faults and hold vm->lock
  through successful reply submission.
- Preserve the original fault details for errors detected before
  acknowledgment and report failed prefetches.
- Reject exec requests on closing VMs before userptr pinning,
  out-sync signaling and rebind.
- Use zero wait on file close and document that internal bind queue
  cleanup can also defer VM teardown.
- Let user bind jobs drain in the exec queue destroy ioctl.
- Count user bind queues under vm->lock before VM close can proceed.
- Track whether a user bind queue owns a close count and balance it
  during final queue destruction.
- Make xe_vm_kill_bind_queues() static and remove the unused wait header.

Arvind Yadav (3):
  drm/xe: Hold a device reference across deferred VM destruction
  drm/xe: Mark VMs as closing before queue cleanup
  drm/xe: Defer VM teardown until exec queue cleanup completes

 drivers/gpu/drm/xe/xe_device.c           |  26 ++-
 drivers/gpu/drm/xe/xe_exec.c             |   9 ++
 drivers/gpu/drm/xe/xe_exec_queue.c       |  39 ++++-
 drivers/gpu/drm/xe/xe_exec_queue_types.h |  11 ++
 drivers/gpu/drm/xe/xe_pagefault.c        |  87 +++++++++--
 drivers/gpu/drm/xe/xe_svm.c              |   3 +-
 drivers/gpu/drm/xe/xe_vm.c               | 191 ++++++++++++++++++++---
 drivers/gpu/drm/xe/xe_vm.h               |  13 +-
 drivers/gpu/drm/xe/xe_vm_types.h         |  17 ++
 drivers/gpu/drm/xe/xe_wait_user_fence.c  |   5 +
 10 files changed, 355 insertions(+), 46 deletions(-)

-- 
2.43.0

Reply via email to