From: Matthew Auld <matthew.auld@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH i-g-t v2 5/6] i915/tests/capture: add a negative test for NEEDS_CPU_ACCESS
Date: Mon, 21 Feb 2022 14:16:19 +0000 [thread overview]
Message-ID: <20220221141620.2490914-6-matthew.auld@intel.com> (raw)
In-Reply-To: <20220221141620.2490914-1-matthew.auld@intel.com>
Sanity check that the kernel does indeed reject LMEM buffers marked with
EXEC_OBJECT_CAPTURE, that are not also marked with NEEDS_CPU_ACCESS.
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
tests/i915/gem_exec_capture.c | 69 +++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 24ba6036..09187f62 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -735,6 +735,71 @@ static void userptr(int fd, int dir)
gem_engine_properties_restore(fd, &saved_engine);
}
+static bool supports_needs_cpu_access(int fd)
+{
+ struct drm_i915_gem_memory_class_instance regions[] = {
+ { I915_MEMORY_CLASS_DEVICE, },
+ { I915_MEMORY_CLASS_SYSTEM, },
+ };
+ struct drm_i915_gem_create_ext_memory_regions setparam_region = {
+ .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS },
+ .regions = to_user_pointer(®ions),
+ .num_regions = ARRAY_SIZE(regions),
+ };
+ uint64_t size = 4096;
+ uint32_t handle;
+ int ret;
+
+ ret = __gem_create_ext(fd, &size,
+ I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS,
+ &handle, &setparam_region.base);
+ if (!ret) {
+ gem_close(fd, handle);
+ igt_assert(gem_has_lmem(fd)); /* Should be dgpu only */
+ }
+
+ return ret == 0;
+}
+
+static void capture_no_cpu_access(int fd)
+{
+ struct drm_i915_gem_exec_object2 exec = {
+ .flags = EXEC_OBJECT_CAPTURE,
+ };
+ struct drm_i915_gem_execbuffer2 execbuf = {
+ .buffers_ptr = to_user_pointer(&exec),
+ .buffer_count = 1,
+ };
+ uint64_t size = 4096;
+ uint32_t handle;
+ int ret;
+
+ igt_require(gem_has_lmem(fd));
+ igt_require(supports_needs_cpu_access(fd));
+
+ /*
+ * Sanity check that execbuf rejects EXEC_OBJECT_CAPTURE marked BO, that
+ * is not also tagged with I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS, if
+ * it can be placed in LMEM. This is only relevant for Dg2+.
+ */
+
+ igt_require(__gem_create_in_memory_regions(fd, &handle, &size,
+ REGION_LMEM(0)) == 0);
+
+ exec.handle = handle;
+ ret = __gem_execbuf(fd, &execbuf);
+ if (IS_DG1(fd)) /* Should be no impact on existing ABI */
+ igt_assert(ret == 0);
+ else
+ igt_assert(ret == -EINVAL);
+
+ /* SMEM only buffers should work as normal */
+ igt_assert(__gem_create_in_memory_regions(fd, &handle, &size,
+ REGION_SMEM) == 0);
+ exec.handle = handle;
+ igt_assert(__gem_execbuf(fd, &execbuf) == 0);
+}
+
static bool has_capture(int fd)
{
drm_i915_getparam_t gp;
@@ -839,6 +904,10 @@ igt_main
igt_dynamic_f("%s", (e)->name)
prioinv(fd, dir, ctx, e);
+ igt_describe("Verify the ABI contract when using EXEC_OBJECT_CAPTURE without I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS");
+ igt_subtest_f("capture-non-cpu-access")
+ capture_no_cpu_access(fd);
+
igt_fixture {
close(dir);
igt_disallow_hang(fd, hang);
--
2.34.1
next prev parent reply other threads:[~2022-02-21 14:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 14:16 [Intel-gfx] [PATCH i-g-t v2 0/6] Exercise NEEDS_CPU_ACCESS Matthew Auld
2022-02-21 14:16 ` [Intel-gfx] [PATCH i-g-t v2 1/6] lib/i915_drm_local: Add I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS Matthew Auld
2022-02-21 14:16 ` [Intel-gfx] [PATCH i-g-t v2 2/6] lib/i915: wire up optional flags for gem_create_ext Matthew Auld
2022-02-21 14:16 ` [Intel-gfx] [PATCH i-g-t v2 3/6] tests/i915/gem_create: test NEEDS_CPU_ACCESS Matthew Auld
2022-02-21 14:16 ` [Intel-gfx] [PATCH i-g-t v2 4/6] lib/i915: add gem_create_with_cpu_access_in_memory_regions Matthew Auld
2022-02-21 14:16 ` Matthew Auld [this message]
2022-02-21 14:16 ` [Intel-gfx] [PATCH i-g-t v2 6/6] lib/i915: request CPU_ACCESS for fb objects Matthew Auld
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=20220221141620.2490914-6-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=thomas.hellstrom@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox