summaryrefslogtreecommitdiff
path: root/lib/igt_draw.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-01-07 10:53:34 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-01-23 14:24:22 +0000
commit85cf76182087c09604bcae2bbee9e58b33bcb4f2 (patch)
treee0b943d9155adb26f1f7862dfd2b512d52be4c17 /lib/igt_draw.c
parent70749c70926f12043d3408b160606e1e6238ed3a (diff)
lib/draw: Align mmap requests to page boundaries
Since we trust fb->size as either calculated by calc_fb_size() or the supplied by the user, it invariably isn't page aligned. The mmap routines and ioctls only deal in pages... Not sure if fb->size should be page aligned, but that may break some other drawing tests, so opt to just fix up the mmap requests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Diffstat (limited to 'lib/igt_draw.c')
-rw-r--r--lib/igt_draw.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index a9a73cb8..4990d4a0 100644
--- a/lib/igt_draw.c
+++ b/lib/igt_draw.c
@@ -34,6 +34,13 @@
#include "ioctl_wrappers.h"
#include "i830_reg.h"
+#ifndef PAGE_ALIGN
+#ifndef PAGE_SIZE
+#define PAGE_SIZE 4096
+#endif
+#define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE)
+#endif
+
/**
* SECTION:igt_draw
* @short_description: drawing helpers for tests
@@ -336,7 +343,7 @@ static void draw_rect_mmap_cpu(int fd, struct buf_data *buf, struct rect *rect,
if (tiling != I915_TILING_NONE)
igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
- ptr = gem_mmap__cpu(fd, buf->handle, 0, buf->size, 0);
+ ptr = gem_mmap__cpu(fd, buf->handle, 0, PAGE_ALIGN(buf->size), 0);
switch (tiling) {
case I915_TILING_NONE:
@@ -365,7 +372,8 @@ static void draw_rect_mmap_gtt(int fd, struct buf_data *buf, struct rect *rect,
gem_set_domain(fd, buf->handle, I915_GEM_DOMAIN_GTT,
I915_GEM_DOMAIN_GTT);
- ptr = gem_mmap__gtt(fd, buf->handle, buf->size, PROT_READ | PROT_WRITE);
+ ptr = gem_mmap__gtt(fd, buf->handle, PAGE_ALIGN(buf->size),
+ PROT_READ | PROT_WRITE);
draw_rect_ptr_linear(ptr, buf->stride, rect, color, buf->bpp);
@@ -386,7 +394,7 @@ static void draw_rect_mmap_wc(int fd, struct buf_data *buf, struct rect *rect,
if (tiling != I915_TILING_NONE)
igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
- ptr = gem_mmap__wc(fd, buf->handle, 0, buf->size,
+ ptr = gem_mmap__wc(fd, buf->handle, 0, PAGE_ALIGN(buf->size),
PROT_READ | PROT_WRITE);
switch (tiling) {