summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi Doyu <hdoyu@nvidia.com>2013-01-24 14:49:32 +0200
committerHarshada Kale <hkale@nvidia.com>2013-06-10 03:51:38 -0700
commit0fb92b140130138427701ee5bd6600e1b41a1cc9 (patch)
tree8167778ca44d83a9c08a5967aef82eb2bcbcc139
parentab30491df5386eb2873b53bb8bcfae83e91b2cb6 (diff)
ARM: dma-mapping: Add arm_iommu_detach_device()
Need the counter part of arm_iommu_attach_device(). bug 1286500 Change-Id: I7663075ba56e0cf7a0762927247bfb5b884cd750 (cherry picked from commit 96425941ba18e0aa68e22cdd476bd3e521aa8256) Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com> Reviewed-on: http://git-master/r/234133 Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
-rw-r--r--arch/arm/include/asm/dma-iommu.h1
-rw-r--r--arch/arm/mm/dma-mapping.c25
2 files changed, 26 insertions, 0 deletions
diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
index 799b09409fad..af1ac4ed264f 100644
--- a/arch/arm/include/asm/dma-iommu.h
+++ b/arch/arm/include/asm/dma-iommu.h
@@ -29,6 +29,7 @@ void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping);
int arm_iommu_attach_device(struct device *dev,
struct dma_iommu_mapping *mapping);
+void arm_iommu_detach_device(struct device *dev);
#endif /* __KERNEL__ */
#endif
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 2d3172b0aecd..9dfe4798a330 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1968,4 +1968,29 @@ int arm_iommu_attach_device(struct device *dev,
return 0;
}
+/**
+ * arm_iommu_detach_device
+ * @dev: valid struct device pointer
+ *
+ * Detaches the provided device from a previously attached map.
+ * This voids the dma operations (dma_map_ops pointer)
+ */
+void arm_iommu_detach_device(struct device *dev)
+{
+ struct dma_iommu_mapping *mapping;
+
+ mapping = to_dma_iommu_mapping(dev);
+ if (!mapping) {
+ dev_warn(dev, "Not attached\n");
+ return;
+ }
+
+ iommu_detach_device(mapping->domain, dev);
+ kref_put(&mapping->kref, release_iommu_mapping);
+ mapping = NULL;
+ set_dma_ops(dev, NULL);
+
+ pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
+}
+
#endif