From: eric.auger@linaro.org (Eric Auger)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v4 06/14] dma-reserved-iommu: iommu_unmap_reserved
Date: Fri, 26 Feb 2016 17:35:46 +0000 [thread overview]
Message-ID: <1456508154-2253-7-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1456508154-2253-1-git-send-email-eric.auger@linaro.org>
Introduce a new function whose role is to unmap all allocated
reserved IOVAs and free the reserved iova domain
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
v3 -> v4:
- previously "iommu/arm-smmu: relinquish reserved resources on
domain deletion"
---
drivers/iommu/dma-reserved-iommu.c | 27 ++++++++++++++++++++++++---
include/linux/dma-reserved-iommu.h | 7 +++++++
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/dma-reserved-iommu.c b/drivers/iommu/dma-reserved-iommu.c
index 537c83e..7217bb7 100644
--- a/drivers/iommu/dma-reserved-iommu.c
+++ b/drivers/iommu/dma-reserved-iommu.c
@@ -116,7 +116,7 @@ unlock:
}
EXPORT_SYMBOL_GPL(iommu_alloc_reserved_iova_domain);
-void iommu_free_reserved_iova_domain(struct iommu_domain *domain)
+void __iommu_free_reserved_iova_domain(struct iommu_domain *domain)
{
struct iova_domain *iovad =
(struct iova_domain *)domain->reserved_iova_cookie;
@@ -124,11 +124,14 @@ void iommu_free_reserved_iova_domain(struct iommu_domain *domain)
if (!iovad)
return;
- mutex_lock(&domain->reserved_mutex);
-
put_iova_domain(iovad);
kfree(iovad);
+}
+void iommu_free_reserved_iova_domain(struct iommu_domain *domain)
+{
+ mutex_lock(&domain->reserved_mutex);
+ __iommu_free_reserved_iova_domain(domain);
mutex_unlock(&domain->reserved_mutex);
}
EXPORT_SYMBOL_GPL(iommu_free_reserved_iova_domain);
@@ -245,5 +248,23 @@ unlock:
}
EXPORT_SYMBOL_GPL(iommu_put_single_reserved);
+void iommu_unmap_reserved(struct iommu_domain *domain)
+{
+ struct rb_node *node;
+
+ mutex_lock(&domain->reserved_mutex);
+ while ((node = rb_first(&domain->reserved_binding_list))) {
+ struct iommu_reserved_binding *b =
+ rb_entry(node, struct iommu_reserved_binding, node);
+
+ while (!kref_put(&b->kref, reserved_binding_release))
+ ;
+ }
+ domain->reserved_binding_list = RB_ROOT;
+ __iommu_free_reserved_iova_domain(domain);
+ mutex_unlock(&domain->reserved_mutex);
+}
+EXPORT_SYMBOL_GPL(iommu_unmap_reserved);
+
diff --git a/include/linux/dma-reserved-iommu.h b/include/linux/dma-reserved-iommu.h
index 71ec800..766c58c 100644
--- a/include/linux/dma-reserved-iommu.h
+++ b/include/linux/dma-reserved-iommu.h
@@ -66,6 +66,13 @@ int iommu_get_single_reserved(struct iommu_domain *domain,
*/
void iommu_put_single_reserved(struct iommu_domain *domain, dma_addr_t iova);
+/**
+ * iommu_unmap_reserved: unmap & destroy the reserved iova bindings
+ *
+ * @domain: iommu domain handle
+ */
+void iommu_unmap_reserved(struct iommu_domain *domain);
+
#endif /* CONFIG_IOMMU_DMA_RESERVED */
#endif /* __KERNEL__ */
#endif /* __DMA_RESERVED_IOMMU_H */
--
1.9.1
next prev parent reply other threads:[~2016-02-26 17:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 17:35 [RFC v4 00/14] KVM PCIe/MSI passthrough on ARM/ARM64 Eric Auger
2016-02-26 17:35 ` [RFC v4 01/14] iommu: Add DOMAIN_ATTR_MSI_MAPPING attribute Eric Auger
2016-02-26 17:35 ` [RFC v4 02/14] iommu: introduce a reserved iova cookie Eric Auger
2016-02-26 17:35 ` [RFC v4 03/14] dma-reserved-iommu: alloc/free_reserved_iova_domain Eric Auger
2016-02-26 17:35 ` [RFC v4 04/14] dma-reserved-iommu: reserved binding rb-tree and helpers Eric Auger
2016-02-26 17:35 ` [RFC v4 05/14] dma-reserved-iommu: iommu_get/put_single_reserved Eric Auger
2016-02-26 17:35 ` Eric Auger [this message]
2016-02-26 17:35 ` [RFC v4 07/14] msi: Add a new MSI_FLAG_IRQ_REMAPPING flag Eric Auger
2016-02-26 18:06 ` Thomas Gleixner
2016-02-29 15:25 ` Eric Auger
2016-02-26 17:35 ` [RFC v4 08/14] msi: export msi_get_domain_info Eric Auger
2016-02-26 17:35 ` [RFC v4 09/14] msi: IOMMU map the doorbell address when needed Eric Auger
2016-02-26 18:19 ` Thomas Gleixner
2016-02-29 15:27 ` Eric Auger
2016-02-26 17:35 ` [RFC v4 10/14] vfio: introduce VFIO_IOVA_RESERVED vfio_dma type Eric Auger
2016-02-26 17:35 ` [RFC v4 11/14] vfio: allow the user to register reserved iova range for MSI mapping Eric Auger
2016-02-26 17:35 ` [RFC v4 12/14] vfio/type1: also check IRQ remapping capability at msi domain Eric Auger
2016-02-26 17:35 ` [RFC v4 13/14] iommu/arm-smmu: do not advertise IOMMU_CAP_INTR_REMAP Eric Auger
2016-02-26 17:35 ` [RFC v4 14/14] vfio/type1: return MSI mapping requirements with VFIO_IOMMU_GET_INFO Eric Auger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456508154-2253-7-git-send-email-eric.auger@linaro.org \
--to=eric.auger@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).