WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 08/15] [swiotlb] Add 'is_swiotlb_buffer' to the swiot

To: fujita.tomonori@xxxxxxxxxxxxx, alex.williamson@xxxxxx, joerg.roedel@xxxxxxx, dwmw2@xxxxxxxxxxxxx, chrisw@xxxxxxxxxxxx, iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 08/15] [swiotlb] Add 'is_swiotlb_buffer' to the swiotlb_ops function decleration.
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Thu, 14 Jan 2010 18:00:57 -0500
Cc: Ian.Campbell@xxxxxxxxxxxxx, jeremy@xxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Delivery-date: Thu, 14 Jan 2010 15:10:25 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1263510064-16788-8-git-send-email-konrad.wilk@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1263510064-16788-1-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-2-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-3-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-4-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-5-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-6-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-7-git-send-email-konrad.wilk@xxxxxxxxxx> <1263510064-16788-8-git-send-email-konrad.wilk@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>