diff options
author | Thierry Reding <treding@nvidia.com> | 2014-08-25 07:02:52 -0400 |
---|---|---|
committer | Marek Szyprowski <m.szyprowski@samsung.com> | 2014-08-26 01:39:12 -0400 |
commit | 90114d65feea716eeae0ab51e92c95b140b2e6fc (patch) | |
tree | 72d7ce0a1cf61c34a3122b77ea914dad50cff68b /arch/s390 | |
parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) |
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>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/Kconfig | 5 | ||||
-rw-r--r-- | arch/s390/include/asm/dma-mapping.h | 31 |
2 files changed, 22 insertions, 14 deletions
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index ab39ceb89ecf..fafeae01725a 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
@@ -498,8 +498,8 @@ config QDIO | |||
498 | 498 | ||
499 | menuconfig PCI | 499 | menuconfig PCI |
500 | bool "PCI support" | 500 | bool "PCI support" |
501 | default n | ||
502 | depends on 64BIT | 501 | depends on 64BIT |
502 | select HAVE_DMA_ATTRS | ||
503 | select PCI_MSI | 503 | select PCI_MSI |
504 | help | 504 | help |
505 | Enable PCI support. | 505 | Enable PCI support. |
@@ -546,9 +546,6 @@ config HAS_DMA | |||
546 | config NEED_SG_DMA_LENGTH | 546 | config NEED_SG_DMA_LENGTH |
547 | def_bool PCI | 547 | def_bool PCI |
548 | 548 | ||
549 | config HAVE_DMA_ATTRS | ||
550 | def_bool PCI | ||
551 | |||
552 | config NEED_DMA_MAP_STATE | 549 | config NEED_DMA_MAP_STATE |
553 | def_bool PCI | 550 | def_bool PCI |
554 | 551 | ||
diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/s390/include/asm/dma-mapping.h index 3fbc67d9e197..709955ddaa4d 100644 --- a/arch/s390/include/asm/dma-mapping.h +++ b/arch/s390/include/asm/dma-mapping.h | |||
@@ -56,24 +56,35 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
56 | return dma_addr == DMA_ERROR_CODE; | 56 | return dma_addr == DMA_ERROR_CODE; |
57 | } | 57 | } |
58 | 58 | ||
59 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 59 | #define dma_alloc_coherent(d, s, h, f) dma_alloc_attrs(d, s, h, f, NULL) |
60 | dma_addr_t *dma_handle, gfp_t flag) | 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) | ||
61 | { | 64 | { |
62 | struct dma_map_ops *ops = get_dma_ops(dev); | 65 | struct dma_map_ops *ops = get_dma_ops(dev); |
63 | void *ret; | 66 | void *cpu_addr; |
67 | |||
68 | BUG_ON(!ops); | ||
64 | 69 | ||
65 | ret = ops->alloc(dev, size, dma_handle, flag, NULL); | 70 | cpu_addr = ops->alloc(dev, size, dma_handle, flags, attrs); |
66 | debug_dma_alloc_coherent(dev, size, *dma_handle, ret); | 71 | debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); |
67 | return ret; | 72 | |
73 | return cpu_addr; | ||
68 | } | 74 | } |
69 | 75 | ||
70 | static inline void dma_free_coherent(struct device *dev, size_t size, | 76 | #define dma_free_coherent(d, s, c, h) dma_free_attrs(d, s, c, h, NULL) |
71 | void *cpu_addr, dma_addr_t dma_handle) | 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) | ||
72 | { | 81 | { |
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); | ||
74 | 85 | ||
75 | debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); | 86 | 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); |
77 | } | 88 | } |
78 | 89 | ||
79 | #endif /* _ASM_S390_DMA_MAPPING_H */ | 90 | #endif /* _ASM_S390_DMA_MAPPING_H */ |