From: Xiang Chen chenxiang66@hisilicon.com
Add a function to free all rcached iovas including cpu rcache iovas and global rcache iovas, and export it.
Signed-off-by: Xiang Chen chenxiang66@hisilicon.com --- drivers/iommu/iova.c | 11 +++++++++++ include/linux/iova.h | 5 +++++ 2 files changed, 16 insertions(+)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index b7ecd5b..f595867 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -1077,5 +1077,16 @@ static void free_global_cached_iovas(struct iova_domain *iovad) spin_unlock_irqrestore(&rcache->lock, flags); } } + +void free_rcache_cached_iovas(struct iova_domain *iovad) +{ + unsigned int cpu; + + for_each_online_cpu(cpu) + free_cpu_cached_iovas(cpu, iovad); + free_global_cached_iovas(iovad); +} +EXPORT_SYMBOL_GPL(free_rcache_cached_iovas); + MODULE_AUTHOR("Anil S Keshavamurthy anil.s.keshavamurthy@intel.com"); MODULE_LICENSE("GPL"); diff --git a/include/linux/iova.h b/include/linux/iova.h index 71d8a2d..7006d9f 100644 --- a/include/linux/iova.h +++ b/include/linux/iova.h @@ -157,6 +157,7 @@ int init_iova_flush_queue(struct iova_domain *iovad, iova_flush_cb flush_cb, iova_entry_dtor entry_dtor); struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn); void put_iova_domain(struct iova_domain *iovad); +void free_rcache_cached_iovas(struct iova_domain *iovad); #else static inline int iova_cache_get(void) { @@ -233,6 +234,10 @@ static inline void put_iova_domain(struct iova_domain *iovad) { }
+static inline void free_rcache_cached_iovas(struct iova_domain *iovad) +{ +} + #endif
#endif