xen/swiotlb: Pass addresses rather than frame numbers to xen_arch_need_swiotlb
authorJulien Grall <julien.grall@citrix.com>
Wed, 9 Sep 2015 14:17:33 +0000 (15:17 +0100)
committerDavid Vrabel <david.vrabel@citrix.com>
Fri, 23 Oct 2015 13:20:43 +0000 (14:20 +0100)
With 64KB page granularity support, the frame number will be different.

It will be easier to modify the behavior in a single place rather than
in each caller.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
arch/arm/include/asm/xen/page.h
arch/arm/xen/mm.c
arch/x86/include/asm/xen/page.h
drivers/xen/swiotlb-xen.c

index e3d94cfa4d464c4d144eb07c2ce5f527c0679f4b..415dbc6e43fd7ac6c256e2b30b704567ab5966d2 100644 (file)
@@ -115,8 +115,8 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 #define xen_unmap(cookie) iounmap((cookie))
 
 bool xen_arch_need_swiotlb(struct device *dev,
-                          unsigned long pfn,
-                          unsigned long bfn);
+                          phys_addr_t phys,
+                          dma_addr_t dev_addr);
 unsigned long xen_get_swiotlb_free_pages(unsigned int order);
 
 #endif /* _ASM_ARM_XEN_PAGE_H */
index 6dd911d1f0ac6c0f2c328abbee593d85d5bd5bcd..7b517e913762ceccc243dbf092c88d97ad4ddcf6 100644 (file)
@@ -138,9 +138,12 @@ void __xen_dma_sync_single_for_device(struct device *hwdev,
 }
 
 bool xen_arch_need_swiotlb(struct device *dev,
-                          unsigned long pfn,
-                          unsigned long bfn)
+                          phys_addr_t phys,
+                          dma_addr_t dev_addr)
 {
+       unsigned long pfn = PFN_DOWN(phys);
+       unsigned long bfn = PFN_DOWN(dev_addr);
+
        return (!hypercall_cflush && (pfn != bfn) && !is_device_dma_coherent(dev));
 }
 
index fe58e3a935deac5c3cbdc6d0b74302c9387f95fb..f5fb840b43e820ae68d1a97f38ebe7ff42dd8641 100644 (file)
@@ -298,8 +298,8 @@ void make_lowmem_page_readwrite(void *vaddr);
 #define xen_unmap(cookie) iounmap((cookie))
 
 static inline bool xen_arch_need_swiotlb(struct device *dev,
-                                        unsigned long pfn,
-                                        unsigned long bfn)
+                                        phys_addr_t phys,
+                                        dma_addr_t dev_addr)
 {
        return false;
 }
index 79bc4933b13e05c220325bb3ad39f7f6c0e243dd..0a5a0e949862bf469151ea4986451df9f0f8f4d7 100644 (file)
@@ -392,7 +392,7 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
         */
        if (dma_capable(dev, dev_addr, size) &&
            !range_straddles_page_boundary(phys, size) &&
-               !xen_arch_need_swiotlb(dev, PFN_DOWN(phys), PFN_DOWN(dev_addr)) &&
+               !xen_arch_need_swiotlb(dev, phys, dev_addr) &&
                !swiotlb_force) {
                /* we are not interested in the dma_addr returned by
                 * xen_dma_map_page, only in the potential cache flushes executed
@@ -551,7 +551,7 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
                dma_addr_t dev_addr = xen_phys_to_bus(paddr);
 
                if (swiotlb_force ||
-                   xen_arch_need_swiotlb(hwdev, PFN_DOWN(paddr), PFN_DOWN(dev_addr)) ||
+                   xen_arch_need_swiotlb(hwdev, paddr, dev_addr) ||
                    !dma_capable(hwdev, dev_addr, sg->length) ||
                    range_straddles_page_boundary(paddr, sg->length)) {
                        phys_addr_t map = swiotlb_tbl_map_single(hwdev,