[Intel-gfx] [PATCH i-g-t 5/7] lib: Die if framebuffer GTT mapping fails

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Fri Oct 9 09:19:14 PDT 2015


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Cairo helpfully allocates a new buffer for us when
cairo_image_surface_create_for_data() is called with a NULL ptr. That
means if gem_mmap__gtt() fails, we get a totally silent failure and
nothing ever drawn into the framebuffer. Very confusing.

Put in an igt_assert() to make sure we managed to mmap something.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_fb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 713bd50..e225f8a 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -774,8 +774,11 @@ static void destroy_cairo_surface__gtt(void *arg)
 
 static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)
 {
+	void *ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size, PROT_READ | PROT_WRITE);
+	igt_assert(ptr);
+
 	fb->cairo_surface =
-		cairo_image_surface_create_for_data(gem_mmap__gtt(fd, fb->gem_handle, fb->size, PROT_READ | PROT_WRITE),
+		cairo_image_surface_create_for_data(ptr,
 						    drm_format_to_cairo(fb->drm_format),
 						    fb->width, fb->height, fb->stride);
 
-- 
2.4.9



More information about the Intel-gfx mailing list