Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [V3] drm/xe: Skip clearing purged page-table BOs
@ 2026-09-08 11:45 Tejas Upadhyay
  2026-09-08 12:04 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Tejas Upadhyay @ 2026-09-08 11:45 UTC (permalink / raw)
  To: intel-xe; +Cc: himal.prasad.ghimiray, matthew.brost, Tejas Upadhyay

VRAM page offlining can clear a page-table BO's vmap before VM teardown
calls xe_pt_clear(). Check for a purged BO under its dma-resv lock before
writing to the mapping.

v3(Sashiko):
- Validate NULL vmap
v2(Sashiko):
- Fix lock ordering

Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
---
 drivers/gpu/drm/xe/xe_pt.c | 6 ++++--
 drivers/gpu/drm/xe/xe_vm.c | 8 +++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
index 7fb2fe1f826c..4b351dbf6572 100644
--- a/drivers/gpu/drm/xe/xe_pt.c
+++ b/drivers/gpu/drm/xe/xe_pt.c
@@ -236,9 +236,11 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred)
  */
 void xe_pt_clear(struct xe_device *xe, struct xe_pt *pt)
 {
-	struct iosys_map *map = &pt->bo->vmap;
+	struct xe_bo *bo = pt->bo;
 
-	xe_map_memset(xe, map, 0, 0, SZ_4K);
+	xe_bo_assert_held(bo);
+	if (!iosys_map_is_null(&bo->vmap))
+		xe_map_memset(xe, &bo->vmap, 0, 0, SZ_4K);
 }
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 9e71567b27cc..e77ff3cf3ca3 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1876,10 +1876,13 @@ static void xe_vm_close(struct xe_vm *vm)
 	bound = drm_dev_enter(&xe->drm, &idx);
 
 	down_write(&vm->lock);
+	xe_vm_lock(vm, false);
+
 	if (xe_vm_in_fault_mode(vm))
 		xe_svm_notifier_lock(vm);
-
 	vm->size = 0;
+	if (xe_vm_in_fault_mode(vm))
+		xe_svm_notifier_unlock(vm);
 
 	if (!((vm->flags & XE_VM_FLAG_MIGRATION))) {
 		struct xe_tile *tile;
@@ -1901,8 +1904,7 @@ static void xe_vm_close(struct xe_vm *vm)
 		}
 	}
 
-	if (xe_vm_in_fault_mode(vm))
-		xe_svm_notifier_unlock(vm);
+	xe_vm_unlock(vm);
 	up_write(&vm->lock);
 
 	if (bound)
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-08 19:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 11:45 [V3] drm/xe: Skip clearing purged page-table BOs Tejas Upadhyay
2026-09-08 12:04 ` sashiko-bot
2026-09-08 13:26   ` Upadhyay, Tejas
2026-09-08 19:09     ` Matthew Brost
2026-09-08 13:56 ` ✓ CI.KUnit: success for drm/xe: Skip clearing purged page-table BOs (rev3) Patchwork
2026-09-08 14:46 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-08 19:31 ` ✓ Xe.CI.FULL: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox