Skip to content

Commit

Permalink
iommu: Add iommu_dma_free_cpu_cached_iovas()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pippy360 authored and willdeacon committed Nov 25, 2020
1 parent 2a2b8ea commit 230309d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/iommu/dma-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions include/linux/dma-iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */

0 comments on commit 230309d

Please sign in to comment.