summaryrefslogtreecommitdiff
path: root/lib
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
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')
-rw-r--r--lib/igt_draw.c10
-rw-r--r--lib/igt_sysfs.c3
-rw-r--r--lib/ioctl_wrappers.c23
-rw-r--r--lib/ioctl_wrappers.h2
4 files changed, 27 insertions, 11 deletions
diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index 45fa10f6..3afb8272 100644
--- a/lib/igt_draw.c
+++ b/lib/igt_draw.c
@@ -246,7 +246,7 @@ static void draw_rect_mmap_cpu(int fd, struct buf_data *buf, struct rect *rect,
gem_set_domain(fd, buf->handle, I915_GEM_DOMAIN_CPU,
I915_GEM_DOMAIN_CPU);
- gem_get_tiling(fd, buf->handle, &tiling, &swizzle);
+ igt_require(gem_get_tiling(fd, buf->handle, &tiling, &swizzle));
/* We didn't implement suport for the older tiling methods yet. */
if (tiling != I915_TILING_NONE)
@@ -295,7 +295,7 @@ static void draw_rect_mmap_wc(int fd, struct buf_data *buf, struct rect *rect,
gem_set_domain(fd, buf->handle, I915_GEM_DOMAIN_GTT,
I915_GEM_DOMAIN_GTT);
- gem_get_tiling(fd, buf->handle, &tiling, &swizzle);
+ igt_require(gem_get_tiling(fd, buf->handle, &tiling, &swizzle));
/* We didn't implement suport for the older tiling methods yet. */
if (tiling != I915_TILING_NONE)
@@ -392,7 +392,7 @@ static void draw_rect_pwrite(int fd, struct buf_data *buf,
{
uint32_t tiling, swizzle;
- gem_get_tiling(fd, buf->handle, &tiling, &swizzle);
+ igt_require(gem_get_tiling(fd, buf->handle, &tiling, &swizzle));
switch (tiling) {
case I915_TILING_NONE:
@@ -419,7 +419,7 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
uint32_t tiling, swizzle;
int pitch;
- gem_get_tiling(fd, buf->handle, &tiling, &swizzle);
+ igt_require(gem_get_tiling(fd, buf->handle, &tiling, &swizzle));
dst = gem_handle_to_libdrm_bo(cmd_data->bufmgr, fd, "", buf->handle);
igt_assert(dst);
@@ -483,7 +483,7 @@ static void draw_rect_render(int fd, struct cmd_data *cmd_data,
rect->w % (32 / buf->bpp) != 0 ||
rect->h % (32 / buf->bpp) != 0);
- gem_get_tiling(fd, buf->handle, &tiling, &swizzle);
+ igt_require(gem_get_tiling(fd, buf->handle, &tiling, &swizzle));
/* We create a temporary buffer and copy from it using rendercopy. */
tmp.size = rect->w * rect->h * pixel_size;
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 612de751..c19821da 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -148,7 +148,8 @@ int igt_sysfs_open_parameters(int device)
if (dir < 0)
return -1;
- params = openat(dir, "device/driver/module/parameters", O_RDONLY);
+ params = -1;
+ //params = openat(dir, "device/driver/module/parameters", O_RDONLY);
close(dir);
if (params < 0) { /* builtin? */
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)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 42dc3cb7..465f760b 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -53,7 +53,7 @@ drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd,
/* ioctl_wrappers.c:
*
* ioctl wrappers and similar stuff for bare metal testing */
-void gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle);
+bool gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle);
void gem_set_tiling(int fd, uint32_t handle, uint32_t tiling, uint32_t stride);
int __gem_set_tiling(int fd, uint32_t handle, uint32_t tiling, uint32_t stride);