Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/6] tests/api_intel_allocator: Verify gem-pool is working as expected
Date: Fri, 11 Mar 2022 13:13:14 +0100	[thread overview]
Message-ID: <20220311121318.112757-3-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20220311121318.112757-1-zbigniew.kempczynski@intel.com>

Simple check which acquires buffer objects from gem-pool. It verifies:
- object reuse (previously created is completed in execbuf)
- object creation (submitting batches when spinner is executing).

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 tests/i915/api_intel_allocator.c | 58 ++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c
index a652caf4ec..a7929e9b13 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c
@@ -692,6 +692,60 @@ static void fork_reopen_allocator(int fd, uint8_t type)
 	intel_allocator_multiprocess_stop();
 }
 
+static uint32_t single_exec_from_pool(int i915, uint64_t ahnd, uint64_t size)
+{
+	struct drm_i915_gem_execbuffer2 execbuf = {};
+	struct drm_i915_gem_exec_object2 obj = {};
+	uint32_t bb = gem_create_from_pool(i915, &size, REGION_SMEM);
+	uint32_t *bbptr;
+
+	bbptr = gem_mmap__device_coherent(i915, bb, 0, size, PROT_WRITE);
+	*bbptr = MI_BATCH_BUFFER_END;
+	gem_munmap(bbptr, size);
+	obj.offset = get_offset(ahnd, bb, size, 0);
+	if (ahnd)
+		obj.flags = EXEC_OBJECT_PINNED;
+	obj.handle = bb;
+	execbuf.buffer_count = 1;
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	gem_execbuf(i915, &execbuf);
+
+	return bb;
+}
+
+static void gem_pool(int i915)
+{
+	uint32_t bb[4];
+	uint64_t ahnd = get_reloc_ahnd(i915, 0);
+	igt_spin_t *spin;
+
+	bb[0] = single_exec_from_pool(i915, ahnd, 4096);
+	gem_sync(i915, bb[0]);
+	bb[1] = single_exec_from_pool(i915, ahnd, 4096);
+	igt_assert(bb[0] == bb[1]);
+
+	bb[2] = single_exec_from_pool(i915, ahnd, 8192);
+	gem_sync(i915, bb[2]);
+	bb[3] = single_exec_from_pool(i915, ahnd, 8192);
+	igt_assert(bb[2] == bb[3]);
+	igt_assert(bb[0] != bb[2]);
+
+	spin = igt_spin_new(i915,
+			    .ahnd = ahnd,
+			    .engine = I915_EXEC_DEFAULT);
+	bb[0] = single_exec_from_pool(i915, ahnd, 4096);
+	bb[1] = single_exec_from_pool(i915, ahnd, 4096);
+	bb[2] = single_exec_from_pool(i915, ahnd, 8192);
+	bb[3] = single_exec_from_pool(i915, ahnd, 8192);
+	igt_spin_free(i915, spin);
+	igt_assert(bb[0] != bb[1]);
+	igt_assert(bb[2] != bb[3]);
+
+	put_ahnd(ahnd);
+
+	gem_pool_dump();
+}
+
 struct allocators {
 	const char *name;
 	uint8_t type;
@@ -790,6 +844,10 @@ igt_main
 	igt_subtest_f("execbuf-with-allocator")
 		execbuf_with_allocator(fd);
 
+	igt_describe("Verifies creating and executing bb from gem pool");
+	igt_subtest_f("gem-pool")
+		gem_pool(fd);
+
 	igt_fixture
 		close(fd);
 }
-- 
2.32.0

  parent reply	other threads:[~2022-03-11 12:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 12:13 [igt-dev] [PATCH i-g-t 0/6] Add i915 blt library + gem_ccs test Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 1/6] lib/i915/gem_create: Introduce gem-pool bo cache Zbigniew Kempczyński
2022-03-11 12:13 ` Zbigniew Kempczyński [this message]
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 3/6] lib/i915: Introduce library intel_mocs Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 4/6] i915/gem_engine_topology: Add helpers for checking driver capabilities Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 5/6] lib/i915_blt: Add library for blitter Zbigniew Kempczyński
2022-03-11 12:13 ` [igt-dev] [PATCH i-g-t 6/6] tests/gem_ccs: Verify uncompressed and compressed blits Zbigniew Kempczyński
2022-03-11 13:00 ` [igt-dev] ✓ Fi.CI.BAT: success for Add i915 blt library + gem_ccs test (rev8) Patchwork
2022-03-11 15:06 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2022-03-10  7:15 [igt-dev] [PATCH i-g-t 0/6] Add i915 blt library + gem_ccs test Zbigniew Kempczyński
2022-03-10  7:15 ` [igt-dev] [PATCH i-g-t 2/6] tests/api_intel_allocator: Verify gem-pool is working as expected Zbigniew Kempczyński
2022-03-11 10:51   ` Kamil Konieczny

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=20220311121318.112757-3-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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