Skip to contentSkip to conversation

tests/i915/gem_exec_capture : Add support for local memory

PATCH In review [email protected] 3 participants 3 messages May 9, 2022 – May 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/i915/gem_exec_capture : Add support for local memory

From: Sai Gowtham Ch <[email protected]>

v1: Adding local memory support to many-4K-zero subtest
and used new macro for_each_memory_region for memory regioning.

v2: Add 48b exec flag for execbuf.

v3: Iterate make-4k-incremental subtest over memory region and
also reducing the number of objects created in lmem so that allocations in lmem is done adequate based on the allocation size available , as lmem is occupied by flatccs + gtt.

Cc Zbigniew Kempczyński <[email protected]>
---
 tests/i915/gem_exec_capture.c | 103 ++++++++++++++++++++--------------
 1 file changed, 61 insertions(+), 42 deletions(-)
tests/i915/gem_exec_capture.c +61 -42
index 60f8df04..ca3703a3 100644
@@ -250,7 +250,8 @@ static void wait_to_die(int fence_out)
 
 static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 		       const struct intel_execution_engine2 *e,
-		       uint32_t target, uint64_t target_size, uint32_t region)
+		       uint32_t target, uint64_t target_size,
+		       struct drm_i915_gem_memory_class_instance *region)
 {
 	const unsigned int gen = intel_gen(intel_get_drm_devid(fd));
 	struct drm_i915_gem_exec_object2 obj[4];
@@ -268,13 +269,13 @@ static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 	saved_engine = configure_hangs(fd, e, ctx->id);
 
 	memset(obj, 0, sizeof(obj));
-	obj[SCRATCH].handle = gem_create_in_memory_regions(fd, 4096, region);
+	obj[SCRATCH].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[SCRATCH].flags = EXEC_OBJECT_WRITE;
 	obj[CAPTURE].handle = target;
 	obj[CAPTURE].flags = EXEC_OBJECT_CAPTURE;
 	obj[NOCAPTURE].handle = gem_create(fd, 4096);
 
-	obj[BATCH].handle = gem_create_in_memory_regions(fd, 4096, region);
+	obj[BATCH].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[BATCH].relocs_ptr = (uintptr_t)reloc;
 	obj[BATCH].relocation_count = !ahnd ? ARRAY_SIZE(reloc) : 0;
 
@@ -384,12 +385,13 @@ static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 }
 
 static void capture(int fd, int dir, const intel_ctx_t *ctx,
-		    const struct intel_execution_engine2 *e, uint32_t region)
+		const struct intel_execution_engine2 *e,
+		struct drm_i915_gem_memory_class_instance *region)
 {
 	uint32_t handle;
 	uint64_t ahnd, obj_size = 4096;
 
-	igt_assert_eq(__gem_create_in_memory_regions(fd, &handle, &obj_size, region), 0);
+	igt_assert_eq(__gem_create_in_memory_region_list(fd, &handle, &obj_size, region, 1), 0);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
 	__capture1(fd, dir, ahnd, ctx, e, handle, obj_size, region);
@@ -415,7 +417,8 @@ static struct offset *
 __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 	   const struct intel_execution_engine2 *e,
 	   unsigned int size, int count,
-	   unsigned int flags, int *_fence_out)
+	   unsigned int flags, int *_fence_out,
+	   struct drm_i915_gem_memory_class_instance *region)
 #define INCREMENTAL 0x1
 #define ASYNC 0x2
 {
@@ -436,9 +439,10 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 	obj = calloc(count + 2, sizeof(*obj));
 	igt_assert(obj);
 
-	obj[0].handle = gem_create(fd, 4096);
+	obj[0].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[0].offset = get_offset(ahnd, obj[0].handle, 4096, 0);
-	obj[0].flags = EXEC_OBJECT_WRITE | (ahnd ? EXEC_OBJECT_PINNED : 0);
+	obj[0].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_WRITE |
+			(ahnd ? EXEC_OBJECT_PINNED : 0);
 
 	for (i = 0; i < count; i++) {
 		obj[i + 1].handle = gem_create(fd, size);
@@ -459,11 +463,12 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 		}
 	}
 
-	obj[count + 1].handle = gem_create(fd, 4096);
+	obj[count + 1].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[count + 1].relocs_ptr = (uintptr_t)reloc;
 	obj[count + 1].relocation_count = !ahnd ? ARRAY_SIZE(reloc) : 0;
 	obj[count + 1].offset = get_offset(ahnd, obj[count + 1].handle, 4096, 0);
-	obj[count + 1].flags = ahnd ? EXEC_OBJECT_PINNED : 0;
+	obj[count + 1].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS |
+			(ahnd ? EXEC_OBJECT_PINNED : 0);
 
 	memset(reloc, 0, sizeof(reloc));
 	reloc[0].target_handle = obj[count + 1].handle; /* recurse */
@@ -585,29 +590,41 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 		saved = configure_hangs(fd, e, ctx->id); \
 	} while(0)
 
-static void many(int fd, int dir, uint64_t size, unsigned int flags)
+static void many(int fd, int dir, uint64_t size, unsigned int flags,
+		struct drm_i915_gem_memory_class_instance *region)
 {
 	const struct intel_execution_engine2 *e;
 	const intel_ctx_t *ctx;
-	uint64_t ram, gtt, ahnd;
+	uint64_t ram, gtt, ahnd, lmem_size;
 	unsigned long count, blobs;
 	struct offset *offsets;
 	struct gem_engine_properties saved_engine;
+	struct drm_i915_query_memory_regions *info;
 
 	find_first_available_engine(fd, ctx, e, saved_engine);
 
 	gtt = gem_aperture_size(fd) / size;
-	ram = (intel_get_avail_ram_mb() << 20) / size;
+	ram = (intel_get_avail_ram_mb() << 20) / (size * 32);
 	igt_debug("Available objects in GTT:%"PRIu64", RAM:%"PRIu64"\n",
 		  gtt, ram);
 
-	count = min(gtt, ram) / 4;
-	igt_require(count > 1);
+	info = gem_get_query_memory_regions(fd);
+	lmem_size = gpu_meminfo_region_total_size(info, I915_MEMORY_CLASS_DEVICE) / (size * 16);
+
+	if (region->memory_class == I915_MEMORY_CLASS_SYSTEM) {
+		count = min(gtt, ram) / 4;
+		igt_require(count > 1);
+		intel_require_memory(count, size, CHECK_RAM);
+
+	} else {
+		count = min(gtt, lmem_size) / 4;
+		igt_require(count > 1);
+	}
 
-	intel_require_memory(count, size, CHECK_RAM);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
-	offsets = __captureN(fd, dir, ahnd, ctx, e, size, count, flags, NULL);
+	offsets = __captureN(fd, dir, ahnd, ctx, e, size, count, flags, NULL,
+			region);
 
 	blobs = check_error_state(dir, offsets, count, size, !!(flags & INCREMENTAL));
 	igt_info("Captured %lu %"PRId64"-blobs out of a total of %lu\n",
@@ -620,7 +637,8 @@ static void many(int fd, int dir, uint64_t size, unsigned int flags)
 }
 
 static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
-		    const struct intel_execution_engine2 *e)
+		    const struct intel_execution_engine2 *e,
+		    struct drm_i915_gem_memory_class_instance *region)
 {
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj = {
@@ -677,7 +695,8 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
 		/* Reopen the allocator in the new process. */
 		ahnd = get_reloc_ahnd(fd, ctx2->id);
 
-		free(__captureN(fd, dir, ahnd, ctx2, e, size, count, ASYNC, &fence_out));
+		free(__captureN(fd, dir, ahnd, ctx2, e, size, count, ASYNC,
+					&fence_out, region));
 		put_ahnd(ahnd);
 
 		write(link[1], &fd, sizeof(fd)); /* wake the parent up */
@@ -708,7 +727,8 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
 	put_ahnd(ahnd);
 }
 
-static void userptr(int fd, int dir)
+static void userptr(int fd, int dir,
+		struct drm_i915_gem_memory_class_instance *region)
 {
 	const struct intel_execution_engine2 *e;
 	const intel_ctx_t *ctx;
@@ -716,7 +736,7 @@ static void userptr(int fd, int dir)
 	uint64_t ahnd;
 	void *ptr;
 	int obj_size = 4096;
-	uint32_t system_region = INTEL_MEMORY_REGION_ID(I915_SYSTEM_MEMORY, 0);
+
 	struct gem_engine_properties saved_engine;
 
 	find_first_available_engine(fd, ctx, e, saved_engine);
@@ -726,7 +746,8 @@ static void userptr(int fd, int dir)
 	igt_require(__gem_userptr(fd, ptr, obj_size, 0, 0, &handle) == 0);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
-	__capture1(fd, dir, ahnd, ctx, e, handle, obj_size, system_region);
+	__capture1(fd, dir, ahnd, ctx, e, handle, obj_size,
+			region);
 
 	gem_close(fd, handle);
 	put_ahnd(ahnd);
@@ -764,9 +785,10 @@ igt_main
 	int fd = -1;
 	int dir = -1;
 	struct drm_i915_query_memory_regions *query_info;
-	struct igt_collection *regions, *set;
-	char *sub_name;
-	uint32_t region;
+	struct drm_i915_gem_memory_class_instance region_smem = {
+		.memory_class = I915_MEMORY_CLASS_SYSTEM,
+		.memory_instance = 0,
+	};
 
 	igt_fixture {
 		int gen;
@@ -788,56 +810,53 @@ igt_main
 		igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0);
 		query_info = gem_get_query_memory_regions(fd);
 		igt_assert(query_info);
-		set = get_memory_region_set(query_info,
-				I915_SYSTEM_MEMORY,
-				I915_DEVICE_MEMORY);
 	}
 
 	test_each_engine("capture", fd, ctx, e) {
-		for_each_combination(regions, 1, set) {
-			sub_name = memregion_dynamic_subtest_name(regions);
-			region = igt_collection_get_value(regions, 0);
-			igt_dynamic_f("%s-%s", e->name, sub_name)
-				capture(fd, dir, ctx, e, region);
-			free(sub_name);
+		for_each_memory_region(r, fd) {
+			igt_dynamic_f("%s-%s", e->name, r->name)
+				capture(fd, dir, ctx, e, &r->ci);
 		}
 	}
 
 	igt_subtest_f("many-4K-zero") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 1<<12, 0);
+		many(fd, dir, 1<<12, 0, &region_smem);
 	}
 
-	igt_subtest_f("many-4K-incremental") {
+	igt_subtest_with_dynamic("many-4K-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 1<<12, INCREMENTAL);
+		for_each_memory_region(r, fd) {
+			igt_dynamic_f("%s", r->name)
+				many(fd, dir, 1<<12, INCREMENTAL, &r->ci);
+		}
 	}
 
 	igt_subtest_f("many-2M-zero") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 2<<20, 0);
+		many(fd, dir, 2<<20, 0, &region_smem);
 	}
 
 	igt_subtest_f("many-2M-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 2<<20, INCREMENTAL);
+		many(fd, dir, 2<<20, INCREMENTAL, &region_smem);
 	}
 
 	igt_subtest_f("many-256M-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 256<<20, INCREMENTAL);
+		many(fd, dir, 256<<20, INCREMENTAL, &region_smem);
 	}
 
 	/* And check we can read from different types of objects */
 
 	igt_subtest_f("userptr") {
 		igt_require(gem_can_store_dword(fd, 0));
-		userptr(fd, dir);
+		userptr(fd, dir, &region_smem);
 	}
 
 	test_each_engine("pi", fd, ctx, e)
 		igt_dynamic_f("%s", (e)->name)
-			prioinv(fd, dir, ctx, e);
+			prioinv(fd, dir, ctx, e, &region_smem);
 
 	igt_fixture {
 		close(dir);
Signature · 1 line
2.35.1
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for tests/i915/gem_exec_capture : Add support for local memory (rev5)

== Series Details ==

== Series Details ==

Series: tests/i915/gem_exec_capture : Add support for local memory (rev5)
URL : https://patchwork.freedesktop.org/series/95707/
State : success

== Summary ==

CI Bug Log - changes from IGT_6469 -> IGTPW_7072
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/index.html

Participating hosts (43 -> 40)
------------------------------

Additional (1): bat-dg2-9
Missing (4): bat-adlm-1 fi-bsw-cyan bat-dg1-6 bat-adlp-4

Known issues
------------

Here are the changes found in IGTPW_7072 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_module_load@reload:
- fi-kbl-soraka: [PASS][1] -> [DMESG-WARN][2] ([i915#1982])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/fi-kbl-soraka/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/fi-kbl-soraka/igt@[email protected]

* igt@i915_selftest@live@requests:
- fi-blb-e6850: [PASS][3] -> [DMESG-FAIL][4] ([i915#4528])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/fi-blb-e6850/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/fi-blb-e6850/igt@i915_selftest@[email protected]
- fi-pnv-d510: [PASS][5] -> [DMESG-FAIL][6] ([i915#4528])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/fi-pnv-d510/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/fi-pnv-d510/igt@i915_selftest@[email protected]

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-hsw-4770: NOTRUN -> [SKIP][7] ([fdo#109271] / [fdo#111827])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/fi-hsw-4770/igt@[email protected]

#### Possible fixes ####

* igt@core_hotunplug@unbind-rebind:
- {bat-rpls-2}: [DMESG-WARN][8] ([i915#4391]) -> [PASS][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/bat-rpls-2/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/bat-rpls-2/igt@[email protected]

* igt@gem_ringfill@basic-all:
- {bat-dg2-8}: [TIMEOUT][10] ([i915#5647]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/bat-dg2-8/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/bat-dg2-8/igt@[email protected]

* igt@i915_selftest@live@gt_pm:
- fi-tgl-1115g4: [DMESG-FAIL][12] ([i915#3987]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/fi-tgl-1115g4/igt@i915_selftest@live@gt_pm.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/fi-tgl-1115g4/igt@i915_selftest@live@gt_pm.html

* igt@i915_selftest@live@hangcheck:
- fi-hsw-4770: [INCOMPLETE][14] ([i915#4785]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/fi-hsw-4770/igt@i915_selftest@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/fi-hsw-4770/igt@i915_selftest@[email protected]

* igt@kms_flip@basic-flip-vs-modeset@b-edp1:
- {bat-adlp-6}: [DMESG-WARN][16] ([i915#3576]) -> [PASS][17] +2 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_6469/bat-adlp-6/igt@kms_flip@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/bat-adlp-6/igt@kms_flip@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3576]: https://gitlab.freedesktop.org/drm/intel/issues/3576
[i915#3987]: https://gitlab.freedesktop.org/drm/intel/issues/3987
[i915#4391]: https://gitlab.freedesktop.org/drm/intel/issues/4391
[i915#4528]: https://gitlab.freedesktop.org/drm/intel/issues/4528
[i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
[i915#5171]: https://gitlab.freedesktop.org/drm/intel/issues/5171
[i915#5174]: https://gitlab.freedesktop.org/drm/intel/issues/5174
[i915#5181]: https://gitlab.freedesktop.org/drm/intel/issues/5181
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5606]: https://gitlab.freedesktop.org/drm/intel/issues/5606
[i915#5647]: https://gitlab.freedesktop.org/drm/intel/issues/5647
[i915#5703]: https://gitlab.freedesktop.org/drm/intel/issues/5703
[i915#5775]: https://gitlab.freedesktop.org/drm/intel/issues/5775

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_6469 -> IGTPW_7072

CI-20190529: 20190529
CI_DRM_11626: 1672d1c43e4377628b445ab011343fe2496a41ce @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_7072: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/index.html
IGT_6469: fe3c194ba90615e2402461348357c88a23864275 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_7072/index.html

#2 lore raw
In reply to [email protected]
Quoted 49 lines · On Tue, May 10, 2022 at 03:50:20AM +0530, [email protected] wrote:

From: Sai Gowtham Ch <[email protected]>

v1: Adding local memory support to many-4K-zero subtest
and used new macro for_each_memory_region for memory regioning.

v2: Add 48b exec flag for execbuf.

v3: Iterate make-4k-incremental subtest over memory region and
also reducing the number of objects created in lmem so that allocations in lmem is done adequate based on the allocation size available , as lmem is occupied by flatccs + gtt.

Cc Zbigniew Kempczyński <[email protected]>
---
 tests/i915/gem_exec_capture.c | 103 ++++++++++++++++++++--------------
 1 file changed, 61 insertions(+), 42 deletions(-)
tests/i915/gem_exec_capture.c +4 -3
index 60f8df04..ca3703a3 100644
@@ -250,7 +250,8 @@ static void wait_to_die(int fence_out)
 
 static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 		       const struct intel_execution_engine2 *e,
-		       uint32_t target, uint64_t target_size, uint32_t region)
+		       uint32_t target, uint64_t target_size,
+		       struct drm_i915_gem_memory_class_instance *region)
 {
 	const unsigned int gen = intel_gen(intel_get_drm_devid(fd));
 	struct drm_i915_gem_exec_object2 obj[4];
@@ -268,13 +269,13 @@ static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 	saved_engine = configure_hangs(fd, e, ctx->id);
 
 	memset(obj, 0, sizeof(obj));
-	obj[SCRATCH].handle = gem_create_in_memory_regions(fd, 4096, region);
+	obj[SCRATCH].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[SCRATCH].flags = EXEC_OBJECT_WRITE;
 	obj[CAPTURE].handle = target;
 	obj[CAPTURE].flags = EXEC_OBJECT_CAPTURE;
 	obj[NOCAPTURE].handle = gem_create(fd, 4096);
 
-	obj[BATCH].handle = gem_create_in_memory_regions(fd, 4096, region);
+	obj[BATCH].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[BATCH].relocs_ptr = (uintptr_t)reloc;
 	obj[BATCH].relocation_count = !ahnd ? ARRAY_SIZE(reloc) : 0;
 

tests/i915/gem_exec_capture.c static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx, · line 389

Quoted 6 lines
tests/i915/gem_exec_capture.c +2 -1
@@ -384,12 +385,13 @@ static void __capture1(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 }
 
 static void capture(int fd, int dir, const intel_ctx_t *ctx,
-		    const struct intel_execution_engine2 *e, uint32_t region)
+		const struct intel_execution_engine2 *e,
+		struct drm_i915_gem_memory_class_instance *region)

Invalid indentation.

Quoted 20 lines
tests/i915/gem_exec_capture.c +3 -2
 {
 	uint32_t handle;
 	uint64_t ahnd, obj_size = 4096;
 
-	igt_assert_eq(__gem_create_in_memory_regions(fd, &handle, &obj_size, region), 0);
+	igt_assert_eq(__gem_create_in_memory_region_list(fd, &handle, &obj_size, region, 1), 0);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
 	__capture1(fd, dir, ahnd, ctx, e, handle, obj_size, region);
@@ -415,7 +417,8 @@ static struct offset *
 __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 	   const struct intel_execution_engine2 *e,
 	   unsigned int size, int count,
-	   unsigned int flags, int *_fence_out)
+	   unsigned int flags, int *_fence_out,
+	   struct drm_i915_gem_memory_class_instance *region)
 #define INCREMENTAL 0x1
 #define ASYNC 0x2
 {

tests/i915/gem_exec_capture.c __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx, · line 445

Quoted 9 lines
tests/i915/gem_exec_capture.c +3 -2
@@ -436,9 +439,10 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 	obj = calloc(count + 2, sizeof(*obj));
 	igt_assert(obj);
 
-	obj[0].handle = gem_create(fd, 4096);
+	obj[0].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[0].offset = get_offset(ahnd, obj[0].handle, 4096, 0);
-	obj[0].flags = EXEC_OBJECT_WRITE | (ahnd ? EXEC_OBJECT_PINNED : 0);
+	obj[0].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_WRITE |
+			(ahnd ? EXEC_OBJECT_PINNED : 0);

Same here.

Quoted 5 lines
tests/i915/gem_exec_capture.c +0 -0
 	for (i = 0; i < count; i++) {
 		obj[i + 1].handle = gem_create(fd, size);
@@ -459,11 +463,12 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 		}

tests/i915/gem_exec_capture.c __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx, · line 471

Quoted 10 lines
tests/i915/gem_exec_capture.c +3 -2
 	}
 
-	obj[count + 1].handle = gem_create(fd, 4096);
+	obj[count + 1].handle = gem_create_in_memory_region_list(fd, 4096, region, 1);
 	obj[count + 1].relocs_ptr = (uintptr_t)reloc;
 	obj[count + 1].relocation_count = !ahnd ? ARRAY_SIZE(reloc) : 0;
 	obj[count + 1].offset = get_offset(ahnd, obj[count + 1].handle, 4096, 0);
-	obj[count + 1].flags = ahnd ? EXEC_OBJECT_PINNED : 0;
+	obj[count + 1].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS |
+			(ahnd ? EXEC_OBJECT_PINNED : 0);

And here.

Quoted 32 lines
tests/i915/gem_exec_capture.c +7 -5
 	memset(reloc, 0, sizeof(reloc));
 	reloc[0].target_handle = obj[count + 1].handle; /* recurse */
@@ -585,29 +590,41 @@ __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx,
 		saved = configure_hangs(fd, e, ctx->id); \
 	} while(0)
 
-static void many(int fd, int dir, uint64_t size, unsigned int flags)
+static void many(int fd, int dir, uint64_t size, unsigned int flags,
+		struct drm_i915_gem_memory_class_instance *region)
 {
 	const struct intel_execution_engine2 *e;
 	const intel_ctx_t *ctx;
-	uint64_t ram, gtt, ahnd;
+	uint64_t ram, gtt, ahnd, lmem_size;
 	unsigned long count, blobs;
 	struct offset *offsets;
 	struct gem_engine_properties saved_engine;
+	struct drm_i915_query_memory_regions *info;
 
 	find_first_available_engine(fd, ctx, e, saved_engine);
 
 	gtt = gem_aperture_size(fd) / size;
-	ram = (intel_get_avail_ram_mb() << 20) / size;
+	ram = (intel_get_avail_ram_mb() << 20) / (size * 32);
 	igt_debug("Available objects in GTT:%"PRIu64", RAM:%"PRIu64"\n",
 		  gtt, ram);
 
-	count = min(gtt, ram) / 4;
-	igt_require(count > 1);
+	info = gem_get_query_memory_regions(fd);
+	lmem_size = gpu_meminfo_region_total_size(info, I915_MEMORY_CLASS_DEVICE) / (size * 16);

tests/i915/gem_exec_capture.c __captureN(int fd, int dir, uint64_t ahnd, const intel_ctx_t *ctx, · line 622

Quoted 10 lines
tests/i915/gem_exec_capture.c +10 -0
+
+	if (region->memory_class == I915_MEMORY_CLASS_SYSTEM) {
+		count = min(gtt, ram) / 4;
+		igt_require(count > 1);
+		intel_require_memory(count, size, CHECK_RAM);
+
+	} else {
+		count = min(gtt, lmem_size) / 4;
+		igt_require(count > 1);
+	}

igt_require() can be outside condition. BTW you've limited this memory constraint too much and I got:

Starting subtest: many-256M-incremental
Test requirement not met in function many, file ../tests/i915/gem_exec_capture.c:616:
Test requirement: count > 1
Subtest many-256M-incremental: SKIP (0.066s)

Even if machine has enough memory to run the test.

Quoted 31 lines
tests/i915/gem_exec_capture.c +6 -4
-	intel_require_memory(count, size, CHECK_RAM);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
-	offsets = __captureN(fd, dir, ahnd, ctx, e, size, count, flags, NULL);
+	offsets = __captureN(fd, dir, ahnd, ctx, e, size, count, flags, NULL,
+			region);
 
 	blobs = check_error_state(dir, offsets, count, size, !!(flags & INCREMENTAL));
 	igt_info("Captured %lu %"PRId64"-blobs out of a total of %lu\n",
@@ -620,7 +637,8 @@ static void many(int fd, int dir, uint64_t size, unsigned int flags)
 }
 
 static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
-		    const struct intel_execution_engine2 *e)
+		    const struct intel_execution_engine2 *e,
+		    struct drm_i915_gem_memory_class_instance *region)
 {
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj = {
@@ -677,7 +695,8 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
 		/* Reopen the allocator in the new process. */
 		ahnd = get_reloc_ahnd(fd, ctx2->id);
 
-		free(__captureN(fd, dir, ahnd, ctx2, e, size, count, ASYNC, &fence_out));
+		free(__captureN(fd, dir, ahnd, ctx2, e, size, count, ASYNC,
+					&fence_out, region));
 		put_ahnd(ahnd);
 
 		write(link[1], &fd, sizeof(fd)); /* wake the parent up */

tests/i915/gem_exec_capture.c static void prioinv(int fd, int dir, const intel_ctx_t *ctx, · line 731

Quoted 6 lines
tests/i915/gem_exec_capture.c +2 -1
@@ -708,7 +727,8 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
 	put_ahnd(ahnd);
 }
 
-static void userptr(int fd, int dir)
+static void userptr(int fd, int dir,
+		struct drm_i915_gem_memory_class_instance *region)

Indentation.

Quoted 13 lines
tests/i915/gem_exec_capture.c +1 -1
 {
 	const struct intel_execution_engine2 *e;
 	const intel_ctx_t *ctx;
@@ -716,7 +736,7 @@ static void userptr(int fd, int dir)
 	uint64_t ahnd;
 	void *ptr;
 	int obj_size = 4096;
-	uint32_t system_region = INTEL_MEMORY_REGION_ID(I915_SYSTEM_MEMORY, 0);
+
 	struct gem_engine_properties saved_engine;
 
 	find_first_available_engine(fd, ctx, e, saved_engine);

tests/i915/gem_exec_capture.c static void userptr(int fd, int dir) · line 750

Quoted 6 lines
tests/i915/gem_exec_capture.c +2 -1
@@ -726,7 +746,8 @@ static void userptr(int fd, int dir)
 	igt_require(__gem_userptr(fd, ptr, obj_size, 0, 0, &handle) == 0);
 	ahnd = get_reloc_ahnd(fd, ctx->id);
 
-	__capture1(fd, dir, ahnd, ctx, e, handle, obj_size, system_region);
+	__capture1(fd, dir, ahnd, ctx, e, handle, obj_size,
+			region);

Keep region in same line.

--
Zbigniew

Quoted 91 lines
tests/i915/gem_exec_capture.c +18 -20
 	gem_close(fd, handle);
 	put_ahnd(ahnd);
@@ -764,9 +785,10 @@ igt_main
 	int fd = -1;
 	int dir = -1;
 	struct drm_i915_query_memory_regions *query_info;
-	struct igt_collection *regions, *set;
-	char *sub_name;
-	uint32_t region;
+	struct drm_i915_gem_memory_class_instance region_smem = {
+		.memory_class = I915_MEMORY_CLASS_SYSTEM,
+		.memory_instance = 0,
+	};
 
 	igt_fixture {
 		int gen;
@@ -788,56 +810,53 @@ igt_main
 		igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0);
 		query_info = gem_get_query_memory_regions(fd);
 		igt_assert(query_info);
-		set = get_memory_region_set(query_info,
-				I915_SYSTEM_MEMORY,
-				I915_DEVICE_MEMORY);
 	}
 
 	test_each_engine("capture", fd, ctx, e) {
-		for_each_combination(regions, 1, set) {
-			sub_name = memregion_dynamic_subtest_name(regions);
-			region = igt_collection_get_value(regions, 0);
-			igt_dynamic_f("%s-%s", e->name, sub_name)
-				capture(fd, dir, ctx, e, region);
-			free(sub_name);
+		for_each_memory_region(r, fd) {
+			igt_dynamic_f("%s-%s", e->name, r->name)
+				capture(fd, dir, ctx, e, &r->ci);
 		}
 	}
 
 	igt_subtest_f("many-4K-zero") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 1<<12, 0);
+		many(fd, dir, 1<<12, 0, &region_smem);
 	}
 
-	igt_subtest_f("many-4K-incremental") {
+	igt_subtest_with_dynamic("many-4K-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 1<<12, INCREMENTAL);
+		for_each_memory_region(r, fd) {
+			igt_dynamic_f("%s", r->name)
+				many(fd, dir, 1<<12, INCREMENTAL, &r->ci);
+		}
 	}
 
 	igt_subtest_f("many-2M-zero") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 2<<20, 0);
+		many(fd, dir, 2<<20, 0, &region_smem);
 	}
 
 	igt_subtest_f("many-2M-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 2<<20, INCREMENTAL);
+		many(fd, dir, 2<<20, INCREMENTAL, &region_smem);
 	}
 
 	igt_subtest_f("many-256M-incremental") {
 		igt_require(gem_can_store_dword(fd, 0));
-		many(fd, dir, 256<<20, INCREMENTAL);
+		many(fd, dir, 256<<20, INCREMENTAL, &region_smem);
 	}
 
 	/* And check we can read from different types of objects */
 
 	igt_subtest_f("userptr") {
 		igt_require(gem_can_store_dword(fd, 0));
-		userptr(fd, dir);
+		userptr(fd, dir, &region_smem);
 	}
 
 	test_each_engine("pi", fd, ctx, e)
 		igt_dynamic_f("%s", (e)->name)
-			prioinv(fd, dir, ctx, e);
+			prioinv(fd, dir, ctx, e, &region_smem);
 
 	igt_fixture {
 		close(dir);
Signature · 1 line
2.35.1