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
Cc: stuart.summers@intel.com, francois.dugast@intel.com
Subject: [PATCH v4 3/7] drm/xe: Implement xe_pagefault_reset
Date: Fri, 31 Oct 2025 09:54:12 -0700	[thread overview]
Message-ID: <20251031165416.2871503-4-matthew.brost@intel.com> (raw)
In-Reply-To: <20251031165416.2871503-1-matthew.brost@intel.com>

Squash any pending faults on the GT being reset by setting the GT field
in struct xe_pagefault to NULL.

v4:
 - Only do reset it page faults queues initialized (CI)

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_gt.c        |  2 ++
 drivers/gpu/drm/xe/xe_pagefault.c | 27 ++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 89808b33d0a8..e4852c4c90cd 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -49,6 +49,7 @@
 #include "xe_map.h"
 #include "xe_migrate.h"
 #include "xe_mmio.h"
+#include "xe_pagefault.h"
 #include "xe_pat.h"
 #include "xe_pm.h"
 #include "xe_mocs.h"
@@ -849,6 +850,7 @@ static int gt_reset(struct xe_gt *gt)
 
 	xe_uc_gucrc_disable(&gt->uc);
 	xe_uc_stop_prepare(&gt->uc);
+	xe_pagefault_reset(gt_to_xe(gt), gt);
 	xe_gt_pagefault_reset(gt);
 
 	xe_uc_stop(&gt->uc);
diff --git a/drivers/gpu/drm/xe/xe_pagefault.c b/drivers/gpu/drm/xe/xe_pagefault.c
index 43b26e7d090a..eedd31120175 100644
--- a/drivers/gpu/drm/xe/xe_pagefault.c
+++ b/drivers/gpu/drm/xe/xe_pagefault.c
@@ -124,6 +124,28 @@ int xe_pagefault_init(struct xe_device *xe)
 	return err;
 }
 
+static void xe_pagefault_queue_reset(struct xe_device *xe, struct xe_gt *gt,
+				     struct xe_pagefault_queue *pf_queue)
+{
+	u32 i;
+
+	/* Driver load failure guard / USM not enabled guard */
+	if (!pf_queue->data)
+		return;
+
+	/* Squash all pending faults on the GT */
+
+	spin_lock_irq(&pf_queue->lock);
+	for (i = pf_queue->tail; i != pf_queue->head;
+	     i = (i + xe_pagefault_entry_size()) % pf_queue->size) {
+		struct xe_pagefault *pf = pf_queue->data + i;
+
+		if (pf->gt == gt)
+			pf->gt = NULL;
+	}
+	spin_unlock_irq(&pf_queue->lock);
+}
+
 /**
  * xe_pagefault_reset() - Page fault reset for a GT
  * @xe: xe device instance
@@ -134,7 +156,10 @@ int xe_pagefault_init(struct xe_device *xe)
  */
 void xe_pagefault_reset(struct xe_device *xe, struct xe_gt *gt)
 {
-	/* TODO - implement */
+	int i;
+
+	for (i = 0; i < XE_PAGEFAULT_QUEUE_COUNT; ++i)
+		xe_pagefault_queue_reset(xe, gt, xe->usm.pf_queue + i);
 }
 
 /**
-- 
2.34.1


  parent reply	other threads:[~2025-10-31 16:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 16:54 [PATCH v4 0/7] Pagefault refactor Matthew Brost
2025-10-31 16:54 ` [PATCH v4 1/7] drm/xe: Stub out new pagefault layer Matthew Brost
2025-11-04  3:57   ` Lucas De Marchi
2025-10-31 16:54 ` [PATCH v4 2/7] drm/xe: Implement xe_pagefault_init Matthew Brost
2025-11-03 13:22   ` Francois Dugast
2025-11-03 17:07     ` Matthew Brost
2025-10-31 16:54 ` Matthew Brost [this message]
2025-11-04  4:02   ` [PATCH v4 3/7] drm/xe: Implement xe_pagefault_reset Lucas De Marchi
2025-10-31 16:54 ` [PATCH v4 4/7] drm/xe: Implement xe_pagefault_handler Matthew Brost
2025-10-31 16:54 ` [PATCH v4 5/7] drm/xe: Implement xe_pagefault_queue_work Matthew Brost
2025-11-04 15:01   ` Lucas De Marchi
2025-11-04 15:50     ` Matthew Brost
2025-10-31 16:54 ` [PATCH v4 6/7] drm/xe: Add xe_guc_pagefault layer Matthew Brost
2025-11-03 18:28   ` Lucas De Marchi
2025-11-03 18:56     ` Matthew Brost
2025-11-03 19:11       ` Lucas De Marchi
2025-11-03 19:15         ` Matthew Brost
2025-11-04 16:12           ` Lucas De Marchi
2025-10-31 16:54 ` [PATCH v4 7/7] drm/xe: Remove unused GT page fault code Matthew Brost
2025-11-04 16:13   ` Lucas De Marchi
2025-10-31 18:00 ` ✗ CI.checkpatch: warning for Pagefault refactor (rev3) Patchwork
2025-10-31 18:01 ` ✓ CI.KUnit: success " Patchwork
2025-10-31 19:04 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-01  6:59 ` ✗ Xe.CI.Full: failure " Patchwork
2025-11-04 16:24 ` [PATCH v4 0/7] Pagefault refactor Francois Dugast

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=20251031165416.2871503-4-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=stuart.summers@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