* [PATCH 1/3] iommu/dma: Clean up Kconfig
2022-08-16 17:28 [PATCH 0/3] iommu/dma: Some housekeeping Robin Murphy
@ 2022-08-16 17:28 ` Robin Murphy
2022-09-02 18:15 ` Catalin Marinas
2023-05-05 14:50 ` Jason Gunthorpe
2022-08-16 17:28 ` [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h Robin Murphy
` (2 subsequent siblings)
3 siblings, 2 replies; 12+ messages in thread
From: Robin Murphy @ 2022-08-16 17:28 UTC (permalink / raw)
To: joro
Cc: jean-philippe, kvm, iommu, catalin.marinas, cohuck, sw0312.kim,
alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
Although iommu-dma is a per-architecture chonce, that is currently
implemented in a rather haphazard way. Selecting from the arch Kconfig
was the original logical approach, but is complicated by having to
manage dependencies; conversely, selecting from drivers ends up hiding
the architecture dependency *too* well. Instead, let's just have it
enable itself automatically when IOMMU API support is enabled for the
relevant architectures. It can't get much clearer than that.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
arch/arm64/Kconfig | 1 -
drivers/iommu/Kconfig | 3 +--
drivers/iommu/amd/Kconfig | 1 -
drivers/iommu/intel/Kconfig | 1 -
4 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 571cc234d0b3..59af600445c2 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -209,7 +209,6 @@ config ARM64
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_GENERIC_VDSO
- select IOMMU_DMA if IOMMU_SUPPORT
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
select KASAN_VMALLOC if KASAN
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 5c5cb5bee8b6..1d99c2d984fb 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -137,7 +137,7 @@ config OF_IOMMU
# IOMMU-agnostic DMA-mapping layer
config IOMMU_DMA
- bool
+ def_bool ARM64 || IA64 || X86
select DMA_OPS
select IOMMU_API
select IOMMU_IOVA
@@ -476,7 +476,6 @@ config VIRTIO_IOMMU
depends on VIRTIO
depends on (ARM64 || X86)
select IOMMU_API
- select IOMMU_DMA
select INTERVAL_TREE
select ACPI_VIOT if ACPI
help
diff --git a/drivers/iommu/amd/Kconfig b/drivers/iommu/amd/Kconfig
index a3cbafb603f5..9b5fc3356bf2 100644
--- a/drivers/iommu/amd/Kconfig
+++ b/drivers/iommu/amd/Kconfig
@@ -9,7 +9,6 @@ config AMD_IOMMU
select PCI_PASID
select IOMMU_API
select IOMMU_IOVA
- select IOMMU_DMA
select IOMMU_IO_PGTABLE
depends on X86_64 && PCI && ACPI && HAVE_CMPXCHG_DOUBLE
help
diff --git a/drivers/iommu/intel/Kconfig b/drivers/iommu/intel/Kconfig
index 39a06d245f12..c48005147ac5 100644
--- a/drivers/iommu/intel/Kconfig
+++ b/drivers/iommu/intel/Kconfig
@@ -19,7 +19,6 @@ config INTEL_IOMMU
select DMAR_TABLE
select SWIOTLB
select IOASID
- select IOMMU_DMA
select PCI_ATS
help
DMA remapping (DMAR) devices support enables independent address
--
2.36.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] iommu/dma: Clean up Kconfig
2022-08-16 17:28 ` [PATCH 1/3] iommu/dma: Clean up Kconfig Robin Murphy
@ 2022-09-02 18:15 ` Catalin Marinas
2023-05-05 14:50 ` Jason Gunthorpe
1 sibling, 0 replies; 12+ messages in thread
From: Catalin Marinas @ 2022-09-02 18:15 UTC (permalink / raw)
To: Robin Murphy
Cc: jean-philippe, kvm, iommu, maz, joro, cohuck, sw0312.kim,
alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, tglx, will, linux-arm-kernel
On Tue, Aug 16, 2022 at 06:28:03PM +0100, Robin Murphy wrote:
> Although iommu-dma is a per-architecture chonce, that is currently
> implemented in a rather haphazard way. Selecting from the arch Kconfig
> was the original logical approach, but is complicated by having to
> manage dependencies; conversely, selecting from drivers ends up hiding
> the architecture dependency *too* well. Instead, let's just have it
> enable itself automatically when IOMMU API support is enabled for the
> relevant architectures. It can't get much clearer than that.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> arch/arm64/Kconfig | 1 -
For this change:
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] iommu/dma: Clean up Kconfig
2022-08-16 17:28 ` [PATCH 1/3] iommu/dma: Clean up Kconfig Robin Murphy
2022-09-02 18:15 ` Catalin Marinas
@ 2023-05-05 14:50 ` Jason Gunthorpe
2023-05-05 14:53 ` Robin Murphy
1 sibling, 1 reply; 12+ messages in thread
From: Jason Gunthorpe @ 2023-05-05 14:50 UTC (permalink / raw)
To: Robin Murphy
Cc: jean-philippe, kvm, iommu, catalin.marinas, joro, cohuck,
sw0312.kim, alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
On Tue, Aug 16, 2022 at 06:28:03PM +0100, Robin Murphy wrote:
> Although iommu-dma is a per-architecture chonce, that is currently
> implemented in a rather haphazard way. Selecting from the arch Kconfig
> was the original logical approach, but is complicated by having to
> manage dependencies; conversely, selecting from drivers ends up hiding
> the architecture dependency *too* well. Instead, let's just have it
> enable itself automatically when IOMMU API support is enabled for the
> relevant architectures. It can't get much clearer than that.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> arch/arm64/Kconfig | 1 -
> drivers/iommu/Kconfig | 3 +--
> drivers/iommu/amd/Kconfig | 1 -
> drivers/iommu/intel/Kconfig | 1 -
> 4 files changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 571cc234d0b3..59af600445c2 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -209,7 +209,6 @@ config ARM64
> select HAVE_KPROBES
> select HAVE_KRETPROBES
> select HAVE_GENERIC_VDSO
> - select IOMMU_DMA if IOMMU_SUPPORT
> select IRQ_DOMAIN
> select IRQ_FORCED_THREADING
> select KASAN_VMALLOC if KASAN
> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
> index 5c5cb5bee8b6..1d99c2d984fb 100644
> --- a/drivers/iommu/Kconfig
> +++ b/drivers/iommu/Kconfig
> @@ -137,7 +137,7 @@ config OF_IOMMU
>
> # IOMMU-agnostic DMA-mapping layer
> config IOMMU_DMA
> - bool
> + def_bool ARM64 || IA64 || X86
Robin, do you remember why you added IA64 here? What is the Itanimum
IOMMU driver?
Thanks,
Jason
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] iommu/dma: Clean up Kconfig
2023-05-05 14:50 ` Jason Gunthorpe
@ 2023-05-05 14:53 ` Robin Murphy
2023-05-05 19:22 ` Jason Gunthorpe
0 siblings, 1 reply; 12+ messages in thread
From: Robin Murphy @ 2023-05-05 14:53 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: jean-philippe, kvm, iommu, catalin.marinas, joro, cohuck,
sw0312.kim, alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
On 2023-05-05 15:50, Jason Gunthorpe wrote:
> On Tue, Aug 16, 2022 at 06:28:03PM +0100, Robin Murphy wrote:
>> Although iommu-dma is a per-architecture chonce, that is currently
>> implemented in a rather haphazard way. Selecting from the arch Kconfig
>> was the original logical approach, but is complicated by having to
>> manage dependencies; conversely, selecting from drivers ends up hiding
>> the architecture dependency *too* well. Instead, let's just have it
>> enable itself automatically when IOMMU API support is enabled for the
>> relevant architectures. It can't get much clearer than that.
>>
>> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
>> ---
>> arch/arm64/Kconfig | 1 -
>> drivers/iommu/Kconfig | 3 +--
>> drivers/iommu/amd/Kconfig | 1 -
>> drivers/iommu/intel/Kconfig | 1 -
>> 4 files changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 571cc234d0b3..59af600445c2 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -209,7 +209,6 @@ config ARM64
>> select HAVE_KPROBES
>> select HAVE_KRETPROBES
>> select HAVE_GENERIC_VDSO
>> - select IOMMU_DMA if IOMMU_SUPPORT
>> select IRQ_DOMAIN
>> select IRQ_FORCED_THREADING
>> select KASAN_VMALLOC if KASAN
>> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
>> index 5c5cb5bee8b6..1d99c2d984fb 100644
>> --- a/drivers/iommu/Kconfig
>> +++ b/drivers/iommu/Kconfig
>> @@ -137,7 +137,7 @@ config OF_IOMMU
>>
>> # IOMMU-agnostic DMA-mapping layer
>> config IOMMU_DMA
>> - bool
>> + def_bool ARM64 || IA64 || X86
>
> Robin, do you remember why you added IA64 here? What is the Itanimum
> IOMMU driver?
config INTEL_IOMMU
bool "Support for Intel IOMMU using DMA Remapping Devices"
depends on PCI_MSI && ACPI && (X86 || IA64)
Yes, really :)
Robin.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] iommu/dma: Clean up Kconfig
2023-05-05 14:53 ` Robin Murphy
@ 2023-05-05 19:22 ` Jason Gunthorpe
0 siblings, 0 replies; 12+ messages in thread
From: Jason Gunthorpe @ 2023-05-05 19:22 UTC (permalink / raw)
To: Robin Murphy
Cc: jean-philippe, kvm, iommu, catalin.marinas, joro, cohuck,
sw0312.kim, alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
On Fri, May 05, 2023 at 03:53:54PM +0100, Robin Murphy wrote:
> > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
> > > index 5c5cb5bee8b6..1d99c2d984fb 100644
> > > --- a/drivers/iommu/Kconfig
> > > +++ b/drivers/iommu/Kconfig
> > > @@ -137,7 +137,7 @@ config OF_IOMMU
> > > # IOMMU-agnostic DMA-mapping layer
> > > config IOMMU_DMA
> > > - bool
> > > + def_bool ARM64 || IA64 || X86
> >
> > Robin, do you remember why you added IA64 here? What is the Itanimum
> > IOMMU driver?
>
> config INTEL_IOMMU
> bool "Support for Intel IOMMU using DMA Remapping Devices"
> depends on PCI_MSI && ACPI && (X86 || IA64)
>
> Yes, really :)
Wowo, thanks!
Jason
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h
2022-08-16 17:28 [PATCH 0/3] iommu/dma: Some housekeeping Robin Murphy
2022-08-16 17:28 ` [PATCH 1/3] iommu/dma: Clean up Kconfig Robin Murphy
@ 2022-08-16 17:28 ` Robin Murphy
2022-08-17 12:19 ` Marc Zyngier
` (2 more replies)
2022-08-16 17:28 ` [PATCH 3/3] iommu/dma: Make header private Robin Murphy
2022-09-07 12:49 ` [PATCH 0/3] iommu/dma: Some housekeeping Joerg Roedel
3 siblings, 3 replies; 12+ messages in thread
From: Robin Murphy @ 2022-08-16 17:28 UTC (permalink / raw)
To: joro
Cc: jean-philippe, kvm, iommu, catalin.marinas, cohuck, sw0312.kim,
alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
The iommu-dma layer is now mostly encapsulated by iommu_dma_ops, with
only a couple more public interfaces left pertaining to MSI integration.
Since these depend on the main IOMMU API header anyway, move their
declarations there, taking the opportunity to update the half-baked
comments to proper kerneldoc along the way.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
Note that iommu_setup_dma_ops() should also become internal in a future
phase of the great IOMMU API upheaval - for now as the last bit of true
arch code glue I consider it more "necessarily exposed" than "public".
arch/arm64/mm/dma-mapping.c | 2 +-
drivers/iommu/dma-iommu.c | 15 ++++++++++--
drivers/irqchip/irq-gic-v2m.c | 2 +-
drivers/irqchip/irq-gic-v3-its.c | 2 +-
drivers/irqchip/irq-gic-v3-mbi.c | 2 +-
drivers/irqchip/irq-ls-scfg-msi.c | 2 +-
drivers/vfio/vfio_iommu_type1.c | 1 -
include/linux/dma-iommu.h | 40 -------------------------------
include/linux/iommu.h | 36 ++++++++++++++++++++++++++++
9 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 599cf81f5685..7d7e9a046305 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -7,7 +7,7 @@
#include <linux/gfp.h>
#include <linux/cache.h>
#include <linux/dma-map-ops.h>
-#include <linux/dma-iommu.h>
+#include <linux/iommu.h>
#include <xen/xen.h>
#include <asm/cacheflush.h>
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 17dd683b2fce..6809b33ac9df 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1633,6 +1633,13 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,
return NULL;
}
+/**
+ * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU domain
+ * @desc: MSI descriptor, will store the MSI page
+ * @msi_addr: MSI target address to be mapped
+ *
+ * Return: 0 on success or negative error code if the mapping failed.
+ */
int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
{
struct device *dev = msi_desc_to_dev(desc);
@@ -1661,8 +1668,12 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
return 0;
}
-void iommu_dma_compose_msi_msg(struct msi_desc *desc,
- struct msi_msg *msg)
+/**
+ * iommu_dma_compose_msi_msg() - Apply translation to an MSI message
+ * @desc: MSI descriptor prepared by iommu_dma_prepare_msi()
+ * @msg: MSI message containing target physical address
+ */
+void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
{
struct device *dev = msi_desc_to_dev(desc);
const struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index b249d4df899e..6e1ac330d7a6 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -13,7 +13,7 @@
#define pr_fmt(fmt) "GICv2m: " fmt
#include <linux/acpi.h>
-#include <linux/dma-iommu.h>
+#include <linux/iommu.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/kernel.h>
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 5ff09de6c48f..e7d8d4208ee6 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -11,9 +11,9 @@
#include <linux/cpu.h>
#include <linux/crash_dump.h>
#include <linux/delay.h>
-#include <linux/dma-iommu.h>
#include <linux/efi.h>
#include <linux/interrupt.h>
+#include <linux/iommu.h>
#include <linux/iopoll.h>
#include <linux/irqdomain.h>
#include <linux/list.h>
diff --git a/drivers/irqchip/irq-gic-v3-mbi.c b/drivers/irqchip/irq-gic-v3-mbi.c
index a2163d32f17d..e1efdec9e9ac 100644
--- a/drivers/irqchip/irq-gic-v3-mbi.c
+++ b/drivers/irqchip/irq-gic-v3-mbi.c
@@ -6,7 +6,7 @@
#define pr_fmt(fmt) "GICv3: " fmt
-#include <linux/dma-iommu.h>
+#include <linux/iommu.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/kernel.h>
diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
index b4927e425f7b..527c90e0920e 100644
--- a/drivers/irqchip/irq-ls-scfg-msi.c
+++ b/drivers/irqchip/irq-ls-scfg-msi.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/msi.h>
#include <linux/interrupt.h>
+#include <linux/iommu.h>
#include <linux/irq.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
@@ -18,7 +19,6 @@
#include <linux/of_pci.h>
#include <linux/of_platform.h>
#include <linux/spinlock.h>
-#include <linux/dma-iommu.h>
#define MSI_IRQS_PER_MSIR 32
#define MSI_MSIR_OFFSET 4
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index c766aa683110..e65861fdba7b 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -37,7 +37,6 @@
#include <linux/vfio.h>
#include <linux/workqueue.h>
#include <linux/notifier.h>
-#include <linux/dma-iommu.h>
#include <linux/irqdomain.h>
#include "vfio.h"
diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h
index 24607dc3c2ac..e83de4f1f3d6 100644
--- a/include/linux/dma-iommu.h
+++ b/include/linux/dma-iommu.h
@@ -15,27 +15,10 @@
/* Domain management interface for IOMMU drivers */
int iommu_get_dma_cookie(struct iommu_domain *domain);
-int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
void iommu_put_dma_cookie(struct iommu_domain *domain);
-/* Setup call for arch DMA mapping code */
-void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
int iommu_dma_init_fq(struct iommu_domain *domain);
-/* The DMA API isn't _quite_ the whole story, though... */
-/*
- * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU device
- *
- * The MSI page will be stored in @desc.
- *
- * Return: 0 on success otherwise an error describing the failure.
- */
-int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
-
-/* Update the MSI message if required. */
-void iommu_dma_compose_msi_msg(struct msi_desc *desc,
- struct msi_msg *msg);
-
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
@@ -46,15 +29,8 @@ extern bool iommu_dma_forcedac;
#else /* CONFIG_IOMMU_DMA */
struct iommu_domain;
-struct msi_desc;
-struct msi_msg;
struct device;
-static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
- u64 dma_limit)
-{
-}
-
static inline int iommu_dma_init_fq(struct iommu_domain *domain)
{
return -EINVAL;
@@ -65,26 +41,10 @@ static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
return -ENODEV;
}
-static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
-{
- return -ENODEV;
-}
-
static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
{
}
-static inline int iommu_dma_prepare_msi(struct msi_desc *desc,
- phys_addr_t msi_addr)
-{
- return 0;
-}
-
-static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc,
- struct msi_msg *msg)
-{
-}
-
static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
{
}
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 70393fbb57ed..79cb6eb560a8 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -1059,4 +1059,40 @@ void iommu_debugfs_setup(void);
static inline void iommu_debugfs_setup(void) {}
#endif
+#ifdef CONFIG_IOMMU_DMA
+#include <linux/msi.h>
+
+/* Setup call for arch DMA mapping code */
+void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
+
+int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
+
+int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
+void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg);
+
+#else /* CONFIG_IOMMU_DMA */
+
+struct msi_desc;
+struct msi_msg;
+
+static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit)
+{
+}
+
+static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
+{
+ return -ENODEV;
+}
+
+static inline int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
+{
+ return 0;
+}
+
+static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
+{
+}
+
+#endif /* CONFIG_IOMMU_DMA */
+
#endif /* __LINUX_IOMMU_H */
--
2.36.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h
2022-08-16 17:28 ` [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h Robin Murphy
@ 2022-08-17 12:19 ` Marc Zyngier
[not found] ` <YwNmosMGZdGtY3LX@infradead.org>
2022-09-02 18:16 ` Catalin Marinas
2 siblings, 0 replies; 12+ messages in thread
From: Marc Zyngier @ 2022-08-17 12:19 UTC (permalink / raw)
To: Robin Murphy
Cc: jean-philippe, kvm, iommu, catalin.marinas, joro, cohuck,
sw0312.kim, alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, tglx, will, linux-arm-kernel
On Tue, 16 Aug 2022 18:28:04 +0100,
Robin Murphy <robin.murphy@arm.com> wrote:
>
> The iommu-dma layer is now mostly encapsulated by iommu_dma_ops, with
> only a couple more public interfaces left pertaining to MSI integration.
> Since these depend on the main IOMMU API header anyway, move their
> declarations there, taking the opportunity to update the half-baked
> comments to proper kerneldoc along the way.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>
> Note that iommu_setup_dma_ops() should also become internal in a future
> phase of the great IOMMU API upheaval - for now as the last bit of true
> arch code glue I consider it more "necessarily exposed" than "public".
>
> arch/arm64/mm/dma-mapping.c | 2 +-
> drivers/iommu/dma-iommu.c | 15 ++++++++++--
> drivers/irqchip/irq-gic-v2m.c | 2 +-
> drivers/irqchip/irq-gic-v3-its.c | 2 +-
> drivers/irqchip/irq-gic-v3-mbi.c | 2 +-
> drivers/irqchip/irq-ls-scfg-msi.c | 2 +-
> drivers/vfio/vfio_iommu_type1.c | 1 -
> include/linux/dma-iommu.h | 40 -------------------------------
> include/linux/iommu.h | 36 ++++++++++++++++++++++++++++
> 9 files changed, 54 insertions(+), 48 deletions(-)
For the irqchip side:
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <YwNmosMGZdGtY3LX@infradead.org>]
* Re: [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h
[not found] ` <YwNmosMGZdGtY3LX@infradead.org>
@ 2022-08-22 12:55 ` Robin Murphy
0 siblings, 0 replies; 12+ messages in thread
From: Robin Murphy @ 2022-08-22 12:55 UTC (permalink / raw)
To: Christoph Hellwig
Cc: jean-philippe, kvm, iommu, catalin.marinas, joro, cohuck,
sw0312.kim, alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
On 2022-08-22 12:21, Christoph Hellwig wrote:
>> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
>> index 70393fbb57ed..79cb6eb560a8 100644
>> --- a/include/linux/iommu.h
>> +++ b/include/linux/iommu.h
>> @@ -1059,4 +1059,40 @@ void iommu_debugfs_setup(void);
>> static inline void iommu_debugfs_setup(void) {}
>> #endif
>>
>> +#ifdef CONFIG_IOMMU_DMA
>> +#include <linux/msi.h>
>
> I don't think msi.h is actually needed here.
>
> Just make the struct msi_desc and struct msi_msg forward declarations
> unconditional and we should be fine.
dma-iommu.c still needs to pick up msi.h for the actual definitions
somehow, so it seemed logical to keep things the same shape as before.
However I don't have a particularly strong preference either way.
Thanks,
Robin.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h
2022-08-16 17:28 ` [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h Robin Murphy
2022-08-17 12:19 ` Marc Zyngier
[not found] ` <YwNmosMGZdGtY3LX@infradead.org>
@ 2022-09-02 18:16 ` Catalin Marinas
2 siblings, 0 replies; 12+ messages in thread
From: Catalin Marinas @ 2022-09-02 18:16 UTC (permalink / raw)
To: Robin Murphy
Cc: jean-philippe, kvm, iommu, maz, joro, cohuck, sw0312.kim,
alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, tglx, will, linux-arm-kernel
On Tue, Aug 16, 2022 at 06:28:04PM +0100, Robin Murphy wrote:
> The iommu-dma layer is now mostly encapsulated by iommu_dma_ops, with
> only a couple more public interfaces left pertaining to MSI integration.
> Since these depend on the main IOMMU API header anyway, move their
> declarations there, taking the opportunity to update the half-baked
> comments to proper kerneldoc along the way.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>
> Note that iommu_setup_dma_ops() should also become internal in a future
> phase of the great IOMMU API upheaval - for now as the last bit of true
> arch code glue I consider it more "necessarily exposed" than "public".
>
> arch/arm64/mm/dma-mapping.c | 2 +-
And here:
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] iommu/dma: Make header private
2022-08-16 17:28 [PATCH 0/3] iommu/dma: Some housekeeping Robin Murphy
2022-08-16 17:28 ` [PATCH 1/3] iommu/dma: Clean up Kconfig Robin Murphy
2022-08-16 17:28 ` [PATCH 2/3] iommu/dma: Move public interfaces to linux/iommu.h Robin Murphy
@ 2022-08-16 17:28 ` Robin Murphy
2022-09-07 12:49 ` [PATCH 0/3] iommu/dma: Some housekeeping Joerg Roedel
3 siblings, 0 replies; 12+ messages in thread
From: Robin Murphy @ 2022-08-16 17:28 UTC (permalink / raw)
To: joro
Cc: jean-philippe, kvm, iommu, catalin.marinas, cohuck, sw0312.kim,
alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
Now that dma-iommu.h only contains internal interfaces, make it
private to the IOMMU subsytem.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
drivers/acpi/viot.c | 1 -
drivers/gpu/drm/exynos/exynos_drm_dma.c | 1 -
drivers/iommu/amd/iommu.c | 2 +-
drivers/iommu/apple-dart.c | 3 ++-
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
drivers/iommu/dma-iommu.c | 3 ++-
{include/linux => drivers/iommu}/dma-iommu.h | 17 +----------------
drivers/iommu/intel/iommu.c | 2 +-
drivers/iommu/iommu.c | 3 ++-
drivers/iommu/virtio-iommu.c | 3 ++-
11 files changed, 13 insertions(+), 26 deletions(-)
rename {include/linux => drivers/iommu}/dma-iommu.h (67%)
diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
index 6132092dab2a..ed752cbbe636 100644
--- a/drivers/acpi/viot.c
+++ b/drivers/acpi/viot.c
@@ -19,7 +19,6 @@
#define pr_fmt(fmt) "ACPI: VIOT: " fmt
#include <linux/acpi_viot.h>
-#include <linux/dma-iommu.h>
#include <linux/fwnode.h>
#include <linux/iommu.h>
#include <linux/list.h>
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c
index d819ee69dfb7..7012aa8ed4c6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dma.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c
@@ -4,7 +4,6 @@
// Author: Inki Dae <inki.dae@samsung.com>
// Author: Andrzej Hajda <a.hajda@samsung.com>
-#include <linux/dma-iommu.h>
#include <linux/dma-map-ops.h>
#include <linux/iommu.h>
#include <linux/platform_device.h>
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 2df1bfa884e5..b339bf13259d 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -18,7 +18,6 @@
#include <linux/scatterlist.h>
#include <linux/dma-map-ops.h>
#include <linux/dma-direct.h>
-#include <linux/dma-iommu.h>
#include <linux/iommu-helper.h>
#include <linux/delay.h>
#include <linux/amd-iommu.h>
@@ -40,6 +39,7 @@
#include <asm/dma.h>
#include "amd_iommu.h"
+#include "../dma-iommu.h"
#include "../irq_remapping.h"
#define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28))
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index ed6b5fa538af..716f34a768b1 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -15,7 +15,6 @@
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/dev_printk.h>
-#include <linux/dma-iommu.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/interrupt.h>
@@ -33,6 +32,8 @@
#include <linux/swab.h>
#include <linux/types.h>
+#include "dma-iommu.h"
+
#define DART_MAX_STREAMS 16
#define DART_MAX_TTBR 4
#define MAX_DARTS_PER_DEVICE 2
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index c13b46a15dcb..f1785e518a90 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -14,7 +14,6 @@
#include <linux/bitops.h>
#include <linux/crash_dump.h>
#include <linux/delay.h>
-#include <linux/dma-iommu.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/io-pgtable.h>
@@ -29,6 +28,7 @@
#include <linux/platform_device.h>
#include "arm-smmu-v3.h"
+#include "../../dma-iommu.h"
#include "../../iommu-sva-lib.h"
static bool disable_bypass = true;
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 2cece34f4824..c30f82c19240 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -21,7 +21,6 @@
#include <linux/acpi_iort.h>
#include <linux/bitfield.h>
#include <linux/delay.h>
-#include <linux/dma-iommu.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/interrupt.h>
@@ -40,6 +39,7 @@
#include <linux/fsl/mc.h>
#include "arm-smmu.h"
+#include "../../dma-iommu.h"
/*
* Apparently, some Qualcomm arm64 platforms which appear to expose their SMMU
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 6809b33ac9df..9297b741f5e8 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -13,7 +13,6 @@
#include <linux/crash_dump.h>
#include <linux/device.h>
#include <linux/dma-direct.h>
-#include <linux/dma-iommu.h>
#include <linux/dma-map-ops.h>
#include <linux/gfp.h>
#include <linux/huge_mm.h>
@@ -30,6 +29,8 @@
#include <linux/swiotlb.h>
#include <linux/vmalloc.h>
+#include "dma-iommu.h"
+
struct iommu_dma_msi_page {
struct list_head list;
dma_addr_t iova;
diff --git a/include/linux/dma-iommu.h b/drivers/iommu/dma-iommu.h
similarity index 67%
rename from include/linux/dma-iommu.h
rename to drivers/iommu/dma-iommu.h
index e83de4f1f3d6..c6d0235feb6e 100644
--- a/include/linux/dma-iommu.h
+++ b/drivers/iommu/dma-iommu.h
@@ -5,15 +5,10 @@
#ifndef __DMA_IOMMU_H
#define __DMA_IOMMU_H
-#include <linux/errno.h>
-#include <linux/types.h>
+#include <linux/iommu.h>
#ifdef CONFIG_IOMMU_DMA
-#include <linux/dma-mapping.h>
-#include <linux/iommu.h>
-#include <linux/msi.h>
-/* Domain management interface for IOMMU drivers */
int iommu_get_dma_cookie(struct iommu_domain *domain);
void iommu_put_dma_cookie(struct iommu_domain *domain);
@@ -21,16 +16,10 @@ int iommu_dma_init_fq(struct iommu_domain *domain);
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
-void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
- struct iommu_domain *domain);
-
extern bool iommu_dma_forcedac;
#else /* CONFIG_IOMMU_DMA */
-struct iommu_domain;
-struct device;
-
static inline int iommu_dma_init_fq(struct iommu_domain *domain)
{
return -EINVAL;
@@ -45,9 +34,5 @@ static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
{
}
-static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
-{
-}
-
#endif /* CONFIG_IOMMU_DMA */
#endif /* __DMA_IOMMU_H */
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 9441c070c811..4375d1ee9389 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -15,7 +15,6 @@
#include <linux/crash_dump.h>
#include <linux/dma-direct.h>
-#include <linux/dma-iommu.h>
#include <linux/dmi.h>
#include <linux/intel-svm.h>
#include <linux/memory.h>
@@ -26,6 +25,7 @@
#include <linux/tboot.h>
#include "iommu.h"
+#include "../dma-iommu.h"
#include "../irq_remapping.h"
#include "../iommu-sva-lib.h"
#include "pasid.h"
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 07eda7c41aee..862d4e73efd2 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -8,7 +8,6 @@
#include <linux/amba/bus.h>
#include <linux/device.h>
-#include <linux/dma-iommu.h>
#include <linux/kernel.h>
#include <linux/bits.h>
#include <linux/bug.h>
@@ -30,6 +29,8 @@
#include <linux/cc_platform.h>
#include <trace/events/iommu.h>
+#include "dma-iommu.h"
+
static struct kset *iommu_group_kset;
static DEFINE_IDA(iommu_group_ida);
diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index bdae3939260a..e355cb5d1e5b 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -8,7 +8,6 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/delay.h>
-#include <linux/dma-iommu.h>
#include <linux/dma-map-ops.h>
#include <linux/freezer.h>
#include <linux/interval_tree.h>
@@ -23,6 +22,8 @@
#include <uapi/linux/virtio_iommu.h>
+#include "dma-iommu.h"
+
#define MSI_IOVA_BASE 0x8000000
#define MSI_IOVA_LENGTH 0x100000
--
2.36.1.dirty
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 0/3] iommu/dma: Some housekeeping
2022-08-16 17:28 [PATCH 0/3] iommu/dma: Some housekeeping Robin Murphy
` (2 preceding siblings ...)
2022-08-16 17:28 ` [PATCH 3/3] iommu/dma: Make header private Robin Murphy
@ 2022-09-07 12:49 ` Joerg Roedel
3 siblings, 0 replies; 12+ messages in thread
From: Joerg Roedel @ 2022-09-07 12:49 UTC (permalink / raw)
To: Robin Murphy
Cc: jean-philippe, kvm, iommu, catalin.marinas, cohuck, sw0312.kim,
alex.williamson, dri-devel, linux-kernel, linux-acpi,
kyungmin.park, maz, tglx, will, linux-arm-kernel
On Tue, Aug 16, 2022 at 06:28:02PM +0100, Robin Murphy wrote:
> Robin Murphy (3):
> iommu/dma: Clean up Kconfig
> iommu/dma: Move public interfaces to linux/iommu.h
> iommu/dma: Make header private
Applied, thanks.
> include/linux/dma-iommu.h | 93 ---------------------
Squashed the updated file path in MAINTAINERS into the last patch.
^ permalink raw reply [flat|nested] 12+ messages in thread