diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-23 11:07:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-23 11:07:35 -0400 |
commit | 72441bdc76f7f71d7b75cdaa48f26dbb1f3d932e (patch) | |
tree | df818d5e210c0c31c6634d43401d02a99ee87d1b /arch/ia64/kernel/pci-dma.c | |
parent | 2515ddc6db8eb49a79f0fe5e67ff09ac7c81eab4 (diff) | |
parent | fe393164c529f72def1952fb66c11732d0984d78 (diff) |
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6: (41 commits)
[IA64] Fix annoying IA64_TR_ALLOC_MAX message.
[IA64] kill sys32_pipe
[IA64] remove sys32_pause
[IA64] Add Variable Page Size and IA64 Support in Intel IOMMU
ia64/pv_ops: paravirtualized instruction checker.
ia64/xen: a recipe for using xen/ia64 with pv_ops.
ia64/pv_ops: update Kconfig for paravirtualized guest and xen.
ia64/xen: preliminary support for save/restore.
ia64/xen: define xen machine vector for domU.
ia64/pv_ops/xen: implement xen pv_time_ops.
ia64/pv_ops/xen: implement xen pv_irq_ops.
ia64/pv_ops/xen: define the nubmer of irqs which xen needs.
ia64/pv_ops/xen: implement xen pv_iosapic_ops.
ia64/pv_ops/xen: paravirtualize entry.S for ia64/xen.
ia64/pv_ops/xen: paravirtualize ivt.S for xen.
ia64/pv_ops/xen: paravirtualize DO_SAVE_MIN for xen.
ia64/pv_ops/xen: define xen paravirtualized instructions for hand written assembly code
ia64/pv_ops/xen: define xen pv_cpu_ops.
ia64/pv_ops/xen: define xen pv_init_ops for various xen initialization.
ia64/pv_ops/xen: elf note based xen startup.
...
Diffstat (limited to 'arch/ia64/kernel/pci-dma.c')
-rw-r--r-- | arch/ia64/kernel/pci-dma.c | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c new file mode 100644 index 000000000000..10a75b557650 --- /dev/null +++ b/arch/ia64/kernel/pci-dma.c | |||
@@ -0,0 +1,129 @@ | |||
1 | /* | ||
2 | * Dynamic DMA mapping support. | ||
3 | */ | ||
4 | |||
5 | #include <linux/types.h> | ||
6 | #include <linux/mm.h> | ||
7 | #include <linux/string.h> | ||
8 | #include <linux/pci.h> | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/dmar.h> | ||
11 | #include <asm/iommu.h> | ||
12 | #include <asm/machvec.h> | ||
13 | #include <linux/dma-mapping.h> | ||
14 | |||
15 | #include <asm/machvec.h> | ||
16 | #include <asm/system.h> | ||
17 | |||
18 | #ifdef CONFIG_DMAR | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/string.h> | ||
22 | |||
23 | #include <asm/page.h> | ||
24 | #include <asm/iommu.h> | ||
25 | |||
26 | dma_addr_t bad_dma_address __read_mostly; | ||
27 | EXPORT_SYMBOL(bad_dma_address); | ||
28 | |||
29 | static int iommu_sac_force __read_mostly; | ||
30 | |||
31 | int no_iommu __read_mostly; | ||
32 | #ifdef CONFIG_IOMMU_DEBUG | ||
33 | int force_iommu __read_mostly = 1; | ||
34 | #else | ||
35 | int force_iommu __read_mostly; | ||
36 | #endif | ||
37 | |||
38 | /* Set this to 1 if there is a HW IOMMU in the system */ | ||
39 | int iommu_detected __read_mostly; | ||
40 | |||
41 | /* Dummy device used for NULL arguments (normally ISA). Better would | ||
42 | be probably a smaller DMA mask, but this is bug-to-bug compatible | ||
43 | to i386. */ | ||
44 | struct device fallback_dev = { | ||
45 | .bus_id = "fallback device", | ||
46 | .coherent_dma_mask = DMA_32BIT_MASK, | ||
47 | .dma_mask = &fallback_dev.coherent_dma_mask, | ||
48 | }; | ||
49 | |||
50 | void __init pci_iommu_alloc(void) | ||
51 | { | ||
52 | /* | ||
53 | * The order of these functions is important for | ||
54 | * fall-back/fail-over reasons | ||
55 | */ | ||
56 | detect_intel_iommu(); | ||
57 | |||
58 | #ifdef CONFIG_SWIOTLB | ||
59 | pci_swiotlb_init(); | ||
60 | #endif | ||
61 | } | ||
62 | |||
63 | static int __init pci_iommu_init(void) | ||
64 | { | ||
65 | if (iommu_detected) | ||
66 | intel_iommu_init(); | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | /* Must execute after PCI subsystem */ | ||
72 | fs_initcall(pci_iommu_init); | ||
73 | |||
74 | void pci_iommu_shutdown(void) | ||
75 | { | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | void __init | ||
80 | iommu_dma_init(void) | ||
81 | { | ||
82 | return; | ||
83 | } | ||
84 | |||
85 | struct dma_mapping_ops *dma_ops; | ||
86 | EXPORT_SYMBOL(dma_ops); | ||
87 | |||
88 | int iommu_dma_supported(struct device *dev, u64 mask) | ||
89 | { | ||
90 | struct dma_mapping_ops *ops = get_dma_ops(dev); | ||
91 | |||
92 | #ifdef CONFIG_PCI | ||
93 | if (mask > 0xffffffff && forbid_dac > 0) { | ||
94 | dev_info(dev, "Disallowing DAC for device\n"); | ||
95 | return 0; | ||
96 | } | ||
97 | #endif | ||
98 | |||
99 | if (ops->dma_supported_op) | ||
100 | return ops->dma_supported_op(dev, mask); | ||
101 | |||
102 | /* Copied from i386. Doesn't make much sense, because it will | ||
103 | only work for pci_alloc_coherent. | ||
104 | The caller just has to use GFP_DMA in this case. */ | ||
105 | if (mask < DMA_24BIT_MASK) | ||
106 | return 0; | ||
107 | |||
108 | /* Tell the device to use SAC when IOMMU force is on. This | ||
109 | allows the driver to use cheaper accesses in some cases. | ||
110 | |||
111 | Problem with this is that if we overflow the IOMMU area and | ||
112 | return DAC as fallback address the device may not handle it | ||
113 | correctly. | ||
114 | |||
115 | As a special case some controllers have a 39bit address | ||
116 | mode that is as efficient as 32bit (aic79xx). Don't force | ||
117 | SAC for these. Assume all masks <= 40 bits are of this | ||
118 | type. Normally this doesn't make any difference, but gives | ||
119 | more gentle handling of IOMMU overflow. */ | ||
120 | if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) { | ||
121 | dev_info(dev, "Force SAC with mask %lx\n", mask); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | return 1; | ||
126 | } | ||
127 | EXPORT_SYMBOL(iommu_dma_supported); | ||
128 | |||
129 | #endif | ||