[igt-dev] [PATCH i-g-t] lib/igt_fb: Add missing set_domain calls

Ville Syrjala ville.syrjala at linux.intel.com
Thu Sep 6 12:27:49 UTC 2018


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

We're missing some set_domain calls around the ggtt mmap paths. This
means we never tell the kernel that we've dirtied the object. And
then at some point down the line the kernel throws the pages into
/dev/null instead of hanging on to them/swapping them out because
they were never marked as dirty.

Throw in the missing set_domains(GTT,GTT) calls and rip out the old
bogus set_domain(CPU,CPU).

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

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ae71d9673228..1085d25d33ce 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -404,6 +404,9 @@ static int create_bo_for_fb(int fd, int width, int height,
 			bo = gem_create(fd, size);
 			gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);
 
+			gem_set_domain(fd, bo,
+				       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
 			/* Ensure the framebuffer is preallocated */
 			ptr = gem_mmap__gtt(fd, bo, size, PROT_READ | PROT_WRITE);
 			igt_assert(*(uint32_t *)ptr == 0);
@@ -1342,6 +1345,9 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)
 {
 	void *ptr;
 
+	gem_set_domain(fd, fb->gem_handle,
+		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
 	if (fb->is_dumb)
 		ptr = kmstest_dumb_map_buffer(fd, fb->gem_handle, fb->size,
 					      PROT_READ | PROT_WRITE);
@@ -1790,6 +1796,8 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 		setup_linear_mapping(fd, fb, &blit->linear);
 	} else {
 		blit->linear.handle = 0;
+		gem_set_domain(fd, fb->gem_handle,
+			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		blit->linear.map = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
 					      PROT_READ | PROT_WRITE);
 		igt_assert(blit->linear.map);
@@ -1848,10 +1856,6 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
 			create_cairo_surface__gtt(fd, fb);
 	}
 
-	if (!fb->is_dumb)
-		gem_set_domain(fd, fb->gem_handle, I915_GEM_DOMAIN_CPU,
-			       I915_GEM_DOMAIN_CPU);
-
 	igt_assert(cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS);
 	return fb->cairo_surface;
 }
-- 
2.16.4



More information about the igt-dev mailing list