From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> To: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org, will.deacon-5wv7dgnIgG8@public.gmane.org, catalin.marinas-5wv7dgnIgG8@public.gmane.org Cc: laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org, arnd-r2nGTMty4D4@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, djkurtz-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, yingjoe.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org, treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org Subject: [PATCH v5 3/3] arm64: Hook up IOMMU dma_ops Date: Fri, 31 Jul 2015 18:18:29 +0100 [thread overview] Message-ID: <caecbce93dd4870995a000bebc8f58d1ca7e551e.1438362603.git.robin.murphy@arm.com> (raw) In-Reply-To: <cover.1438362603.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 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-5wv7dgnIgG8@public.gmane.org> Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> --- 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 c8933dc..81584ef 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -73,6 +73,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 c735f45..175dcb2 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -952,6 +952,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, @@ -959,3 +973,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
WARNING: multiple messages have this Message-ID (diff)
From: robin.murphy@arm.com (Robin Murphy) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 3/3] arm64: Hook up IOMMU dma_ops Date: Fri, 31 Jul 2015 18:18:29 +0100 [thread overview] Message-ID: <caecbce93dd4870995a000bebc8f58d1ca7e551e.1438362603.git.robin.murphy@arm.com> (raw) In-Reply-To: <cover.1438362603.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. Acked-by: Catalin Marinas <catalin.marinas@arm.com> 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 c8933dc..81584ef 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -73,6 +73,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 c735f45..175dcb2 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -952,6 +952,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, @@ -959,3 +973,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-31 17:18 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-07-31 17:18 [PATCH v5 0/3] arm64: IOMMU-backed DMA mapping Robin Murphy 2015-07-31 17:18 ` Robin Murphy [not found] ` <cover.1438362603.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2015-07-31 17:18 ` [PATCH v5 1/3] iommu: Implement common IOMMU ops for " Robin Murphy 2015-07-31 17:18 ` Robin Murphy [not found] ` <6ce6b501501f611297ae0eae31e07b0d2060eaae.1438362603.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2015-08-03 17:40 ` Catalin Marinas 2015-08-03 17:40 ` Catalin Marinas 2015-08-06 15:23 ` Will Deacon 2015-08-06 15:23 ` Will Deacon [not found] ` <20150806152327.GH25483-5wv7dgnIgG8@public.gmane.org> 2015-08-06 17:54 ` joro-zLv9SwRftAIdnm+yROfE0A 2015-08-06 17:54 ` joro at 8bytes.org 2015-08-07 8:42 ` Joerg Roedel 2015-08-07 8:42 ` Joerg Roedel [not found] ` <20150807084228.GU14980-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2015-08-07 13:38 ` Robin Murphy 2015-08-07 13:38 ` Robin Murphy [not found] ` <55C4B4DF.4040608-5wv7dgnIgG8@public.gmane.org> 2015-08-11 9:37 ` Joerg Roedel 2015-08-11 9:37 ` Joerg Roedel [not found] ` <20150811093742.GC14980-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2015-08-11 13:31 ` Robin Murphy 2015-08-11 13:31 ` Robin Murphy 2015-07-31 17:18 ` [PATCH v5 2/3] arm64: Add IOMMU dma_ops Robin Murphy 2015-07-31 17:18 ` Robin Murphy [not found] ` <8a5abd0a9929aae160ccb74d7a8d9c3698f61910.1438362603.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2015-08-03 17:33 ` Catalin Marinas 2015-08-03 17:33 ` Catalin Marinas 2015-08-07 8:52 ` Joerg Roedel 2015-08-07 8:52 ` Joerg Roedel [not found] ` <20150807085233.GV14980-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2015-08-07 15:27 ` Robin Murphy 2015-08-07 15:27 ` Robin Murphy [not found] ` <55C4CE7C.7050205-5wv7dgnIgG8@public.gmane.org> 2015-08-11 9:49 ` Joerg Roedel 2015-08-11 9:49 ` Joerg Roedel [not found] ` <20150811094951.GD14980-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2015-08-11 20:15 ` Robin Murphy 2015-08-11 20:15 ` Robin Murphy 2015-09-22 17:12 ` Daniel Kurtz via iommu 2015-09-22 17:12 ` Daniel Kurtz [not found] ` <CAGS+omCDYrjpr--+sUzaKCxo12Eff6TC04RgroDgKvxHwK3t2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-09-22 18:11 ` Robin Murphy 2015-09-22 18:11 ` Robin Murphy 2015-07-31 17:18 ` Robin Murphy [this message] 2015-07-31 17:18 ` [PATCH v5 3/3] arm64: Hook up " Robin Murphy [not found] ` <caecbce93dd4870995a000bebc8f58d1ca7e551e.1438362603.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2015-08-07 8:55 ` Joerg Roedel 2015-08-07 8:55 ` Joerg Roedel 2015-08-26 6:19 ` [PATCH v5 0/3] arm64: IOMMU-backed DMA mapping Yong Wu 2015-08-26 6:19 ` Yong Wu
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=caecbce93dd4870995a000bebc8f58d1ca7e551e.1438362603.git.robin.murphy@arm.com \ --to=robin.murphy-5wv7dgnigg8@public.gmane.org \ --cc=arnd-r2nGTMty4D4@public.gmane.org \ --cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \ --cc=djkurtz-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \ --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \ --cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \ --cc=laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \ --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \ --cc=treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \ --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \ --cc=yingjoe.chen-NuS5LvNUpcJWk0Htik3J/w@public.gmane.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.