[igt-dev] [PATCH i-g-t 3/3] lib/fb: Clear framebuffer on amdgpu

Nicholas Kazlauskas nicholas.kazlauskas at amd.com
Fri Mar 8 14:36:03 UTC 2019


IGT expects buffers returned from DRM_IOCTL_MODE_MAP_DUMB to be
cleared, but amdgpu retains the contents previously in memory
in the buffer - clear it on amdgpu by with a memset to 0.

While there's a clear_yuv_buffer directly below this that should take
care of the YUV format case for us, it has an assert to ensure that
the buffer contents were previously cleared. We'll fail that assert
if we don't clear it every time.

Cc: Leo Li <sunpeng.li at amd.com>
Cc: Harry Wentland <harry.wentland at amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
---
 lib/igt_fb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index f49becbd..084fed1e 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -595,6 +595,15 @@ uint64_t igt_fb_tiling_to_mod(uint64_t tiling)
 	}
 }
 
+static void clear_buffer(struct igt_fb *fb)
+{
+	void *ptr;
+
+	ptr = igt_fb_map_buffer(fb->fd, fb);
+	memset(ptr, 0, fb->size);
+	igt_fb_unmap_buffer(fb, ptr);
+}
+
 static void clear_yuv_buffer(struct igt_fb *fb)
 {
 	bool full_range = fb->color_range == IGT_COLOR_YCBCR_FULL_RANGE;
@@ -715,6 +724,14 @@ static int create_bo_for_fb(struct igt_fb *fb)
 					     bpp, strides, &fb->size);
 
 out:
+	/*
+	 * IGT expects buffers returned from DRM_IOCTL_MODE_MAP_DUMB to be
+	 * cleared, but amdgpu retains the contents previously in memory
+	 * in the buffer - clear it on amdgpu.
+	 */
+	if (is_amdgpu_device(fd))
+		clear_buffer(fb);
+
 	if (igt_format_is_yuv(fb->drm_format))
 		clear_yuv_buffer(fb);
 
-- 
2.17.1



More information about the igt-dev mailing list