From cd34c7f5b8ba0de28d3e80c89d61026f0bf22883 Mon Sep 17 00:00:00 2001 From: Yogesh Mohanmarimuthu Date: Wed, 21 Apr 2021 20:48:23 +0530 Subject: [PATCH] radv: set RADEON_FLAG_GTT_WC flag for prime memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With display on iGPU and render on dGPU, VRR is not working. To fix this set RADEON_FLAG_GTT_WC flag when allocating memory for prime. This allows kernel function amdgpu_display_user_framebuffer_create() to allocate GTT memory with USWC flag making the buffer scanout for iGPU. This helps the ddx amdgpu_present_check_flip() function to return true. Now, xserver will flip the framebuffer instead of blit. Due to this VRR feature will work where iGPU supports USWC flag. v2: modify commit message with use case (Michel Dänzer) v3: allow GTT_WC flag only if VRAM_DOMAIN and NO_CPU_ACCESS (Bas Nieuwenhuizen) v4: add check for wsi_info is NULL v5: use wsi_info pointer to check for prime alloc (Bas Nieuwenhuizen) v6: set _GTT_WC flag when wsi_info pointer is not NULL (Bas Nieuwenhuizen) Signed-off-by: Yogesh Mohanmarimuthu Signed-off-by: Vitaly Prosyak Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_device.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 38de336d39d..0ab8ee285c3 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -5180,8 +5180,20 @@ radv_alloc_memory(struct radv_device *device, const VkMemoryAllocateInfo *pAlloc vk_object_base_init(&device->vk, &mem->base, VK_OBJECT_TYPE_DEVICE_MEMORY); - if (wsi_info && wsi_info->implicit_sync) - flags |= RADEON_FLAG_IMPLICIT_SYNC; + if (wsi_info) { + if(wsi_info->implicit_sync) + flags |= RADEON_FLAG_IMPLICIT_SYNC; + + /* In case of prime, linear buffer is allocated in default heap which is VRAM. + * Due to this when display is connected to iGPU and render on dGPU, ddx + * function amdgpu_present_check_flip() fails due to which there is blit + * instead of flip. Setting the flag RADEON_FLAG_GTT_WC allows kernel to + * allocate GTT memory in supported hardware where GTT can be directly scanout. + * Using wsi_info variable check to set the flag RADEON_FLAG_GTT_WC so that + * only for memory allocated by driver this flag is set. + */ + flags |= RADEON_FLAG_GTT_WC; + } if (dedicate_info) { mem->image = radv_image_from_handle(dedicate_info->image);