* [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
@ 2023-03-02 14:35 Simon Ser
2023-03-02 14:35 ` [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export Simon Ser
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Simon Ser @ 2023-03-02 14:35 UTC (permalink / raw)
To: dri-devel
Cc: Daniel Vetter, Hans de Goede, Maxime Ripard, Thomas Zimmermann,
Tian Tao, Christian König
drm_gem_map_dma_buf() requires drm_gem_object_funcs.get_sg_table
to be implemented, or else WARNs.
Allow drivers to leave this hook unimplemented to implement purely
local DMA-BUFs (ie, DMA-BUFs which cannot be imported anywhere
else but the device which allocated them). In that case, reject
imports to other devices in drm_gem_map_attach().
v2: new patch
Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Christian König <christian.koenig@amd.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
drivers/gpu/drm/drm_prime.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index f924b8b4ab6b..ab1d21d63a03 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -544,7 +544,8 @@ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
* Optional pinning of buffers is handled at dma-buf attach and detach time in
* drm_gem_map_attach() and drm_gem_map_detach(). Backing storage itself is
* handled by drm_gem_map_dma_buf() and drm_gem_unmap_dma_buf(), which relies on
- * &drm_gem_object_funcs.get_sg_table.
+ * &drm_gem_object_funcs.get_sg_table. If &drm_gem_object_funcs.get_sg_table is
+ * unimplemented, exports into another device are rejected.
*
* For kernel-internal access there's drm_gem_dmabuf_vmap() and
* drm_gem_dmabuf_vunmap(). Userspace mmap support is provided by
@@ -583,6 +584,9 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
{
struct drm_gem_object *obj = dma_buf->priv;
+ if (!obj->funcs->get_sg_table)
+ return -EOPNOTSUPP;
+
return drm_gem_pin(obj);
}
EXPORT_SYMBOL(drm_gem_map_attach);
--
2.39.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export
2023-03-02 14:35 [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Simon Ser
@ 2023-03-02 14:35 ` Simon Ser
2023-03-02 15:05 ` Thomas Zimmermann
2023-03-02 15:03 ` [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Thomas Zimmermann
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Simon Ser @ 2023-03-02 14:35 UTC (permalink / raw)
To: dri-devel
Cc: Daniel Vetter, Hans de Goede, Maxime Ripard, Thomas Zimmermann,
Tian Tao, Christian König
We don't populate drm_driver.gem_prime_import_sg_table so only
DMA-BUFs exported from our own device can be imported. We don't
populate drm_gem_object_funcs.get_sg_table so DMA-BUFs cannot be
imported into another device. Still, this is useful to user-space
to share buffers between processes and between API boundaries
(e.g. wlroots hard-requires PRIME import/export support).
v2: expand commit message
Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Christian König <christian.koenig@amd.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
include/drm/drm_gem_vram_helper.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h
index d3e8920c0b64..f4aab64411d8 100644
--- a/include/drm/drm_gem_vram_helper.h
+++ b/include/drm/drm_gem_vram_helper.h
@@ -160,7 +160,9 @@ void drm_gem_vram_simple_display_pipe_cleanup_fb(
.debugfs_init = drm_vram_mm_debugfs_init, \
.dumb_create = drm_gem_vram_driver_dumb_create, \
.dumb_map_offset = drm_gem_ttm_dumb_map_offset, \
- .gem_prime_mmap = drm_gem_prime_mmap
+ .gem_prime_mmap = drm_gem_prime_mmap, \
+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
+ .prime_fd_to_handle = drm_gem_prime_fd_to_handle
/*
* VRAM memory manager
--
2.39.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-03-02 14:35 [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Simon Ser
2023-03-02 14:35 ` [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export Simon Ser
@ 2023-03-02 15:03 ` Thomas Zimmermann
2023-03-02 15:05 ` Thomas Zimmermann
2023-03-02 15:56 ` Christian König
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Thomas Zimmermann @ 2023-03-02 15:03 UTC (permalink / raw)
To: Simon Ser, dri-devel
Cc: Daniel Vetter, Christian König, Tian Tao, Maxime Ripard,
Hans de Goede
[-- Attachment #1.1: Type: text/plain, Size: 2249 bytes --]
Hi
Am 02.03.23 um 15:35 schrieb Simon Ser:
> drm_gem_map_dma_buf() requires drm_gem_object_funcs.get_sg_table
> to be implemented, or else WARNs.
>
> Allow drivers to leave this hook unimplemented to implement purely
> local DMA-BUFs (ie, DMA-BUFs which cannot be imported anywhere
> else but the device which allocated them). In that case, reject
> imports to other devices in drm_gem_map_attach().
>
> v2: new patch
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tian Tao <tiantao6@hisilicon.com>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/gpu/drm/drm_prime.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index f924b8b4ab6b..ab1d21d63a03 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -544,7 +544,8 @@ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
> * Optional pinning of buffers is handled at dma-buf attach and detach time in
> * drm_gem_map_attach() and drm_gem_map_detach(). Backing storage itself is
> * handled by drm_gem_map_dma_buf() and drm_gem_unmap_dma_buf(), which relies on
> - * &drm_gem_object_funcs.get_sg_table.
> + * &drm_gem_object_funcs.get_sg_table. If &drm_gem_object_funcs.get_sg_table is
> + * unimplemented, exports into another device are rejected.
> *
> * For kernel-internal access there's drm_gem_dmabuf_vmap() and
> * drm_gem_dmabuf_vunmap(). Userspace mmap support is provided by
> @@ -583,6 +584,9 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
> {
> struct drm_gem_object *obj = dma_buf->priv;
>
> + if (!obj->funcs->get_sg_table)
> + return -EOPNOTSUPP;
-ENOSYS please.
Best regards
Thomas
> +
> return drm_gem_pin(obj);
> }
> EXPORT_SYMBOL(drm_gem_map_attach);
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-03-02 15:03 ` [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Thomas Zimmermann
@ 2023-03-02 15:05 ` Thomas Zimmermann
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2023-03-02 15:05 UTC (permalink / raw)
To: Simon Ser, dri-devel
Cc: Daniel Vetter, Hans de Goede, Christian König,
Maxime Ripard, Tian Tao
[-- Attachment #1.1: Type: text/plain, Size: 2514 bytes --]
Hi
Am 02.03.23 um 16:03 schrieb Thomas Zimmermann:
> Hi
>
> Am 02.03.23 um 15:35 schrieb Simon Ser:
>> drm_gem_map_dma_buf() requires drm_gem_object_funcs.get_sg_table
>> to be implemented, or else WARNs.
>>
>> Allow drivers to leave this hook unimplemented to implement purely
>> local DMA-BUFs (ie, DMA-BUFs which cannot be imported anywhere
>> else but the device which allocated them). In that case, reject
>> imports to other devices in drm_gem_map_attach().
>>
>> v2: new patch
>>
>> Signed-off-by: Simon Ser <contact@emersion.fr>
>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Cc: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Tian Tao <tiantao6@hisilicon.com>
>> Cc: Maxime Ripard <maxime@cerno.tech>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: Hans de Goede <hdegoede@redhat.com>
>> ---
>> drivers/gpu/drm/drm_prime.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
>> index f924b8b4ab6b..ab1d21d63a03 100644
>> --- a/drivers/gpu/drm/drm_prime.c
>> +++ b/drivers/gpu/drm/drm_prime.c
>> @@ -544,7 +544,8 @@ int drm_prime_handle_to_fd_ioctl(struct drm_device
>> *dev, void *data,
>> * Optional pinning of buffers is handled at dma-buf attach and
>> detach time in
>> * drm_gem_map_attach() and drm_gem_map_detach(). Backing storage
>> itself is
>> * handled by drm_gem_map_dma_buf() and drm_gem_unmap_dma_buf(),
>> which relies on
>> - * &drm_gem_object_funcs.get_sg_table.
>> + * &drm_gem_object_funcs.get_sg_table. If
>> &drm_gem_object_funcs.get_sg_table is
>> + * unimplemented, exports into another device are rejected.
>> *
>> * For kernel-internal access there's drm_gem_dmabuf_vmap() and
>> * drm_gem_dmabuf_vunmap(). Userspace mmap support is provided by
>> @@ -583,6 +584,9 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
>> {
>> struct drm_gem_object *obj = dma_buf->priv;
>> + if (!obj->funcs->get_sg_table)
>> + return -EOPNOTSUPP;
>
> -ENOSYS please.
With this changed:
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> Best regards
> Thomas
>
>> +
>> return drm_gem_pin(obj);
>> }
>> EXPORT_SYMBOL(drm_gem_map_attach);
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export
2023-03-02 14:35 ` [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export Simon Ser
@ 2023-03-02 15:05 ` Thomas Zimmermann
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2023-03-02 15:05 UTC (permalink / raw)
To: Simon Ser, dri-devel
Cc: Daniel Vetter, Christian König, Tian Tao, Maxime Ripard,
Hans de Goede
[-- Attachment #1.1: Type: text/plain, Size: 1870 bytes --]
Am 02.03.23 um 15:35 schrieb Simon Ser:
> We don't populate drm_driver.gem_prime_import_sg_table so only
> DMA-BUFs exported from our own device can be imported. We don't
> populate drm_gem_object_funcs.get_sg_table so DMA-BUFs cannot be
> imported into another device. Still, this is useful to user-space
> to share buffers between processes and between API boundaries
> (e.g. wlroots hard-requires PRIME import/export support).
>
> v2: expand commit message
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tian Tao <tiantao6@hisilicon.com>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
> include/drm/drm_gem_vram_helper.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h
> index d3e8920c0b64..f4aab64411d8 100644
> --- a/include/drm/drm_gem_vram_helper.h
> +++ b/include/drm/drm_gem_vram_helper.h
> @@ -160,7 +160,9 @@ void drm_gem_vram_simple_display_pipe_cleanup_fb(
> .debugfs_init = drm_vram_mm_debugfs_init, \
> .dumb_create = drm_gem_vram_driver_dumb_create, \
> .dumb_map_offset = drm_gem_ttm_dumb_map_offset, \
> - .gem_prime_mmap = drm_gem_prime_mmap
> + .gem_prime_mmap = drm_gem_prime_mmap, \
> + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
> + .prime_fd_to_handle = drm_gem_prime_fd_to_handle
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> /*
> * VRAM memory manager
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-03-02 14:35 [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Simon Ser
2023-03-02 14:35 ` [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export Simon Ser
2023-03-02 15:03 ` [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Thomas Zimmermann
@ 2023-03-02 15:56 ` Christian König
2023-06-09 11:31 ` Thomas Zimmermann
2024-03-20 14:16 ` Rob Clark
4 siblings, 0 replies; 10+ messages in thread
From: Christian König @ 2023-03-02 15:56 UTC (permalink / raw)
To: Simon Ser, dri-devel
Cc: Daniel Vetter, Hans de Goede, Maxime Ripard, Thomas Zimmermann, Tian Tao
Am 02.03.23 um 15:35 schrieb Simon Ser:
> drm_gem_map_dma_buf() requires drm_gem_object_funcs.get_sg_table
> to be implemented, or else WARNs.
>
> Allow drivers to leave this hook unimplemented to implement purely
> local DMA-BUFs (ie, DMA-BUFs which cannot be imported anywhere
> else but the device which allocated them). In that case, reject
> imports to other devices in drm_gem_map_attach().
>
> v2: new patch
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tian Tao <tiantao6@hisilicon.com>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
With Thomas comment addressed: Reviewed-by: Christian König
<christian.koenig@amd.com> for the series.
> ---
> drivers/gpu/drm/drm_prime.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index f924b8b4ab6b..ab1d21d63a03 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -544,7 +544,8 @@ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
> * Optional pinning of buffers is handled at dma-buf attach and detach time in
> * drm_gem_map_attach() and drm_gem_map_detach(). Backing storage itself is
> * handled by drm_gem_map_dma_buf() and drm_gem_unmap_dma_buf(), which relies on
> - * &drm_gem_object_funcs.get_sg_table.
> + * &drm_gem_object_funcs.get_sg_table. If &drm_gem_object_funcs.get_sg_table is
> + * unimplemented, exports into another device are rejected.
> *
> * For kernel-internal access there's drm_gem_dmabuf_vmap() and
> * drm_gem_dmabuf_vunmap(). Userspace mmap support is provided by
> @@ -583,6 +584,9 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
> {
> struct drm_gem_object *obj = dma_buf->priv;
>
> + if (!obj->funcs->get_sg_table)
> + return -EOPNOTSUPP;
> +
> return drm_gem_pin(obj);
> }
> EXPORT_SYMBOL(drm_gem_map_attach);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-03-02 14:35 [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Simon Ser
` (2 preceding siblings ...)
2023-03-02 15:56 ` Christian König
@ 2023-06-09 11:31 ` Thomas Zimmermann
2023-06-09 13:04 ` Simon Ser
2024-03-20 14:16 ` Rob Clark
4 siblings, 1 reply; 10+ messages in thread
From: Thomas Zimmermann @ 2023-06-09 11:31 UTC (permalink / raw)
To: Simon Ser, dri-devel
Cc: Daniel Vetter, Christian König, Hans de Goede,
Maxime Ripard, Tian Tao
[-- Attachment #1.1: Type: text/plain, Size: 2357 bytes --]
Hi Simon
Am 02.03.23 um 15:35 schrieb Simon Ser:
> drm_gem_map_dma_buf() requires drm_gem_object_funcs.get_sg_table
> to be implemented, or else WARNs.
>
> Allow drivers to leave this hook unimplemented to implement purely
> local DMA-BUFs (ie, DMA-BUFs which cannot be imported anywhere
> else but the device which allocated them). In that case, reject
> imports to other devices in drm_gem_map_attach().
>
> v2: new patch
Is there a v3 of this patchset? It was Acked with the one errno code
changed.
Best regards
Thomas
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tian Tao <tiantao6@hisilicon.com>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/gpu/drm/drm_prime.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index f924b8b4ab6b..ab1d21d63a03 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -544,7 +544,8 @@ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
> * Optional pinning of buffers is handled at dma-buf attach and detach time in
> * drm_gem_map_attach() and drm_gem_map_detach(). Backing storage itself is
> * handled by drm_gem_map_dma_buf() and drm_gem_unmap_dma_buf(), which relies on
> - * &drm_gem_object_funcs.get_sg_table.
> + * &drm_gem_object_funcs.get_sg_table. If &drm_gem_object_funcs.get_sg_table is
> + * unimplemented, exports into another device are rejected.
> *
> * For kernel-internal access there's drm_gem_dmabuf_vmap() and
> * drm_gem_dmabuf_vunmap(). Userspace mmap support is provided by
> @@ -583,6 +584,9 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
> {
> struct drm_gem_object *obj = dma_buf->priv;
>
> + if (!obj->funcs->get_sg_table)
> + return -EOPNOTSUPP;
> +
> return drm_gem_pin(obj);
> }
> EXPORT_SYMBOL(drm_gem_map_attach);
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-06-09 11:31 ` Thomas Zimmermann
@ 2023-06-09 13:04 ` Simon Ser
2023-06-12 15:10 ` Thomas Zimmermann
0 siblings, 1 reply; 10+ messages in thread
From: Simon Ser @ 2023-06-09 13:04 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Daniel Vetter, dri-devel, Hans de Goede, Maxime Ripard, Tian Tao,
Christian König
Hi,
On Friday, June 9th, 2023 at 13:31, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Is there a v3 of this patchset? It was Acked with the one errno code
> changed.
Since this was a minor change, I did it locally and pushed the patch
to drm-misc-next already.
Simon
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-06-09 13:04 ` Simon Ser
@ 2023-06-12 15:10 ` Thomas Zimmermann
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2023-06-12 15:10 UTC (permalink / raw)
To: Simon Ser
Cc: Daniel Vetter, dri-devel, Hans de Goede, Maxime Ripard, Tian Tao,
Christian König
[-- Attachment #1.1: Type: text/plain, Size: 664 bytes --]
Hi
Am 09.06.23 um 15:04 schrieb Simon Ser:
> Hi,
>
> On Friday, June 9th, 2023 at 13:31, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>> Is there a v3 of this patchset? It was Acked with the one errno code
>> changed.
>
> Since this was a minor change, I did it locally and pushed the patch
> to drm-misc-next already.
Found it. Thanks for committing and sorry for the noise.
Best regards
Thomas
>
> Simon
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing
2023-03-02 14:35 [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Simon Ser
` (3 preceding siblings ...)
2023-06-09 11:31 ` Thomas Zimmermann
@ 2024-03-20 14:16 ` Rob Clark
4 siblings, 0 replies; 10+ messages in thread
From: Rob Clark @ 2024-03-20 14:16 UTC (permalink / raw)
To: Simon Ser
Cc: dri-devel, Daniel Vetter, Hans de Goede, Maxime Ripard,
Thomas Zimmermann, Tian Tao, Christian König, Dominik Behr
On Thu, Mar 2, 2023 at 6:35 AM Simon Ser <contact@emersion.fr> wrote:
>
> drm_gem_map_dma_buf() requires drm_gem_object_funcs.get_sg_table
> to be implemented, or else WARNs.
>
> Allow drivers to leave this hook unimplemented to implement purely
> local DMA-BUFs (ie, DMA-BUFs which cannot be imported anywhere
> else but the device which allocated them). In that case, reject
> imports to other devices in drm_gem_map_attach().
>
> v2: new patch
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Tian Tao <tiantao6@hisilicon.com>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/gpu/drm/drm_prime.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index f924b8b4ab6b..ab1d21d63a03 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -544,7 +544,8 @@ int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
> * Optional pinning of buffers is handled at dma-buf attach and detach time in
> * drm_gem_map_attach() and drm_gem_map_detach(). Backing storage itself is
> * handled by drm_gem_map_dma_buf() and drm_gem_unmap_dma_buf(), which relies on
> - * &drm_gem_object_funcs.get_sg_table.
> + * &drm_gem_object_funcs.get_sg_table. If &drm_gem_object_funcs.get_sg_table is
> + * unimplemented, exports into another device are rejected.
> *
> * For kernel-internal access there's drm_gem_dmabuf_vmap() and
> * drm_gem_dmabuf_vunmap(). Userspace mmap support is provided by
> @@ -583,6 +584,9 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
> {
> struct drm_gem_object *obj = dma_buf->priv;
>
> + if (!obj->funcs->get_sg_table)
> + return -EOPNOTSUPP;
This breaks virtgpu, where buffers may not necessarily have guest
backing pages, but still may be shared with other virtual devices
(because the host side buffer _does_ have backing pages)
BR,
-R
> +
> return drm_gem_pin(obj);
> }
> EXPORT_SYMBOL(drm_gem_map_attach);
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-03-20 14:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-02 14:35 [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Simon Ser
2023-03-02 14:35 ` [PATCH v2 2/2] drm/vram-helper: turn on PRIME import/export Simon Ser
2023-03-02 15:05 ` Thomas Zimmermann
2023-03-02 15:03 ` [PATCH v2 1/2] drm/prime: reject DMA-BUF attach when get_sg_table is missing Thomas Zimmermann
2023-03-02 15:05 ` Thomas Zimmermann
2023-03-02 15:56 ` Christian König
2023-06-09 11:31 ` Thomas Zimmermann
2023-06-09 13:04 ` Simon Ser
2023-06-12 15:10 ` Thomas Zimmermann
2024-03-20 14:16 ` Rob Clark
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.