Commit f5079a9a authored by Stefano Stabellini's avatar Stefano Stabellini Committed by Juergen Gross
Browse files

xen/arm: introduce XENFEAT_direct_mapped and XENFEAT_not_direct_mapped



Newer Xen versions expose two Xen feature flags to tell us if the domain
is directly mapped or not. Only when a domain is directly mapped it
makes sense to enable swiotlb-xen on ARM.

Introduce a function on ARM to check the new Xen feature flags and also
to deal with the legacy case. Call the function xen_swiotlb_detect.

Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20210319200140.12512-1-sstabellini@kernel.org


Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent a929e124
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
#include <xen/arm/swiotlb-xen.h>
+13 −1
Original line number Diff line number Diff line
@@ -135,10 +135,22 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
	return;
}

int xen_swiotlb_detect(void)
{
	if (!xen_domain())
		return 0;
	if (xen_feature(XENFEAT_direct_mapped))
		return 1;
	/* legacy case */
	if (!xen_feature(XENFEAT_not_direct_mapped) && xen_initial_domain())
		return 1;
	return 0;
}

static int __init xen_mm_init(void)
{
	struct gnttab_cache_flush cflush;
	if (!xen_initial_domain())
	if (!xen_swiotlb_detect())
		return 0;
	xen_swiotlb_init(1, false);

+1 −0
Original line number Diff line number Diff line
#include <xen/arm/swiotlb-xen.h>
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
		iommu_setup_dma_ops(dev, dma_base, size);

#ifdef CONFIG_XEN
	if (xen_initial_domain())
	if (xen_swiotlb_detect())
		dev->dma_ops = &xen_swiotlb_dma_ops;
#endif
}
+7 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_ARM_SWIOTLB_XEN_H
#define _ASM_ARM_SWIOTLB_XEN_H

extern int xen_swiotlb_detect(void);

#endif /* _ASM_ARM_SWIOTLB_XEN_H */
Loading