Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm/xen: Introduce xen_setup_dma_ops()

This patch introduces new helper and places it in new header.
The helper's purpose is to assign any Xen specific DMA ops in
a single place. For now, we deal with xen-swiotlb DMA ops only.
The one of the subsequent commits in current series will add
xen-grant DMA ops case.

Also re-use the xen_swiotlb_detect() check on Arm32.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
[For arm64]
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/1654197833-25362-2-git-send-email-olekstysh@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Oleksandr Tyshchenko and committed by
Juergen Gross
9bf22421 3f9dfbeb

+23 -10
+2
arch/arm/include/asm/xen/xen-ops.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #include <xen/arm/xen-ops.h>
+2 -5
arch/arm/mm/dma-mapping.c
··· 33 33 #include <asm/dma-iommu.h> 34 34 #include <asm/mach/map.h> 35 35 #include <asm/system_info.h> 36 - #include <xen/swiotlb-xen.h> 36 + #include <asm/xen/xen-ops.h> 37 37 38 38 #include "dma.h" 39 39 #include "mm.h" ··· 2287 2287 2288 2288 set_dma_ops(dev, dma_ops); 2289 2289 2290 - #ifdef CONFIG_XEN 2291 - if (xen_initial_domain()) 2292 - dev->dma_ops = &xen_swiotlb_dma_ops; 2293 - #endif 2290 + xen_setup_dma_ops(dev); 2294 2291 dev->archdata.dma_ops_setup = true; 2295 2292 } 2296 2293
+2
arch/arm64/include/asm/xen/xen-ops.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #include <xen/arm/xen-ops.h>
+2 -5
arch/arm64/mm/dma-mapping.c
··· 9 9 #include <linux/dma-map-ops.h> 10 10 #include <linux/dma-iommu.h> 11 11 #include <xen/xen.h> 12 - #include <xen/swiotlb-xen.h> 13 12 14 13 #include <asm/cacheflush.h> 14 + #include <asm/xen/xen-ops.h> 15 15 16 16 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, 17 17 enum dma_data_direction dir) ··· 52 52 if (iommu) 53 53 iommu_setup_dma_ops(dev, dma_base, dma_base + size - 1); 54 54 55 - #ifdef CONFIG_XEN 56 - if (xen_swiotlb_detect()) 57 - dev->dma_ops = &xen_swiotlb_dma_ops; 58 - #endif 55 + xen_setup_dma_ops(dev); 59 56 }
+15
include/xen/arm/xen-ops.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _ASM_ARM_XEN_OPS_H 3 + #define _ASM_ARM_XEN_OPS_H 4 + 5 + #include <xen/swiotlb-xen.h> 6 + 7 + static inline void xen_setup_dma_ops(struct device *dev) 8 + { 9 + #ifdef CONFIG_XEN 10 + if (xen_swiotlb_detect()) 11 + dev->dma_ops = &xen_swiotlb_dma_ops; 12 + #endif 13 + } 14 + 15 + #endif /* _ASM_ARM_XEN_OPS_H */