aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/iommu_table.h4
-rw-r--r--arch/x86/include/asm/swiotlb.h13
-rw-r--r--arch/x86/kernel/pci-dma.c4
-rw-r--r--arch/x86/kernel/pci-swiotlb.c33
4 files changed, 43 insertions, 11 deletions
diff --git a/arch/x86/include/asm/iommu_table.h b/arch/x86/include/asm/iommu_table.h
index 2124e3ef6f98..df55a78888e3 100644
--- a/arch/x86/include/asm/iommu_table.h
+++ b/arch/x86/include/asm/iommu_table.h
@@ -64,10 +64,10 @@ struct iommu_table_entry {
64 * to stop detecting the other IOMMUs after yours has been detected. 64 * to stop detecting the other IOMMUs after yours has been detected.
65 */ 65 */
66#define IOMMU_INIT_POST(_detect) \ 66#define IOMMU_INIT_POST(_detect) \
67 __IOMMU_INIT(_detect, pci_swiotlb_detect, 0, 0, 0) 67 __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, 0, 0, 0)
68 68
69#define IOMMU_INIT_POST_FINISH(detect) \ 69#define IOMMU_INIT_POST_FINISH(detect) \
70 __IOMMU_INIT(_detect, pci_swiotlb_detect, 0, 0, 1) 70 __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, 0, 0, 1)
71 71
72/* 72/*
73 * A more sophisticated version of IOMMU_INIT. This variant requires: 73 * A more sophisticated version of IOMMU_INIT. This variant requires:
diff --git a/arch/x86/include/asm/swiotlb.h b/arch/x86/include/asm/swiotlb.h
index 8085277e1b8b..977f1761a25d 100644
--- a/arch/x86/include/asm/swiotlb.h
+++ b/arch/x86/include/asm/swiotlb.h
@@ -5,17 +5,26 @@
5 5
6#ifdef CONFIG_SWIOTLB 6#ifdef CONFIG_SWIOTLB
7extern int swiotlb; 7extern int swiotlb;
8extern int __init pci_swiotlb_detect(void); 8extern int __init pci_swiotlb_detect_override(void);
9extern int __init pci_swiotlb_detect_4gb(void);
9extern void __init pci_swiotlb_init(void); 10extern void __init pci_swiotlb_init(void);
11extern void __init pci_swiotlb_late_init(void);
10#else 12#else
11#define swiotlb 0 13#define swiotlb 0
12static inline int pci_swiotlb_detect(void) 14static inline int pci_swiotlb_detect_override(void)
15{
16 return 0;
17}
18static inline int pci_swiotlb_detect_4gb(void)
13{ 19{
14 return 0; 20 return 0;
15} 21}
16static inline void pci_swiotlb_init(void) 22static inline void pci_swiotlb_init(void)
17{ 23{
18} 24}
25static inline void pci_swiotlb_late_init(void)
26{
27}
19#endif 28#endif
20 29
21static inline void dma_mark_clean(void *addr, size_t size) {} 30static inline void dma_mark_clean(void *addr, size_t size) {}
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 9f07cfcbd3a5..1b3beb5075e6 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -133,9 +133,11 @@ void __init pci_iommu_alloc(void)
133 /* free the range so iommu could get some range less than 4G */ 133 /* free the range so iommu could get some range less than 4G */
134 dma32_free_bootmem(); 134 dma32_free_bootmem();
135 135
136 if (pci_xen_swiotlb_detect() || pci_swiotlb_detect()) 136 if (pci_xen_swiotlb_detect() || pci_swiotlb_detect_override())
137 goto out; 137 goto out;
138 138
139 pci_swiotlb_detect_4gb();
140
139 gart_iommu_hole_init(); 141 gart_iommu_hole_init();
140 142
141 detect_calgary(); 143 detect_calgary();
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index a5bc528d4328..c7a72faeb146 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -41,24 +41,33 @@ static struct dma_map_ops swiotlb_dma_ops = {
41}; 41};
42 42
43/* 43/*
44 * pci_swiotlb_detect - set swiotlb to 1 if necessary 44 * pci_swiotlb_detect_override - set swiotlb to 1 if necessary
45 * 45 *
46 * This returns non-zero if we are forced to use swiotlb (by the boot 46 * This returns non-zero if we are forced to use swiotlb (by the boot
47 * option). 47 * option).
48 */ 48 */
49int __init pci_swiotlb_detect(void) 49int __init pci_swiotlb_detect_override(void)
50{ 50{
51 int use_swiotlb = swiotlb | swiotlb_force; 51 int use_swiotlb = swiotlb | swiotlb_force;
52 52
53 if (swiotlb_force)
54 swiotlb = 1;
55
56 return use_swiotlb;
57}
58
59/*
60 * if 4GB or more detected (and iommu=off not set) return 1
61 * and set swiotlb to 1.
62 */
63int __init pci_swiotlb_detect_4gb(void)
64{
53 /* don't initialize swiotlb if iommu=off (no_iommu=1) */ 65 /* don't initialize swiotlb if iommu=off (no_iommu=1) */
54#ifdef CONFIG_X86_64 66#ifdef CONFIG_X86_64
55 if (!no_iommu && max_pfn > MAX_DMA32_PFN) 67 if (!no_iommu && max_pfn > MAX_DMA32_PFN)
56 swiotlb = 1; 68 swiotlb = 1;
57#endif 69#endif
58 if (swiotlb_force) 70 return swiotlb;
59 swiotlb = 1;
60
61 return use_swiotlb;
62} 71}
63 72
64void __init pci_swiotlb_init(void) 73void __init pci_swiotlb_init(void)
@@ -68,3 +77,15 @@ void __init pci_swiotlb_init(void)
68 dma_ops = &swiotlb_dma_ops; 77 dma_ops = &swiotlb_dma_ops;
69 } 78 }
70} 79}
80
81void __init pci_swiotlb_late_init(void)
82{
83 /* An IOMMU turned us off. */
84 if (!swiotlb)
85 swiotlb_free();
86 else {
87 printk(KERN_INFO "PCI-DMA: "
88 "Using software bounce buffering for IO (SWIOTLB)\n");
89 swiotlb_print_info();
90 }
91}