All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: linux-arm-kernel@lists.infradead.org,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	will.deacon@arm.com
Cc: joro@8bytes.org, van.freenix@gmail.com
Subject: [RFC] iommu: arm-smmu: correct reference count
Date: Tue,  3 Nov 2015 20:59:17 +0800	[thread overview]
Message-ID: <1446555557-3097-1-git-send-email-van.freenix@gmail.com> (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

WARNING: multiple messages have this Message-ID (diff)
From: van.freenix@gmail.com (Peng Fan)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] iommu: arm-smmu: correct reference count
Date: Tue,  3 Nov 2015 20:59:17 +0800	[thread overview]
Message-ID: <1446555557-3097-1-git-send-email-van.freenix@gmail.com> (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

             reply	other threads:[~2015-11-03 12:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 12:59 Peng Fan [this message]
2015-11-03 12:59 ` [RFC] iommu: arm-smmu: correct reference count Peng Fan
     [not found] ` <1446555557-3097-1-git-send-email-van.freenix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-03 13:17   ` Will Deacon
2015-11-03 13:17     ` Will Deacon
2015-11-03 13:17     ` Will Deacon
     [not found]     ` <20151103131734.GE14159-5wv7dgnIgG8@public.gmane.org>
2015-11-04  2:48       ` Peng Fan
2015-11-04  2:48         ` Peng Fan
2015-11-04  2:48         ` Peng Fan
2015-11-06 12:23         ` Will Deacon
2015-11-06 12:23           ` Will Deacon
2015-11-06 12:23           ` Will Deacon
     [not found]           ` <20151106122338.GI6087-5wv7dgnIgG8@public.gmane.org>
2015-11-09  5:41             ` Peng Fan
2015-11-09  5:41               ` Peng Fan
2015-11-09  5:41               ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446555557-3097-1-git-send-email-van.freenix@gmail.com \
    --to=van.freenix@gmail.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.