[igt-dev] [PATCH i-g-t] tests/i915/gem_tiled_wc: skip on platforms without GGTT

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Jan 28 09:00:22 UTC 2020


On platforms without aperture ensure test is skipped. Localize
GEM_MMAP ioctl() to make sure this interface is tested.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_tiled_wc.c | 48 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_tiled_wc.c b/tests/i915/gem_tiled_wc.c
index 845ec228..89b5fea9 100644
--- a/tests/i915/gem_tiled_wc.c
+++ b/tests/i915/gem_tiled_wc.c
@@ -54,6 +54,50 @@ static int tile_width;
 static int tile_height;
 static int tile_size;
 
+struct local_i915_gem_mmap_v2 {
+	uint32_t handle;
+	uint32_t pad;
+	uint64_t offset;
+	uint64_t size;
+	uint64_t addr_ptr;
+	uint64_t flags;
+#define I915_MMAP_WC 0x1
+};
+#define LOCAL_IOCTL_I915_GEM_MMAP_v2 DRM_IOWR(DRM_COMMAND_BASE \
+	+ DRM_I915_GEM_MMAP, struct local_i915_gem_mmap_v2)
+
+static int mmap_ioctl(int i915, struct drm_i915_gem_mmap *arg)
+{
+	int err = 0;
+
+	if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_MMAP, arg))
+		err = -errno;
+
+	errno = 0;
+	return err;
+}
+
+/*
+ * Local WC GEM_MMAP IOCTL wrapper.
+ */
+static void *
+local_gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size,
+		   unsigned prot)
+{
+	struct drm_i915_gem_mmap arg = {
+		.handle = handle,
+		.offset = offset,
+		.size = size,
+		.flags = I915_MMAP_WC,
+	};
+	(void) prot; //currently not used
+
+	igt_assert_eq(mmap_ioctl(fd, &arg), 0);
+	igt_assert(arg.addr_ptr);
+
+	return from_user_pointer(arg.addr_ptr);
+}
+
 static uint32_t
 create_bo(int fd)
 {
@@ -114,6 +158,7 @@ igt_simple_main
 
 	fd = drm_open_driver(DRIVER_INTEL);
 	gem_require_mmap_wc(fd);
+	gem_require_mappable_ggtt(fd);
 
 	handle = create_bo(fd);
 	igt_require(gem_get_tiling(fd, handle, &tiling, &swizzle));
@@ -153,7 +198,8 @@ igt_simple_main
 		first_page = offset & -PAGE_SIZE;
 		last_page = (offset + len + PAGE_SIZE - 1) & -PAGE_SIZE;
 
-		linear = gem_mmap__wc(fd, handle, first_page, last_page - first_page, PROT_READ);
+		linear = local_gem_mmap__wc(fd, handle, first_page,
+					    last_page - first_page, PROT_READ);
 
 		/* Translate from offsets in the read buffer to the swizzled
 		 * address that it corresponds to.  This is the opposite of
-- 
2.23.0



More information about the igt-dev mailing list