<div dir="ltr">It also fixes importing virtgpu blobs into real hardware, for instance amdgpu for DRI_PRIME rendering.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 22, 2024 at 2:48 PM Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Rob Clark <<a href="mailto:robdclark@chromium.org" target="_blank">robdclark@chromium.org</a>><br>
<br>
virtgpu "vram" GEM objects do not implement obj->get_sg_table(). But<br>
they also don't use drm_gem_map_dma_buf(). In fact they may not even<br>
have guest visible pages. But it is perfectly fine to export and share<br>
with other virtual devices.<br>
<br>
Reported-by: Dominik Behr <<a href="mailto:dbehr@chromium.org" target="_blank">dbehr@chromium.org</a>><br>
Fixes: 207395da5a97 ("drm/prime: reject DMA-BUF attach when get_sg_table is missing")<br>
Signed-off-by: Rob Clark <<a href="mailto:robdclark@chromium.org" target="_blank">robdclark@chromium.org</a>><br>
---<br>
drivers/gpu/drm/drm_prime.c | 7 ++++++-<br>
1 file changed, 6 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c<br>
index 7352bde299d5..64dd6276e828 100644<br>
--- a/drivers/gpu/drm/drm_prime.c<br>
+++ b/drivers/gpu/drm/drm_prime.c<br>
@@ -582,7 +582,12 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,<br>
{<br>
struct drm_gem_object *obj = dma_buf->priv;<br>
<br>
- if (!obj->funcs->get_sg_table)<br>
+ /*<br>
+ * drm_gem_map_dma_buf() requires obj->get_sg_table(), but drivers<br>
+ * that implement their own ->map_dma_buf() do not.<br>
+ */<br>
+ if ((dma_buf->ops->map_dma_buf == drm_gem_map_dma_buf) &&<br>
+ !obj->funcs->get_sg_table)<br>
return -ENOSYS;<br>
<br>
return drm_gem_pin(obj);<br>
-- <br>
2.44.0<br>
<br>
</blockquote></div>