Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <dev@lankhorst.se>
To: intel-xe@lists.freedesktop.org
Cc: Maarten Lankhorst <dev@lankhorst.se>
Subject: [RFC PATCH 3/3] drm/xe: Add migration selftest for validating job submission and basic features work
Date: Mon, 26 Jan 2026 13:52:07 +0100	[thread overview]
Message-ID: <20260126125207.1119351-4-dev@lankhorst.se> (raw)
In-Reply-To: <20260126125207.1119351-1-dev@lankhorst.se>

Add a migration selftest that copies either from local VRAM to sysmem,
or sysmem to sysmem. The idea is to validate whether accessing VRAM and
system memory works, so we don't run into slightly harder issues later
if ATS fails.

TODO: Do we want to run this all the time, put it behind a module
parameter, or only if DRM_XE_DEBUG_VM is set?

Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
 drivers/gpu/drm/xe/xe_device.c  |  7 ++++++
 drivers/gpu/drm/xe/xe_migrate.c | 43 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_migrate.h |  1 +
 3 files changed, 51 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index aad4aa53a51f9..4e244c0ed23cc 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -46,6 +46,7 @@
 #include "xe_i2c.h"
 #include "xe_irq.h"
 #include "xe_late_bind_fw.h"
+#include "xe_migrate.h"
 #include "xe_mmio.h"
 #include "xe_module.h"
 #include "xe_nvm.h"
@@ -974,6 +975,12 @@ int xe_device_probe(struct xe_device *xe)
 	if (err)
 		return err;
 
+	for_each_tile(tile, xe, id) {
+		err = xe_migrate_selftest(tile->migrate);
+		if (err)
+			return err;
+	}
+
 	err = drm_dev_register(&xe->drm, 0);
 	if (err)
 		return err;
diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index cbcac57b2c760..bf2000d8d7c23 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -37,6 +37,7 @@
 #include "xe_sriov_vf_ccs.h"
 #include "xe_svm.h"
 #include "xe_sync.h"
+#include "xe_tile_printk.h"
 #include "xe_trace_bo.h"
 #include "xe_validation.h"
 #include "xe_vm.h"
@@ -519,6 +520,48 @@ int xe_migrate_init(struct xe_migrate *m)
 
 }
 
+int xe_migrate_selftest(struct xe_migrate *m)
+{
+	struct xe_tile *tile = m->tile;
+	struct xe_device *xe = tile->xe;
+	struct xe_bo *mem_bo;
+	struct xe_bo *tile_bo;
+	struct dma_fence *fence;
+	int err;
+
+	tile_bo = xe_bo_create_pin_map_novm(xe, tile, SZ_2M, ttm_bo_type_kernel,
+					    XE_BO_FLAG_VRAM_IF_DGFX(tile), false);
+
+	if (IS_ERR(tile_bo))
+		return PTR_ERR(tile_bo);
+
+	mem_bo = xe_bo_create_pin_map_novm(xe, tile, xe_bo_size(tile_bo), ttm_bo_type_kernel,
+					   XE_BO_FLAG_SYSTEM, false);
+
+	if (IS_ERR(mem_bo)) {
+		err = PTR_ERR(mem_bo);
+		goto out_put_tile;
+	}
+
+	xe_map_memset(xe, &mem_bo->vmap, 0, 0xc0, xe_bo_size(mem_bo));
+
+	fence = xe_migrate_copy(m, tile_bo, mem_bo, tile_bo->ttm.resource, mem_bo->ttm.resource, false);
+	if (IS_ERR(fence)) {
+		err = PTR_ERR(fence);
+		goto out_put_mem;
+	}
+	err = dma_fence_wait(fence, false);
+	dma_fence_put(fence);
+
+out_put_mem:
+	xe_bo_unpin_map_no_vm(mem_bo);
+out_put_tile:
+	xe_bo_unpin_map_no_vm(tile_bo);
+	if (err)
+		xe_tile_err(tile, "Migration selftest failed with %pe\n", ERR_PTR(err));
+	return err;
+}
+
 static u64 max_mem_transfer_per_pass(struct xe_device *xe)
 {
 	if (!IS_DGFX(xe) && xe_device_has_flat_ccs(xe))
diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
index 1522afb37dcfa..92f40bc671d40 100644
--- a/drivers/gpu/drm/xe/xe_migrate.h
+++ b/drivers/gpu/drm/xe/xe_migrate.h
@@ -112,6 +112,7 @@ struct xe_migrate_pt_update {
 
 struct xe_migrate *xe_migrate_alloc(struct xe_tile *tile);
 int xe_migrate_init(struct xe_migrate *m);
+int xe_migrate_selftest(struct xe_migrate *m);
 
 struct dma_fence *xe_migrate_to_vram(struct xe_migrate *m,
 				     unsigned long npages,
-- 
2.51.0


  parent reply	other threads:[~2026-01-26 12:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 12:52 [RFC PATCH 0/3] drm/xe: Enable ATS Maarten Lankhorst
2026-01-26 12:52 ` [RFC PATCH 1/3] drm/xe: Force page fault Maarten Lankhorst
2026-01-26 12:52 ` [RFC PATCH 2/3] drm/xe: Set the bits in PASID to enable ATS Maarten Lankhorst
2026-01-26 12:52 ` Maarten Lankhorst [this message]
2026-01-26 19:19   ` [RFC PATCH 3/3] drm/xe: Add migration selftest for validating job submission and basic features work Matthew Brost
2026-01-26 12:58 ` ✗ CI.checkpatch: warning for drm/xe: Enable ATS Patchwork
2026-01-26 13:00 ` ✓ CI.KUnit: success " Patchwork
2026-01-26 13:38 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-01-26 14:32 ` ✗ Xe.CI.Full: " Patchwork
2026-01-26 23:23 ` [RFC PATCH 0/3] " Matthew Brost
2026-01-27  8:01 ` ✗ Xe.CI.BAT: failure for " 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=20260126125207.1119351-4-dev@lankhorst.se \
    --to=dev@lankhorst.se \
    --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