All of lore.kernel.org
 help / color / mirror / Atom feed
From: sai.gowtham.ch@intel.com
To: igt-dev@lists.freedesktop.org, sai.gowtham.ch@intel.com,
	zbigniew.kempczynski@intel.com
Subject: [igt-dev] [PATCH i-g-t] tests/i915/gem_exec_suspend: Add support for local memory
Date: Tue, 12 Oct 2021 10:31:22 +0530	[thread overview]
Message-ID: <20211012050122.21907-1-sai.gowtham.ch@intel.com> (raw)

From: Ch Sai Gowtham <sai.gowtham.ch@intel.com>

Add support for local memory region (Device memory)

Signed-off-by: Ch Sai Gowtham <sai.gowtham.ch@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 tests/i915/gem_exec_suspend.c | 187 ++++++++++++++++++++++++++--------
 1 file changed, 147 insertions(+), 40 deletions(-)

diff --git a/tests/i915/gem_exec_suspend.c b/tests/i915/gem_exec_suspend.c
index 887bb735..ac7e1b7c 100644
--- a/tests/i915/gem_exec_suspend.c
+++ b/tests/i915/gem_exec_suspend.c
@@ -51,8 +51,19 @@
 #define CACHED (1<<8)
 #define HANG (2<<8)
 
+static uint32_t batch_create(int fd, uint32_t batch_size, uint32_t region)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	uint32_t handle;
+
+	handle = gem_create_in_memory_regions(fd, batch_size, region);
+	gem_write(fd, handle, 0, &bbe, sizeof(bbe));
+
+	return handle;
+}
+
 static void run_test(int fd, const intel_ctx_t *ctx,
-		     unsigned engine, unsigned flags);
+		     unsigned engine, unsigned flags, uint32_t region);
 
 static void check_bo(int fd, uint32_t handle)
 {
@@ -67,16 +78,15 @@ static void check_bo(int fd, uint32_t handle)
 	munmap(map, 4096);
 }
 
-static void test_all(int fd, const intel_ctx_t *ctx, unsigned flags)
+static void test_all(int fd, const intel_ctx_t *ctx, unsigned flags, uint32_t region)
 {
-	run_test(fd, ctx, ALL_ENGINES, flags & ~0xff);
+	run_test(fd, ctx, ALL_ENGINES, flags & ~0xff, region);
 }
 
 static void run_test(int fd, const intel_ctx_t *ctx,
-		     unsigned engine, unsigned flags)
+		     unsigned engine, unsigned flags, uint32_t region)
 {
 	const unsigned int gen = intel_gen(intel_get_drm_devid(fd));
-	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj[2];
 	struct drm_i915_gem_relocation_entry reloc;
 	struct drm_i915_gem_execbuffer2 execbuf;
@@ -100,7 +110,7 @@ static void run_test(int fd, const intel_ctx_t *ctx,
 
 	/* Before suspending, check normal operation */
 	if (mode(flags) != NOSLEEP)
-		test_all(fd, ctx, flags);
+		test_all(fd, ctx, flags, region);
 
 	gem_quiescent_gpu(fd);
 
@@ -117,8 +127,7 @@ static void run_test(int fd, const intel_ctx_t *ctx,
 	if (!gem_has_lmem(fd))
 		gem_set_caching(fd, obj[0].handle, !!(flags & CACHED));
 	obj[0].flags |= EXEC_OBJECT_WRITE;
-	obj[1].handle = gem_create(fd, 4096);
-	gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
+	obj[1].handle = batch_create(fd, 4096, region);
 	igt_require(__gem_execbuf(fd, &execbuf) == 0);
 	gem_close(fd, obj[1].handle);
 
@@ -222,7 +231,7 @@ static void run_test(int fd, const intel_ctx_t *ctx,
 
 	/* After resume, make sure it still works */
 	if (mode(flags) != NOSLEEP)
-		test_all(fd, ctx, flags);
+		test_all(fd, ctx, flags, region);
 }
 
 struct battery_sample {
@@ -250,7 +259,7 @@ static double d_time(const struct battery_sample *after,
 }
 
 static void power_test(int i915, const intel_ctx_t *ctx,
-		       unsigned engine, unsigned flags)
+		       unsigned engine, unsigned flags, uint32_t region)
 {
 	struct battery_sample before, after;
 	char *status;
@@ -270,7 +279,7 @@ static void power_test(int i915, const intel_ctx_t *ctx,
 	igt_set_autoresume_delay(5 * 60); /* 5 minutes; longer == more stable */
 
 	igt_assert(get_power(dir, &before));
-	run_test(i915, ctx, engine, flags);
+	run_test(i915, ctx, engine, flags, region);
 	igt_assert(get_power(dir, &after));
 
 	igt_set_autoresume_delay(0);
@@ -296,6 +305,10 @@ igt_main
 	igt_hang_t hang;
 	const intel_ctx_t *ctx;
 	int fd;
+	char *sub_name;
+	uint32_t region;
+	struct drm_i915_query_memory_regions *query_info;
+	struct igt_collection *set, *regions;
 
 	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
@@ -304,49 +317,111 @@ igt_main
 		ctx = intel_ctx_create_all_physical(fd);
 
 		igt_fork_hang_detector(fd);
+		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);
+	}
+
+	igt_subtest_with_dynamic("basic") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, ctx, ALL_ENGINES, NOSLEEP, region);
+			free(sub_name);
+		}
 	}
 
-	igt_subtest("basic")
-		run_test(fd, ctx, ALL_ENGINES, NOSLEEP);
-	igt_subtest("basic-S0")
-		run_test(fd, ctx, ALL_ENGINES, IDLE);
-	igt_subtest("basic-S3-devices")
-		run_test(fd, ctx, ALL_ENGINES, SUSPEND_DEVICES);
-	igt_subtest("basic-S3")
-		run_test(fd, ctx, ALL_ENGINES, SUSPEND);
-	igt_subtest("basic-S4-devices")
-		run_test(fd, ctx, ALL_ENGINES, HIBERNATE_DEVICES);
-	igt_subtest("basic-S4")
-		run_test(fd, ctx, ALL_ENGINES, HIBERNATE);
+	igt_subtest_with_dynamic("basic-S0") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, ctx, ALL_ENGINES, IDLE, region);
+			free(sub_name);
+		}
+	}
+
+	igt_subtest_with_dynamic("basic-S3-devices") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, ctx, ALL_ENGINES, SUSPEND_DEVICES, region);
+			free(sub_name);
+		}
+	}
+
+	igt_subtest_with_dynamic("basic-S3") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, ctx, ALL_ENGINES, SUSPEND, region);
+			free(sub_name);
+		}
+	}
+
+	igt_subtest_with_dynamic("basic-S4-devices") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, ctx, ALL_ENGINES, HIBERNATE_DEVICES, region);
+			free(sub_name);
+		}
+	}
+
+	igt_subtest_with_dynamic("basic-S4") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, ctx, ALL_ENGINES, HIBERNATE, region);
+			free(sub_name);
+		}
+	}
 
 	for (m = modes; m->suffix; m++) {
 		igt_subtest_with_dynamic_f("fixed%s", m->suffix) {
-			igt_require(gem_has_lmem(fd));
 			for_each_ctx_engine(fd, ctx, e) {
 				if (!gem_class_can_store_dword(fd, e->class))
 					continue;
-				igt_dynamic_f("%s", e->name)
-					run_test(fd, ctx, e->flags, m->mode);
+				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)
+						run_test(fd, ctx, e->flags, m->mode, region);
+				}
 			}
 		}
 
 		igt_subtest_with_dynamic_f("uncached%s", m->suffix) {
-			igt_require(!gem_has_lmem(fd));
 			for_each_ctx_engine(fd, ctx, e) {
 				if (!gem_class_can_store_dword(fd, e->class))
 					continue;
-				igt_dynamic_f("%s", e->name)
-					run_test(fd, ctx, e->flags, m->mode | UNCACHED);
+				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)
+						run_test(fd, ctx, e->flags, m->mode | UNCACHED, region);
+				}
 			}
 		}
 
 		igt_subtest_with_dynamic_f("cached%s", m->suffix) {
-			igt_require(!gem_has_lmem(fd));
 			for_each_ctx_engine(fd, ctx, e) {
 				if (!gem_class_can_store_dword(fd, e->class))
 					continue;
-				igt_dynamic_f("%s", e->name)
-					run_test(fd, ctx, e->flags, m->mode | CACHED);
+				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)
+						run_test(fd, ctx, e->flags, m->mode | CACHED, region);
+				}
 			}
 		}
 	}
@@ -356,17 +431,49 @@ igt_main
 		hang = igt_allow_hang(fd, 0, 0);
 	}
 
-	igt_subtest("hang-S3")
-		run_test(fd, intel_ctx_0(fd), 0, SUSPEND | HANG);
-	igt_subtest("hang-S4")
-		run_test(fd, intel_ctx_0(fd), 0, HIBERNATE | HANG);
+	igt_subtest_with_dynamic("hang-S3") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, intel_ctx_0(fd), 0, SUSPEND | HANG, region);
+			free(sub_name);
+		}
+	}
 
-	igt_subtest("power-S0")
-		power_test(fd, intel_ctx_0(fd), 0, IDLE);
-	igt_subtest("power-S3")
-		power_test(fd, intel_ctx_0(fd), 0, SUSPEND);
+	igt_subtest_with_dynamic("hang-S4") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				run_test(fd, intel_ctx_0(fd), 0, HIBERNATE | HANG, region);
+			free(sub_name);
+		}
+	}
+
+	igt_subtest_with_dynamic("power-S0") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				power_test(fd, intel_ctx_0(fd), 0, IDLE, region);
+			free(sub_name);
+		}
+	}
+
+	igt_subtest_with_dynamic("power-S3") {
+		for_each_combination(regions, 1, set) {
+			sub_name = memregion_dynamic_subtest_name(regions);
+			region = igt_collection_get_value(regions, 0);
+			igt_dynamic_f("%s", sub_name)
+				power_test(fd, intel_ctx_0(fd), 0, SUSPEND, region);
+			free(sub_name);
+		}
+	}
 
 	igt_fixture {
+		free(query_info);
+		igt_collection_destroy(set);
 		igt_disallow_hang(fd, hang);
 		intel_ctx_destroy(fd, ctx);
 		close(fd);
-- 
2.32.0

             reply	other threads:[~2021-10-12  5:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  5:01 sai.gowtham.ch [this message]
2021-10-12  5:47 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/i915/gem_exec_suspend: Add support for local memory Patchwork
2021-10-13 15:10 ` [igt-dev] [PATCH i-g-t] " Zbigniew Kempczyński
2021-11-22  7:36 sai.gowtham.ch
2021-11-25 17:54 ` Zbigniew Kempczyński
2021-12-13  8:46 sai.gowtham.ch
2021-12-13 12:50 ` Zbigniew Kempczyński
2021-12-16  5:17 sai.gowtham.ch
2021-12-16  7:16 ` Zbigniew Kempczyński

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=20211012050122.21907-1-sai.gowtham.ch@intel.com \
    --to=sai.gowtham.ch@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --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.