dma-buf: add dma_data_direction to unmap dma_buf_op
Subsystems (3)
PATCH 1/1 dma-buf: add dma_data_direction to unmap dma_buf_op
Some exporters may use DMA map/unmap APIs in dma-buf ops, which require enum dma_data_direction for both map and unmap operations.
Thus, the unmap dma_buf_op also needs to have enum dma_data_direction as a parameter.
--- drivers/base/dma-buf.c | 7 +++++-- include/linux/dma-buf.h | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/base/dma-buf.c +5 -2
@@ -271,16 +271,19 @@ EXPORT_SYMBOL_GPL(dma_buf_map_attachment);* dma_buf_ops. * @attach: [in] attachment to unmap buffer from * @sg_table: [in] scatterlist info of the buffer to unmap +* @direction: [in] direction of DMA transfer * */ void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, -struct sg_table *sg_table) +struct sg_table *sg_table, +enum dma_data_direction direction) {if (WARN_ON (!attach || !attach->dmabuf || !sg_table))return ;mutex_lock (&attach->dmabuf->lock); - attach->dmabuf->ops->unmap_dma_buf (attach, sg_table); + attach->dmabuf->ops->unmap_dma_buf (attach, sg_table, + direction);mutex_unlock (&attach->dmabuf->lock); }
include/linux/dma-buf.h +5 -3
@@ -63,7 +63,8 @@ struct dma_buf_ops {struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *,enum dma_data_direction );void (*unmap_dma_buf)(struct dma_buf_attachment *, -struct sg_table *); +struct sg_table *, +enum dma_data_direction );/* TODO: Add try_map_dma_buf version, to return immed with -EBUSY * if the call would block. */
@@ -122,7 +123,8 @@ void dma_buf_put(struct dma_buf *dmabuf);struct sg_table *dma_buf_map_attachment (struct dma_buf_attachment *,enum dma_data_direction ); -void dma_buf_unmap_attachment (struct dma_buf_attachment *,struct sg_table *); +void dma_buf_unmap_attachment (struct dma_buf_attachment *,struct sg_table *, +enum dma_data_direction );#else static inline struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
@@ -166,7 +168,7 @@ static inline struct sg_table *dma_buf_map_attachment( }static inline void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, -struct sg_table *sg) +struct sg_table *sg,enum dma_data_direction write) {return ; }
Signature · 1 line
1.7.5.4
Quoted 8 lines · Sumit Semwal
Some exporters may use DMA map/unmap APIs in dma-buf ops, which require enum
dma_data_directionfor both map and unmap operations.Thus, the unmap
dma_buf_opalso needs to have enumdma_data_directionas a parameter.Reported-by Tomasz Stanislawski <[email protected]>Signed-off-by Sumit Semwal <[email protected]>
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Hi Sumit,
Quoted 68 lines · On Friday 27 January 2012 10:43:28 Sumit Semwal wrote:
Some exporters may use DMA map/unmap APIs in dma-buf ops, which require enum
dma_data_directionfor both map and unmap operations.Thus, the unmap
dma_buf_opalso needs to have enumdma_data_directionas a parameter.Reported-by Tomasz Stanislawski <[email protected]>Signed-off-by Sumit Semwal <[email protected]>--- drivers/base/dma-buf.c | 7 +++++-- include/linux/dma-buf.h | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-)drivers/base/dma-buf.c +5
-2@@ -271,16 +271,19 @@ EXPORT_SYMBOL_GPL(dma_buf_map_attachment);* dma_buf_ops. * @attach: [in] attachment to unmap buffer from * @sg_table: [in] scatterlist info of the buffer to unmap +* @direction: [in] direction of DMA transfer * */ void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, -struct sg_table *sg_table) +struct sg_table *sg_table, +enum dma_data_direction direction) {if (WARN_ON (!attach || !attach->dmabuf || !sg_table))return ;mutex_lock (&attach->dmabuf->lock); - attach->dmabuf->ops->unmap_dma_buf (attach, sg_table); + attach->dmabuf->ops->unmap_dma_buf (attach, sg_table, + direction);mutex_unlock (&attach->dmabuf->lock); }include/linux/dma-buf.h +2
-2@@ -63,7 +63,8 @@ struct dma_buf_ops {struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *,enum dma_data_direction );void (*unmap_dma_buf)(struct dma_buf_attachment *, -struct sg_table *); +struct sg_table *, +enum dma_data_direction );/* TODO: Add try_map_dma_buf version, to return immed with -EBUSY * if the call would block. */ @@ -122,7 +123,8 @@ void dma_buf_put(struct dma_buf *dmabuf);struct sg_table *dma_buf_map_attachment (struct dma_buf_attachment *,enum dma_data_direction ); -void dma_buf_unmap_attachment (struct dma_buf_attachment *,struct sg_table *); +void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *, + enum dma_data_direction);#else static inline struct dma_buf_attachment *dma_buf_attach(struct dma_buf*dmabuf, @@ -166,7 +168,7 @@ static inline struct
sg_table*dma_buf_map_attachment( }static inline void dma_buf_unmap_attachment(struct
dma_buf_attachment
*attach, - structsg_table*sg)
include/linux/dma-buf.h static inline struct sg_table *dma_buf_map_attachment( · line 171
Quoted 1 line
include/linux/dma-buf.h +1
-0+ struct sg_table *sg, enum dma_data_direction write)
s/write/dir/ (or direction) ?
Quoted 3 lines
{
return;
}
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Quoted 59 lines · Laurent Pinchart
Hi Sumit,
Quoted 55 lines · On Friday 27 January 2012 10:43:28 Sumit Semwal wrote:
Some exporters may use DMA map/unmap APIs in dma-buf ops, which require enum
dma_data_directionfor both map and unmap operations.Thus, the unmap
dma_buf_opalso needs to have enumdma_data_directionas a parameter.Reported-by Tomasz Stanislawski <[email protected]>Signed-off-by Sumit Semwal <[email protected]>--- drivers/base/dma-buf.c | 7 +++++-- include/linux/dma-buf.h | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-)drivers/base/dma-buf.c +5
-2@@ -271,16 +271,19 @@ EXPORT_SYMBOL_GPL(dma_buf_map_attachment);* dma_buf_ops. * @attach: [in] attachment to unmap buffer from * @sg_table: [in] scatterlist info of the buffer to unmap +* @direction: [in] direction of DMA transfer * */ void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, -struct sg_table *sg_table) +struct sg_table *sg_table, +enum dma_data_direction direction) {if (WARN_ON (!attach || !attach->dmabuf || !sg_table))return ;mutex_lock (&attach->dmabuf->lock); - attach->dmabuf->ops->unmap_dma_buf (attach, sg_table); + attach->dmabuf->ops->unmap_dma_buf (attach, sg_table, + direction);mutex_unlock (&attach->dmabuf->lock); }include/linux/dma-buf.h +2
-1@@ -63,7 +63,8 @@ struct dma_buf_ops {struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *,enum dma_data_direction );void (*unmap_dma_buf)(struct dma_buf_attachment *, -struct sg_table *); +struct sg_table *, +enum dma_data_direction );/* TODO: Add try_map_dma_buf version, to return immed with -EBUSY * if the call would block. */ @@ -122,7 +123,8 @@ void dma_buf_put(struct dma_buf *dmabuf);
Quoted 3 lines
include/linux/dma-buf.h void dma_buf_put(struct dma_buf *dmabuf);
Quoted 3 lines
include/linux/dma-buf.h +0
-1struct sg_table *dma_buf_map_attachment (struct dma_buf_attachment *,enum dma_data_direction ); -void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct
sg_table
Quoted 10 lines
Quoted 10 lines
include/linux/dma-buf.h +0
-0*); +void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table *, + enum dma_data_direction);#else static inline struct dma_buf_attachment *dma_buf_attach(struct dma_buf*dmabuf, @@ -166,7 +168,7 @@ static inline struct
sg_table*dma_buf_map_attachment( }static inline void dma_buf_unmap_attachment(struct
dma_buf_attachment
*attach, - structsg_table
*sg)
Quoted 1 line
Quoted 1 line
+ struct
sg_table*sg, enumdma_data_direction
write)
Quoted 3 lines
s/write/dir/ (or direction) ?
:-) sure.
Quoted 8 lines
Quoted 3 lines
{ return;}
--
Regards,Laurent Pinchart
Best regards,
-Sumit.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Sumit,
Quoted 1 line · On Friday 27 January 2012 10:43:28 Sumit Semwal wrote:
[snip]
include/linux/dma-buf.h static inline struct sg_table *dma_buf_map_attachment( · line 171
Quoted 4 lines
static inline void dma_buf_unmap_attachment(struct
dma_buf_attachment
*attach,include/linux/dma-buf.h +1
-1- struct sg_table *sg) + struct sg_table *sg, enum dma_data_direction write)
On a second thought, would it make sense to store the direction in struct dma_buf_attachment in dma_buf_map_attachment(), and pass the value directly to the .unmap_dma_buf() instead of requiring the dma_buf_unmap_attachment() caller to remember it ? Or is an attachment allowed to map the buffer several times with different directions ?
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 11 lines · Laurent Pinchart
Hi Sumit,
Quoted 1 line · On Friday 27 January 2012 10:43:28 Sumit Semwal wrote:
[snip]
include/linux/dma-buf.h static inline struct sg_table *dma_buf_map_attachment( · line 171
Quoted 4 lines
static inline void dma_buf_unmap_attachment(struct
dma_buf_attachment
*attach,include/linux/dma-buf.h +1
-1- struct sg_table *sg) + struct sg_table *sg, enum dma_data_direction write)
Quoted 5 lines
On a second thought, would it make sense to store the direction in struct
dma_buf_attachmentindma_buf_map_attachment(), and pass the value directly to the .unmap_dma_buf() instead of requiring thedma_buf_unmap_attachment()caller to remember it ? Or is an attachment allowed to map the buffer several times with different directions ?
Current dma api functions already require you to supply the direction argument on unmap and I think for cpu access I'm also leaning towards an interface where the importer has to supply the direction argument for both begin_access and end_access. So for consistency reasons I'm leaning towards adding it to unmap.
-Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Hi Daniel,
Quoted 13 lines · On Tuesday 31 January 2012 11:36:02 Daniel Vetter wrote:
Quoted 12 lines · Laurent Pinchart
Hi Sumit,
Quoted 1 line · On Friday 27 January 2012 10:43:28 Sumit Semwal wrote:
[snip]
Quoted 6 lines
static inline void dma_buf_unmap_attachment(struct
dma_buf_attachment*attach,
(quoted diff) +1
-1- struct sg_table *sg) + struct sg_table *sg, enum dma_data_directionwrite)
Quoted 8 lines
Quoted 5 lines
On a second thought, would it make sense to store the direction in struct
dma_buf_attachmentindma_buf_map_attachment(), and pass the value directly to the .unmap_dma_buf() instead of requiring thedma_buf_unmap_attachment()caller to remember it ? Or is an attachment allowed to map the buffer several times with different directions ?Current dma api functions already require you to supply the direction argument on unmap
If I understand it correctly, that's mostly because the DMA API doesn't keep track of DMA mappings in a way that it can store the direction on map(), and use it on unmap(). In this case we have an attachment object that we can use to cache the information.
Quoted 4 lines
and I think for cpu access I'm also leaning towards an interface where the importer has to supply the direction argument for both
begin_accessandend_access. So for consistency reasons I'm leaning towards adding it to unmap.
I'm OK with keeping the direction as an argument to unmap() if you think that's better.
Signature · 3 lines
Regards, Laurent Pinchart