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 09/15] [swiotlb] Add 'dma_capable' to the swiotlb_ops

To: fujita.tomonori@xxxxxxxxxxxxx, alex.williamson@xxxxxx, joerg.roedel@xxxxxxx, dwmw2@xxxxxxxxxxxxx, chrisw@xxxxxxxxxxxx, iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 09/15] [swiotlb] Add 'dma_capable' to the swiotlb_ops structure.
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Thu, 14 Jan 2010 18:00:58 -0500
Cc: Ian.Campbell@xxxxxxxxxxxxx, jeremy@xxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Delivery-date: Thu, 14 Jan 2010 15:17:11 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1263510064-16788-9-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> <1263510064-16788-9-git-send-email-konrad.wilk@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
And we also replace the 'dma_capable' with iommu_sw->dma_capable
to abstract the functionality of that function.

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

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 688965d..4da8151 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -253,10 +253,18 @@ static int is_swiotlb_buffer(struct swiotlb_engine 
*iommu_sw,
                paddr < virt_to_phys(iommu_sw->end);
 }
 
+static bool swiotlb_dma_capable(struct device *hwdev, dma_addr_t dma_addr,
+                               phys_addr_t phys, size_t size)
+{
+       /* Phys is not neccessary in this case. */
+       return dma_capable(hwdev, dma_addr, size);
+}
+
 static struct swiotlb_engine swiotlb_ops = {
        .name = "software IO TLB",
        .overflow = 32 * 1024,
        .release = swiotlb_release,
+       .dma_capable = swiotlb_dma_capable,
        .is_swiotlb_buffer = is_swiotlb_buffer,
        .phys_to_bus =  phys_to_dma,
        .bus_to_phys = dma_to_phys,
@@ -725,7 +733,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page 
*page,
         * we can safely return the device addr and not worry about bounce
         * buffering it.
         */
-       if (dma_capable(dev, dev_addr, size) && !swiotlb_force)
+       if (iommu_sw->dma_capable(dev, dev_addr, phys, size) && !swiotlb_force)
                return dev_addr;
 
        /*
@@ -742,7 +750,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page 
*page,
        /*
         * Ensure that the address returned is DMA'ble
         */
-       if (!dma_capable(dev, dev_addr, size))
+       if (!iommu_sw->dma_capable(dev, dev_addr, phys, size))
                panic("map_single: bounce buffer is not DMA'ble");
 
        return dev_addr;
@@ -895,7 +903,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct 
scatterlist *sgl, int nelems,
                dma_addr_t dev_addr = phys_to_dma(hwdev, paddr);
 
                if (swiotlb_force ||
-                   !dma_capable(hwdev, dev_addr, sg->length)) {
+                   !iommu_sw->dma_capable(hwdev, dev_addr, paddr, sg->length)) 
{
                        void *map = map_single(hwdev, sg_phys(sg),
                                               sg->length, dir);
                        if (!map) {
-- 
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>