dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com,
	thomas.hellstrom@linux.intel.com, rodrigo.vivi@intel.com
Subject: [PATCH 04/13] drm/xe: Stop VM work when device I/O is blocked
Date: Thu, 27 Aug 2026 15:47:52 +0530	[thread overview]
Message-ID: <20260827101801.1247654-5-arvind.yadav@intel.com> (raw)
In-Reply-To: <20260827101801.1247654-1-arvind.yadav@intel.com>

SVM fault handling and VM rebind work may still run when PCI error
recovery starts or the device becomes permanently wedged. This work can
validate BOs, update page tables or submit migration work after device
I/O has been blocked.

Stop SVM fault handling, pagemap population, device-memory copies and
preempt rebind work when device I/O is blocked.

SVM invalidation still performs its software cleanup. Do not warn when
TLB invalidation returns -ECANCELED because hardware access is blocked.

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: Claude:claude-opus-4-8
Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
---
 drivers/gpu/drm/xe/xe_svm.c | 21 ++++++++++++++++++++-
 drivers/gpu/drm/xe/xe_vm.c  | 16 ++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index 627a741293d5..9e78131bfa39 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -11,6 +11,7 @@
 #include <drm/drm_pagemap_util.h>
 
 #include "xe_bo.h"
+#include "xe_device.h"
 #include "xe_exec_queue_types.h"
 #include "xe_gt_stats.h"
 #include "xe_migrate.h"
@@ -288,8 +289,11 @@ static void xe_svm_invalidate(struct drm_gpusvm *gpusvm,
 
 	err = xe_tlb_inval_range_tilemask_submit(xe, vm->usm.asid, adj_start, adj_end,
 						 tile_mask, &batch);
-	if (!WARN_ON_ONCE(err))
+	if (!err)
 		xe_tlb_inval_batch_wait(&batch);
+	else if (!(err == -ECANCELED &&
+		   xe_device_io_blocked(xe)))
+		WARN_ON_ONCE(err);
 
 range_notifier_event_end:
 	r = first;
@@ -631,6 +635,11 @@ static int xe_svm_copy(struct page **pages,
 		}
 		XE_WARN_ON(spage && xe_page_to_vr(spage) != vr);
 
+		if (vr && xe_device_io_blocked(xe)) {
+			err = -ECANCELED;
+			goto err_out;
+		}
+
 		/*
 		 * CPU page and device page valid, capture physical address on
 		 * first device page, check if physical contiguous on subsequent
@@ -1125,6 +1134,11 @@ static int xe_drm_pagemap_populate_mm(struct drm_pagemap *dpagemap,
 	if (!drm_dev_enter(&xe->drm, &idx))
 		return -ENODEV;
 
+	if (xe_device_io_blocked(xe)) {
+		err = -ECANCELED;
+		goto out_drm;
+	}
+
 	xe_pm_runtime_get(xe);
 
 	xe_validation_guard(&vctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
@@ -1165,6 +1179,8 @@ static int xe_drm_pagemap_populate_mm(struct drm_pagemap *dpagemap,
 		xe_bo_put(bo);
 	}
 	xe_pm_runtime_put(xe);
+
+out_drm:
 	drm_dev_exit(idx);
 
 	return err;
@@ -1301,6 +1317,9 @@ static int __xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
 		drm_gpusvm_range_put(&range->base);
 	}
 
+	if (xe_device_io_blocked(vm->xe))
+		return -ECANCELED;
+
 	/* Always process UNMAPs first so view SVM ranges is current */
 	err = xe_svm_garbage_collector(vm);
 	if (err)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 19b3d0be7928..0cee5306fb9c 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -497,6 +497,11 @@ static void preempt_rebind_work_func(struct work_struct *w)
 	}
 
 retry:
+	if (xe_device_io_blocked(vm->xe)) {
+		err = 0;
+		goto out_unlock_outer;
+	}
+
 	if (!try_wait_for_completion(&vm->xe->pm_block) && vm_suspend_rebind_worker(vm)) {
 		up_write(&vm->lock);
 		/* We don't actually block but don't make progress. */
@@ -518,6 +523,12 @@ static void preempt_rebind_work_func(struct work_struct *w)
 	drm_exec_until_all_locked(&exec) {
 		bool done = false;
 
+		if (xe_device_io_blocked(vm->xe)) {
+			xe_validation_ctx_fini(&ctx);
+			err = 0;
+			goto out_unlock_outer;
+		}
+
 		err = xe_preempt_work_begin(&exec, vm, &done);
 		drm_exec_retry_on_contention(&exec);
 		xe_validation_retry_on_oom(&ctx, &err);
@@ -531,6 +542,11 @@ static void preempt_rebind_work_func(struct work_struct *w)
 	if (err)
 		goto out_unlock;
 
+	if (xe_device_io_blocked(vm->xe)) {
+		err = 0;
+		goto out_unlock;
+	}
+
 	xe_vm_set_validation_exec(vm, &exec);
 	err = xe_vm_rebind(vm, true);
 	xe_vm_set_validation_exec(vm, NULL);
-- 
2.43.0


  parent reply	other threads:[~2026-08-27 10:18 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 10:17 [PATCH 00/13] drm/xe: Isolate wedged devices from hardware access Arvind Yadav
2026-08-27 10:17 ` [PATCH 01/13] drm/xe/irq: Always free requested IRQs on uninstall Arvind Yadav
2026-08-27 10:39   ` Ghimiray, Himal Prasad
2026-08-31 20:30     ` Rodrigo Vivi
2026-09-01  9:32       ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 02/13] drm/xe: Separate AER reset state from device wedging Arvind Yadav
2026-08-27 10:36   ` sashiko-bot
2026-08-27 21:55   ` Andi Shyti
2026-08-28  3:32     ` Yadav, Arvind
2026-08-28 11:36   ` [PATCH 2/13] " Raag Jadav
2026-08-27 10:17 ` [PATCH 03/13] drm/xe: Drop queued page faults when device I/O is blocked Arvind Yadav
2026-08-31 20:43   ` Rodrigo Vivi
2026-09-02  4:49     ` Yadav, Arvind
2026-09-02  5:30       ` Matthew Brost
2026-09-02  5:33         ` Matthew Brost
2026-08-27 10:17 ` Arvind Yadav [this message]
2026-08-31 20:55   ` [PATCH 04/13] drm/xe: Stop VM work " Rodrigo Vivi
2026-09-01  9:11     ` Yadav, Arvind
2026-09-02  5:40       ` Matthew Brost
2026-08-27 10:17 ` [PATCH 05/13] drm/xe: Send wedged notification from a worker Arvind Yadav
2026-08-27 22:12   ` Andi Shyti
2026-08-28  3:39     ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 06/13] drm/xe: Reuse one dummy page per BO after wedge Arvind Yadav
2026-08-27 10:30   ` sashiko-bot
2026-08-27 10:17 ` [PATCH 07/13] drm/xe: Invalidate existing VRAM mappings on wedge Arvind Yadav
2026-08-27 10:17 ` [PATCH 08/13] drm/xe/irq: Serialize IRQ suspend and resume Arvind Yadav
2026-08-31 21:06   ` Rodrigo Vivi
2026-09-01  9:07     ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 09/13] drm/xe: Isolate a wedged device before notifying userspace Arvind Yadav
2026-08-27 10:35   ` sashiko-bot
2026-08-27 10:17 ` [PATCH 10/13] drm/xe/ttm: Reject VRAM allocations on wedged devices Arvind Yadav
2026-08-31 21:03   ` Rodrigo Vivi
2026-09-01  8:19     ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 11/13] drm/xe/guc: Skip timeout recovery on a wedged device Arvind Yadav
2026-08-31 21:01   ` Rodrigo Vivi
2026-08-27 10:18 ` [PATCH 12/13] drm/xe: Skip PM notifier preparation for wedged devices Arvind Yadav
2026-08-31 21:00   ` Rodrigo Vivi
2026-09-01  7:03     ` Yadav, Arvind
2026-09-02 19:21       ` Rodrigo Vivi
2026-08-27 10:18 ` [PATCH 13/13] drm/xe: Block BO VM access when device I/O is unavailable Arvind Yadav
2026-08-27 10:30   ` sashiko-bot

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=20260827101801.1247654-5-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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox