Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <robin.murphy@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/9cd99738f52094e6bed44bfee03fa4f288d20695.1660668998.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Robin Murphy and committed by
Joerg Roedel
fa49364c de9f8a91

+54 -48
+1 -1
arch/arm64/mm/dma-mapping.c
··· 7 7 #include <linux/gfp.h> 8 8 #include <linux/cache.h> 9 9 #include <linux/dma-map-ops.h> 10 - #include <linux/dma-iommu.h> 10 + #include <linux/iommu.h> 11 11 #include <xen/xen.h> 12 12 13 13 #include <asm/cacheflush.h>
+13 -2
drivers/iommu/dma-iommu.c
··· 1633 1633 return NULL; 1634 1634 } 1635 1635 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 + */ 1636 1643 int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr) 1637 1644 { 1638 1645 struct device *dev = msi_desc_to_dev(desc); ··· 1668 1661 return 0; 1669 1662 } 1670 1663 1671 - void iommu_dma_compose_msi_msg(struct msi_desc *desc, 1672 - struct msi_msg *msg) 1664 + /** 1665 + * iommu_dma_compose_msi_msg() - Apply translation to an MSI message 1666 + * @desc: MSI descriptor prepared by iommu_dma_prepare_msi() 1667 + * @msg: MSI message containing target physical address 1668 + */ 1669 + void iommu_dma_compose_msi_msg(struct msi_desc *desc, struct msi_msg *msg) 1673 1670 { 1674 1671 struct device *dev = msi_desc_to_dev(desc); 1675 1672 const struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
+1 -1
drivers/irqchip/irq-gic-v2m.c
··· 13 13 #define pr_fmt(fmt) "GICv2m: " fmt 14 14 15 15 #include <linux/acpi.h> 16 - #include <linux/dma-iommu.h> 16 + #include <linux/iommu.h> 17 17 #include <linux/irq.h> 18 18 #include <linux/irqdomain.h> 19 19 #include <linux/kernel.h>
+1 -1
drivers/irqchip/irq-gic-v3-its.c
··· 11 11 #include <linux/cpu.h> 12 12 #include <linux/crash_dump.h> 13 13 #include <linux/delay.h> 14 - #include <linux/dma-iommu.h> 15 14 #include <linux/efi.h> 16 15 #include <linux/interrupt.h> 16 + #include <linux/iommu.h> 17 17 #include <linux/iopoll.h> 18 18 #include <linux/irqdomain.h> 19 19 #include <linux/list.h>
+1 -1
drivers/irqchip/irq-gic-v3-mbi.c
··· 6 6 7 7 #define pr_fmt(fmt) "GICv3: " fmt 8 8 9 - #include <linux/dma-iommu.h> 9 + #include <linux/iommu.h> 10 10 #include <linux/irq.h> 11 11 #include <linux/irqdomain.h> 12 12 #include <linux/kernel.h>
+1 -1
drivers/irqchip/irq-ls-scfg-msi.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/msi.h> 13 13 #include <linux/interrupt.h> 14 + #include <linux/iommu.h> 14 15 #include <linux/irq.h> 15 16 #include <linux/irqchip/chained_irq.h> 16 17 #include <linux/irqdomain.h> ··· 19 18 #include <linux/of_pci.h> 20 19 #include <linux/of_platform.h> 21 20 #include <linux/spinlock.h> 22 - #include <linux/dma-iommu.h> 23 21 24 22 #define MSI_IRQS_PER_MSIR 32 25 23 #define MSI_MSIR_OFFSET 4
-1
drivers/vfio/vfio_iommu_type1.c
··· 37 37 #include <linux/vfio.h> 38 38 #include <linux/workqueue.h> 39 39 #include <linux/notifier.h> 40 - #include <linux/dma-iommu.h> 41 40 #include <linux/irqdomain.h> 42 41 #include "vfio.h" 43 42
-40
include/linux/dma-iommu.h
··· 15 15 16 16 /* Domain management interface for IOMMU drivers */ 17 17 int iommu_get_dma_cookie(struct iommu_domain *domain); 18 - int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base); 19 18 void iommu_put_dma_cookie(struct iommu_domain *domain); 20 19 21 - /* Setup call for arch DMA mapping code */ 22 - void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit); 23 20 int iommu_dma_init_fq(struct iommu_domain *domain); 24 - 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 21 39 22 void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list); 40 23 ··· 29 46 #else /* CONFIG_IOMMU_DMA */ 30 47 31 48 struct iommu_domain; 32 - struct msi_desc; 33 - struct msi_msg; 34 49 struct device; 35 - 36 - static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base, 37 - u64 dma_limit) 38 - { 39 - } 40 50 41 51 static inline int iommu_dma_init_fq(struct iommu_domain *domain) 42 52 { ··· 41 65 return -ENODEV; 42 66 } 43 67 44 - static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base) 45 - { 46 - return -ENODEV; 47 - } 48 - 49 68 static inline void iommu_put_dma_cookie(struct iommu_domain *domain) 50 - { 51 - } 52 - 53 - static inline int iommu_dma_prepare_msi(struct msi_desc *desc, 54 - phys_addr_t msi_addr) 55 - { 56 - return 0; 57 - } 58 - 59 - static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc, 60 - struct msi_msg *msg) 61 69 { 62 70 } 63 71
+36
include/linux/iommu.h
··· 1063 1063 static inline void iommu_debugfs_setup(void) {} 1064 1064 #endif 1065 1065 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 + 1066 1102 #endif /* __LINUX_IOMMU_H */