]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Implement xe_pagefault_reset
authorMatthew Brost <matthew.brost@intel.com>
Fri, 31 Oct 2025 16:54:12 +0000 (09:54 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Tue, 4 Nov 2025 17:04:29 +0000 (09:04 -0800)
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>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Tested-by: Francois Dugast <francois.dugast@intel.com>
Link: https://patch.msgid.link/20251031165416.2871503-4-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_gt.c
drivers/gpu/drm/xe/xe_pagefault.c

index e008e3c1bf680b4645692209ebeb03f2faa40ab2..f50bf98f44c99bc86d8db3d1981224ad6e128d5e 100644 (file)
@@ -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"
@@ -853,6 +854,7 @@ static void gt_reset_worker(struct work_struct *w)
 
        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);
index 42952a91d1f567d7af5675d6ef58ba964142f233..b1decad9b54cd2e90d35b63368029cb8818ff287 100644 (file)
@@ -129,6 +129,28 @@ err_out:
        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
@@ -139,7 +161,10 @@ err_out:
  */
 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);
 }
 
 /**