LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] dma-buf: make map_atomic and map function pointers optional
@ 2018-05-29 13:59 Gerd Hoffmann
  2018-05-30 10:30 ` Daniel Vetter
  2018-05-30 11:36 ` Oleksandr Andrushchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-05-29 13:59 UTC (permalink / raw)
  To: dri-devel
  Cc: Gerd Hoffmann, Daniel Vetter, Sumit Semwal,
	open list:DMA BUFFER SHARING FRAMEWORK,
	moderated list:DMA BUFFER SHARING FRAMEWORK, open list

So drivers don't need dummy functions just returning NULL.

Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/linux/dma-buf.h   | 4 ++--
 drivers/dma-buf/dma-buf.c | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 085db2fee2..88917fa796 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -39,12 +39,12 @@ struct dma_buf_attachment;
 
 /**
  * struct dma_buf_ops - operations possible on struct dma_buf
- * @map_atomic: maps a page from the buffer into kernel address
+ * @map_atomic: [optional] maps a page from the buffer into kernel address
  *		space, users may not block until the subsequent unmap call.
  *		This callback must not sleep.
  * @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer.
  *		  This Callback must not sleep.
- * @map: maps a page from the buffer into kernel address space.
+ * @map: [optional] maps a page from the buffer into kernel address space.
  * @unmap: [optional] unmaps a page from the buffer.
  * @vmap: [optional] creates a virtual mapping for the buffer into kernel
  *	  address space. Same restrictions as for vmap and friends apply.
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index d78d5fc173..4c45e31258 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num)
 {
 	WARN_ON(!dmabuf);
 
+	if (!dmabuf->ops->map_atomic)
+		return NULL;
 	return dmabuf->ops->map_atomic(dmabuf, page_num);
 }
 EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
@@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num)
 {
 	WARN_ON(!dmabuf);
 
+	if (!dmabuf->ops->map)
+		return NULL;
 	return dmabuf->ops->map(dmabuf, page_num);
 }
 EXPORT_SYMBOL_GPL(dma_buf_kmap);
-- 
2.9.3

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

* Re: [PATCH] dma-buf: make map_atomic and map function pointers optional
  2018-05-29 13:59 [PATCH] dma-buf: make map_atomic and map function pointers optional Gerd Hoffmann
@ 2018-05-30 10:30 ` Daniel Vetter
  2018-06-01  7:01   ` Gerd Hoffmann
  2018-05-30 11:36 ` Oleksandr Andrushchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2018-05-30 10:30 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: dri-devel, Daniel Vetter, Sumit Semwal,
	open list:DMA BUFFER SHARING FRAMEWORK,
	moderated list:DMA BUFFER SHARING FRAMEWORK, open list

On Tue, May 29, 2018 at 03:59:18PM +0200, Gerd Hoffmann wrote:
> So drivers don't need dummy functions just returning NULL.
> 
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Please push to drm-misc-next (maybe after a few more days of waiting for
feedback).
-Daniel

> ---
>  include/linux/dma-buf.h   | 4 ++--
>  drivers/dma-buf/dma-buf.c | 4 ++++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index 085db2fee2..88917fa796 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -39,12 +39,12 @@ struct dma_buf_attachment;
>  
>  /**
>   * struct dma_buf_ops - operations possible on struct dma_buf
> - * @map_atomic: maps a page from the buffer into kernel address
> + * @map_atomic: [optional] maps a page from the buffer into kernel address
>   *		space, users may not block until the subsequent unmap call.
>   *		This callback must not sleep.
>   * @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer.
>   *		  This Callback must not sleep.
> - * @map: maps a page from the buffer into kernel address space.
> + * @map: [optional] maps a page from the buffer into kernel address space.
>   * @unmap: [optional] unmaps a page from the buffer.
>   * @vmap: [optional] creates a virtual mapping for the buffer into kernel
>   *	  address space. Same restrictions as for vmap and friends apply.
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index d78d5fc173..4c45e31258 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num)
>  {
>  	WARN_ON(!dmabuf);
>  
> +	if (!dmabuf->ops->map_atomic)
> +		return NULL;
>  	return dmabuf->ops->map_atomic(dmabuf, page_num);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
> @@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num)
>  {
>  	WARN_ON(!dmabuf);
>  
> +	if (!dmabuf->ops->map)
> +		return NULL;
>  	return dmabuf->ops->map(dmabuf, page_num);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_kmap);
> -- 
> 2.9.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [PATCH] dma-buf: make map_atomic and map function pointers optional
  2018-05-29 13:59 [PATCH] dma-buf: make map_atomic and map function pointers optional Gerd Hoffmann
  2018-05-30 10:30 ` Daniel Vetter
@ 2018-05-30 11:36 ` Oleksandr Andrushchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Oleksandr Andrushchenko @ 2018-05-30 11:36 UTC (permalink / raw)
  To: Gerd Hoffmann, dri-devel
  Cc: open list, moderated list:DMA BUFFER SHARING FRAMEWORK,
	open list:DMA BUFFER SHARING FRAMEWORK

On 05/29/2018 04:59 PM, Gerd Hoffmann wrote:
> So drivers don't need dummy functions just returning NULL.
>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   include/linux/dma-buf.h   | 4 ++--
>   drivers/dma-buf/dma-buf.c | 4 ++++
>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index 085db2fee2..88917fa796 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -39,12 +39,12 @@ struct dma_buf_attachment;
>   
>   /**
>    * struct dma_buf_ops - operations possible on struct dma_buf
> - * @map_atomic: maps a page from the buffer into kernel address
> + * @map_atomic: [optional] maps a page from the buffer into kernel address
>    *		space, users may not block until the subsequent unmap call.
>    *		This callback must not sleep.
>    * @unmap_atomic: [optional] unmaps a atomically mapped page from the buffer.
>    *		  This Callback must not sleep.
> - * @map: maps a page from the buffer into kernel address space.
> + * @map: [optional] maps a page from the buffer into kernel address space.
>    * @unmap: [optional] unmaps a page from the buffer.
>    * @vmap: [optional] creates a virtual mapping for the buffer into kernel
>    *	  address space. Same restrictions as for vmap and friends apply.
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index d78d5fc173..4c45e31258 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -872,6 +872,8 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num)
>   {
>   	WARN_ON(!dmabuf);
>   
> +	if (!dmabuf->ops->map_atomic)
> +		return NULL;
>   	return dmabuf->ops->map_atomic(dmabuf, page_num);
>   }
>   EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
> @@ -907,6 +909,8 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num)
>   {
>   	WARN_ON(!dmabuf);
>   
> +	if (!dmabuf->ops->map)
> +		return NULL;
>   	return dmabuf->ops->map(dmabuf, page_num);
>   }
>   EXPORT_SYMBOL_GPL(dma_buf_kmap);
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

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

* Re: [PATCH] dma-buf: make map_atomic and map function pointers optional
  2018-05-30 10:30 ` Daniel Vetter
@ 2018-06-01  7:01   ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-06-01  7:01 UTC (permalink / raw)
  To: dri-devel, Sumit Semwal, open list:DMA BUFFER SHARING FRAMEWORK,
	moderated list:DMA BUFFER SHARING FRAMEWORK, open list

On Wed, May 30, 2018 at 12:30:51PM +0200, Daniel Vetter wrote:
> On Tue, May 29, 2018 at 03:59:18PM +0200, Gerd Hoffmann wrote:
> > So drivers don't need dummy functions just returning NULL.
> > 
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> Please push to drm-misc-next (maybe after a few more days of waiting for
> feedback).

Done.

cheers,
  Gerd

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

end of thread, other threads:[~2018-06-01  7:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29 13:59 [PATCH] dma-buf: make map_atomic and map function pointers optional Gerd Hoffmann
2018-05-30 10:30 ` Daniel Vetter
2018-06-01  7:01   ` Gerd Hoffmann
2018-05-30 11:36 ` Oleksandr Andrushchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).