[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 08/15] [swiotlb] Add 'is_swiotlb_buffer' to the swiotlb_ops function decleration.



We move the 'io_swiotlb_buffer' function before the swiotlb_ops_
structure decleration to avoid compilation problems.

Also we replace the calls to is_swiotlb_buffer to go through the
iommu_sw->is_swiotlb_buffer function.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 lib/swiotlb.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 72c9abe..688965d 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -246,11 +246,18 @@ static int swiotlb_release(struct swiotlb_engine *iotlb)
        swiotlb_free();
        return 0;
 }
+static int is_swiotlb_buffer(struct swiotlb_engine *iommu_sw,
+                            dma_addr_t dev_addr, phys_addr_t paddr)
+{
+       return paddr >= virt_to_phys(iommu_sw->start) &&
+               paddr < virt_to_phys(iommu_sw->end);
+}
 
 static struct swiotlb_engine swiotlb_ops = {
        .name = "software IO TLB",
        .overflow = 32 * 1024,
        .release = swiotlb_release,
+       .is_swiotlb_buffer = is_swiotlb_buffer,
        .phys_to_bus =  phys_to_dma,
        .bus_to_phys = dma_to_phys,
        .virt_to_bus = swiotlb_virt_to_bus,
@@ -388,11 +395,6 @@ void __init swiotlb_free(void)
        }
 }
 
-static int is_swiotlb_buffer(phys_addr_t paddr)
-{
-       return paddr >= virt_to_phys(iommu_sw->start) &&
-               paddr < virt_to_phys(iommu_sw->end);
-}
 
 /*
  * Bounce: copy the swiotlb buffer back to the original dma location
@@ -669,7 +671,7 @@ swiotlb_free_coherent(struct device *hwdev, size_t size, 
void *vaddr,
        phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
 
        WARN_ON(irqs_disabled());
-       if (!is_swiotlb_buffer(paddr))
+       if (!iommu_sw->is_swiotlb_buffer(iommu_sw, dev_addr, paddr))
                free_pages((unsigned long)vaddr, get_order(size));
        else
                /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
@@ -762,7 +764,7 @@ static void unmap_single(struct device *hwdev, dma_addr_t 
dev_addr,
 
        BUG_ON(dir == DMA_NONE);
 
-       if (is_swiotlb_buffer(paddr)) {
+       if (iommu_sw->is_swiotlb_buffer(iommu_sw, dev_addr, paddr)) {
                do_unmap_single(hwdev, phys_to_virt(paddr), size, dir);
                return;
        }
@@ -805,7 +807,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t 
dev_addr,
 
        BUG_ON(dir == DMA_NONE);
 
-       if (is_swiotlb_buffer(paddr)) {
+       if (iommu_sw->is_swiotlb_buffer(iommu_sw, dev_addr, paddr)) {
                sync_single(hwdev, phys_to_virt(paddr), size, dir, target);
                return;
        }
-- 
1.6.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.