From: Matthew Brost <matthew.brost@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH] tests/intel/xe_vm: Add BO partial mmap test
Date: Wed, 14 Aug 2024 08:58:54 -0700 [thread overview]
Message-ID: <20240814155854.3846990-1-matthew.brost@intel.com> (raw)
Ensure BO partial mmap works by setting a BO to 0, partially mmap BO and
setting to a canned value, and then mmap entire BO ensure data
integrity.
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
tests/intel/xe_vm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index c3960fedee..57534a2a8c 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -106,6 +106,56 @@ test_scratch(int fd)
xe_vm_destroy(fd, vm);
}
+/**
+ * SUBTEST: bo-mmap-partial
+ * Description: Test partially mmap of a BO
+ * Functionality: BO mmap
+ * Test category: functionality test
+ */
+
+static void test_bo_mmap_partial(int fd, size_t bo_size)
+{
+#define MMAP_VALUE(idx) ((0xdeadull << 32) | idx)
+ uint32_t bo;
+ uint64_t offset;
+ uint64_t *ptr;
+ size_t partial_size = bo_size / 2;
+ void *map;
+ int i, j;
+
+ bo = xe_bo_create(fd, 0, bo_size, vram_if_possible(fd, 0),
+ DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+
+ /* Set to zero */
+ map = xe_bo_map(fd, bo, bo_size);
+ memset(map, 0, bo_size);
+ munmap(map, bo_size);
+
+ /* Partial map */
+ offset = xe_bo_mmap_offset(fd, bo);
+ map = mmap(NULL, partial_size, PROT_WRITE, MAP_SHARED, fd,
+ offset + partial_size);
+ igt_assert(map != MAP_FAILED);
+ ptr = map;
+ for (i = 0, j = partial_size / sizeof(uint64_t);
+ j < bo_size / sizeof(uint64_t); ++i, ++j)
+ ptr[i] = MMAP_VALUE(j);
+ munmap(map, partial_size);
+
+ /* Map entire BO and check */
+ map = xe_bo_map(fd, bo, bo_size);
+ ptr = map;
+ for (i = 0; i < bo_size / sizeof(uint64_t); ++i) {
+ if (i < partial_size / sizeof(uint64_t))
+ igt_assert_eq(ptr[i], 0);
+ else
+ igt_assert_eq(ptr[i], MMAP_VALUE(i));
+ }
+ munmap(map, bo_size);
+ gem_close(fd, bo);
+#undef MMAP_VALUE
+}
+
static void
__test_bind_one_bo(int fd, uint32_t vm, int n_addrs, uint64_t *addrs)
{
@@ -2354,6 +2404,9 @@ igt_main
}
}
+ igt_subtest("bo-mmap-partial")
+ test_bo_mmap_partial(fd, SZ_2M);
+
igt_subtest("bind-once")
test_bind_once(fd);
--
2.34.1
next reply other threads:[~2024-08-14 15:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 15:58 Matthew Brost [this message]
2024-08-14 16:48 ` [PATCH] tests/intel/xe_vm: Add BO partial mmap test Matthew Auld
2024-08-14 17:00 ` Matthew Brost
2024-08-14 17:40 ` ✓ CI.xeBAT: success for " Patchwork
2024-08-14 17:51 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-08-15 0:44 ` ✗ CI.xeFULL: " Patchwork
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=20240814155854.3846990-1-matthew.brost@intel.com \
--to=matthew.brost@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