Skip to contentSkip to conversation

test/intel/xe_vm: Add multi-GPU VRAM overcommit test

PATCH New Sobin Thomas 1 participant 1 message Sep 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/intel/xe_vm: Add multi-GPU VRAM overcommit test

Extend the VRAM overcommit test to cover all available Xe GPUs independently. Run each existing overcommit scenarios on every physical GPU and use the VRAM capacity of the respective GPU when calculating the overcommit size.

---
 tests/intel/xe_vm.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
tests/intel/xe_vm.c +56 -0
index 545350894..6588baa75 100644
@@ -22,6 +22,11 @@
 #include <string.h>
 #define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
 
+struct overcommit_gpu {
+	int fd;
+	struct drm_xe_engine_class_instance *hwe_non_copy;
+};
+
 enum overcommit_stage {
 	EXPECT_NONE,
 	EXPECT_CREATE,
@@ -35,6 +40,40 @@ addr_low(uint64_t addr)
 	return addr;
 }
 
+/* Get the number of the GPUs */
+static int get_overcommit_gpus(struct overcommit_gpu **gpus)
+{
+	struct overcommit_gpu *tmp = NULL;
+	int num_gpus = 0, i;
+
+	for (i = 0; ; i++) {
+		int gpu_fd;
+		struct drm_xe_engine *engine;
+		struct drm_xe_engine_class_instance *eci;
+
+		gpu_fd = __drm_open_driver_another(i, DRIVER_XE);
+		if (gpu_fd < 0)
+			break;
+		if (!xe_has_vram(gpu_fd) || !xe_visible_vram_size(gpu_fd, 0)) {
+			drm_close_driver(gpu_fd);
+			continue;
+		}
+		engine = xe_engine(gpu_fd, 0);
+		if (!engine) {
+			drm_close_driver(gpu_fd);
+			continue;
+		}
+		eci = &engine->instance;
+		tmp = realloc(tmp, (num_gpus + 1) * sizeof(*tmp));
+		igt_assert(tmp);
+		tmp[num_gpus].fd = gpu_fd;
+		tmp[num_gpus].hwe_non_copy = eci;
+		num_gpus++;
+	}
+	*gpus = tmp;
+	return num_gpus;
+}
+
 static uint32_t
 addr_high(int fd, uint64_t addr)
 {
@@ -3539,6 +3578,23 @@ int igt_main()
 		}
 	}
 
+	igt_subtest("overcommit-multigpu") {
+		struct overcommit_gpu *gpus = NULL;
+		int num_gpus = get_overcommit_gpus(&gpus);
+
+		for (int i = 0; i < num_gpus; i++) {
+			for (int j = 0; overcommit_cases[j].name; j++) {
+				const struct vm_overcommit_case *c = &overcommit_cases[j];
+
+				test_vm_overcommit(gpus[i].fd, gpus[i].hwe_non_copy, c,
+						   igt_get_avail_ram_mb() << 20,
+						   xe_visible_vram_size(gpus[i].fd, 0));
+			}
+			drm_close_driver(gpus[i].fd);
+		}
+		free(gpus);
+	}
+
 	igt_fixture()
 		drm_close_driver(fd);
 }
Signature · 1 line
2.52.0