aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHiroshi Doyu <hdoyu@nvidia.com>2013-01-24 15:16:57 +0200
committerMarek Szyprowski <m.szyprowski@samsung.com>2013-02-25 15:30:41 +0100
commit6fe367580339a3adf77273d4366652665319bdeb (patch)
tree211fd3d066c016afaac35d1802d7cd09b64a1f73 /arch
parentARM: dma-mapping: Add macro to_dma_iommu_mapping() (diff)
downloadlinux-dev-6fe367580339a3adf77273d4366652665319bdeb.tar.xz
linux-dev-6fe367580339a3adf77273d4366652665319bdeb.zip
ARM: dma-mapping: Add arm_iommu_detach_device()
A counter part of arm_iommu_attach_device(). Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'arch')
-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 666d8a8c3a2b..a8c56acc8c98 100644
--- a/arch/arm/include/asm/dma-iommu.h
+++ b/arch/arm/include/asm/dma-iommu.h
@@ -30,6 +30,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 d91c4880f559..6563e3872659 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1848,4 +1848,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