[PATCH i-g-t] lib/draw: Align mmap requests to page boundaries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
---
 lib/igt_draw.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index a9a73cb89..4990d4a01 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) {
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux