diff options
author | Christoph Hellwig <hch@lst.de> | 2015-09-09 18:39:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-10 16:29:01 -0400 |
commit | 452e06af1f0149b01201f94264d452cd7a95db7a (patch) | |
tree | c8bae903b45001869d4565c73d32a601e06070cf /arch | |
parent | ee196371d5cb1942ebdccc16bdce389812aa265e (diff) |
dma-mapping: consolidate dma_set_mask
Almost everyone implements dma_set_mask the same way, although some time
that's hidden in ->set_dma_mask methods.
This patch consolidates those into a common implementation that either
calls ->set_dma_mask if present or otherwise uses the default
implementation. Some architectures used to only call ->set_dma_mask
after the initial checks, and those instance have been fixed to do the
full work. h8300 implemented dma_set_mask bogusly as a no-ops and has
been fixed.
Unfortunately some architectures overload unrelated semantics like changing
the dma_ops into it so we still need to allow for an architecture override
for now.
[jcmvbkbc@gmail.com: fix xtensa]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
23 files changed, 13 insertions, 169 deletions
diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h index 9d763e535c5a..72a8ca7796d9 100644 --- a/arch/alpha/include/asm/dma-mapping.h +++ b/arch/alpha/include/asm/dma-mapping.h | |||
@@ -12,11 +12,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
12 | 12 | ||
13 | #include <asm-generic/dma-mapping-common.h> | 13 | #include <asm-generic/dma-mapping-common.h> |
14 | 14 | ||
15 | static inline int dma_set_mask(struct device *dev, u64 mask) | ||
16 | { | ||
17 | return get_dma_ops(dev)->set_dma_mask(dev, mask); | ||
18 | } | ||
19 | |||
20 | #define dma_cache_sync(dev, va, size, dir) ((void)0) | 15 | #define dma_cache_sync(dev, va, size, dir) ((void)0) |
21 | 16 | ||
22 | #endif /* _ALPHA_DMA_MAPPING_H */ | 17 | #endif /* _ALPHA_DMA_MAPPING_H */ |
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c index df24b76f9246..2b1f4a1e9272 100644 --- a/arch/alpha/kernel/pci-noop.c +++ b/arch/alpha/kernel/pci-noop.c | |||
@@ -166,15 +166,6 @@ static int alpha_noop_supported(struct device *dev, u64 mask) | |||
166 | return mask < 0x00ffffffUL ? 0 : 1; | 166 | return mask < 0x00ffffffUL ? 0 : 1; |
167 | } | 167 | } |
168 | 168 | ||
169 | static int alpha_noop_set_mask(struct device *dev, u64 mask) | ||
170 | { | ||
171 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
172 | return -EIO; | ||
173 | |||
174 | *dev->dma_mask = mask; | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | struct dma_map_ops alpha_noop_ops = { | 169 | struct dma_map_ops alpha_noop_ops = { |
179 | .alloc = alpha_noop_alloc_coherent, | 170 | .alloc = alpha_noop_alloc_coherent, |
180 | .free = alpha_noop_free_coherent, | 171 | .free = alpha_noop_free_coherent, |
@@ -182,7 +173,6 @@ struct dma_map_ops alpha_noop_ops = { | |||
182 | .map_sg = alpha_noop_map_sg, | 173 | .map_sg = alpha_noop_map_sg, |
183 | .mapping_error = alpha_noop_mapping_error, | 174 | .mapping_error = alpha_noop_mapping_error, |
184 | .dma_supported = alpha_noop_supported, | 175 | .dma_supported = alpha_noop_supported, |
185 | .set_dma_mask = alpha_noop_set_mask, | ||
186 | }; | 176 | }; |
187 | 177 | ||
188 | struct dma_map_ops *dma_ops = &alpha_noop_ops; | 178 | struct dma_map_ops *dma_ops = &alpha_noop_ops; |
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index eddee7720343..8969bf2dfe3a 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c | |||
@@ -939,16 +939,6 @@ static int alpha_pci_mapping_error(struct device *dev, dma_addr_t dma_addr) | |||
939 | return dma_addr == 0; | 939 | return dma_addr == 0; |
940 | } | 940 | } |
941 | 941 | ||
942 | static int alpha_pci_set_mask(struct device *dev, u64 mask) | ||
943 | { | ||
944 | if (!dev->dma_mask || | ||
945 | !pci_dma_supported(alpha_gendev_to_pci(dev), mask)) | ||
946 | return -EIO; | ||
947 | |||
948 | *dev->dma_mask = mask; | ||
949 | return 0; | ||
950 | } | ||
951 | |||
952 | struct dma_map_ops alpha_pci_ops = { | 942 | struct dma_map_ops alpha_pci_ops = { |
953 | .alloc = alpha_pci_alloc_coherent, | 943 | .alloc = alpha_pci_alloc_coherent, |
954 | .free = alpha_pci_free_coherent, | 944 | .free = alpha_pci_free_coherent, |
@@ -958,7 +948,6 @@ struct dma_map_ops alpha_pci_ops = { | |||
958 | .unmap_sg = alpha_pci_unmap_sg, | 948 | .unmap_sg = alpha_pci_unmap_sg, |
959 | .mapping_error = alpha_pci_mapping_error, | 949 | .mapping_error = alpha_pci_mapping_error, |
960 | .dma_supported = alpha_pci_supported, | 950 | .dma_supported = alpha_pci_supported, |
961 | .set_dma_mask = alpha_pci_set_mask, | ||
962 | }; | 951 | }; |
963 | 952 | ||
964 | struct dma_map_ops *dma_ops = &alpha_pci_ops; | 953 | struct dma_map_ops *dma_ops = &alpha_pci_ops; |
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 2f9c731691c0..ccb3aa64640d 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -48,11 +48,6 @@ extern int dma_supported(struct device *dev, u64 mask); | |||
48 | */ | 48 | */ |
49 | #include <asm-generic/dma-mapping-common.h> | 49 | #include <asm-generic/dma-mapping-common.h> |
50 | 50 | ||
51 | static inline int dma_set_mask(struct device *dev, u64 mask) | ||
52 | { | ||
53 | return get_dma_ops(dev)->set_dma_mask(dev, mask); | ||
54 | } | ||
55 | |||
56 | #ifdef __arch_page_to_dma | 51 | #ifdef __arch_page_to_dma |
57 | #error Please update to __arch_pfn_to_dma | 52 | #error Please update to __arch_pfn_to_dma |
58 | #endif | 53 | #endif |
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h index f519a58c55ae..cfdb34bedbcd 100644 --- a/arch/arm64/include/asm/dma-mapping.h +++ b/arch/arm64/include/asm/dma-mapping.h | |||
@@ -84,15 +84,6 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) | |||
84 | return (phys_addr_t)dev_addr; | 84 | return (phys_addr_t)dev_addr; |
85 | } | 85 | } |
86 | 86 | ||
87 | static inline int dma_set_mask(struct device *dev, u64 mask) | ||
88 | { | ||
89 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
90 | return -EIO; | ||
91 | *dev->dma_mask = mask; | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | 87 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) |
97 | { | 88 | { |
98 | if (!dev->dma_mask) | 89 | if (!dev->dma_mask) |
diff --git a/arch/h8300/include/asm/dma-mapping.h b/arch/h8300/include/asm/dma-mapping.h index 48d652eb1b5f..d9b5b806afe6 100644 --- a/arch/h8300/include/asm/dma-mapping.h +++ b/arch/h8300/include/asm/dma-mapping.h | |||
@@ -10,9 +10,4 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
10 | 10 | ||
11 | #include <asm-generic/dma-mapping-common.h> | 11 | #include <asm-generic/dma-mapping-common.h> |
12 | 12 | ||
13 | static inline int dma_set_mask(struct device *dev, u64 mask) | ||
14 | { | ||
15 | return 0; | ||
16 | } | ||
17 | |||
18 | #endif | 13 | #endif |
diff --git a/arch/hexagon/include/asm/dma-mapping.h b/arch/hexagon/include/asm/dma-mapping.h index 36e8de710b32..268fde8a4575 100644 --- a/arch/hexagon/include/asm/dma-mapping.h +++ b/arch/hexagon/include/asm/dma-mapping.h | |||
@@ -45,7 +45,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
45 | 45 | ||
46 | #define HAVE_ARCH_DMA_SUPPORTED 1 | 46 | #define HAVE_ARCH_DMA_SUPPORTED 1 |
47 | extern int dma_supported(struct device *dev, u64 mask); | 47 | extern int dma_supported(struct device *dev, u64 mask); |
48 | extern int dma_set_mask(struct device *dev, u64 mask); | ||
49 | extern int dma_is_consistent(struct device *dev, dma_addr_t dma_handle); | 48 | extern int dma_is_consistent(struct device *dev, dma_addr_t dma_handle); |
50 | extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | 49 | extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
51 | enum dma_data_direction direction); | 50 | enum dma_data_direction direction); |
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c index b74f9bae31a3..9e3ddf792bd3 100644 --- a/arch/hexagon/kernel/dma.c +++ b/arch/hexagon/kernel/dma.c | |||
@@ -44,17 +44,6 @@ int dma_supported(struct device *dev, u64 mask) | |||
44 | } | 44 | } |
45 | EXPORT_SYMBOL(dma_supported); | 45 | EXPORT_SYMBOL(dma_supported); |
46 | 46 | ||
47 | int dma_set_mask(struct device *dev, u64 mask) | ||
48 | { | ||
49 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
50 | return -EIO; | ||
51 | |||
52 | *dev->dma_mask = mask; | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | EXPORT_SYMBOL(dma_set_mask); | ||
57 | |||
58 | static struct gen_pool *coherent_pool; | 47 | static struct gen_pool *coherent_pool; |
59 | 48 | ||
60 | 49 | ||
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h index 7982caa7c5e7..9beccf8010bd 100644 --- a/arch/ia64/include/asm/dma-mapping.h +++ b/arch/ia64/include/asm/dma-mapping.h | |||
@@ -27,15 +27,6 @@ extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, | |||
27 | 27 | ||
28 | #include <asm-generic/dma-mapping-common.h> | 28 | #include <asm-generic/dma-mapping-common.h> |
29 | 29 | ||
30 | static inline int | ||
31 | dma_set_mask (struct device *dev, u64 mask) | ||
32 | { | ||
33 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
34 | return -EIO; | ||
35 | *dev->dma_mask = mask; | ||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | 30 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) |
40 | { | 31 | { |
41 | if (!dev->dma_mask) | 32 | if (!dev->dma_mask) |
diff --git a/arch/microblaze/include/asm/dma-mapping.h b/arch/microblaze/include/asm/dma-mapping.h index 3b453c503a43..24b12970c9cf 100644 --- a/arch/microblaze/include/asm/dma-mapping.h +++ b/arch/microblaze/include/asm/dma-mapping.h | |||
@@ -46,20 +46,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
46 | 46 | ||
47 | #include <asm-generic/dma-mapping-common.h> | 47 | #include <asm-generic/dma-mapping-common.h> |
48 | 48 | ||
49 | static inline int dma_set_mask(struct device *dev, u64 dma_mask) | ||
50 | { | ||
51 | struct dma_map_ops *ops = get_dma_ops(dev); | ||
52 | |||
53 | if (unlikely(ops == NULL)) | ||
54 | return -EIO; | ||
55 | if (ops->set_dma_mask) | ||
56 | return ops->set_dma_mask(dev, dma_mask); | ||
57 | if (!dev->dma_mask || !dma_supported(dev, dma_mask)) | ||
58 | return -EIO; | ||
59 | *dev->dma_mask = dma_mask; | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static inline void __dma_sync(unsigned long paddr, | 49 | static inline void __dma_sync(unsigned long paddr, |
64 | size_t size, enum dma_data_direction direction) | 50 | size_t size, enum dma_data_direction direction) |
65 | { | 51 | { |
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h index 8bf8ec30a4b2..e604f760c4a0 100644 --- a/arch/mips/include/asm/dma-mapping.h +++ b/arch/mips/include/asm/dma-mapping.h | |||
@@ -31,22 +31,6 @@ static inline void dma_mark_clean(void *addr, size_t size) {} | |||
31 | 31 | ||
32 | #include <asm-generic/dma-mapping-common.h> | 32 | #include <asm-generic/dma-mapping-common.h> |
33 | 33 | ||
34 | static inline int | ||
35 | dma_set_mask(struct device *dev, u64 mask) | ||
36 | { | ||
37 | struct dma_map_ops *ops = get_dma_ops(dev); | ||
38 | |||
39 | if(!dev->dma_mask || !dma_supported(dev, mask)) | ||
40 | return -EIO; | ||
41 | |||
42 | if (ops->set_dma_mask) | ||
43 | return ops->set_dma_mask(dev, mask); | ||
44 | |||
45 | *dev->dma_mask = mask; | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | 34 | extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
51 | enum dma_data_direction direction); | 35 | enum dma_data_direction direction); |
52 | 36 | ||
diff --git a/arch/mips/loongson64/common/dma-swiotlb.c b/arch/mips/loongson64/common/dma-swiotlb.c index ef9da3b5c543..4ffa6fc81c8f 100644 --- a/arch/mips/loongson64/common/dma-swiotlb.c +++ b/arch/mips/loongson64/common/dma-swiotlb.c | |||
@@ -85,6 +85,9 @@ static void loongson_dma_sync_sg_for_device(struct device *dev, | |||
85 | 85 | ||
86 | static int loongson_dma_set_mask(struct device *dev, u64 mask) | 86 | static int loongson_dma_set_mask(struct device *dev, u64 mask) |
87 | { | 87 | { |
88 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
89 | return -EIO; | ||
90 | |||
88 | if (mask > DMA_BIT_MASK(loongson_sysconf.dma_mask_bits)) { | 91 | if (mask > DMA_BIT_MASK(loongson_sysconf.dma_mask_bits)) { |
89 | *dev->dma_mask = DMA_BIT_MASK(loongson_sysconf.dma_mask_bits); | 92 | *dev->dma_mask = DMA_BIT_MASK(loongson_sysconf.dma_mask_bits); |
90 | return -EIO; | 93 | return -EIO; |
diff --git a/arch/openrisc/include/asm/dma-mapping.h b/arch/openrisc/include/asm/dma-mapping.h index 8fc08b883477..413bfcf86384 100644 --- a/arch/openrisc/include/asm/dma-mapping.h +++ b/arch/openrisc/include/asm/dma-mapping.h | |||
@@ -44,13 +44,4 @@ static inline int dma_supported(struct device *dev, u64 dma_mask) | |||
44 | 44 | ||
45 | #include <asm-generic/dma-mapping-common.h> | 45 | #include <asm-generic/dma-mapping-common.h> |
46 | 46 | ||
47 | static inline int dma_set_mask(struct device *dev, u64 dma_mask) | ||
48 | { | ||
49 | if (!dev->dma_mask || !dma_supported(dev, dma_mask)) | ||
50 | return -EIO; | ||
51 | |||
52 | *dev->dma_mask = dma_mask; | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | #endif /* __ASM_OPENRISC_DMA_MAPPING_H */ | 47 | #endif /* __ASM_OPENRISC_DMA_MAPPING_H */ |
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index dd43e0c6f219..7f522c021dc3 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h | |||
@@ -122,9 +122,11 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off) | |||
122 | /* this will be removed soon */ | 122 | /* this will be removed soon */ |
123 | #define flush_write_buffers() | 123 | #define flush_write_buffers() |
124 | 124 | ||
125 | #define HAVE_ARCH_DMA_SET_MASK 1 | ||
126 | extern int dma_set_mask(struct device *dev, u64 dma_mask); | ||
127 | |||
125 | #include <asm-generic/dma-mapping-common.h> | 128 | #include <asm-generic/dma-mapping-common.h> |
126 | 129 | ||
127 | extern int dma_set_mask(struct device *dev, u64 dma_mask); | ||
128 | extern int __dma_set_mask(struct device *dev, u64 dma_mask); | 130 | extern int __dma_set_mask(struct device *dev, u64 dma_mask); |
129 | extern u64 __dma_get_required_mask(struct device *dev); | 131 | extern u64 __dma_get_required_mask(struct device *dev); |
130 | 132 | ||
diff --git a/arch/s390/include/asm/dma-mapping.h b/arch/s390/include/asm/dma-mapping.h index 1f42489797da..b3fd54d93dd2 100644 --- a/arch/s390/include/asm/dma-mapping.h +++ b/arch/s390/include/asm/dma-mapping.h | |||
@@ -18,8 +18,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
18 | return &s390_dma_ops; | 18 | return &s390_dma_ops; |
19 | } | 19 | } |
20 | 20 | ||
21 | extern int dma_set_mask(struct device *dev, u64 mask); | ||
22 | |||
23 | static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | 21 | static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
24 | enum dma_data_direction direction) | 22 | enum dma_data_direction direction) |
25 | { | 23 | { |
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index 42b76580c8b8..37505b8b4093 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c | |||
@@ -262,16 +262,6 @@ out: | |||
262 | spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags); | 262 | spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags); |
263 | } | 263 | } |
264 | 264 | ||
265 | int dma_set_mask(struct device *dev, u64 mask) | ||
266 | { | ||
267 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
268 | return -EIO; | ||
269 | |||
270 | *dev->dma_mask = mask; | ||
271 | return 0; | ||
272 | } | ||
273 | EXPORT_SYMBOL_GPL(dma_set_mask); | ||
274 | |||
275 | static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, | 265 | static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page, |
276 | unsigned long offset, size_t size, | 266 | unsigned long offset, size_t size, |
277 | enum dma_data_direction direction, | 267 | enum dma_data_direction direction, |
diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h index 088f6e5f1a92..a3745a3fe029 100644 --- a/arch/sh/include/asm/dma-mapping.h +++ b/arch/sh/include/asm/dma-mapping.h | |||
@@ -13,20 +13,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
13 | 13 | ||
14 | #include <asm-generic/dma-mapping-common.h> | 14 | #include <asm-generic/dma-mapping-common.h> |
15 | 15 | ||
16 | static inline int dma_set_mask(struct device *dev, u64 mask) | ||
17 | { | ||
18 | struct dma_map_ops *ops = get_dma_ops(dev); | ||
19 | |||
20 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
21 | return -EIO; | ||
22 | if (ops->set_dma_mask) | ||
23 | return ops->set_dma_mask(dev, mask); | ||
24 | |||
25 | *dev->dma_mask = mask; | ||
26 | |||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | 16 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
31 | enum dma_data_direction dir); | 17 | enum dma_data_direction dir); |
32 | 18 | ||
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h index 184651bb0b46..a21da597b0b5 100644 --- a/arch/sparc/include/asm/dma-mapping.h +++ b/arch/sparc/include/asm/dma-mapping.h | |||
@@ -37,7 +37,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
37 | return dma_ops; | 37 | return dma_ops; |
38 | } | 38 | } |
39 | 39 | ||
40 | #include <asm-generic/dma-mapping-common.h> | 40 | #define HAVE_ARCH_DMA_SET_MASK 1 |
41 | 41 | ||
42 | static inline int dma_set_mask(struct device *dev, u64 mask) | 42 | static inline int dma_set_mask(struct device *dev, u64 mask) |
43 | { | 43 | { |
@@ -52,4 +52,6 @@ static inline int dma_set_mask(struct device *dev, u64 mask) | |||
52 | return -EINVAL; | 52 | return -EINVAL; |
53 | } | 53 | } |
54 | 54 | ||
55 | #include <asm-generic/dma-mapping-common.h> | ||
56 | |||
55 | #endif | 57 | #endif |
diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h index 559ed4a60077..96ac6cce4a32 100644 --- a/arch/tile/include/asm/dma-mapping.h +++ b/arch/tile/include/asm/dma-mapping.h | |||
@@ -59,8 +59,6 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) | |||
59 | 59 | ||
60 | static inline void dma_mark_clean(void *addr, size_t size) {} | 60 | static inline void dma_mark_clean(void *addr, size_t size) {} |
61 | 61 | ||
62 | #include <asm-generic/dma-mapping-common.h> | ||
63 | |||
64 | static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) | 62 | static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) |
65 | { | 63 | { |
66 | dev->archdata.dma_ops = ops; | 64 | dev->archdata.dma_ops = ops; |
@@ -74,6 +72,10 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) | |||
74 | return addr + size - 1 <= *dev->dma_mask; | 72 | return addr + size - 1 <= *dev->dma_mask; |
75 | } | 73 | } |
76 | 74 | ||
75 | #define HAVE_ARCH_DMA_SET_MASK 1 | ||
76 | |||
77 | #include <asm-generic/dma-mapping-common.h> | ||
78 | |||
77 | static inline int | 79 | static inline int |
78 | dma_set_mask(struct device *dev, u64 mask) | 80 | dma_set_mask(struct device *dev, u64 mask) |
79 | { | 81 | { |
diff --git a/arch/unicore32/include/asm/dma-mapping.h b/arch/unicore32/include/asm/dma-mapping.h index 21231c14182c..8140e053ccd3 100644 --- a/arch/unicore32/include/asm/dma-mapping.h +++ b/arch/unicore32/include/asm/dma-mapping.h | |||
@@ -50,16 +50,6 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) | |||
50 | 50 | ||
51 | static inline void dma_mark_clean(void *addr, size_t size) {} | 51 | static inline void dma_mark_clean(void *addr, size_t size) {} |
52 | 52 | ||
53 | static inline int dma_set_mask(struct device *dev, u64 dma_mask) | ||
54 | { | ||
55 | if (!dev->dma_mask || !dma_supported(dev, dma_mask)) | ||
56 | return -EIO; | ||
57 | |||
58 | *dev->dma_mask = dma_mask; | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static inline void dma_cache_sync(struct device *dev, void *vaddr, | 53 | static inline void dma_cache_sync(struct device *dev, void *vaddr, |
64 | size_t size, enum dma_data_direction direction) | 54 | size_t size, enum dma_data_direction direction) |
65 | { | 55 | { |
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index b1fbf582048b..953b7263f844 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h | |||
@@ -48,8 +48,6 @@ extern int dma_supported(struct device *hwdev, u64 mask); | |||
48 | 48 | ||
49 | #include <asm-generic/dma-mapping-common.h> | 49 | #include <asm-generic/dma-mapping-common.h> |
50 | 50 | ||
51 | extern int dma_set_mask(struct device *dev, u64 mask); | ||
52 | |||
53 | extern void *dma_generic_alloc_coherent(struct device *dev, size_t size, | 51 | extern void *dma_generic_alloc_coherent(struct device *dev, size_t size, |
54 | dma_addr_t *dma_addr, gfp_t flag, | 52 | dma_addr_t *dma_addr, gfp_t flag, |
55 | struct dma_attrs *attrs); | 53 | struct dma_attrs *attrs); |
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index bd23971e8f1d..84b8ef82a159 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c | |||
@@ -58,17 +58,6 @@ EXPORT_SYMBOL(x86_dma_fallback_dev); | |||
58 | /* Number of entries preallocated for DMA-API debugging */ | 58 | /* Number of entries preallocated for DMA-API debugging */ |
59 | #define PREALLOC_DMA_DEBUG_ENTRIES 65536 | 59 | #define PREALLOC_DMA_DEBUG_ENTRIES 65536 |
60 | 60 | ||
61 | int dma_set_mask(struct device *dev, u64 mask) | ||
62 | { | ||
63 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
64 | return -EIO; | ||
65 | |||
66 | *dev->dma_mask = mask; | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | EXPORT_SYMBOL(dma_set_mask); | ||
71 | |||
72 | void __init pci_iommu_alloc(void) | 61 | void __init pci_iommu_alloc(void) |
73 | { | 62 | { |
74 | struct iommu_table_entry *p; | 63 | struct iommu_table_entry *p; |
diff --git a/arch/xtensa/include/asm/dma-mapping.h b/arch/xtensa/include/asm/dma-mapping.h index 329abc7211e9..4427f38b634e 100644 --- a/arch/xtensa/include/asm/dma-mapping.h +++ b/arch/xtensa/include/asm/dma-mapping.h | |||
@@ -32,17 +32,6 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) | |||
32 | 32 | ||
33 | #include <asm-generic/dma-mapping-common.h> | 33 | #include <asm-generic/dma-mapping-common.h> |
34 | 34 | ||
35 | static inline int | ||
36 | dma_set_mask(struct device *dev, u64 mask) | ||
37 | { | ||
38 | if(!dev->dma_mask || !dma_supported(dev, mask)) | ||
39 | return -EIO; | ||
40 | |||
41 | *dev->dma_mask = mask; | ||
42 | |||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, | 35 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
47 | enum dma_data_direction direction); | 36 | enum dma_data_direction direction); |
48 | 37 | ||