diff mbox

[v2,1/5] dma-mapping: add dma_{map,unmap}_page_attrs

Message ID 1453384895-20395-2-git-send-email-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Niklas Söderlund Jan. 21, 2016, 2:01 p.m. UTC
Add a version of dmap_{map,unmap}_page that can pass on attributes to
the underlaying map_page. This already exists for dma_{map,unmap}_single
and dmap_{map,unmap}_sg versions.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 include/asm-generic/dma-mapping-common.h | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Comments

Laurent Pinchart Jan. 24, 2016, 8:43 p.m. UTC | #1
Hi Niklas,

(CC'ing LKML, linux-arch and Arnd Bergmann)

Thank you for the patch.

On Thursday 21 January 2016 15:01:31 Niklas Söderlund wrote:
> Add a version of dmap_{map,unmap}_page that can pass on attributes to
> the underlaying map_page. This already exists for dma_{map,unmap}_single
> and dmap_{map,unmap}_sg versions.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  include/asm-generic/dma-mapping-common.h | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/include/asm-generic/dma-mapping-common.h
> b/include/asm-generic/dma-mapping-common.h index b1bc954..bb08302 100644
> --- a/include/asm-generic/dma-mapping-common.h
> +++ b/include/asm-generic/dma-mapping-common.h
> @@ -74,29 +74,33 @@ static inline void dma_unmap_sg_attrs(struct device
> *dev, struct scatterlist *sg ops->unmap_sg(dev, sg, nents, dir, attrs);
>  }
> 
> -static inline dma_addr_t dma_map_page(struct device *dev, struct page
> *page, -				      size_t offset, size_t size,
> -				      enum dma_data_direction dir)
> +static inline dma_addr_t dma_map_page_attrs(struct device *dev,
> +					    struct page *page,
> +					    size_t offset, size_t size,
> +					    enum dma_data_direction dir,
> +					    struct dma_attrs *attrs)
>  {
>  	struct dma_map_ops *ops = get_dma_ops(dev);
>  	dma_addr_t addr;
> 
>  	kmemcheck_mark_initialized(page_address(page) + offset, size);
>  	BUG_ON(!valid_dma_direction(dir));
> -	addr = ops->map_page(dev, page, offset, size, dir, NULL);
> +	addr = ops->map_page(dev, page, offset, size, dir, attrs);
>  	debug_dma_map_page(dev, page, offset, size, dir, addr, false);
> 
>  	return addr;
>  }
> 
> -static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
> -				  size_t size, enum dma_data_direction dir)
> +static inline void dma_unmap_page_attrs(struct device *dev, dma_addr_t
> addr, +					size_t size,
> +					enum dma_data_direction dir,
> +					struct dma_attrs *attrs)
>  {
>  	struct dma_map_ops *ops = get_dma_ops(dev);
> 
>  	BUG_ON(!valid_dma_direction(dir));
>  	if (ops->unmap_page)
> -		ops->unmap_page(dev, addr, size, dir, NULL);
> +		ops->unmap_page(dev, addr, size, dir, attrs);
>  	debug_dma_unmap_page(dev, addr, size, dir, false);
>  }
> 
> @@ -181,6 +185,8 @@ dma_sync_sg_for_device(struct device *dev, struct
> scatterlist *sg, #define dma_unmap_single(d, a, s, r)
> dma_unmap_single_attrs(d, a, s, r, NULL) #define dma_map_sg(d, s, n, r)
> dma_map_sg_attrs(d, s, n, r, NULL) #define dma_unmap_sg(d, s, n, r)
> dma_unmap_sg_attrs(d, s, n, r, NULL) +#define dma_map_page(d, p, o, s, r)
> dma_map_page_attrs(d, p, o, s, r, NULL) +#define dma_unmap_page(d, a, s, r)
> dma_unmap_page_attrs(d, a, s, r, NULL)
> 
>  extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
>  			   void *cpu_addr, dma_addr_t dma_addr, size_t size);
Arnd Bergmann Jan. 25, 2016, 9:09 a.m. UTC | #2
On Sunday 24 January 2016 22:43:57 Laurent Pinchart wrote:
> Hi Niklas,
> 
> (CC'ing LKML, linux-arch and Arnd Bergmann)
> 
> Thank you for the patch.
> 
> On Thursday 21 January 2016 15:01:31 Niklas Söderlund wrote:
> > Add a version of dmap_{map,unmap}_page that can pass on attributes to
> > the underlaying map_page. This already exists for dma_{map,unmap}_single
> > and dmap_{map,unmap}_sg versions.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 

The patch looks fine, but won't apply any more now that the code has
been moved to include/linux/dma-mapping.h

	Arnd
diff mbox

Patch

diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index b1bc954..bb08302 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -74,29 +74,33 @@  static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg
 		ops->unmap_sg(dev, sg, nents, dir, attrs);
 }
 
-static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
-				      size_t offset, size_t size,
-				      enum dma_data_direction dir)
+static inline dma_addr_t dma_map_page_attrs(struct device *dev,
+					    struct page *page,
+					    size_t offset, size_t size,
+					    enum dma_data_direction dir,
+					    struct dma_attrs *attrs)
 {
 	struct dma_map_ops *ops = get_dma_ops(dev);
 	dma_addr_t addr;
 
 	kmemcheck_mark_initialized(page_address(page) + offset, size);
 	BUG_ON(!valid_dma_direction(dir));
-	addr = ops->map_page(dev, page, offset, size, dir, NULL);
+	addr = ops->map_page(dev, page, offset, size, dir, attrs);
 	debug_dma_map_page(dev, page, offset, size, dir, addr, false);
 
 	return addr;
 }
 
-static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
-				  size_t size, enum dma_data_direction dir)
+static inline void dma_unmap_page_attrs(struct device *dev, dma_addr_t addr,
+					size_t size,
+					enum dma_data_direction dir,
+					struct dma_attrs *attrs)
 {
 	struct dma_map_ops *ops = get_dma_ops(dev);
 
 	BUG_ON(!valid_dma_direction(dir));
 	if (ops->unmap_page)
-		ops->unmap_page(dev, addr, size, dir, NULL);
+		ops->unmap_page(dev, addr, size, dir, attrs);
 	debug_dma_unmap_page(dev, addr, size, dir, false);
 }
 
@@ -181,6 +185,8 @@  dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
 #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL)
 #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
 #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
+#define dma_map_page(d, p, o, s, r) dma_map_page_attrs(d, p, o, s, r, NULL)
+#define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, NULL)
 
 extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
 			   void *cpu_addr, dma_addr_t dma_addr, size_t size);