public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled
@ 2025-12-10 15:39 Val Packett
  2025-12-10 16:51 ` Dmitry Osipenko
  2026-02-11 22:58 ` Dmitry Osipenko
  0 siblings, 2 replies; 6+ messages in thread
From: Val Packett @ 2025-12-10 15:39 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Dmitry Osipenko, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Vivek Kasireddy
  Cc: Val Packett, Dongwon Kim, Christian Koenig, dri-devel,
	virtualization, linux-kernel

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.

Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")
Signed-off-by: Val Packett <val@invisiblethingslab.com>
---

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(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index ce49282198cb..2fedd5d3bd62 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -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);
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled
  2025-12-10 15:39 [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled Val Packett
@ 2025-12-10 16:51 ` Dmitry Osipenko
  2025-12-10 22:11   ` Val Packett
  2026-02-11 22:58 ` Dmitry Osipenko
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Osipenko @ 2025-12-10 16:51 UTC (permalink / raw)
  To: Val Packett, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Vivek Kasireddy
  Cc: Dongwon Kim, Christian Koenig, dri-devel, virtualization,
	linux-kernel

Hi,

On 12/10/25 18:39, Val Packett wrote:
> 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.
> 
> Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")
> Signed-off-by: Val Packett <val@invisiblethingslab.com>
> ---
> 
> 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)`?

Returning -ENODEV should break dmabuf self-importing where virtio-gpu
driver export dmabuf and then imports to itself.

> ---
>  drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
> index ce49282198cb..2fedd5d3bd62 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
> @@ -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.

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled
  2025-12-10 16:51 ` Dmitry Osipenko
@ 2025-12-10 22:11   ` Val Packett
  2025-12-11  3:51     ` Dmitry Osipenko
  0 siblings, 1 reply; 6+ messages in thread
From: Val Packett @ 2025-12-10 22:11 UTC (permalink / raw)
  To: Dmitry Osipenko, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Vivek Kasireddy
  Cc: Dongwon Kim, Christian Koenig, dri-devel, virtualization,
	linux-kernel


On 12/10/25 1:51 PM, Dmitry Osipenko wrote:
> Hi,
>
> On 12/10/25 18:39, Val Packett wrote:
>> 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.
>>
>> Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")
>> Signed-off-by: Val Packett <val@invisiblethingslab.com>
>> ---
>>
>> 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)`?
> Returning -ENODEV should 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`..

>> ---
>>   drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
>> index ce49282198cb..2fedd5d3bd62 100644
>> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
>> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
>> @@ -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.

Thanks!
~val


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled
  2025-12-10 22:11   ` Val Packett
@ 2025-12-11  3:51     ` Dmitry Osipenko
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2025-12-11  3:51 UTC (permalink / raw)
  To: Val Packett, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Vivek Kasireddy
  Cc: Dongwon Kim, Christian Koenig, dri-devel, virtualization,
	linux-kernel

On 12/11/25 01:11, Val Packett wrote:
> 
> On 12/10/25 1:51 PM, Dmitry Osipenko wrote:
>> Hi,
>>
>> On 12/10/25 18:39, Val Packett wrote:
>>> 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.
>>>
>>> Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other
>>> devices as guest blobs")
>>> Signed-off-by: Val Packett <val@invisiblethingslab.com>
>>> ---
>>>
>>> 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)`?
>> Returning -ENODEV should 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`..

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.

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled
  2025-12-10 15:39 [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled Val Packett
  2025-12-10 16:51 ` Dmitry Osipenko
@ 2026-02-11 22:58 ` Dmitry Osipenko
  2026-02-11 23:35   ` Dmitry Osipenko
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Osipenko @ 2026-02-11 22:58 UTC (permalink / raw)
  To: Val Packett, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Vivek Kasireddy
  Cc: Dongwon Kim, Christian Koenig, dri-devel, virtualization,
	linux-kernel

On 12/10/25 18:39, Val Packett wrote:
> 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.
> 
> Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")
> Signed-off-by: Val Packett <val@invisiblethingslab.com>
> ---
> 
> 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(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
> index ce49282198cb..2fedd5d3bd62 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
> @@ -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);

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

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled
  2026-02-11 22:58 ` Dmitry Osipenko
@ 2026-02-11 23:35   ` Dmitry Osipenko
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2026-02-11 23:35 UTC (permalink / raw)
  To: Val Packett, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Vivek Kasireddy
  Cc: Dongwon Kim, Christian Koenig, dri-devel, virtualization,
	linux-kernel

On 2/12/26 01:58, Dmitry Osipenko wrote:
> On 12/10/25 18:39, Val Packett wrote:
>> 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.
>>
>> Fixes: ca77f27a2665 ("drm/virtio: Import prime buffers from other devices as guest blobs")
>> Signed-off-by: Val Packett <val@invisiblethingslab.com>
>> ---
>>
>> 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(-)
>>
>> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
>> index ce49282198cb..2fedd5d3bd62 100644
>> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
>> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
>> @@ -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);
> 
> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>

Applied to misc-next, thanks

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-11 23:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 15:39 [PATCH] drm/virtio: Allow importing prime buffers when 3D is enabled Val Packett
2025-12-10 16:51 ` Dmitry Osipenko
2025-12-10 22:11   ` Val Packett
2025-12-11  3:51     ` Dmitry Osipenko
2026-02-11 22:58 ` Dmitry Osipenko
2026-02-11 23:35   ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox