Prev: [PATCH 09/19] swiotlb-xen: Make 'xen_swiotlb_free_coherent' work.
Next: [PATCH 08/19] swiotlb-xen: Don't allocate DMA-memory beyond 4GB in 32-bit mode.
From: Konrad Rzeszutek Wilk on 22 Jun 2010 15:50 We utilize the SWIOTLB proper book-keeping functions and compared to bare-metal SWIOTLB, we use a different virt->bus address translation. This is necessary as under Xen, the PFN is a pseudo-number that is not necessarily the true MFN. Because of that, successive pages might not physically contiguous, meaning mfn++ != pfn_to_mfn(pfn++), so we have to check for that too. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk(a)oracle.com> --- lib/swiotlb-xen.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/swiotlb-xen.c b/lib/swiotlb-xen.c index 2640052..efafcce 100644 --- a/lib/swiotlb-xen.c +++ b/lib/swiotlb-xen.c @@ -192,7 +192,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page, struct dma_attrs *attrs) { phys_addr_t phys = page_to_phys(page) + offset; - dma_addr_t dev_addr = phys_to_dma(dev, phys); + dma_addr_t dev_addr = xen_phys_to_bus(dev, phys); void *map; BUG_ON(dir == DMA_NONE); @@ -201,7 +201,8 @@ dma_addr_t xen_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 (dma_capable(dev, dev_addr, size) && + !range_straddles_page_boundary(phys, size) && !swiotlb_force) return dev_addr; /* @@ -236,11 +237,12 @@ EXPORT_SYMBOL_GPL(xen_swiotlb_map_page); static void xen_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size, enum dma_data_direction dir) { - phys_addr_t paddr = dma_to_phys(hwdev, dev_addr); + phys_addr_t paddr = xen_bus_to_phys(hwdev, dev_addr); BUG_ON(dir == DMA_NONE); - if (is_xen_swiotlb_buffer(paddr)) { + /* NOTE: We use dev_addr here, not paddr! */ + if (is_xen_swiotlb_buffer(dev_addr)) { swiotlb_tbl_unmap_single(hwdev, phys_to_virt(paddr), size, dir); return; } -- 1.7.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |