@@ -2280,7 +2280,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
set_dma_ops(dev, dma_ops);
#ifdef CONFIG_XEN
- if (xen_initial_domain())
+ if (xen_initial_domain() && !xen_is_device_protected(dev))
dev->dma_ops = &xen_swiotlb_dma_ops;
#endif
dev->archdata.dma_ops_setup = true;
@@ -425,6 +425,10 @@ static int __init xen_pm_init(void)
}
late_initcall(xen_pm_init);
+bool xen_is_device_protected(void *obj) {
+ struct device *dev = obj;
+ return of_property_read_bool(dev->of_node, "xen,behind-iommu");
+}
/* empty stubs */
void xen_arch_pre_suspend(void) { }
@@ -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_initial_domain() && !xen_is_device_protected(dev))
dev->dma_ops = &xen_swiotlb_dma_ops;
#endif
}
@@ -61,4 +61,6 @@ void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
#include <xen/balloon.h>
#endif
+bool xen_is_device_protected(void *obj);
+
#endif /* _XEN_XEN_H */
Prior to this patch swiotlb-xen fops are set for all devices when we are booting as as Dom0 or direct-mapped DomU. Since Xen now marks devices which are IOMMU-protected by adding additional property to the relevant device, we can check for this property and don't set swiotlb-xen fops for any IOMMU-protected device. Signed-off-by: Roman Skakun <Roman_Skakun@epam.com> --- arch/arm/mm/dma-mapping.c | 2 +- arch/arm/xen/enlighten.c | 4 ++++ arch/arm64/mm/dma-mapping.c | 2 +- include/xen/xen.h | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-)