public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH i-g-t] lib/draw: Align mmap requests to page boundaries
@ 2019-01-07 10:56 Chris Wilson
  2019-01-07 11:19 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2019-01-07 10:56 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

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>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-23 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-07 10:56 [Intel-gfx] [PATCH i-g-t] lib/draw: Align mmap requests to page boundaries Chris Wilson
2019-01-07 11:19 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-01-07 13:43 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-01-23 14:22 ` [igt-dev] [PATCH i-g-t] " Joonas Lahtinen
2019-01-23 14:25   ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox