drm/virtio: Allow importing prime buffers when 3D is enabled
Subsystems (4)
PATCH 1/1 drm/virtio: Allow importing prime buffers when 3D is enabled
This functionality was added for using a KMS-only virtgpu with a physical (or SR-IOV) headless GPU in passthrough, but it should not be restricted to KMS-only mode. It can be used with cross-domain to pass guest memfds to the host compositor with zero copies (using udmabuf on both sides).
Drop the check for the absence of virgl_3d to allow for more use cases.
---
Hi. I couldn't find any comments on that line in the reviews (on patchwork), so I assume there was never a specific technical reason for that check, just an abundance of caution?
BTW, while here.. The drm_gem_prime_import "fallback" seems pretty much equivalent to return (-ENODEV), as drm_gem_prime_import(_dev) just translates the call to gem_prime_import_sg_table which we don't use. Should it be replaced with return (-ENODEV)?
--- drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_prime.c +1 -1
@@ -312,7 +312,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, } } -if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) +if (!vgdev->has_resource_blob)return drm_gem_prime_import (dev, buf); bo =kzalloc (sizeof (*bo),GFP_KERNEL );
Signature · 1 line
2.51.2
Dmitry Osipenko
maintainerHi,
Quoted 9 lines · Val Packett
This functionality was added for using a KMS-only virtgpu with a physical (or SR-IOV) headless GPU in passthrough, but it should not be restricted to KMS-only mode. It can be used with cross-domain to pass guest memfds to the host compositor with zero copies (using udmabuf on both sides).
Drop the check for the absence of
virgl_3dto allow for more use cases.Fixes ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")Signed-off-by Val Packett <[email protected]>
Quoted 8 lines
---
Hi. I couldn't find any comments on that line in the reviews (on patchwork), so I assume there was never a specific technical reason for that check, just an abundance of caution?
BTW, while here.. The
drm_gem_prime_import"fallback" seems pretty much equivalent toreturn (-ENODEV), asdrm_gem_prime_import(_dev)just translates the call togem_prime_import_sg_tablewhich we don't use. Should it be replaced withreturn (-ENODEV)?
Returning -ENODEV should break dmabuf self-importing where virtio-gpu driver export dmabuf and then imports to itself.
Quoted 9 lines
--- drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/virtio/virtgpu_prime.c +0
-0
drivers/gpu/drm/virtio/virtgpu_prime.c struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, · line 318
Quoted 8 lines
drivers/gpu/drm/virtio/virtgpu_prime.c +1
-1@@ -312,7 +312,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, } } -if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) +if (!vgdev->has_resource_blob)return drm_gem_prime_import (dev, buf); bo =kzalloc (sizeof (*bo),GFP_KERNEL );
At a quick glance the change looks fine. Will take another stab after Holidays and merge if no problems will be spotted. Thanks.
Signature · 2 lines
Best regards, Dmitry
Quoted 14 lines · Dmitry Osipenko
Hi,
Quoted 11 lines · Val Packett
This functionality was added for using a KMS-only virtgpu with a physical (or SR-IOV) headless GPU in passthrough, but it should not be restricted to KMS-only mode. It can be used with cross-domain to pass guest memfds to the host compositor with zero copies (using udmabuf on both sides).
Drop the check for the absence of
virgl_3dto allow for more use cases.Fixes ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")Signed-off-by Val Packett <[email protected]>---
Quoted 8 lines
Quoted 6 lines
Hi. I couldn't find any comments on that line in the reviews (on patchwork), so I assume there was never a specific technical reason for that check, just an abundance of caution?
BTW, while here.. The
drm_gem_prime_import"fallback" seems pretty much equivalent toreturn (-ENODEV), asdrm_gem_prime_import(_dev)just translates the call togem_prime_import_sg_tablewhich we don't use. Should it be replaced withreturn (-ENODEV)?Returning
-ENODEVshould break dmabuf self-importing where virtio-gpu driver export dmabuf and then imports to itself.
Hm, I don't think so because the self-import case (for when buf->ops == &virtgpu_dmabuf_ops) is handled right here, right above this check.
drm_gem_prime_import would handle the self-import for buf->ops == &drm_gem_prime_dmabuf_ops which shouldn't be the case since we have virtgpu_dmabuf_ops..
Quoted 12 lines
Quoted 12 lines
--- drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/virtio/virtgpu_prime.c +0
-0@@ -312,7 +312,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, } }
Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_prime.c struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, · line 318
Quoted 5 lines
drivers/gpu/drm/virtio/virtgpu_prime.c +1
-1-if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) +if (!vgdev->has_resource_blob)return drm_gem_prime_import (dev, buf); bo =kzalloc (sizeof (*bo),GFP_KERNEL );At a quick glance the change looks fine. Will take another stab after Holidays and merge if no problems will be spotted. Thanks.
Thanks!
~val
Dmitry Osipenko
maintainerQuoted 32 lines · Val Packett
Quoted 21 lines · Dmitry Osipenko
Hi,
Quoted 18 lines · Val Packett
This functionality was added for using a KMS-only virtgpu with a physical
(or SR-IOV) headless GPU in passthrough, but it should not be restricted to KMS-only mode. It can be used with cross-domain to pass guest memfds to the host compositor with zero copies (using udmabuf on both sides).Drop the check for the absence of
virgl_3dto allow for more use cases.Fixes ca77f27a2665 ("drm/virtio: Import prime buffers from otherdevices as guest blobs")
Signed-off-by Val Packett <[email protected]>---
Hi. I couldn't find any comments on that line in the reviews (on patchwork), so I assume
there was never a specific technical reason for that check, just an abundance of caution?Quoted 8 lines
Quoted 6 lines
BTW, while here.. The
drm_gem_prime_import"fallback" seems pretty much equivalent toreturn (-ENODEV), asdrm_gem_prime_import(_dev)just translates the call togem_prime_import_sg_tablewhich we don't use. Should it be replaced withreturn (-ENODEV)?Returning
-ENODEVshould break dmabuf self-importing where virtio-gpu driver export dmabuf and then imports to itself.
Quoted 6 lines
Hm, I don't think so because the self-import case (for when
buf->ops == &virtgpu_dmabuf_ops) is handled right here, right above this check.
drm_gem_prime_importwould handle the self-import forbuf->ops == &drm_gem_prime_dmabuf_opswhich shouldn't be the case since we havevirtgpu_dmabuf_ops..
Indeed, then it should be redundant. Practically, there should be no difference with removal of drm_gem_prime_import() and virtgpu_gem_prime_import_sg_table() from the code. Not sure if changing it will be worthwhile.
Signature · 2 lines
Best regards, Dmitry
Quoted 27 lines · Val Packett
This functionality was added for using a KMS-only virtgpu with a physical (or SR-IOV) headless GPU in passthrough, but it should not be restricted to KMS-only mode. It can be used with cross-domain to pass guest memfds to the host compositor with zero copies (using udmabuf on both sides).
Drop the check for the absence of
virgl_3dto allow for more use cases.Fixes ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")Signed-off-by Val Packett <[email protected]>---
Hi. I couldn't find any comments on that line in the reviews (on patchwork), so I assume there was never a specific technical reason for that check, just an abundance of caution?
BTW, while here.. The
drm_gem_prime_import"fallback" seems pretty much equivalent toreturn (-ENODEV), asdrm_gem_prime_import(_dev)just translates the call togem_prime_import_sg_tablewhich we don't use. Should it be replaced withreturn (-ENODEV)?--- drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/virtio/virtgpu_prime.c +0
-0
drivers/gpu/drm/virtio/virtgpu_prime.c struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, · line 318
Quoted 8 lines
drivers/gpu/drm/virtio/virtgpu_prime.c +1
-1@@ -312,7 +312,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, } } -if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) +if (!vgdev->has_resource_blob)return drm_gem_prime_import (dev, buf); bo =kzalloc (sizeof (*bo),GFP_KERNEL );
Signature · 2 lines
Best regards, Dmitry
Quoted 31 lines · Dmitry Osipenko
Quoted 30 lines · Val Packett
This functionality was added for using a KMS-only virtgpu with a physical (or SR-IOV) headless GPU in passthrough, but it should not be restricted to KMS-only mode. It can be used with cross-domain to pass guest memfds to the host compositor with zero copies (using udmabuf on both sides).
Drop the check for the absence of
virgl_3dto allow for more use cases.Fixes ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")Signed-off-by Val Packett <[email protected]>---
Hi. I couldn't find any comments on that line in the reviews (on patchwork), so I assume there was never a specific technical reason for that check, just an abundance of caution?
BTW, while here.. The
drm_gem_prime_import"fallback" seems pretty much equivalent toreturn (-ENODEV), asdrm_gem_prime_import(_dev)just translates the call togem_prime_import_sg_tablewhich we don't use. Should it be replaced withreturn (-ENODEV)?--- drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/virtio/virtgpu_prime.c +0
-0@@ -312,7 +312,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, } }
Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_prime.c struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, · line 318
Quoted 5 lines
drivers/gpu/drm/virtio/virtgpu_prime.c +1
-1-if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) +if (!vgdev->has_resource_blob)return drm_gem_prime_import (dev, buf); bo =kzalloc (sizeof (*bo),GFP_KERNEL );Reviewed-by Dmitry Osipenko <[email protected]>
Applied to misc-next, thanks
Signature · 2 lines
Best regards, Dmitry