xen-devel
[Xen-devel] [PATCH 12/27] xen: add hooks for mapping phys<->bus addresse
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Add hooks to allow Xen to do translation between pfn and mfns for the swiotlb
layer, so that dma actually ends up going to the proper machine pages.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
arch/x86/kernel/pci-swiotlb.c | 8 ++++++++
drivers/pci/xen-iommu.c | 10 ++++++++++
include/xen/swiotlb.h | 3 +++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 298f01d..0943813 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -33,11 +33,19 @@ void *swiotlb_alloc(unsigned order, unsigned long nslabs)
dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
{
+#ifdef CONFIG_PCI_XEN
+ if (xen_pv_domain())
+ return xen_phys_to_bus(paddr);
+#endif
return paddr;
}
phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr)
{
+#ifdef CONFIG_PCI_XEN
+ if (xen_pv_domain())
+ return xen_bus_to_phys(baddr);
+#endif
return baddr;
}
diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c
index d546698..e7ba06b 100644
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -67,6 +67,16 @@ void xen_swiotlb_fixup(void *buf, size_t size, unsigned long
nslabs)
}
}
+dma_addr_t xen_phys_to_bus(phys_addr_t paddr)
+{
+ return phys_to_machine(XPADDR(paddr)).maddr;
+}
+
+phys_addr_t xen_bus_to_phys(dma_addr_t daddr)
+{
+ return machine_to_phys(XMADDR(daddr)).paddr;
+}
+
static inline int address_needs_mapping(struct device *hwdev,
dma_addr_t addr)
{
diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h
index 8d59439..9ecaff1 100644
--- a/include/xen/swiotlb.h
+++ b/include/xen/swiotlb.h
@@ -9,4 +9,7 @@ static inline void xen_swiotlb_fixup(void *buf, size_t size,
unsigned long nslab
}
#endif
+extern phys_addr_t xen_bus_to_phys(dma_addr_t daddr);
+extern dma_addr_t xen_phys_to_bus(phys_addr_t paddr);
+
#endif /* _XEN_SWIOTLB_H */
--
1.6.0.6
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [PATCH 04/27] xen: Add xen_create_contiguous_region, (continued)
- [Xen-devel] [PATCH 12/27] xen: add hooks for mapping phys<->bus addresses in swiotlb,
Jeremy Fitzhardinge <=
- [Xen-devel] [PATCH 11/27] xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 16/27] swiotlb: use swiotlb_alloc_boot to allocate emergency pool, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 14/27] xen: enable swiotlb for xen domain 0., Jeremy Fitzhardinge
- [Xen-devel] [PATCH 17/27] xen/swiotlb: improve comment on gfp flags in xen_alloc_coherent(), Jeremy Fitzhardinge
- [Xen-devel] [PATCH 07/27] Xen/x86/PCI: Add support for the Xen PCI subsytem, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 19/27] xen: set callout_map to make mtrr work, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 18/27] xen/swiotlb: add sync functions, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 15/27] xen/swiotlb: use dma_alloc_from_coherent to get device coherent memory, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 20/27] xen mtrr: Use specific cpu_has_foo macros instead of generic cpu_has(), Jeremy Fitzhardinge
- [Xen-devel] [PATCH 24/27] xen mtrr: Kill some unneccessary includes, Jeremy Fitzhardinge
|
|
|