]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: dma-mapping: Add arm_iommu_detach_device()
authorHiroshi Doyu <hdoyu@nvidia.com>
Thu, 24 Jan 2013 13:16:57 +0000 (15:16 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 6 Feb 2013 07:48:18 +0000 (08:48 +0100)
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>
arch/arm/include/asm/dma-iommu.h
arch/arm/mm/dma-mapping.c

index 666d8a8c3a2b0664992e6169e92e8e00dce23897..a8c56acc8c985ba54b917f08c2956f3d26a1cca1 100644 (file)
@@ -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
index 2e8c98673d170ca93522dacb6d9aed91c8db95cc..d79c618a7fac4c24d3c89e91086debb57f327ff2 100644 (file)
@@ -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