From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 5/5] arm64: hook up IOMMU dma_ops
Date: Mon, 12 Jan 2015 20:48:57 +0000 [thread overview]
Message-ID: <096cb0e8c8fe7f25ce4ae0dd5771d7dc920d80ed.1421086706.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1421086706.git.robin.murphy@arm.com>
With iommu_dma_ops in place, hook them up to the configuration code, so
IOMMU-fronted devices will get them automatically.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/dma-mapping.h | 10 +++++-----
arch/arm64/mm/dma-mapping.c | 22 ++++++++++++++++++++++
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b1f9a20..e2abcdc 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -66,6 +66,7 @@ config ARM64
select HAVE_PERF_USER_STACK_DUMP
select HAVE_RCU_TABLE_FREE
select HAVE_SYSCALL_TRACEPOINTS
+ select IOMMU_DMA if IOMMU_SUPPORT
select IRQ_DOMAIN
select MODULES_USE_ELF_RELA
select NO_BOOTMEM
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index 82082c4..0791a78 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -45,13 +45,13 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev)
return __generic_dma_ops(dev);
}
-static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
- struct iommu_ops *iommu, bool coherent)
-{
- dev->archdata.dma_coherent = coherent;
-}
+void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
+ struct iommu_ops *iommu, bool coherent);
#define arch_setup_dma_ops arch_setup_dma_ops
+void arch_teardown_dma_ops(struct device *dev);
+#define arch_teardown_dma_ops arch_teardown_dma_ops
+
/* do not use this function in a driver */
static inline bool is_device_dma_coherent(struct device *dev)
{
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 8e449a7..d52175d 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -729,10 +729,32 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
iommu_dma_release_mapping(mapping);
}
+static void __iommu_teardown_dma_ops(struct device *dev)
+{
+ if (dev->archdata.mapping) {
+ iommu_dma_detach_device(dev);
+ dev->archdata.dma_ops = NULL;
+ }
+}
+
#else
static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
struct iommu_ops *iommu)
{ }
+static void __iommu_teardown_dma_ops(struct device *dev) { }
+
#endif /* CONFIG_IOMMU_DMA */
+
+void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
+ struct iommu_ops *iommu, bool coherent)
+{
+ dev->archdata.dma_coherent = coherent;
+ __iommu_setup_dma_ops(dev, dma_base, size, iommu);
+}
+
+void arch_teardown_dma_ops(struct device *dev)
+{
+ __iommu_teardown_dma_ops(dev);
+}
--
1.9.1
next prev parent reply other threads:[~2015-01-12 20:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-12 20:48 [RFC PATCH 0/5] arm64: IOMMU-backed DMA mapping Robin Murphy
2015-01-12 20:48 ` [RFC PATCH 1/5] arm64: Combine coherent and non-coherent swiotlb dma_ops Robin Murphy
2015-01-12 20:48 ` [RFC PATCH 2/5] arm64: implement generic IOMMU configuration Robin Murphy
2015-01-12 20:48 ` [RFC PATCH 3/5] iommu: implement common IOMMU ops for DMA mapping Robin Murphy
2015-01-23 17:42 ` Laura Abbott
2015-01-23 18:14 ` Robin Murphy
2015-01-27 0:21 ` Joerg Roedel
2015-01-27 12:27 ` Robin Murphy
2015-01-27 12:38 ` Joerg Roedel
2015-01-28 13:53 ` Will Deacon
2015-01-12 20:48 ` [RFC PATCH 4/5] arm64: add IOMMU dma_ops Robin Murphy
2015-01-23 15:26 ` Will Deacon
2015-01-23 17:33 ` Robin Murphy
2015-01-26 3:25 ` Joseph Lo
2015-01-27 17:30 ` Robin Murphy
2015-01-26 9:10 ` Joseph Lo
2015-01-28 2:22 ` Joseph Lo
2015-03-05 14:31 ` Marek Szyprowski
2015-01-12 20:48 ` Robin Murphy [this message]
2015-01-13 8:02 ` [RFC PATCH 0/5] arm64: IOMMU-backed DMA mapping Yingjoe Chen
2015-01-13 12:07 ` Robin Murphy
2015-01-15 18:35 ` Robin Murphy
2015-01-16 7:21 ` Yong Wu
2015-01-16 20:12 ` Robin Murphy
2015-01-13 11:08 ` Stefano Stabellini
2015-01-13 11:45 ` Robin Murphy
2015-01-23 16:47 ` Catalin Marinas
2015-01-23 17:41 ` Robin Murphy
2015-03-05 14:31 ` Marek Szyprowski
2015-03-05 16:42 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=096cb0e8c8fe7f25ce4ae0dd5771d7dc920d80ed.1421086706.git.robin.murphy@arm.com \
--to=robin.murphy@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).