From a1701d0bb565de68d2db279fdf4f95ecb0e61c59 Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Tue, 2 Apr 2019 13:45:22 -0400 Subject: lib/igt_fb: Create AMD YUV buffers with AMD GEM IOCTL The kmstest_dumb_create API isn't suitable for creating multi-planar buffers since it tries to calculate the size based on the first plane's pitch only. AMDGPU requires that the luma pitch be aligned to 256 for YUV buffers which results in crashes on kms_plane@pixel-format-pipe-*-planes tests when using kmstest_dumb_create since the buffer returned is smaller than needed (16384 size returned, 24576 size required). Create and map the buffer with the correct size by using the AMD helpers introduced by this patch: igt_amd_create_bo and igt_amd_mmap_bo. Cc: Harry Wentland Cc: Leo Li Signed-off-by: Nicholas Kazlauskas Reviewed-by: Leo Li --- lib/igt_fb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/igt_fb.c') diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 6adf4222..f5c9a9f1 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -38,6 +38,7 @@ #include "igt_kms.h" #include "igt_matrix.h" #include "igt_vc4.h" +#include "igt_amd.h" #include "igt_x86.h" #include "ioctl_wrappers.h" #include "intel_batchbuffer.h" @@ -763,7 +764,8 @@ static int create_bo_for_fb(struct igt_fb *fb) * them, so we need to make sure to use a device BO then. */ if (fb->modifier || fb->size || fb->strides[0] || - (is_i915_device(fd) && igt_format_is_yuv(fb->drm_format))) + (is_i915_device(fd) && igt_format_is_yuv(fb->drm_format)) || + (is_amdgpu_device(fd) && igt_format_is_yuv(fb->drm_format))) device_bo = true; /* Sets offets and stride if necessary. */ @@ -787,6 +789,8 @@ static int create_bo_for_fb(struct igt_fb *fb) if (fb->modifier == DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED) igt_vc4_set_tiling(fd, fb->gem_handle, fb->modifier); + } else if (is_amdgpu_device(fd)) { + fb->gem_handle = igt_amd_create_bo(fd, fb->size); } else { igt_assert(false); } @@ -1832,6 +1836,9 @@ static void *map_bo(int fd, struct igt_fb *fb) else if (is_vc4_device(fd)) ptr = igt_vc4_mmap_bo(fd, fb->gem_handle, fb->size, PROT_READ | PROT_WRITE); + else if (is_amdgpu_device(fd)) + ptr = igt_amd_mmap_bo(fd, fb->gem_handle, fb->size, + PROT_READ | PROT_WRITE); else igt_assert(false); -- cgit v1.2.3