Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752553AbdGEHMw (ORCPT ); Wed, 5 Jul 2017 03:12:52 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:33194 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975AbdGEHMt (ORCPT ); Wed, 5 Jul 2017 03:12:49 -0400 From: Tomasz Figa To: iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Greg Kroah-Hartman , Joerg Roedel , Will Deacon , Vineet Gupta , Hans-Christian Noren Egtvedt , Mitchel Humpherys , Krzysztof Kozlowski , Arnd Bergmann , Tomasz Figa Subject: [RFC PATCH 5/5] iommu/dma: Add iommu_dma_cleanup() Date: Wed, 5 Jul 2017 16:12:15 +0900 Message-Id: <20170705071215.17603-6-tfiga@chromium.org> X-Mailer: git-send-email 2.13.2.725.g09c95d1e9-goog In-Reply-To: <20170705071215.17603-1-tfiga@chromium.org> References: <20170705071215.17603-1-tfiga@chromium.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1596 Lines: 55 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 --- 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 #include +/* 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