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 while unmapping.
Thus, the unmap dma_buf_op also needs to have enum dma_data_direction as a parameter.
--- drivers/base/Kconfig | 2 +- drivers/base/dma-buf.c | 7 +++++-- include/linux/dma-buf.h | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-)
drivers/base/Kconfig +1 -1
@@ -179,7 +179,7 @@ config GENERIC_CPU_DEVICES source "drivers/base/regmap/Kconfig" config DMA_SHARED_BUFFER - bool + bool "Temporary mechanism to enable build of dma-buf" default n select ANON_INODES depends on EXPERIMENTAL
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
Please ignore! I will send out a new version in a minute.
Thanks and best regards,
~Sumit.
Quoted 89 lines · Sumit Semwal
Some exporters may use DMA map/unmap APIs in dma-buf ops, which require enum
dma_data_directionwhile unmapping.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/Kconfig | 2 +-
drivers/base/dma-buf.c | 7 +++++--
include/linux/dma-buf.h | 8 +++++---3 files changed, 11 insertions(+), 6 deletions(-)drivers/base/Kconfig +0
-0@@ -179,7 +179,7 @@ config GENERIC_CPU_DEVICESsource "
drivers/base/regmap/Kconfig"config
DMA_SHARED_BUFFER
- bool
+ bool "Temporary mechanism to enable build of dma-buf" default n
selectANON_INODES
depends on EXPERIMENTALdrivers/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
-4@@ -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; } --1.7.5.4