diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2013-10-10 09:40:44 -0400 |
---|---|---|
committer | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2013-10-10 09:40:44 -0400 |
commit | 83862ccfc0a03212fde43b4ac29c28381828768b (patch) | |
tree | f750d82b6d3162d066687d55de2bce0cf48e0b43 /drivers/xen | |
parent | 69908907b02efee31377af0cefbcd5a3ba66334a (diff) |
xen/arm,arm64: enable SWIOTLB_XEN
Xen on arm and arm64 needs SWIOTLB_XEN: when running on Xen we need to
program the hardware with mfns rather than pfns for dma addresses.
Remove SWIOTLB_XEN dependency on X86 and PCI and make XEN select
SWIOTLB_XEN on arm and arm64.
At the moment always rely on swiotlb-xen, but when Xen starts supporting
hardware IOMMUs we'll be able to avoid it conditionally on the presence
of an IOMMU on the platform.
Implement xen_create_contiguous_region on arm and arm64: for the moment
we assume that dom0 has been mapped 1:1 (physical addresses == machine
addresses) therefore we don't need to call XENMEM_exchange. Simply
return the physical address as dma address.
Initialize the xen-swiotlb from xen_early_init (before the native
dma_ops are initialized), set xen_dma_ops to &xen_swiotlb_dma_ops.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Changes in v8:
- assume dom0 is mapped 1:1, no need to call XENMEM_exchange.
Changes in v7:
- call __set_phys_to_machine_multi from xen_create_contiguous_region and
xen_destroy_contiguous_region to update the P2M;
- don't call XENMEM_unpin, it has been removed;
- call XENMEM_exchange instead of XENMEM_exchange_and_pin;
- set nr_exchanged to 0 before calling the hypercall.
Changes in v6:
- introduce and export xen_dma_ops;
- call xen_mm_init from as arch_initcall.
Changes in v4:
- remove redefinition of DMA_ERROR_CODE;
- update the code to use XENMEM_exchange_and_pin and XENMEM_unpin;
- add a note about hardware IOMMU in the commit message.
Changes in v3:
- code style changes;
- warn on XENMEM_put_dma_buf failures.
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/Kconfig | 1 | ||||
-rw-r--r-- | drivers/xen/swiotlb-xen.c | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index 23eae5cb69c2..c794ea182140 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
@@ -140,7 +140,6 @@ config XEN_GRANT_DEV_ALLOC | |||
140 | 140 | ||
141 | config SWIOTLB_XEN | 141 | config SWIOTLB_XEN |
142 | def_bool y | 142 | def_bool y |
143 | depends on PCI && X86 | ||
144 | select SWIOTLB | 143 | select SWIOTLB |
145 | 144 | ||
146 | config XEN_TMEM | 145 | config XEN_TMEM |
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index b72f31c1e018..f0fc1a4f565a 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -42,12 +42,27 @@ | |||
42 | #include <xen/page.h> | 42 | #include <xen/page.h> |
43 | #include <xen/xen-ops.h> | 43 | #include <xen/xen-ops.h> |
44 | #include <xen/hvc-console.h> | 44 | #include <xen/hvc-console.h> |
45 | #include <asm/dma-mapping.h> | ||
45 | /* | 46 | /* |
46 | * Used to do a quick range check in swiotlb_tbl_unmap_single and | 47 | * Used to do a quick range check in swiotlb_tbl_unmap_single and |
47 | * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this | 48 | * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this |
48 | * API. | 49 | * API. |
49 | */ | 50 | */ |
50 | 51 | ||
52 | #ifndef CONFIG_X86 | ||
53 | static unsigned long dma_alloc_coherent_mask(struct device *dev, | ||
54 | gfp_t gfp) | ||
55 | { | ||
56 | unsigned long dma_mask = 0; | ||
57 | |||
58 | dma_mask = dev->coherent_dma_mask; | ||
59 | if (!dma_mask) | ||
60 | dma_mask = (gfp & GFP_DMA) ? DMA_BIT_MASK(24) : DMA_BIT_MASK(32); | ||
61 | |||
62 | return dma_mask; | ||
63 | } | ||
64 | #endif | ||
65 | |||
51 | static char *xen_io_tlb_start, *xen_io_tlb_end; | 66 | static char *xen_io_tlb_start, *xen_io_tlb_end; |
52 | static unsigned long xen_io_tlb_nslabs; | 67 | static unsigned long xen_io_tlb_nslabs; |
53 | /* | 68 | /* |