Commit 754c7809 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-v3.18' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping

Pull dma-mapping update from Marek Szyprowski:
 "Provide the dma write coherent api (available previously on ARM
  architecture) for all other architectures, which use dma_ops-based dma
  mapping implementation.

  This lets one to use the same code in the device drivers regardless of
  the selected architecture"

* 'for-v3.18' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping:
  dma-mapping: Provide write-combine allocations
  s390: Implement dma_{alloc,free}_attrs()
parents 40c43269 b4bbb107
...@@ -265,22 +265,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, ...@@ -265,22 +265,6 @@ 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); struct dma_attrs *attrs);
static inline void *dma_alloc_writecombine(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
return dma_alloc_attrs(dev, size, dma_handle, flag, &attrs);
}
static inline void dma_free_writecombine(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
return dma_free_attrs(dev, size, cpu_addr, dma_handle, &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
* coherent DMA pool above the default value of 256KiB. It must be called * coherent DMA pool above the default value of 256KiB. It must be called
......
...@@ -496,8 +496,8 @@ config QDIO ...@@ -496,8 +496,8 @@ config QDIO
menuconfig PCI menuconfig PCI
bool "PCI support" bool "PCI support"
default n
depends on 64BIT depends on 64BIT
select HAVE_DMA_ATTRS
select PCI_MSI select PCI_MSI
help help
Enable PCI support. Enable PCI support.
...@@ -544,9 +544,6 @@ config HAS_DMA ...@@ -544,9 +544,6 @@ config HAS_DMA
config NEED_SG_DMA_LENGTH config NEED_SG_DMA_LENGTH
def_bool PCI def_bool PCI
config HAVE_DMA_ATTRS
def_bool PCI
config NEED_DMA_MAP_STATE config NEED_DMA_MAP_STATE
def_bool PCI def_bool PCI
......
...@@ -56,24 +56,35 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) ...@@ -56,24 +56,35 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
return dma_addr == DMA_ERROR_CODE; return dma_addr == DMA_ERROR_CODE;
} }
static inline void *dma_alloc_coherent(struct device *dev, size_t size, #define dma_alloc_coherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
dma_addr_t *dma_handle, gfp_t flag)
static inline void *dma_alloc_attrs(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flags,
struct dma_attrs *attrs)
{ {
struct dma_map_ops *ops = get_dma_ops(dev); struct dma_map_ops *ops = get_dma_ops(dev);
void *ret; void *cpu_addr;
BUG_ON(!ops);
ret = ops->alloc(dev, size, dma_handle, flag, NULL); cpu_addr = ops->alloc(dev, size, dma_handle, flags, attrs);
debug_dma_alloc_coherent(dev, size, *dma_handle, ret); debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
return ret;
return cpu_addr;
} }
static inline void dma_free_coherent(struct device *dev, size_t size, #define dma_free_coherent(d, s, c, h) dma_free_attrs(d, s, c, h, NULL)
void *cpu_addr, dma_addr_t dma_handle)
static inline void dma_free_attrs(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle,
struct dma_attrs *attrs)
{ {
struct dma_map_ops *dma_ops = get_dma_ops(dev); struct dma_map_ops *ops = get_dma_ops(dev);
BUG_ON(!ops);
debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
dma_ops->free(dev, size, cpu_addr, dma_handle, NULL); ops->free(dev, size, cpu_addr, dma_handle, attrs);
} }
#endif /* _ASM_S390_DMA_MAPPING_H */ #endif /* _ASM_S390_DMA_MAPPING_H */
...@@ -214,14 +214,6 @@ dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, ...@@ -214,14 +214,6 @@ dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL) #define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
void *cpu_addr, dma_addr_t dma_addr, size_t size)
{
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
}
int int
dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, dma_common_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);
......
...@@ -263,6 +263,32 @@ struct dma_attrs; ...@@ -263,6 +263,32 @@ struct dma_attrs;
#define dma_unmap_sg_attrs(dev, sgl, nents, dir, attrs) \ #define dma_unmap_sg_attrs(dev, sgl, nents, dir, attrs) \
dma_unmap_sg(dev, sgl, nents, dir) dma_unmap_sg(dev, sgl, nents, dir)
#else
static inline void *dma_alloc_writecombine(struct device *dev, size_t size,
dma_addr_t *dma_addr, gfp_t gfp)
{
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
return dma_alloc_attrs(dev, size, dma_addr, gfp, &attrs);
}
static inline void dma_free_writecombine(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_addr)
{
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
return dma_free_attrs(dev, size, cpu_addr, dma_addr, &attrs);
}
static inline int dma_mmap_writecombine(struct device *dev,
struct vm_area_struct *vma,
void *cpu_addr, dma_addr_t dma_addr,
size_t size)
{
DEFINE_DMA_ATTRS(attrs);
dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
}
#endif /* CONFIG_HAVE_DMA_ATTRS */ #endif /* CONFIG_HAVE_DMA_ATTRS */
#ifdef CONFIG_NEED_DMA_MAP_STATE #ifdef CONFIG_NEED_DMA_MAP_STATE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment