Skip to content

Commit

Permalink
drm/prime: Unbreak virtgpu dma-buf export
Browse files Browse the repository at this point in the history
virtgpu "vram" GEM objects do not implement obj->get_sg_table().  But
they also don't use drm_gem_map_dma_buf().  In fact they may not even
have guest visible pages.  But it is perfectly fine to export and share
with other virtual devices.

Reported-by: Dominik Behr <dbehr@chromium.org>
Fixes: 207395d ("drm/prime: reject DMA-BUF attach when get_sg_table is missing")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Simon Ser <contact@emersion.fr>
Link: https://patchwork.freedesktop.org/patch/msgid/20240322214801.319975-1-robdclark@gmail.com
  • Loading branch information
Rob Clark authored and Simon Ser committed Mar 28, 2024
1 parent be14184 commit a4ec240
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/gpu/drm/drm_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,12 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
{
struct drm_gem_object *obj = dma_buf->priv;

if (!obj->funcs->get_sg_table)
/*
* drm_gem_map_dma_buf() requires obj->get_sg_table(), but drivers
* that implement their own ->map_dma_buf() do not.
*/
if (dma_buf->ops->map_dma_buf == drm_gem_map_dma_buf &&
!obj->funcs->get_sg_table)
return -ENOSYS;

return drm_gem_pin(obj);
Expand Down

0 comments on commit a4ec240

Please sign in to comment.