From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 4/4] arm64: Hook up IOMMU dma_ops
Date: Thu, 16 Jul 2015 19:40:15 +0100 [thread overview]
Message-ID: <fecbcc50e62ae86639c886ab86e4ec067d52b16a.1437070995.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1437070995.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 | 15 +++++++--------
arch/arm64/mm/dma-mapping.c | 24 ++++++++++++++++++++++++
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0f6edb1..3509621 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -72,6 +72,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 IRQ_FORCED_THREADING
select MODULES_USE_ELF_RELA
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index f0d6d0b..7f9edcb 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -56,16 +56,15 @@ 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)
-{
- if (!acpi_disabled && !dev->archdata.dma_ops)
- dev->archdata.dma_ops = dma_ops;
-
- 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
+#ifdef CONFIG_IOMMU_DMA
+void arch_teardown_dma_ops(struct device *dev);
+#define arch_teardown_dma_ops arch_teardown_dma_ops
+#endif
+
/* 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 c89012e..bdab211 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -947,6 +947,20 @@ out_no_domain:
pr_warn("Failed to set up IOMMU domain for device %s\n", dev_name(dev));
}
+void arch_teardown_dma_ops(struct device *dev)
+{
+ struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
+
+ if (domain) {
+ iommu_detach_device(domain, dev);
+ if (domain->type & __IOMMU_DOMAIN_ARM64_IOVA)
+ iommu_put_dma_cookie(domain);
+ if (domain->type & __IOMMU_DOMAIN_ARM64)
+ iommu_domain_free(domain);
+ dev->archdata.dma_ops = NULL;
+ }
+}
+
#else
static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
@@ -954,3 +968,13 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
{ }
#endif /* CONFIG_IOMMU_DMA */
+
+void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
+ struct iommu_ops *iommu, bool coherent)
+{
+ if (!acpi_disabled && !dev->archdata.dma_ops)
+ dev->archdata.dma_ops = dma_ops;
+
+ dev->archdata.dma_coherent = coherent;
+ __iommu_setup_dma_ops(dev, dma_base, size, iommu);
+}
--
1.9.1
next prev parent reply other threads:[~2015-07-16 18:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 18:40 [PATCH v4 0/4] arm64: IOMMU-backed DMA mapping Robin Murphy
2015-07-16 18:40 ` [PATCH v4 1/4] iommu/iova: Avoid over-allocating when size-aligned Robin Murphy
2015-07-28 13:31 ` David Woodhouse
2015-07-16 18:40 ` [PATCH v4 2/4] iommu: Implement common IOMMU ops for DMA mapping Robin Murphy
2015-07-28 16:45 ` Catalin Marinas
2015-07-16 18:40 ` [PATCH v4 3/4] arm64: Add IOMMU dma_ops Robin Murphy
2015-07-28 17:27 ` Catalin Marinas
2015-07-16 18:40 ` Robin Murphy [this message]
2015-07-28 17:30 ` [PATCH v4 4/4] arm64: Hook up " Catalin Marinas
2015-07-20 15:26 ` [PATCH v4 0/4] arm64: IOMMU-backed DMA mapping Joerg Roedel
2015-07-20 17:23 ` Robin Murphy
2015-07-28 12:46 ` Will Deacon
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=fecbcc50e62ae86639c886ab86e4ec067d52b16a.1437070995.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).