aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-09-22 20:01:16 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-09-22 20:01:24 -0400
commita5f95155709cb854e96aa27969d110668cdbda9d (patch)
treec9392d6871184838bf81a0b70900e28558e92870 /arch/x86/xen
parentc571898ffc24a1768e1b2dabeac0fc7dd4c14601 (diff)
parent2a3bce8f6afb9118a7ac3c360a5baf7cdaec87bc (diff)
Merge branch 'stable/late-swiotlb.v3.3' into stable/for-linus-3.7
* stable/late-swiotlb.v3.3: xen/swiotlb: Fix compile warnings when using plain integer instead of NULL pointer. xen/swiotlb: Remove functions not needed anymore. xen/pcifront: Use Xen-SWIOTLB when initting if required. xen/swiotlb: For early initialization, return zero on success. xen/swiotlb: Use the swiotlb_late_init_with_tbl to init Xen-SWIOTLB late when PV PCI is used. xen/swiotlb: Move the error strings to its own function. xen/swiotlb: Move the nr_tbl determination in its own function. swiotlb: add the late swiotlb initialization function with iotlb memory xen/swiotlb: With more than 4GB on 64-bit, disable the native SWIOTLB. xen/swiotlb: Simplify the logic. Conflicts: arch/x86/xen/pci-swiotlb-xen.c Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'arch/x86/xen')
-rw-r--r--arch/x86/xen/pci-swiotlb-xen.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index 1ab45941502d..969570491c39 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -8,7 +8,14 @@
8#include <xen/xen.h> 8#include <xen/xen.h>
9#include <asm/iommu_table.h> 9#include <asm/iommu_table.h>
10 10
11
11#include <asm/xen/swiotlb-xen.h> 12#include <asm/xen/swiotlb-xen.h>
13#ifdef CONFIG_X86_64
14#include <asm/iommu.h>
15#include <asm/dma.h>
16#endif
17#include <linux/export.h>
18
12int xen_swiotlb __read_mostly; 19int xen_swiotlb __read_mostly;
13 20
14static struct dma_map_ops xen_swiotlb_dma_ops = { 21static struct dma_map_ops xen_swiotlb_dma_ops = {
@@ -35,33 +42,63 @@ static struct dma_map_ops xen_swiotlb_dma_ops = {
35int __init pci_xen_swiotlb_detect(void) 42int __init pci_xen_swiotlb_detect(void)
36{ 43{
37 44
45 if (!xen_pv_domain())
46 return 0;
47
38 /* If running as PV guest, either iommu=soft, or swiotlb=force will 48 /* If running as PV guest, either iommu=soft, or swiotlb=force will
39 * activate this IOMMU. If running as PV privileged, activate it 49 * activate this IOMMU. If running as PV privileged, activate it
40 * irregardless. 50 * irregardless.
41 */ 51 */
42 if ((xen_initial_domain() || swiotlb || swiotlb_force) && 52 if ((xen_initial_domain() || swiotlb || swiotlb_force))
43 (xen_pv_domain()))
44 xen_swiotlb = 1; 53 xen_swiotlb = 1;
45 54
46 /* If we are running under Xen, we MUST disable the native SWIOTLB. 55 /* If we are running under Xen, we MUST disable the native SWIOTLB.
47 * Don't worry about swiotlb_force flag activating the native, as 56 * Don't worry about swiotlb_force flag activating the native, as
48 * the 'swiotlb' flag is the only one turning it on. */ 57 * the 'swiotlb' flag is the only one turning it on. */
49 if (xen_pv_domain()) 58 swiotlb = 0;
50 swiotlb = 0;
51 59
60#ifdef CONFIG_X86_64
61 /* pci_swiotlb_detect_4gb turns on native SWIOTLB if no_iommu == 0
62 * (so no iommu=X command line over-writes).
63 * Considering that PV guests do not want the *native SWIOTLB* but
64 * only Xen SWIOTLB it is not useful to us so set no_iommu=1 here.
65 */
66 if (max_pfn > MAX_DMA32_PFN)
67 no_iommu = 1;
68#endif
52 return xen_swiotlb; 69 return xen_swiotlb;
53} 70}
54 71
55void __init pci_xen_swiotlb_init(void) 72void __init pci_xen_swiotlb_init(void)
56{ 73{
57 if (xen_swiotlb) { 74 if (xen_swiotlb) {
58 xen_swiotlb_init(1); 75 xen_swiotlb_init(1, true /* early */);
59 dma_ops = &xen_swiotlb_dma_ops; 76 dma_ops = &xen_swiotlb_dma_ops;
60 77
61 /* Make sure ACS will be enabled */ 78 /* Make sure ACS will be enabled */
62 pci_request_acs(); 79 pci_request_acs();
63 } 80 }
64} 81}
82
83int pci_xen_swiotlb_init_late(void)
84{
85 int rc;
86
87 if (xen_swiotlb)
88 return 0;
89
90 rc = xen_swiotlb_init(1, false /* late */);
91 if (rc)
92 return rc;
93
94 dma_ops = &xen_swiotlb_dma_ops;
95 /* Make sure ACS will be enabled */
96 pci_request_acs();
97
98 return 0;
99}
100EXPORT_SYMBOL_GPL(pci_xen_swiotlb_init_late);
101
65IOMMU_INIT_FINISH(pci_xen_swiotlb_detect, 102IOMMU_INIT_FINISH(pci_xen_swiotlb_detect,
66 NULL, 103 NULL,
67 pci_xen_swiotlb_init, 104 pci_xen_swiotlb_init,