lkml.org 
[lkml]   [2009]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/10] xen/swiotlb: add hook for swiotlb_arch_range_needs_mapping
Date
From: Ian Campbell <ian.campbell@citrix.com>

Add hook so that Xen can determine whether a particular address range needs
pfn<->mfn mapping.

[ Impact: make Xen DMA work ]
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>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/pci-swiotlb.c | 5 -----
arch/x86/xen/pci-swiotlb.c | 8 ++++++++
drivers/pci/xen-iommu.c | 5 +++++
include/xen/swiotlb.h | 1 +
4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index 3e2ffd6..9640e17 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -13,11 +13,6 @@

int swiotlb __read_mostly;

-int __weak swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size)
-{
- return 0;
-}
-
static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags)
{
diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c
index 646f2bf..c2850b3 100644
--- a/arch/x86/xen/pci-swiotlb.c
+++ b/arch/x86/xen/pci-swiotlb.c
@@ -41,3 +41,11 @@ phys_addr_t swiotlb_bus_to_phys(dma_addr_t baddr)

return baddr;
}
+
+int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size)
+{
+ if (xen_pv_domain())
+ return xen_range_needs_mapping(paddr, size);
+
+ return 0;
+}
diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c
index a5a3b32..be50f0f 100644
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -119,6 +119,11 @@ static int range_straddles_page_boundary(phys_addr_t p, size_t size)
return 1;
}

+int xen_range_needs_mapping(phys_addr_t paddr, size_t size)
+{
+ return range_straddles_page_boundary(paddr, size);
+}
+
static inline void xen_dma_unmap_page(struct page *page)
{
/* Xen TODO: 2.6.18 xen calls __gnttab_dma_unmap_page here
diff --git a/include/xen/swiotlb.h b/include/xen/swiotlb.h
index 4229f27..8b51ff7 100644
--- a/include/xen/swiotlb.h
+++ b/include/xen/swiotlb.h
@@ -4,5 +4,6 @@
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);
+extern int xen_range_needs_mapping(phys_addr_t phys, size_t size);

#endif /* _XEN_SWIOTLB_H */
--
1.6.0.6


\
 
 \ /
  Last update: 2009-05-13 05:19    [W:0.047 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site