Skip to content

Commit 90114d6

Browse files
thierryredingmszyprow
authored andcommitted
s390: Implement dma_{alloc,free}_attrs()
The S390 architecture advertises support for HAVE_DMA_ATTRS when PCI is enabled. Patches to unify some of the DMA API would like to rely on the dma_alloc_attrs() and dma_free_attrs() functions to be provided when an architecture supports DMA attributes. Rename dma_alloc_coherent() and dma_free_coherent() to dma_alloc_attrs() and dma_free_attrs() since they are functionally equivalent and alias the former to the latter for compatibility. For consistency with other architectures, also reuse the existing symbol HAVE_DMA_ATTRS defined in arch/Kconfig instead of providing a duplicate. Select it when PCI is enabled. While at it, drop a redundant 'default n' from the PCI Kconfig symbol. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-By: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
1 parent 7d1311b commit 90114d6

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

‎arch/s390/Kconfig‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ config QDIO
498498

499499
menuconfig PCI
500500
bool "PCI support"
501-
default n
502501
depends on 64BIT
502+
select HAVE_DMA_ATTRS
503503
select PCI_MSI
504504
help
505505
Enable PCI support.
@@ -546,9 +546,6 @@ config HAS_DMA
546546
config NEED_SG_DMA_LENGTH
547547
def_bool PCI
548548

549-
config HAVE_DMA_ATTRS
550-
def_bool PCI
551-
552549
config NEED_DMA_MAP_STATE
553550
def_bool PCI
554551

‎arch/s390/include/asm/dma-mapping.h‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,35 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
5656
return dma_addr == DMA_ERROR_CODE;
5757
}
5858

59-
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
60-
dma_addr_t *dma_handle, gfp_t flag)
59+
#define dma_alloc_coherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL)
60+
61+
static inline void *dma_alloc_attrs(struct device *dev, size_t size,
62+
dma_addr_t *dma_handle, gfp_t flags,
63+
struct dma_attrs *attrs)
6164
{
6265
struct dma_map_ops *ops = get_dma_ops(dev);
63-
void *ret;
66+
void *cpu_addr;
67+
68+
BUG_ON(!ops);
6469

65-
ret = ops->alloc(dev, size, dma_handle, flag, NULL);
66-
debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
67-
return ret;
70+
cpu_addr = ops->alloc(dev, size, dma_handle, flags, attrs);
71+
debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
72+
73+
return cpu_addr;
6874
}
6975

70-
static inline void dma_free_coherent(struct device *dev, size_t size,
71-
void *cpu_addr, dma_addr_t dma_handle)
76+
#define dma_free_coherent(d, s, c, h) dma_free_attrs(d, s, c, h, NULL)
77+
78+
static inline void dma_free_attrs(struct device *dev, size_t size,
79+
void *cpu_addr, dma_addr_t dma_handle,
80+
struct dma_attrs *attrs)
7281
{
73-
struct dma_map_ops *dma_ops = get_dma_ops(dev);
82+
struct dma_map_ops *ops = get_dma_ops(dev);
83+
84+
BUG_ON(!ops);
7485

7586
debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
76-
dma_ops->free(dev, size, cpu_addr, dma_handle, NULL);
87+
ops->free(dev, size, cpu_addr, dma_handle, attrs);
7788
}
7889

7990
#endif /* _ASM_S390_DMA_MAPPING_H */

0 commit comments

Comments
 (0)