Skip to content

Commit 230309d

Browse files
pippy360willdeacon
authored andcommitted
iommu: Add iommu_dma_free_cpu_cached_iovas()
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 <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Tested-by: Logan Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 2a2b8ea commit 230309d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ struct iommu_dma_cookie {
4949
struct iommu_domain *fq_domain;
5050
};
5151

52+
void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
53+
struct iommu_domain *domain)
54+
{
55+
struct iommu_dma_cookie *cookie = domain->iova_cookie;
56+
struct iova_domain *iovad = &cookie->iovad;
57+
58+
free_cpu_cached_iovas(cpu, iovad);
59+
}
60+
5261
static void iommu_dma_entry_dtor(unsigned long data)
5362
{
5463
struct page *freelist = (struct page *)data;

include/linux/dma-iommu.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ void iommu_dma_compose_msi_msg(struct msi_desc *desc,
3737

3838
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
3939

40+
void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
41+
struct iommu_domain *domain);
42+
4043
#else /* CONFIG_IOMMU_DMA */
4144

4245
struct iommu_domain;
@@ -78,5 +81,10 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he
7881
{
7982
}
8083

84+
static inline void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
85+
struct iommu_domain *domain)
86+
{
87+
}
88+
8189
#endif /* CONFIG_IOMMU_DMA */
8290
#endif /* __DMA_IOMMU_H */

0 commit comments

Comments
 (0)