lkml.org 
[lkml]   [2009]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/9] xen: add hooks for mapping phys<->bus addresses in swiotlb
Date
From: Ian Campbell <ian.campbell@citrix.com>

Impact: Xen support for DMA

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@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Reviewed-by: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/kernel/pci-swiotlb_64.c | 6 ++++++
drivers/pci/xen-iommu.c | 10 ++++++++++
include/xen/swiotlb.h | 12 ++++++++++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c
index be379af..7f87ce2 100644
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -38,11 +38,17 @@ void *swiotlb_alloc(unsigned order, unsigned long nslabs)

dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr)
{
+ if (xen_pv_domain())
+ return xen_phys_to_bus(paddr);
+
return paddr;
}

phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr)
{
+ if (xen_pv_domain())
+ return xen_bus_to_phys(baddr);
+
return baddr;
}

diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c
index b9b4620..47d87a7 100644
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -59,6 +59,16 @@ void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
panic(KERN_ERR "xen_create_contiguous_region failed\n");
}
}
+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..3d96b07 100644
--- a/include/xen/swiotlb.h
+++ b/include/xen/swiotlb.h
@@ -3,10 +3,22 @@

#ifdef CONFIG_PCI_XEN
extern void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs);
+extern phys_addr_t xen_bus_to_phys(dma_addr_t daddr);
+extern dma_addr_t xen_phys_to_bus(phys_addr_t paddr);
#else
static inline void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
{
}
+
+static inline phys_addr_t xen_bus_to_phys(dma_addr_t daddr)
+{
+ return daddr;
+}
+
+static inline dma_addr_t xen_phys_to_bus(phys_addr_t paddr)
+{
+ return paddr;
+}
#endif

#endif /* _XEN_SWIOTLB_H */
--
1.6.0.6


\
 
 \ /
  Last update: 2009-04-01 00:57    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site