[PATCH] drm/virtio: Fix flickering issue seen with imported dmabufs

Dmitry Osipenko dmitry.osipenko at collabora.com
Wed Mar 26 01:23:04 UTC 2025


On 3/25/25 23:10, Vivek Kasireddy wrote:
> We need to save the reservation object pointer associated with the
> imported dmabuf in the newly created GEM object to allow
> drm_gem_plane_helper_prepare_fb() to extract the exclusive fence
> from it and attach it to the plane state during prepare phase.
> This is needed to ensure that drm_atomic_helper_wait_for_fences()
> correctly waits for the relevant fences (move, etc) associated with
> the reservation object, thereby implementing proper synchronization.
> 
> Otherwise, artifacts or slight flickering can be seen when apps
> are dragged across the screen when running Gnome (Wayland). This
> problem is mostly seen with dGPUs in the case where the FBs are
> allocated in VRAM but need to be migrated to System RAM as they
> are shared with virtio-gpu.
> 
> Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> Cc: Dmitry Osipenko <dmitry.osipenko at collabora.com>
> Cc: Gurchetan Singh <gurchetansingh at chromium.org>
> Cc: Chia-I Wu <olvaffe at gmail.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_prime.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
> index fe6a0b018571..ceb0401a000b 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
> @@ -332,6 +332,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
>  	}
>  
>  	obj->import_attach = attach;
> +	obj->resv = buf->resv;
>  	get_dma_buf(buf);
>  
>  	ret = virtgpu_dma_buf_init_obj(dev, bo, attach);

Will be better to set obj->resv before drm_gem_private_object_init()
since it checks whether obj->resv was pre-inited. I'll change it while
applying, thanks.

Reviewed-by: Dmitry Osipenko <dmitry.osipenko at collabora.com>

-- 
Best regards,
Dmitry


More information about the dri-devel mailing list