aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-01-31 14:32:27 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-01-31 14:32:27 -0500
commit2382dc9a3eca644147be83dd2cd0dd64dc9e3e8c (patch)
tree71a152721a9b9b11875bf5ea053edb72c9b3a94e /arch/ia64
parent28bc6fb9596fe1e577d09fc17ee6e1bb051c6ba3 (diff)
parent04f56534786c885f578c24461bcd782fe9a787cf (diff)
Merge tag 'dma-mapping-4.16' of git://git.infradead.org/users/hch/dma-mapping
Pull dma mapping updates from Christoph Hellwig: "Except for a runtime warning fix from Christian this is all about consolidation of the generic no-IOMMU code, a well as the glue code for swiotlb. All the code is based on the x86 implementation with hooks to allow all architectures that aren't cache coherent to use it. The x86 conversion itself has been deferred because the x86 maintainers were a little busy in the last months" * tag 'dma-mapping-4.16' of git://git.infradead.org/users/hch/dma-mapping: (57 commits) MAINTAINERS: add the iommu list for swiotlb and xen-swiotlb arm64: use swiotlb_alloc and swiotlb_free arm64: replace ZONE_DMA with ZONE_DMA32 mips: use swiotlb_{alloc,free} mips/netlogic: remove swiotlb support tile: use generic swiotlb_ops tile: replace ZONE_DMA with ZONE_DMA32 unicore32: use generic swiotlb_ops ia64: remove an ifdef around the content of pci-dma.c ia64: clean up swiotlb support ia64: use generic swiotlb_ops ia64: replace ZONE_DMA with ZONE_DMA32 swiotlb: remove various exports swiotlb: refactor coherent buffer allocation swiotlb: refactor coherent buffer freeing swiotlb: wire up ->dma_supported in swiotlb_dma_ops swiotlb: add common swiotlb_map_ops swiotlb: rename swiotlb_free to swiotlb_exit x86: rename swiotlb_dma_ops powerpc: rename swiotlb_dma_ops ...
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/Kconfig8
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c2
-rw-r--r--arch/ia64/include/asm/dma-mapping.h19
-rw-r--r--arch/ia64/include/asm/dma.h2
-rw-r--r--arch/ia64/include/asm/swiotlb.h18
-rw-r--r--arch/ia64/kernel/dma-mapping.c9
-rw-r--r--arch/ia64/kernel/pci-dma.c19
-rw-r--r--arch/ia64/kernel/pci-swiotlb.c68
-rw-r--r--arch/ia64/mm/contig.c4
-rw-r--r--arch/ia64/mm/discontig.c8
10 files changed, 33 insertions, 124 deletions
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 315c51f58811..bbe12a038d21 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -33,6 +33,7 @@ config IA64
33 select HAVE_MEMBLOCK 33 select HAVE_MEMBLOCK
34 select HAVE_MEMBLOCK_NODE_MAP 34 select HAVE_MEMBLOCK_NODE_MAP
35 select HAVE_VIRT_CPU_ACCOUNTING 35 select HAVE_VIRT_CPU_ACCOUNTING
36 select ARCH_HAS_DMA_MARK_CLEAN
36 select ARCH_HAS_SG_CHAIN 37 select ARCH_HAS_SG_CHAIN
37 select VIRT_TO_BUS 38 select VIRT_TO_BUS
38 select ARCH_DISCARD_MEMBLOCK 39 select ARCH_DISCARD_MEMBLOCK
@@ -65,7 +66,7 @@ config 64BIT
65 select ATA_NONSTANDARD if ATA 66 select ATA_NONSTANDARD if ATA
66 default y 67 default y
67 68
68config ZONE_DMA 69config ZONE_DMA32
69 def_bool y 70 def_bool y
70 depends on !IA64_SGI_SN2 71 depends on !IA64_SGI_SN2
71 72
@@ -145,6 +146,7 @@ config IA64_GENERIC
145 bool "generic" 146 bool "generic"
146 select NUMA 147 select NUMA
147 select ACPI_NUMA 148 select ACPI_NUMA
149 select DMA_DIRECT_OPS
148 select SWIOTLB 150 select SWIOTLB
149 select PCI_MSI 151 select PCI_MSI
150 help 152 help
@@ -165,6 +167,7 @@ config IA64_GENERIC
165 167
166config IA64_DIG 168config IA64_DIG
167 bool "DIG-compliant" 169 bool "DIG-compliant"
170 select DMA_DIRECT_OPS
168 select SWIOTLB 171 select SWIOTLB
169 172
170config IA64_DIG_VTD 173config IA64_DIG_VTD
@@ -180,6 +183,7 @@ config IA64_HP_ZX1
180 183
181config IA64_HP_ZX1_SWIOTLB 184config IA64_HP_ZX1_SWIOTLB
182 bool "HP-zx1/sx1000 with software I/O TLB" 185 bool "HP-zx1/sx1000 with software I/O TLB"
186 select DMA_DIRECT_OPS
183 select SWIOTLB 187 select SWIOTLB
184 help 188 help
185 Build a kernel that runs on HP zx1 and sx1000 systems even when they 189 Build a kernel that runs on HP zx1 and sx1000 systems even when they
@@ -203,6 +207,7 @@ config IA64_SGI_UV
203 bool "SGI-UV" 207 bool "SGI-UV"
204 select NUMA 208 select NUMA
205 select ACPI_NUMA 209 select ACPI_NUMA
210 select DMA_DIRECT_OPS
206 select SWIOTLB 211 select SWIOTLB
207 help 212 help
208 Selecting this option will optimize the kernel for use on UV based 213 Selecting this option will optimize the kernel for use on UV based
@@ -213,6 +218,7 @@ config IA64_SGI_UV
213 218
214config IA64_HP_SIM 219config IA64_HP_SIM
215 bool "Ski-simulator" 220 bool "Ski-simulator"
221 select DMA_DIRECT_OPS
216 select SWIOTLB 222 select SWIOTLB
217 depends on !PM 223 depends on !PM
218 224
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index 63d8e1d2477f..58969039bed2 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -19,7 +19,7 @@
19#include <linux/export.h> 19#include <linux/export.h>
20#include <asm/machvec.h> 20#include <asm/machvec.h>
21 21
22extern const struct dma_map_ops sba_dma_ops, swiotlb_dma_ops; 22extern const struct dma_map_ops sba_dma_ops;
23 23
24/* swiotlb declarations & definitions: */ 24/* swiotlb declarations & definitions: */
25extern int swiotlb_late_init_with_default_size (size_t size); 25extern int swiotlb_late_init_with_default_size (size_t size);
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index c1bab526a046..76e4d6632d68 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -8,7 +8,6 @@
8 */ 8 */
9#include <asm/machvec.h> 9#include <asm/machvec.h>
10#include <linux/scatterlist.h> 10#include <linux/scatterlist.h>
11#include <asm/swiotlb.h>
12#include <linux/dma-debug.h> 11#include <linux/dma-debug.h>
13 12
14#define ARCH_HAS_DMA_GET_REQUIRED_MASK 13#define ARCH_HAS_DMA_GET_REQUIRED_MASK
@@ -27,22 +26,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
27 return platform_dma_get_ops(NULL); 26 return platform_dma_get_ops(NULL);
28} 27}
29 28
30static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
31{
32 if (!dev->dma_mask)
33 return 0;
34
35 return addr + size - 1 <= *dev->dma_mask;
36}
37
38static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
39{
40 return paddr;
41}
42
43static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
44{
45 return daddr;
46}
47
48#endif /* _ASM_IA64_DMA_MAPPING_H */ 29#endif /* _ASM_IA64_DMA_MAPPING_H */
diff --git a/arch/ia64/include/asm/dma.h b/arch/ia64/include/asm/dma.h
index 186850eec934..23604d6a2cb2 100644
--- a/arch/ia64/include/asm/dma.h
+++ b/arch/ia64/include/asm/dma.h
@@ -20,6 +20,4 @@ extern unsigned long MAX_DMA_ADDRESS;
20 20
21#define free_dma(x) 21#define free_dma(x)
22 22
23void dma_mark_clean(void *addr, size_t size);
24
25#endif /* _ASM_IA64_DMA_H */ 23#endif /* _ASM_IA64_DMA_H */
diff --git a/arch/ia64/include/asm/swiotlb.h b/arch/ia64/include/asm/swiotlb.h
deleted file mode 100644
index 841e2c7d0b21..000000000000
--- a/arch/ia64/include/asm/swiotlb.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef ASM_IA64__SWIOTLB_H
3#define ASM_IA64__SWIOTLB_H
4
5#include <linux/dma-mapping.h>
6#include <linux/swiotlb.h>
7
8#ifdef CONFIG_SWIOTLB
9extern int swiotlb;
10extern void pci_swiotlb_init(void);
11#else
12#define swiotlb 0
13static inline void pci_swiotlb_init(void)
14{
15}
16#endif
17
18#endif /* ASM_IA64__SWIOTLB_H */
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
index 7a82c9259609..f2d57e66fd86 100644
--- a/arch/ia64/kernel/dma-mapping.c
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -1,5 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/dma-mapping.h> 2#include <linux/dma-mapping.h>
3#include <linux/swiotlb.h>
3#include <linux/export.h> 4#include <linux/export.h>
4 5
5/* Set this to 1 if there is a HW IOMMU in the system */ 6/* Set this to 1 if there is a HW IOMMU in the system */
@@ -23,3 +24,11 @@ const struct dma_map_ops *dma_get_ops(struct device *dev)
23 return dma_ops; 24 return dma_ops;
24} 25}
25EXPORT_SYMBOL(dma_get_ops); 26EXPORT_SYMBOL(dma_get_ops);
27
28#ifdef CONFIG_SWIOTLB
29void __init swiotlb_dma_init(void)
30{
31 dma_ops = &swiotlb_dma_ops;
32 swiotlb_init(1);
33}
34#endif
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 3ba87c22dfbc..b5df084c0af4 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -12,12 +12,7 @@
12#include <asm/iommu.h> 12#include <asm/iommu.h>
13#include <asm/machvec.h> 13#include <asm/machvec.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15
16
17#ifdef CONFIG_INTEL_IOMMU
18
19#include <linux/kernel.h> 15#include <linux/kernel.h>
20
21#include <asm/page.h> 16#include <asm/page.h>
22 17
23dma_addr_t bad_dma_address __read_mostly; 18dma_addr_t bad_dma_address __read_mostly;
@@ -104,8 +99,14 @@ void __init pci_iommu_alloc(void)
104 detect_intel_iommu(); 99 detect_intel_iommu();
105 100
106#ifdef CONFIG_SWIOTLB 101#ifdef CONFIG_SWIOTLB
107 pci_swiotlb_init(); 102 if (!iommu_detected) {
108#endif 103#ifdef CONFIG_IA64_GENERIC
104 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
105 machvec_init("dig");
106 swiotlb_dma_init();
107#else
108 panic("Unable to find Intel IOMMU");
109#endif /* CONFIG_IA64_GENERIC */
110 }
111#endif /* CONFIG_SWIOTLB */
109} 112}
110
111#endif
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
deleted file mode 100644
index 5e50939aa03e..000000000000
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ /dev/null
@@ -1,68 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/* Glue code to lib/swiotlb.c */
3
4#include <linux/pci.h>
5#include <linux/gfp.h>
6#include <linux/cache.h>
7#include <linux/module.h>
8#include <linux/dma-mapping.h>
9
10#include <asm/swiotlb.h>
11#include <asm/dma.h>
12#include <asm/iommu.h>
13#include <asm/machvec.h>
14
15int swiotlb __read_mostly;
16EXPORT_SYMBOL(swiotlb);
17
18static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
19 dma_addr_t *dma_handle, gfp_t gfp,
20 unsigned long attrs)
21{
22 if (dev->coherent_dma_mask != DMA_BIT_MASK(64))
23 gfp |= GFP_DMA;
24 return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
25}
26
27static void ia64_swiotlb_free_coherent(struct device *dev, size_t size,
28 void *vaddr, dma_addr_t dma_addr,
29 unsigned long attrs)
30{
31 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
32}
33
34const struct dma_map_ops swiotlb_dma_ops = {
35 .alloc = ia64_swiotlb_alloc_coherent,
36 .free = ia64_swiotlb_free_coherent,
37 .map_page = swiotlb_map_page,
38 .unmap_page = swiotlb_unmap_page,
39 .map_sg = swiotlb_map_sg_attrs,
40 .unmap_sg = swiotlb_unmap_sg_attrs,
41 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
42 .sync_single_for_device = swiotlb_sync_single_for_device,
43 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
44 .sync_sg_for_device = swiotlb_sync_sg_for_device,
45 .dma_supported = swiotlb_dma_supported,
46 .mapping_error = swiotlb_dma_mapping_error,
47};
48
49void __init swiotlb_dma_init(void)
50{
51 dma_ops = &swiotlb_dma_ops;
52 swiotlb_init(1);
53}
54
55void __init pci_swiotlb_init(void)
56{
57 if (!iommu_detected) {
58#ifdef CONFIG_IA64_GENERIC
59 swiotlb = 1;
60 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
61 machvec_init("dig");
62 swiotlb_init(1);
63 dma_ops = &swiotlb_dma_ops;
64#else
65 panic("Unable to find Intel IOMMU");
66#endif
67 }
68}
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 52715a71aede..7d64b30913d1 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -237,9 +237,9 @@ paging_init (void)
237 unsigned long max_zone_pfns[MAX_NR_ZONES]; 237 unsigned long max_zone_pfns[MAX_NR_ZONES];
238 238
239 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 239 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
240#ifdef CONFIG_ZONE_DMA 240#ifdef CONFIG_ZONE_DMA32
241 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT; 241 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
242 max_zone_pfns[ZONE_DMA] = max_dma; 242 max_zone_pfns[ZONE_DMA32] = max_dma;
243#endif 243#endif
244 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 244 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
245 245
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 9b2d994cddf6..ac46f0d60b66 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -38,7 +38,7 @@ struct early_node_data {
38 struct ia64_node_data *node_data; 38 struct ia64_node_data *node_data;
39 unsigned long pernode_addr; 39 unsigned long pernode_addr;
40 unsigned long pernode_size; 40 unsigned long pernode_size;
41#ifdef CONFIG_ZONE_DMA 41#ifdef CONFIG_ZONE_DMA32
42 unsigned long num_dma_physpages; 42 unsigned long num_dma_physpages;
43#endif 43#endif
44 unsigned long min_pfn; 44 unsigned long min_pfn;
@@ -669,7 +669,7 @@ static __init int count_node_pages(unsigned long start, unsigned long len, int n
669{ 669{
670 unsigned long end = start + len; 670 unsigned long end = start + len;
671 671
672#ifdef CONFIG_ZONE_DMA 672#ifdef CONFIG_ZONE_DMA32
673 if (start <= __pa(MAX_DMA_ADDRESS)) 673 if (start <= __pa(MAX_DMA_ADDRESS))
674 mem_data[node].num_dma_physpages += 674 mem_data[node].num_dma_physpages +=
675 (min(end, __pa(MAX_DMA_ADDRESS)) - start) >>PAGE_SHIFT; 675 (min(end, __pa(MAX_DMA_ADDRESS)) - start) >>PAGE_SHIFT;
@@ -724,8 +724,8 @@ void __init paging_init(void)
724 } 724 }
725 725
726 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 726 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
727#ifdef CONFIG_ZONE_DMA 727#ifdef CONFIG_ZONE_DMA32
728 max_zone_pfns[ZONE_DMA] = max_dma; 728 max_zone_pfns[ZONE_DMA32] = max_dma;
729#endif 729#endif
730 max_zone_pfns[ZONE_NORMAL] = max_pfn; 730 max_zone_pfns[ZONE_NORMAL] = max_pfn;
731 free_area_init_nodes(max_zone_pfns); 731 free_area_init_nodes(max_zone_pfns);