Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [PATCH 1/1] drm/xe: Flush all page faults when closing a VM
Date: Mon,  9 Sep 2024 15:32:25 -0700	[thread overview]
Message-ID: <20240909223225.665761-2-matthew.brost@intel.com> (raw)
In-Reply-To: <20240909223225.665761-1-matthew.brost@intel.com>

Ensure all page faults on VM are done when closing a VM before removing
page table memory.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_gt_pagefault.c | 15 +++++++++++++++
 drivers/gpu/drm/xe/xe_gt_pagefault.h |  2 ++
 drivers/gpu/drm/xe/xe_vm.c           |  7 +++++++
 3 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c
index 730eec07795e..2dd7065ce54a 100644
--- a/drivers/gpu/drm/xe/xe_gt_pagefault.c
+++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c
@@ -304,6 +304,21 @@ static bool pf_queue_full(struct pf_queue *pf_queue)
 		PF_MSG_LEN_DW;
 }
 
+/**
+ * xe_gt_pagefault_flush() - Flush page faults for a VM
+ * @gt: the GT object
+ * @vm: the VM objecy
+ *
+ * Ensure all page faults per GT and VM pair are done executing.
+ */
+void xe_gt_pagefault_flush(struct xe_gt *gt, struct xe_vm *vm)
+{
+	struct pf_queue *pf_queue = gt->usm.pf_queue +
+		(vm->usm.asid % NUM_PF_QUEUE);
+
+	flush_work(&pf_queue->worker);
+}
+
 int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len)
 {
 	struct xe_gt *gt = guc_to_gt(guc);
diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.h b/drivers/gpu/drm/xe/xe_gt_pagefault.h
index 839c065a5e4c..9f4166617f04 100644
--- a/drivers/gpu/drm/xe/xe_gt_pagefault.h
+++ b/drivers/gpu/drm/xe/xe_gt_pagefault.h
@@ -10,8 +10,10 @@
 
 struct xe_gt;
 struct xe_guc;
+struct xe_vm;
 
 int xe_gt_pagefault_init(struct xe_gt *gt);
+void xe_gt_pagefault_flush(struct xe_gt *gt, struct xe_vm *vm);
 void xe_gt_pagefault_reset(struct xe_gt *gt);
 int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len);
 int xe_guc_access_counter_notify_handler(struct xe_guc *guc, u32 *msg, u32 len);
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 7acd5fc9d032..5139a731ae79 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1543,6 +1543,13 @@ void xe_vm_close_and_put(struct xe_vm *vm)
 	xe_vm_close(vm);
 	if (xe_vm_in_preempt_fence_mode(vm))
 		flush_work(&vm->preempt.rebind_work);
+	if (xe_vm_in_fault_mode(vm)) {
+		struct xe_gt *gt;
+
+		/* Stop all async faults */
+		for_each_gt(gt, xe, id)
+			xe_gt_pagefault_flush(gt, vm);
+	}
 
 	down_write(&vm->lock);
 	for_each_tile(tile, xe, id) {
-- 
2.34.1


  reply	other threads:[~2024-09-09 22:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09 22:32 [PATCH 0/1] Flush all page faults when closing a VM Matthew Brost
2024-09-09 22:32 ` Matthew Brost [this message]
2024-09-10  8:09   ` [PATCH 1/1] drm/xe: " Ghimiray, Himal Prasad
2024-09-10 17:58     ` Matthew Brost
2024-09-09 22:36 ` ✓ CI.Patch_applied: success for " Patchwork
2024-09-09 22:37 ` ✓ CI.checkpatch: " Patchwork
2024-09-09 22:38 ` ✓ CI.KUnit: " Patchwork
2024-09-09 22:50 ` ✓ CI.Build: " Patchwork
2024-09-09 22:52 ` ✓ CI.Hooks: " Patchwork
2024-09-09 22:54 ` ✓ CI.checksparse: " Patchwork
2024-09-09 23:08 ` ✓ CI.BAT: " Patchwork
2024-09-10  3:48 ` ✗ 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=20240909223225.665761-2-matthew.brost@intel.com \
    --to=matthew.brost@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