Commit 00085f1e authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Linus Torvalds

dma-mapping: use unsigned long for dma_attrs

The dma-mapping core and the implementations do not change the DMA
attributes passed by pointer.  Thus the pointer can point to const data.
However the attributes do not have to be a bitfield.  Instead unsigned
long will do fine:

1. This is just simpler.  Both in terms of reading the code and setting
   attributes.  Instead of initializing local attributes on the stack
   and passing pointer to it to dma_set_attr(), just set the bits.

2. It brings safeness and checking for const correctness because the
   attributes are passed by value.

Semantic patches for this change (at least most of them):

    virtual patch
    virtual context

    @r@
    identifier f, attrs;

    @@
    f(...,
    - struct dma_attrs *attrs
    + unsigned long attrs
    , ...)
    {
    ...
    }

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
     )

and

    // Options: --all-includes
    virtual patch
    virtual context

    @r@
    identifier f, attrs;
    type t;

    @@
    t f(..., struct dma_attrs *attrs);

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
     )

Link: http://lkml.kernel.org/r/1468399300-5399-2-git-send-email-k.kozlowski@samsung.comSigned-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: default avatarVineet Gupta <vgupta@synopsys.com>
Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
Acked-by: default avatarHans-Christian Noren Egtvedt <egtvedt@samfundet.no>
Acked-by: Mark Salter <msalter@redhat.com> [c6x]
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> [cris]
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> [drm]
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Acked-by: Joerg Roedel <jroedel@suse.de> [iommu]
Acked-by: Fabien Dessenne <fabien.dessenne@st.com> [bdisp]
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> [vb2-core]
Acked-by: David Vrabel <david.vrabel@citrix.com> [xen]
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [xen swiotlb]
Acked-by: Joerg Roedel <jroedel@suse.de> [iommu]
Acked-by: Richard Kuo <rkuo@codeaurora.org> [hexagon]
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Acked-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> [s390]
Acked-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no> [avr32]
Acked-by: Vineet Gupta <vgupta@synopsys.com> [arc]
Acked-by: Robin Murphy <robin.murphy@arm.com> [arm64 and dma-iommu]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1605d271
...@@ -369,35 +369,32 @@ See also dma_map_single(). ...@@ -369,35 +369,32 @@ See also dma_map_single().
dma_addr_t dma_addr_t
dma_map_single_attrs(struct device *dev, void *cpu_addr, size_t size, dma_map_single_attrs(struct device *dev, void *cpu_addr, size_t size,
enum dma_data_direction dir, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
void void
dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr, dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr,
size_t size, enum dma_data_direction dir, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
int int
dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl,
int nents, enum dma_data_direction dir, int nents, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
void void
dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl,
int nents, enum dma_data_direction dir, int nents, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
The four functions above are just like the counterpart functions The four functions above are just like the counterpart functions
without the _attrs suffixes, except that they pass an optional without the _attrs suffixes, except that they pass an optional
struct dma_attrs*. dma_attrs.
struct dma_attrs encapsulates a set of "DMA attributes". For the
definition of struct dma_attrs see linux/dma-attrs.h.
The interpretation of DMA attributes is architecture-specific, and The interpretation of DMA attributes is architecture-specific, and
each attribute should be documented in Documentation/DMA-attributes.txt. each attribute should be documented in Documentation/DMA-attributes.txt.
If struct dma_attrs* is NULL, the semantics of each of these If dma_attrs are 0, the semantics of each of these functions
functions is identical to those of the corresponding function is identical to those of the corresponding function
without the _attrs suffix. As a result dma_map_single_attrs() without the _attrs suffix. As a result dma_map_single_attrs()
can generally replace dma_map_single(), etc. can generally replace dma_map_single(), etc.
...@@ -405,15 +402,15 @@ As an example of the use of the *_attrs functions, here's how ...@@ -405,15 +402,15 @@ As an example of the use of the *_attrs functions, here's how
you could pass an attribute DMA_ATTR_FOO when mapping memory you could pass an attribute DMA_ATTR_FOO when mapping memory
for DMA: for DMA:
#include <linux/dma-attrs.h> #include <linux/dma-mapping.h>
/* DMA_ATTR_FOO should be defined in linux/dma-attrs.h and /* DMA_ATTR_FOO should be defined in linux/dma-mapping.h and
* documented in Documentation/DMA-attributes.txt */ * documented in Documentation/DMA-attributes.txt */
... ...
DEFINE_DMA_ATTRS(attrs); unsigned long attr;
dma_set_attr(DMA_ATTR_FOO, &attrs); attr |= DMA_ATTR_FOO;
.... ....
n = dma_map_sg_attrs(dev, sg, nents, DMA_TO_DEVICE, &attr); n = dma_map_sg_attrs(dev, sg, nents, DMA_TO_DEVICE, attr);
.... ....
Architectures that care about DMA_ATTR_FOO would check for its Architectures that care about DMA_ATTR_FOO would check for its
...@@ -422,12 +419,10 @@ routines, e.g.: ...@@ -422,12 +419,10 @@ routines, e.g.:
void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr, void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr,
size_t size, enum dma_data_direction dir, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
.... ....
int foo = dma_get_attr(DMA_ATTR_FOO, attrs); if (attrs & DMA_ATTR_FOO)
....
if (foo)
/* twizzle the frobnozzle */ /* twizzle the frobnozzle */
.... ....
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
============== ==============
This document describes the semantics of the DMA attributes that are This document describes the semantics of the DMA attributes that are
defined in linux/dma-attrs.h. defined in linux/dma-mapping.h.
DMA_ATTR_WRITE_BARRIER DMA_ATTR_WRITE_BARRIER
---------------------- ----------------------
......
#ifndef _ALPHA_DMA_MAPPING_H #ifndef _ALPHA_DMA_MAPPING_H
#define _ALPHA_DMA_MAPPING_H #define _ALPHA_DMA_MAPPING_H
#include <linux/dma-attrs.h>
extern struct dma_map_ops *dma_ops; extern struct dma_map_ops *dma_ops;
static inline struct dma_map_ops *get_dma_ops(struct device *dev) static inline struct dma_map_ops *get_dma_ops(struct device *dev)
......
...@@ -109,7 +109,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn, ...@@ -109,7 +109,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
static void *alpha_noop_alloc_coherent(struct device *dev, size_t size, static void *alpha_noop_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp, dma_addr_t *dma_handle, gfp_t gfp,
struct dma_attrs *attrs) unsigned long attrs)
{ {
void *ret; void *ret;
......
...@@ -349,7 +349,7 @@ static struct pci_dev *alpha_gendev_to_pci(struct device *dev) ...@@ -349,7 +349,7 @@ static struct pci_dev *alpha_gendev_to_pci(struct device *dev)
static dma_addr_t alpha_pci_map_page(struct device *dev, struct page *page, static dma_addr_t alpha_pci_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, unsigned long offset, size_t size,
enum dma_data_direction dir, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
struct pci_dev *pdev = alpha_gendev_to_pci(dev); struct pci_dev *pdev = alpha_gendev_to_pci(dev);
int dac_allowed; int dac_allowed;
...@@ -369,7 +369,7 @@ static dma_addr_t alpha_pci_map_page(struct device *dev, struct page *page, ...@@ -369,7 +369,7 @@ static dma_addr_t alpha_pci_map_page(struct device *dev, struct page *page,
static void alpha_pci_unmap_page(struct device *dev, dma_addr_t dma_addr, static void alpha_pci_unmap_page(struct device *dev, dma_addr_t dma_addr,
size_t size, enum dma_data_direction dir, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
unsigned long flags; unsigned long flags;
struct pci_dev *pdev = alpha_gendev_to_pci(dev); struct pci_dev *pdev = alpha_gendev_to_pci(dev);
...@@ -433,7 +433,7 @@ static void alpha_pci_unmap_page(struct device *dev, dma_addr_t dma_addr, ...@@ -433,7 +433,7 @@ static void alpha_pci_unmap_page(struct device *dev, dma_addr_t dma_addr,
static void *alpha_pci_alloc_coherent(struct device *dev, size_t size, static void *alpha_pci_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_addrp, gfp_t gfp, dma_addr_t *dma_addrp, gfp_t gfp,
struct dma_attrs *attrs) unsigned long attrs)
{ {
struct pci_dev *pdev = alpha_gendev_to_pci(dev); struct pci_dev *pdev = alpha_gendev_to_pci(dev);
void *cpu_addr; void *cpu_addr;
...@@ -478,7 +478,7 @@ try_again: ...@@ -478,7 +478,7 @@ try_again:
static void alpha_pci_free_coherent(struct device *dev, size_t size, static void alpha_pci_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_addr, void *cpu_addr, dma_addr_t dma_addr,
struct dma_attrs *attrs) unsigned long attrs)
{ {
struct pci_dev *pdev = alpha_gendev_to_pci(dev); struct pci_dev *pdev = alpha_gendev_to_pci(dev);
pci_unmap_single(pdev, dma_addr, size, PCI_DMA_BIDIRECTIONAL); pci_unmap_single(pdev, dma_addr, size, PCI_DMA_BIDIRECTIONAL);
...@@ -651,7 +651,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end, ...@@ -651,7 +651,7 @@ sg_fill(struct device *dev, struct scatterlist *leader, struct scatterlist *end,
static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg, static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, int nents, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
struct pci_dev *pdev = alpha_gendev_to_pci(dev); struct pci_dev *pdev = alpha_gendev_to_pci(dev);
struct scatterlist *start, *end, *out; struct scatterlist *start, *end, *out;
...@@ -729,7 +729,7 @@ static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg, ...@@ -729,7 +729,7 @@ static int alpha_pci_map_sg(struct device *dev, struct scatterlist *sg,
static void alpha_pci_unmap_sg(struct device *dev, struct scatterlist *sg, static void alpha_pci_unmap_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, int nents, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
struct pci_dev *pdev = alpha_gendev_to_pci(dev); struct pci_dev *pdev = alpha_gendev_to_pci(dev);
unsigned long flags; unsigned long flags;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
static void *arc_dma_alloc(struct device *dev, size_t size, static void *arc_dma_alloc(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp, struct dma_attrs *attrs) dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
{ {
unsigned long order = get_order(size); unsigned long order = get_order(size);
struct page *page; struct page *page;
...@@ -46,7 +46,7 @@ static void *arc_dma_alloc(struct device *dev, size_t size, ...@@ -46,7 +46,7 @@ static void *arc_dma_alloc(struct device *dev, size_t size,
* (vs. always going to memory - thus are faster) * (vs. always going to memory - thus are faster)
*/ */
if ((is_isa_arcv2() && ioc_exists) || if ((is_isa_arcv2() && ioc_exists) ||
dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) (attrs & DMA_ATTR_NON_CONSISTENT))
need_coh = 0; need_coh = 0;
/* /*
...@@ -90,13 +90,13 @@ static void *arc_dma_alloc(struct device *dev, size_t size, ...@@ -90,13 +90,13 @@ static void *arc_dma_alloc(struct device *dev, size_t size,
} }
static void arc_dma_free(struct device *dev, size_t size, void *vaddr, static void arc_dma_free(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle, struct dma_attrs *attrs) dma_addr_t dma_handle, unsigned long attrs)
{ {
phys_addr_t paddr = plat_dma_to_phys(dev, dma_handle); phys_addr_t paddr = plat_dma_to_phys(dev, dma_handle);
struct page *page = virt_to_page(paddr); struct page *page = virt_to_page(paddr);
int is_non_coh = 1; int is_non_coh = 1;
is_non_coh = dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs) || is_non_coh = (attrs & DMA_ATTR_NON_CONSISTENT) ||
(is_isa_arcv2() && ioc_exists); (is_isa_arcv2() && ioc_exists);
if (PageHighMem(page) || !is_non_coh) if (PageHighMem(page) || !is_non_coh)
...@@ -130,7 +130,7 @@ static void _dma_cache_sync(phys_addr_t paddr, size_t size, ...@@ -130,7 +130,7 @@ static void _dma_cache_sync(phys_addr_t paddr, size_t size,
static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page, static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long offset, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
phys_addr_t paddr = page_to_phys(page) + offset; phys_addr_t paddr = page_to_phys(page) + offset;
_dma_cache_sync(paddr, size, dir); _dma_cache_sync(paddr, size, dir);
...@@ -138,7 +138,7 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page, ...@@ -138,7 +138,7 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
} }
static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg, static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, struct dma_attrs *attrs) int nents, enum dma_data_direction dir, unsigned long attrs)
{ {
struct scatterlist *s; struct scatterlist *s;
int i; int i;
......
...@@ -310,7 +310,7 @@ static inline void unmap_single(struct device *dev, struct safe_buffer *buf, ...@@ -310,7 +310,7 @@ static inline void unmap_single(struct device *dev, struct safe_buffer *buf,
*/ */
static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page, static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long offset, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
dma_addr_t dma_addr; dma_addr_t dma_addr;
int ret; int ret;
...@@ -344,7 +344,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page, ...@@ -344,7 +344,7 @@ static dma_addr_t dmabounce_map_page(struct device *dev, struct page *page,
* should be) * should be)
*/ */
static void dmabounce_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, static void dmabounce_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
enum dma_data_direction dir, struct dma_attrs *attrs) enum dma_data_direction dir, unsigned long attrs)
{ {
struct safe_buffer *buf; struct safe_buffer *buf;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <linux/mm_types.h> #include <linux/mm_types.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/dma-attrs.h>
#include <linux/dma-debug.h> #include <linux/dma-debug.h>
#include <asm/memory.h> #include <asm/memory.h>
...@@ -174,7 +173,7 @@ static inline void dma_mark_clean(void *addr, size_t size) { } ...@@ -174,7 +173,7 @@ static inline void dma_mark_clean(void *addr, size_t size) { }
* to be the device-viewed address. * to be the device-viewed address.
*/ */
extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
gfp_t gfp, struct dma_attrs *attrs); gfp_t gfp, unsigned long attrs);
/** /**
* arm_dma_free - free memory allocated by arm_dma_alloc * arm_dma_free - free memory allocated by arm_dma_alloc
...@@ -191,7 +190,7 @@ extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, ...@@ -191,7 +190,7 @@ extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
* during and after this call executing are illegal. * during and after this call executing are illegal.
*/ */
extern void arm_dma_free(struct device *dev, size_t size, void *cpu_addr, extern void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t handle, struct dma_attrs *attrs); dma_addr_t handle, unsigned long attrs);
/** /**
* arm_dma_mmap - map a coherent DMA allocation into user space * arm_dma_mmap - map a coherent DMA allocation into user space
...@@ -208,7 +207,7 @@ extern void arm_dma_free(struct device *dev, size_t size, void *cpu_addr, ...@@ -208,7 +207,7 @@ extern void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
*/ */
extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
void *cpu_addr, dma_addr_t dma_addr, size_t size, void *cpu_addr, dma_addr_t dma_addr, size_t size,
struct dma_attrs *attrs); unsigned long attrs);
/* /*
* This can be called during early boot to increase the size of the atomic * This can be called during early boot to increase the size of the atomic
...@@ -262,16 +261,16 @@ extern void dmabounce_unregister_dev(struct device *); ...@@ -262,16 +261,16 @@ extern void dmabounce_unregister_dev(struct device *);
* The scatter list versions of the above methods. * The scatter list versions of the above methods.
*/ */
extern int arm_dma_map_sg(struct device *, struct scatterlist *, int, extern int arm_dma_map_sg(struct device *, struct scatterlist *, int,
enum dma_data_direction, struct dma_attrs *attrs); enum dma_data_direction, unsigned long attrs);
extern void arm_dma_unmap_sg(struct device *, struct scatterlist *, int, extern void arm_dma_unmap_sg(struct device *, struct scatterlist *, int,
enum dma_data_direction, struct dma_attrs *attrs); enum dma_data_direction, unsigned long attrs);
extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist *, int, extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist *, int,
enum dma_data_direction); enum dma_data_direction);
extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int, extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
enum dma_data_direction); enum dma_data_direction);
extern int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt, extern int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
void *cpu_addr, dma_addr_t dma_addr, size_t size, void *cpu_addr, dma_addr_t dma_addr, size_t size,
struct dma_attrs *attrs); unsigned long attrs);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif #endif
...@@ -2,15 +2,14 @@ ...@@ -2,15 +2,14 @@
#define _ASM_ARM_XEN_PAGE_COHERENT_H #define _ASM_ARM_XEN_PAGE_COHERENT_H
#include <asm/page.h> #include <asm/page.h>
#include <linux/dma-attrs.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
void __xen_dma_map_page(struct device *hwdev, struct page *page, void __xen_dma_map_page(struct device *hwdev, struct page *page,
dma_addr_t dev_addr, unsigned long offset, size_t size, dma_addr_t dev_addr, unsigned long offset, size_t size,
enum dma_data_direction dir, struct dma_attrs *attrs); enum dma_data_direction dir, unsigned long attrs);
void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, void __xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
size_t size, enum dma_data_direction dir, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs); unsigned long attrs);
void __xen_dma_sync_single_for_cpu(struct device *hwdev, void __xen_dma_sync_single_for_cpu(struct device *hwdev,
dma_addr_t handle, size_t size, enum dma_data_direction dir); dma_addr_t handle, size_t size, enum dma_data_direction dir);
...@@ -18,22 +17,20 @@ void __xen_dma_sync_single_for_device(struct device *hwdev, ...@@ -18,22 +17,20 @@ void __xen_dma_sync_single_for_device(struct device *hwdev,
dma_addr_t handle, size_t size, enum dma_data_direction dir); dma_addr_t handle, size_t size, enum dma_data_direction dir);
static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags, dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs)
struct dma_attrs *attrs)
{ {
return __generic_dma_ops(hwdev)->alloc(hwdev, size, dma_handle, flags, attrs); return __generic_dma_ops(hwdev)->alloc(hwdev, size, dma_handle, flags, attrs);
} }
static inline void xen_free_coherent_pages(struct device *hwdev, size_t size, static inline void xen_free_coherent_pages(struct device *hwdev, size_t size,
void *cpu_addr, dma_addr_t dma_handle, void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)
struct dma_attrs *attrs)
{ {
__generic_dma_ops(hwdev)->free(hwdev, size, cpu_addr, dma_handle, attrs); __generic_dma_ops(hwdev)->free(hwdev, size, cpu_addr, dma_handle, attrs);
} }
static inline void xen_dma_map_page(struct device *hwdev, struct page *page, static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
dma_addr_t dev_addr, unsigned long offset, size_t size, dma_addr_t dev_addr, unsigned long offset, size_t size,
enum dma_data_direction dir, struct dma_attrs *attrs) enum dma_data_direction dir, unsigned long attrs)
{ {
unsigned long page_pfn = page_to_xen_pfn(page); unsigned long page_pfn = page_to_xen_pfn(page);
unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr); unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr);
...@@ -58,8 +55,7 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page, ...@@ -58,8 +55,7 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
} }
static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
size_t size, enum dma_data_direction dir, size_t size, enum dma_data_direction dir, unsigned long attrs)
struct dma_attrs *attrs)
{ {
unsigned long pfn = PFN_DOWN(handle); unsigned long pfn = PFN_DOWN(handle);
/* /*
......
...@@ -128,16 +128,16 @@ static void __dma_page_dev_to_cpu(struct page *, unsigned long, ...@@ -128,16 +128,16 @@ static void __dma_page_dev_to_cpu(struct page *, unsigned long,
*/ */
static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page, static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long offset, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_cpu_to_dev(page, offset, size, dir); __dma_page_cpu_to_dev(page, offset, size, dir);
return pfn_to_dma(dev, page_to_pfn(page)) + offset; return pfn_to_dma(dev, page_to_pfn(page)) + offset;
} }
static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *page, static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long offset, size_t size, enum dma_data_direction dir,
struct dma_attrs *attrs) unsigned long attrs)
{ {
return pfn_to_dma(dev, page_to_pfn(page)) + offset; return pfn_to_dma(dev, page_to_pfn(page)) + offset;
} }
...@@ -157,10 +157,9 @@ static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *pag ...@@ -157,10 +157,9 @@ static dma_addr_t arm_coherent_dma_map_page(struct device *dev, struct page *pag
* whatever the device wrote there. * whatever the device wrote there.
*/ */
static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle, static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir, size_t size, enum dma_data_direction dir, unsigned long attrs)
struct dma_attrs *attrs)
{ {
if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
__dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)), __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
handle & ~PAGE_MASK, size, dir); handle & ~PAGE_MASK, size, dir);
} }
...@@ -198,12 +197,12 @@ struct dma_map_ops arm_dma_ops = { ...@@ -198,12 +197,12 @@ struct dma_map_ops arm_dma_ops = {
EXPORT_SYMBOL(arm_dma_ops); EXPORT_SYMBOL(arm_dma_ops);
static void *arm_coherent_dma_alloc(struct device *dev, size_t size, static void *arm_coherent_dma_alloc(struct device *dev, size_t size,
dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs); dma_addr_t *handle, gfp_t gfp, unsigned long attrs);
static void arm_coherent_dma_free(struct device *dev, size_t size, void *cpu_addr, static void arm_coherent_dma_free(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t handle, struct dma_attrs *attrs); dma_addr_t handle, unsigned long attrs);
static int arm_coherent_dma_mmap(struct device *dev, struct vm_area_struct *vma, static int arm_coherent_dma_mmap(struct device *dev, struct vm_area_struct *vma,
void *cpu_addr, dma_addr_t dma_addr, size_t size, void *cpu_addr, dma_addr_t dma_addr, size_t size,
struct dma_attrs *attrs); unsigned long attrs);
struct dma_map_ops arm_coherent_dma_ops = { struct dma_map_ops arm_coherent_dma_ops = {
.alloc = arm_coherent_dma_alloc, .alloc = arm_coherent_dma_alloc,
...@@ -639,11 +638,11 @@ static void __free_from_contiguous(struct device *dev, struct page *page, ...@@ -639,11 +638,11 @@ static void __free_from_contiguous(struct device *dev, struct page *page,
dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT); dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT);
} }
static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot) static inline pgprot_t __get_dma_pgprot(unsigned long attrs, pgprot_t prot)
{ {