Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261466

[RFC] iommu: arm-smmu: correct reference count

From Peng Fan <van.freenix@gmail.com>
Newsgroups linux.kernel
Subject [RFC] iommu: arm-smmu: correct reference count
Date 2015-11-03 14:00 +0100
Message-ID <qqJlV-2OU-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


iommu_group_alloc will initialize the reference count for group to 1.
iommu_group_add_device also increase the group reference count,
if nothing bad happends. And we need to add iommu_group_put to
decrease the reference count for group.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
---

Not sure whether my understanding is correct or not. I checked rockchip-iommu.c
exynos-iommu.c and fsl_pamu_domain.c, and they all have iommu_group_put after
iommu_group_add_device.

 drivers/iommu/arm-smmu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 48a39df..1cab720 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1344,6 +1344,7 @@ static int arm_smmu_add_platform_device(struct device *dev)
 	struct iommu_group *group;
 	struct arm_smmu_master *master;
 	struct arm_smmu_device *smmu = find_smmu_for_device(dev);
+	int ret;
 
 	if (!smmu)
 		return -ENODEV;
@@ -1358,7 +1359,11 @@ static int arm_smmu_add_platform_device(struct device *dev)
 		return PTR_ERR(group);
 
 	iommu_group_set_iommudata(group, &master->cfg, NULL);
-	return iommu_group_add_device(group, dev);
+
+	ret = iommu_group_add_device(group, dev);
+	iommu_group_put(group);
+
+	return ret;
 }
 
 static int arm_smmu_add_device(struct device *dev)
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[RFC] iommu: arm-smmu: correct reference count Peng Fan <van.freenix@gmail.com> - 2015-11-03 14:00 +0100
  Re: [RFC] iommu: arm-smmu: correct reference count Will Deacon <will.deacon@arm.com> - 2015-11-03 14:20 +0100
    Re: [RFC] iommu: arm-smmu: correct reference count Will Deacon <will.deacon@arm.com> - 2015-11-06 13:30 +0100
      Re: [RFC] iommu: arm-smmu: correct reference count Peng Fan <van.freenix@gmail.com> - 2015-11-09 06:50 +0100

csiph-web