From: Konrad Rzeszutek Wilk Subject: [PATCH 09/15] [swiotlb] Add 'dma_capable' to the swiotlb_ops structure. Date: Thu, 14 Jan 2010 18:00:58 -0500 Message-ID: <1263510064-16788-10-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> <1263510064-16788-9-git-send-email-konrad.wilk@oracle.com> Return-path: In-Reply-To: <1263510064-16788-9-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 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 --- 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