summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2015-10-01 15:14:00 -0400
committerJoerg Roedel <jroedel@suse.de>2015-10-15 10:41:47 -0400
commit876945dbf6497c7539ef958fee7ade970fbbe17a (patch)
tree249ed5cde4c8ed71361a50f75f28091e3c281adf
parent13b8629f651164d71f4d38b821925f93ba4236c8 (diff)
arm64: Hook up IOMMU dma_ops
With iommu_dma_ops in place, hook them up to the configuration code, so IOMMU-fronted devices will get them automatically. Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--arch/arm64/Kconfig1
-rw-r--r--arch/arm64/include/asm/dma-mapping.h15
-rw-r--r--arch/arm64/mm/dma-mapping.c22
3 files changed, 30 insertions, 8 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 07d1811aa03f..1f823d1d551d 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -75,6 +75,7 @@ config ARM64
75 select HAVE_PERF_USER_STACK_DUMP 75 select HAVE_PERF_USER_STACK_DUMP
76 select HAVE_RCU_TABLE_FREE 76 select HAVE_RCU_TABLE_FREE
77 select HAVE_SYSCALL_TRACEPOINTS 77 select HAVE_SYSCALL_TRACEPOINTS
78 select IOMMU_DMA if IOMMU_SUPPORT
78 select IRQ_DOMAIN 79 select IRQ_DOMAIN
79 select IRQ_FORCED_THREADING 80 select IRQ_FORCED_THREADING
80 select MODULES_USE_ELF_RELA 81 select MODULES_USE_ELF_RELA
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index cfdb34bedbcd..54d0ead41afc 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -54,16 +54,15 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
54 return __generic_dma_ops(dev); 54 return __generic_dma_ops(dev);
55} 55}
56 56
57static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 57void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
58 struct iommu_ops *iommu, bool coherent) 58 struct iommu_ops *iommu, bool coherent);
59{
60 if (!acpi_disabled && !dev->archdata.dma_ops)
61 dev->archdata.dma_ops = dma_ops;
62
63 dev->archdata.dma_coherent = coherent;
64}
65#define arch_setup_dma_ops arch_setup_dma_ops 59#define arch_setup_dma_ops arch_setup_dma_ops
66 60
61#ifdef CONFIG_IOMMU_DMA
62void arch_teardown_dma_ops(struct device *dev);
63#define arch_teardown_dma_ops arch_teardown_dma_ops
64#endif
65
67/* do not use this function in a driver */ 66/* do not use this function in a driver */
68static inline bool is_device_dma_coherent(struct device *dev) 67static inline bool is_device_dma_coherent(struct device *dev)
69{ 68{
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 322404193044..6320361d8d4c 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -960,6 +960,19 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
960 } 960 }
961} 961}
962 962
963void arch_teardown_dma_ops(struct device *dev)
964{
965 struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
966
967 if (domain) {
968 iommu_detach_device(domain, dev);
969 if (domain->type & __IOMMU_DOMAIN_FAKE_DEFAULT)
970 iommu_domain_free(domain);
971 }
972
973 dev->archdata.dma_ops = NULL;
974}
975
963#else 976#else
964 977
965static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 978static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
@@ -968,3 +981,12 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
968 981
969#endif /* CONFIG_IOMMU_DMA */ 982#endif /* CONFIG_IOMMU_DMA */
970 983
984void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
985 struct iommu_ops *iommu, bool coherent)
986{
987 if (!acpi_disabled && !dev->archdata.dma_ops)
988 dev->archdata.dma_ops = dma_ops;
989
990 dev->archdata.dma_coherent = coherent;
991 __iommu_setup_dma_ops(dev, dma_base, size, iommu);
992}