lkml.org 
[lkml]   [2017]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 5/5] iommu/dma: Add iommu_dma_cleanup()
Date
In case of loadable modules using dma-iommu helpers, it makes sense to
drop the reference to the iova cache on module exit. Add a helper called
iommu_dma_cleanup() that undoes the effects of iommu_dma_init(), so that
modules can be unloaded cleanly.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
---
drivers/iommu/dma-iommu.c | 6 ++++++
include/linux/dma-iommu.h | 6 ++++++
2 files changed, 12 insertions(+)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 7cdeaf930106..51afa18a5de1 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -82,6 +82,12 @@ int iommu_dma_init(void)
}
EXPORT_SYMBOL(iommu_dma_init);

+void iommu_dma_cleanup(void)
+{
+ iova_cache_put();
+}
+EXPORT_SYMBOL(iommu_dma_cleanup);
+
/**
* iommu_get_dma_cookie - Acquire DMA-API resources for a domain
* @domain: IOMMU domain to prepare for DMA-API usage
diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h
index 92f20832fd28..b12d9207a87a 100644
--- a/include/linux/dma-iommu.h
+++ b/include/linux/dma-iommu.h
@@ -24,7 +24,9 @@
#include <linux/iommu.h>
#include <linux/msi.h>

+/* Framework initialization - reference counted */
int iommu_dma_init(void);
+void iommu_dma_cleanup(void);

/* Domain management interface for IOMMU drivers */
int iommu_get_dma_cookie(struct iommu_domain *domain);
@@ -85,6 +87,10 @@ static inline int iommu_dma_init(void)
return 0;
}

+static inline void iommu_dma_cleanup(void)
+{
+}
+
static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
{
return -ENODEV;
--
2.13.2.725.g09c95d1e9-goog
\
 
 \ /
  Last update: 2017-07-05 09:13    [W:0.096 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site