From: Konrad Rzeszutek Wilk Subject: [PATCH 08/15] [swiotlb] Add 'is_swiotlb_buffer' to the swiotlb_ops function decleration. Date: Thu, 14 Jan 2010 18:00:57 -0500 Message-ID: <1263510064-16788-9-git-send-email-konrad.wilk@oracle.com> References: <1263510064-16788-1-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-2-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-3-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-4-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-5-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-6-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-7-git-send-email-konrad.wilk@oracle.com> <1263510064-16788-8-git-send-email-konrad.wilk@oracle.com> Return-path: In-Reply-To: <1263510064-16788-8-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: fujita.tomonori@lab.ntt.co.jp, alex.williamson@hp.com, joerg.roedel@amd.com, dwmw2@infradead.org, chrisw@sous-sol.org, iommu@lists.linux-foundation.org Cc: Ian.Campbell@eu.citrix.com, jeremy@goop.org, xen-devel@lists.xensource.com, Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org 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 --- 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