From: Hiroshi Doyu Date: Thu, 24 Jan 2013 13:16:57 +0000 (+0200) Subject: ARM: dma-mapping: Add arm_iommu_detach_device() X-Git-Tag: upstream/snapshot3+hdmi~5643^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6fe367580339a3adf77273d4366652665319bdeb;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git ARM: dma-mapping: Add arm_iommu_detach_device() A counter part of arm_iommu_attach_device(). Signed-off-by: Hiroshi Doyu Signed-off-by: Marek Szyprowski --- diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h index 666d8a8..a8c56ac 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 d91c488..6563e38 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