summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-10-19 14:07:25 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-10-19 16:15:07 +0100
commite27626898b87a1602e6af6f7effcacf772ead491 (patch)
tree506e8b40ded5291e4f8a8207038a778dd14572fb /lib/ioctl_wrappers.c
parent27d30707410c4a89480effa75bb6792331ca3342 (diff)
igt: Check the physical swizzle status
The kernel tries to hide L-shaped memory with asymmetric swizzling from userspace by reporting lies through the get-tiling interface. Check for these lies by comparing the reported swizzle with the actual swizzle, and only run swizzling tests where we know the underlying physical swizzling. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 8632878f..95bc5e26 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -111,6 +111,19 @@ gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd, const char *name, uint
return bo;
}
+static int
+__gem_get_tiling(int fd, struct drm_i915_gem_get_tiling *arg)
+{
+ int err;
+
+ err = 0;
+ if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, arg))
+ err = -errno;
+ errno = 0;
+
+ return err;
+}
+
/**
* gem_get_tiling:
* @fd: open i915 drm file descriptor
@@ -119,21 +132,23 @@ gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd, const char *name, uint
* @swizzle: (out) bit 6 swizzle mode
*
* This wraps the GET_TILING ioctl.
+ *
+ * Returns whether the actual physical tiling matches the reported tiling.
*/
-void
+bool
gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
{
struct drm_i915_gem_get_tiling get_tiling;
- int ret;
memset(&get_tiling, 0, sizeof(get_tiling));
get_tiling.handle = handle;
- ret = igt_ioctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
- igt_assert(ret == 0);
+ igt_assert_eq(__gem_get_tiling(fd, &get_tiling), 0);
*tiling = get_tiling.tiling_mode;
*swizzle = get_tiling.swizzle_mode;
+
+ return get_tiling.phys_swizzle_mode == get_tiling.swizzle_mode;
}
int __gem_set_tiling(int fd, uint32_t handle, uint32_t tiling, uint32_t stride)