Skip to content

Commit fa49364

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/dma: Move public interfaces to linux/iommu.h
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 <[email protected]> Acked-by: Catalin Marinas <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/9cd99738f52094e6bed44bfee03fa4f288d20695.1660668998.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent de9f8a9 commit fa49364

File tree

9 files changed

+54
-48
lines changed

9 files changed

+54
-48
lines changed

arch/arm64/mm/dma-mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/gfp.h>
88
#include <linux/cache.h>
99
#include <linux/dma-map-ops.h>
10-
#include <linux/dma-iommu.h>
10+
#include <linux/iommu.h>
1111
#include <xen/xen.h>
1212

1313
#include <asm/cacheflush.h>

drivers/iommu/dma-iommu.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,13 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,
16331633
return NULL;
16341634
}
16351635

1636+
/**
1637+
* iommu_dma_prepare_msi() - Map the MSI page in the IOMMU domain
1638+
* @desc: MSI descriptor, will store the MSI page
1639+
* @msi_addr: MSI target address to be mapped
1640+
*
1641+
* Return: 0 on success or negative error code if the mapping failed.
1642+
*/
16361643
int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
16371644
{
16381645
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)
16611668
return 0;
16621669
}
16631670

1664-
void iommu_dma_compose_msi_msg(struct msi_desc *desc,
1665-
struct msi_msg *msg)
1671+
/**
1672+
* iommu_dma_compose_msi_msg() - Apply translation to an MSI message
1673+
* @desc: MSI descriptor prepared by iommu_dma_prepare_msi()
1674+
* @msg: MSI message containing target physical address
1675+
*/
1676+
void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
16661677
{
16671678
struct device *dev = msi_desc_to_dev(desc);
16681679
const struct iommu_domain *domain = iommu_get_domain_for_dev(dev);

drivers/irqchip/irq-gic-v2m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define pr_fmt(fmt) "GICv2m: " fmt
1414

1515
#include <linux/acpi.h>
16-
#include <linux/dma-iommu.h>
16+
#include <linux/iommu.h>
1717
#include <linux/irq.h>
1818
#include <linux/irqdomain.h>
1919
#include <linux/kernel.h>

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <linux/cpu.h>
1212
#include <linux/crash_dump.h>
1313
#include <linux/delay.h>
14-
#include <linux/dma-iommu.h>
1514
#include <linux/efi.h>
1615
#include <linux/interrupt.h>
16+
#include <linux/iommu.h>
1717
#include <linux/iopoll.h>
1818
#include <linux/irqdomain.h>
1919
#include <linux/list.h>

drivers/irqchip/irq-gic-v3-mbi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#define pr_fmt(fmt) "GICv3: " fmt
88

9-
#include <linux/dma-iommu.h>
9+
#include <linux/iommu.h>
1010
#include <linux/irq.h>
1111
#include <linux/irqdomain.h>
1212
#include <linux/kernel.h>

drivers/irqchip/irq-ls-scfg-msi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
#include <linux/module.h>
1212
#include <linux/msi.h>
1313
#include <linux/interrupt.h>
14+
#include <linux/iommu.h>
1415
#include <linux/irq.h>
1516
#include <linux/irqchip/chained_irq.h>
1617
#include <linux/irqdomain.h>
1718
#include <linux/of_irq.h>
1819
#include <linux/of_pci.h>
1920
#include <linux/of_platform.h>
2021
#include <linux/spinlock.h>
21-
#include <linux/dma-iommu.h>
2222

2323
#define MSI_IRQS_PER_MSIR 32
2424
#define MSI_MSIR_OFFSET 4

drivers/vfio/vfio_iommu_type1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <linux/vfio.h>
3838
#include <linux/workqueue.h>
3939
#include <linux/notifier.h>
40-
#include <linux/dma-iommu.h>
4140
#include <linux/irqdomain.h>
4241
#include "vfio.h"
4342

include/linux/dma-iommu.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,10 @@
1515

1616
/* Domain management interface for IOMMU drivers */
1717
int iommu_get_dma_cookie(struct iommu_domain *domain);
18-
int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
1918
void iommu_put_dma_cookie(struct iommu_domain *domain);
2019

21-
/* Setup call for arch DMA mapping code */
22-
void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
2320
int iommu_dma_init_fq(struct iommu_domain *domain);
2421

25-
/* The DMA API isn't _quite_ the whole story, though... */
26-
/*
27-
* iommu_dma_prepare_msi() - Map the MSI page in the IOMMU device
28-
*
29-
* The MSI page will be stored in @desc.
30-
*
31-
* Return: 0 on success otherwise an error describing the failure.
32-
*/
33-
int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
34-
35-
/* Update the MSI message if required. */
36-
void iommu_dma_compose_msi_msg(struct msi_desc *desc,
37-
struct msi_msg *msg);
38-
3922
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
4023

4124
void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
@@ -46,15 +29,8 @@ extern bool iommu_dma_forcedac;
4629
#else /* CONFIG_IOMMU_DMA */
4730

4831
struct iommu_domain;
49-
struct msi_desc;
50-
struct msi_msg;
5132
struct device;
5233

53-
static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
54-
u64 dma_limit)
55-
{
56-
}
57-
5834
static inline int iommu_dma_init_fq(struct iommu_domain *domain)
5935
{
6036
return -EINVAL;
@@ -65,26 +41,10 @@ static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
6541
return -ENODEV;
6642
}
6743

68-
static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
69-
{
70-
return -ENODEV;
71-
}
72-
7344
static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
7445
{
7546
}
7647

77-
static inline int iommu_dma_prepare_msi(struct msi_desc *desc,
78-
phys_addr_t msi_addr)
79-
{
80-
return 0;
81-
}
82-
83-
static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc,
84-
struct msi_msg *msg)
85-
{
86-
}
87-
8848
static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
8949
{
9050
}

include/linux/iommu.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,4 +1063,40 @@ void iommu_debugfs_setup(void);
10631063
static inline void iommu_debugfs_setup(void) {}
10641064
#endif
10651065

1066+
#ifdef CONFIG_IOMMU_DMA
1067+
#include <linux/msi.h>
1068+
1069+
/* Setup call for arch DMA mapping code */
1070+
void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
1071+
1072+
int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
1073+
1074+
int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
1075+
void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg);
1076+
1077+
#else /* CONFIG_IOMMU_DMA */
1078+
1079+
struct msi_desc;
1080+
struct msi_msg;
1081+
1082+
static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit)
1083+
{
1084+
}
1085+
1086+
static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
1087+
{
1088+
return -ENODEV;
1089+
}
1090+
1091+
static inline int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
1092+
{
1093+
return 0;
1094+
}
1095+
1096+
static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
1097+
{
1098+
}
1099+
1100+
#endif /* CONFIG_IOMMU_DMA */
1101+
10661102
#endif /* __LINUX_IOMMU_H */

0 commit comments

Comments
 (0)