Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
To: igt-dev@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org,
	"Christian Koenig" <christian.koenig@amd.com>,
	maarten.lankhorst@linux.intel.com,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Natalie Vock" <natalie.vock@gmx.de>,
	kernel-dev@igalia.com,
	"Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
	"Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>
Subject: [PATCH i-g-t 3/8] Make xe_cgroup test a generic test
Date: Tue, 12 May 2026 18:51:50 -0300	[thread overview]
Message-ID: <20260512215156.4083082-4-cascardo@igalia.com> (raw)
In-Reply-To: <20260512215156.4083082-1-cascardo@igalia.com>

It should not be driver specific anymore. Make it run for multiple drivers,
though there is still only Xe now.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
---
 .../xe_cgroups.c => drv_dmem_cgroups.c}       | 61 +++++++++++--------
 tests/meson.build                             |  2 +-
 2 files changed, 38 insertions(+), 25 deletions(-)
 rename tests/{intel/xe_cgroups.c => drv_dmem_cgroups.c} (83%)

diff --git a/tests/intel/xe_cgroups.c b/tests/drv_dmem_cgroups.c
similarity index 83%
rename from tests/intel/xe_cgroups.c
rename to tests/drv_dmem_cgroups.c
index 9ff8d46570ab..6f4f779f3c2c 100644
--- a/tests/intel/xe_cgroups.c
+++ b/tests/drv_dmem_cgroups.c
@@ -4,13 +4,12 @@
  */
 
 /**
- * TEST: xe_cgroups
- * DESCRIPTION: Tests exercising the dmem cgroup controller on xe devices.
+ * TEST: drv_dmem_cgroups
+ * DESCRIPTION: Tests exercising the dmem cgroup controller on devices.
  * Category: Core
  * Mega feature: General Core features
  * Sub-category: cgroup
  * FUNCTIONALITY: cgroup dmem controller
- * SUBSETS: xe
  */
 
 #include <errno.h>
@@ -26,9 +25,6 @@
 #include "igt_aux.h"
 #include "igt_cgroup.h"
 #include "igt_dmem_driver.h"
-#include "xe_drm.h"
-#include "xe/xe_ioctl.h"
-#include "xe/xe_query.h"
 
 #define BO_SIZE			SZ_128M
 #define MAX_LIMIT		((uint64_t)4 * SZ_1G)
@@ -45,13 +41,12 @@
  * DESCRIPTION:
  *   Create a dmem cgroup, move the current process into it and set the max
  *   device memory limit for the first VRAM region to 4 GiB.  Then fill VRAM
- *   by creating BOs with %DRM_XE_GEM_CREATE_FLAG_DEFER_BACKING (so that the
- *   physical allocation is deferred until VM_BIND) and binding them into an
- *   LR VM until the cgroup limit is hit.  Verify that the reported cgroup
- *   current usage is within the expected range when the error occurs.
+ *   by creating BOs.
+ *   Verify that the reported cgroup current usage is within the expected
+ *   range when the error occurs.
  *   Finally lower the max limit in 256 MiB steps and verify that the cgroup
  *   usage follows.
- * REQUIREMENTS: must run as root; xe device with at least one VRAM region
+ * REQUIREMENTS: must run as root; device with at least one VRAM region
  */
 
 /**
@@ -61,7 +56,7 @@
  *   igt_fork_signal_helper() to verify that the dmem.max write path handles
  *   signal interruption correctly.  A signal handler counts received signals
  *   and the count is reported as debug output at the end of the test.
- * REQUIREMENTS: must run as root; xe device with at least one VRAM region
+ * REQUIREMENTS: must run as root; device with at least one VRAM region
  */
 
 static atomic_int signal_count;
@@ -111,7 +106,7 @@ static uint64_t wait_for_usage_drop(struct igt_cgroup *cg, const char *region,
 	return current;
 }
 
-static int fill_vram(struct igt_dmem_driver *drv, void *ctx, int fd, int max_bo)
+static int fill_vram(const struct igt_dmem_driver *drv, void *ctx, int fd, int max_bo)
 {
 	int n_bo, err = 0;
 
@@ -128,7 +123,7 @@ static int fill_vram(struct igt_dmem_driver *drv, void *ctx, int fd, int max_bo)
 	return n_bo;
 }
 
-static void test_write_eviction(int fd, unsigned int flags, struct igt_dmem_driver *drv)
+static void test_write_eviction(int fd, unsigned int flags, const struct igt_dmem_driver *drv)
 {
 	void *ctx;
 	struct igt_cgroup *cg;
@@ -161,7 +156,7 @@ static void test_write_eviction(int fd, unsigned int flags, struct igt_dmem_driv
 		install_sigcont_counter();
 
 	/* Create cgroup and move into it */
-	cg = igt_cgroup_new("xe_cgroups_test");
+	cg = igt_cgroup_new("igt_cgroups_test");
 	igt_cgroup_move_current(cg);
 	igt_cgroup_dmem_set_max(cg, cg_region, cg_max);
 
@@ -236,20 +231,38 @@ static const struct {
 	{ }
 };
 
+static const struct {
+	int driver_flag;
+	const struct igt_dmem_driver *driver;
+} drivers[] = {
+	{ DRIVER_XE, &xe_dmem_driver },
+	{ },
+};
+
 int igt_main()
 {
-	int fd = -1;
-
 	igt_fixture() {
-		fd = drm_open_driver(DRIVER_XE);
 		igt_require_f(getuid() == 0, "Test requires root\n");
 	}
 
-	for (int i = 0; subtests[i].name; i++)
-		igt_subtest(subtests[i].name)
-			test_write_eviction(fd, subtests[i].flags, &xe_dmem_driver);
-
-	igt_fixture() {
-		drm_close_driver(fd);
+	for (int d = 0; drivers[d].driver; d++) {
+		igt_subtest_group() {
+			int fd = -1;
+			igt_fixture() {
+				fd = drm_open_driver(drivers[d].driver_flag);
+				igt_require_f(fd >= 0,
+					"No %s device found, skipping\n",
+					drivers[d].driver->name);
+			}
+
+			for (int i = 0; subtests[i].name; i++)
+				igt_subtest_f("%s-%s", drivers[d].driver->name, subtests[i].name)
+					test_write_eviction(fd, subtests[i].flags, drivers[d].driver);
+
+			igt_fixture() {
+				if (fd >= 0)
+					drm_close_driver(fd);
+			}
+		}
 	}
 }
diff --git a/tests/meson.build b/tests/meson.build
index b4463a722361..deb049875b46 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -17,6 +17,7 @@ test_progs = [
 	'drm_mm',
 	'drm_read',
 	'drm_virtgpu',
+	'drv_dmem_cgroups',
 	'fbdev',
 	'kms_3d',
 	'kms_addfb_basic',
@@ -292,7 +293,6 @@ intel_xe_progs = [
 	'xe_dma_buf_sync',
 	'xe_drm_fdinfo',
 	'xe_eu_stall',
-	'xe_cgroups',
 	'xe_evict',
 	'xe_evict_ccs',
 	'xe_exec_atomic',
-- 
2.47.3


  parent reply	other threads:[~2026-05-12 21:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 21:51 [PATCH i-g-t 0/8] dmem: add amdgpu support and one more test Thadeu Lima de Souza Cascardo
2026-05-12 21:51 ` [PATCH i-g-t 1/8] Introduce dmem driver and implement Xe support Thadeu Lima de Souza Cascardo
2026-05-12 21:51 ` [PATCH i-g-t 2/8] Adjust xe_cgroups test to use igt_dmem_driver Thadeu Lima de Souza Cascardo
2026-05-13 15:18   ` Kamil Konieczny
2026-05-12 21:51 ` Thadeu Lima de Souza Cascardo [this message]
2026-05-13 15:21   ` [PATCH i-g-t 3/8] Make xe_cgroup test a generic test Kamil Konieczny
2026-05-12 21:51 ` [PATCH i-g-t 4/8] amdgpu: add amdgpu_cgroup_region_name Thadeu Lima de Souza Cascardo
2026-05-12 21:51 ` [PATCH i-g-t 5/8] igt_dmem_driver: add amdgpu support Thadeu Lima de Souza Cascardo
2026-05-13 15:26   ` Kamil Konieczny
2026-05-12 21:51 ` [PATCH i-g-t 6/8] dmem: add test for current/max Thadeu Lima de Souza Cascardo
2026-05-13 15:31   ` Kamil Konieczny
2026-05-12 21:51 ` [PATCH i-g-t 7/8] dmem: only check for dmem availability once Thadeu Lima de Souza Cascardo
2026-05-12 21:51 ` [PATCH i-g-t 8/8] dmem: get region once per driver Thadeu Lima de Souza Cascardo
2026-05-12 22:27 ` [PATCH i-g-t 0/8] dmem: add amdgpu support and one more test Thadeu Lima de Souza Cascardo
2026-05-13  8:06 ` Christian König
2026-05-13  8:54   ` Thomas Hellström

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=20260512215156.4083082-4-cascardo@igalia.com \
    --to=cascardo@igalia.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=kernel-dev@igalia.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=natalie.vock@gmx.de \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tvrtko.ursulin@igalia.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