All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: zbigniew.kempczynski@intel.com, priyanka.dandamudi@intel.com,
	Sobin Thomas <sobin.thomas@intel.com>
Subject: [PATCH v2 i-g-t 1/1] tests/intel/xe_compute_preempt: GPU Compatibility check
Date: Mon,  8 Sep 2025 17:14:21 +0000	[thread overview]
Message-ID: <20250908171421.1787165-2-sobin.thomas@intel.com> (raw)
In-Reply-To: <20250908171421.1787165-1-sobin.thomas@intel.com>

On platforms that do not support walker mid-thread preemption, running
tests in forked threads can lead to inconsistent states due to
igt_skip being called mid-execution. This patch introduces a GPU
compatibility check at the beginning of the xe_compute_preempt test.
If the GPU version does not support the required features, the
entire test is skipped gracefully, ensuring consistent behavior across
platforms.

v2: Fixed review comments to move the compatibility check
    into the igt_fixture.

Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
 lib/intel_compute.c              | 45 +++++++++++++++++++-------------
 lib/intel_compute.h              |  2 ++
 tests/intel/xe_compute_preempt.c |  1 +
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/lib/intel_compute.c b/lib/intel_compute.c
index 147dd2916..2bb70824e 100644
--- a/lib/intel_compute.c
+++ b/lib/intel_compute.c
@@ -2219,24 +2219,6 @@ static bool __run_intel_compute_kernel_preempt(int fd,
 	unsigned int ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
 	unsigned int batch;
 	const struct intel_compute_kernels *kernels = intel_compute_square_kernels;
-	enum intel_driver driver = get_intel_driver(fd);
-
-	for (batch = 0; batch < ARRAY_SIZE(intel_compute_preempt_batches); batch++)
-		if (ip_ver == intel_compute_preempt_batches[batch].ip_ver)
-			break;
-
-
-	if (batch == ARRAY_SIZE(intel_compute_preempt_batches)) {
-		igt_debug("GPU version 0x%x not supported\n", ip_ver);
-		return false;
-	}
-
-	if (!(COMPAT_DRIVER_FLAG(driver) & intel_compute_preempt_batches[batch].compat)) {
-		igt_debug("Driver is not supported: flags %x & %x\n",
-			  COMPAT_DRIVER_FLAG(driver),
-			  intel_compute_preempt_batches[batch].compat);
-		return false;
-	}
 
 	while (kernels->kernel) {
 		if (ip_ver == kernels->ip_ver)
@@ -2260,6 +2242,31 @@ static bool __run_intel_compute_kernel_preempt(int fd,
 
 	return true;
 }
+
+bool check_gpu_compatibility_kernel_preempt(int fd)
+{
+	unsigned int ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
+	unsigned int batch;
+	enum intel_driver driver = get_intel_driver(fd);
+
+	for (batch = 0; batch < ARRAY_SIZE(intel_compute_preempt_batches); batch++)
+		if (ip_ver == intel_compute_preempt_batches[batch].ip_ver)
+			break;
+
+	if (batch == ARRAY_SIZE(intel_compute_preempt_batches)) {
+		igt_debug("GPU version 0x%x not supported\n", ip_ver);
+		return false;
+	}
+
+	if (!(COMPAT_DRIVER_FLAG(driver) & intel_compute_preempt_batches[batch].compat)) {
+		igt_debug("Driver is not supported: flags %x & %x\n",
+			COMPAT_DRIVER_FLAG(driver),
+			intel_compute_preempt_batches[batch].compat);
+		return false;
+	}
+	return true;
+}
+
 /**
  * run_intel_compute_kernel_preempt - runs compute kernels to
  * exercise preemption scenario.
@@ -2275,6 +2282,8 @@ bool run_intel_compute_kernel_preempt(int fd,
 		bool threadgroup_preemption,
 		enum execenv_alloc_prefs alloc_prefs)
 {
+	if (!check_gpu_compatibility_kernel_preempt(fd))
+		return false;
 	return __run_intel_compute_kernel_preempt(fd, eci, threadgroup_preemption,
 						  alloc_prefs);
 }
diff --git a/lib/intel_compute.h b/lib/intel_compute.h
index 412791d07..0998fd661 100644
--- a/lib/intel_compute.h
+++ b/lib/intel_compute.h
@@ -73,6 +73,8 @@ enum execenv_alloc_prefs {
 
 extern const struct intel_compute_kernels intel_compute_square_kernels[];
 
+bool check_gpu_compatibility_kernel_preempt(int fd);
+
 bool run_intel_compute_kernel(int fd, struct user_execenv *user,
 			      enum execenv_alloc_prefs alloc_prefs);
 bool xe_run_intel_compute_kernel_on_engine(int fd, struct drm_xe_engine_class_instance *eci,
diff --git a/tests/intel/xe_compute_preempt.c b/tests/intel/xe_compute_preempt.c
index c9b194869..5722ef3d4 100644
--- a/tests/intel/xe_compute_preempt.c
+++ b/tests/intel/xe_compute_preempt.c
@@ -73,6 +73,7 @@ igt_main
 		ram_mb = igt_get_avail_ram_mb();
 		swap_mb = igt_get_total_swap_mb();
 		vram_mb = xe_visible_vram_size(xe, 0) >> 20;
+		igt_require_f(check_gpu_compatibility_kernel_preempt(xe), "GPU not supported\n");
 	}
 
 	igt_subtest_with_dynamic("compute-preempt") {
-- 
2.34.1


  reply	other threads:[~2025-09-08 17:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08 17:14 [PATCH v2 i-g-t 0/1] tests/intel/xe_compute_preempt: GPU Compatibility check Sobin Thomas
2025-09-08 17:14 ` Sobin Thomas [this message]
2025-09-09  7:40   ` [PATCH v2 i-g-t 1/1] " Zbigniew Kempczyński
2025-09-09  3:11 ` ✓ i915.CI.BAT: success for tests/intel/xe_compute_preempt: GPU Compatibility check (rev2) Patchwork
2025-09-09  3:19 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-09 12:05 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-09 18:40 ` ✗ i915.CI.Full: " 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=20250908171421.1787165-2-sobin.thomas@intel.com \
    --to=sobin.thomas@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=priyanka.dandamudi@intel.com \
    --cc=zbigniew.kempczynski@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.