]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
iommu: Add iommu_dma_free_cpu_cached_iovas()
authorTom Murphy <murphyt7@tcd.ie>
Tue, 24 Nov 2020 08:20:52 +0000 (16:20 +0800)
committerWill Deacon <will@kernel.org>
Wed, 25 Nov 2020 12:03:48 +0000 (12:03 +0000)
Add a iommu_dma_free_cpu_cached_iovas function to allow drivers which
use the dma-iommu ops to free cached cpu iovas.

Signed-off-by: Tom Murphy <murphyt7@tcd.ie>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: Logan Gunthorpe <logang@deltatee.com>
Link: https://lore.kernel.org/r/20201124082057.2614359-3-baolu.lu@linux.intel.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/dma-iommu.c
include/linux/dma-iommu.h

index 9c827a4d22072f706f19957fe1f5043df9abe423..de521e22bafb03c31c1fa1793ae8daccee8dfcc9 100644 (file)
@@ -49,6 +49,15 @@ struct iommu_dma_cookie {
        struct iommu_domain             *fq_domain;
 };
 
+void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
+               struct iommu_domain *domain)
+{
+       struct iommu_dma_cookie *cookie = domain->iova_cookie;
+       struct iova_domain *iovad = &cookie->iovad;
+
+       free_cpu_cached_iovas(cpu, iovad);
+}
+
 static void iommu_dma_entry_dtor(unsigned long data)
 {
        struct page *freelist = (struct page *)data;
index 2112f21f73d82bd7ced1bbfb4b58c91b1cc5ab44..706b68d1359beda8d0bebae3eb718e2bf418c26a 100644 (file)
@@ -37,6 +37,9 @@ void iommu_dma_compose_msi_msg(struct msi_desc *desc,
 
 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);
+
 #else /* CONFIG_IOMMU_DMA */
 
 struct iommu_domain;
@@ -78,5 +81,10 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he
 {
 }
 
+static inline void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
+               struct iommu_domain *domain)
+{
+}
+
 #endif /* CONFIG_IOMMU_DMA */
 #endif /* __DMA_IOMMU_H */