From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Subject: Re: [RFC] iommu: arm-smmu: correct reference count Date: Wed, 4 Nov 2015 10:48:28 +0800 Message-ID: <20151104024825.GA27479@shlinux2> References: <1446555557-3097-1-git-send-email-van.freenix@gmail.com> <20151103131734.GE14159@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20151103131734.GE14159-5wv7dgnIgG8@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Will Deacon Cc: Peng Fan , iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: iommu@lists.linux-foundation.org Hi Will, On Tue, Nov 03, 2015 at 01:17:34PM +0000, Will Deacon wrote: >On Tue, Nov 03, 2015 at 08:59:17PM +0800, Peng Fan wrote: >> 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 >> Cc: Will Deacon >> Cc: Joerg Roedel >> --- >> >> 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. > >Doesn't this pair up with the iommu_group_remove_device in >arm_smmu_remove_device? Are you actually seeing an issue in practice? In arm_smmu_add_platform_device, iommu_group_alloc --> group->device_kobj ref count will be init to 1. iommu_group_add_device --> group->device_kobj ref count will be added 1 to 2. In arm_smmu_remove_device: iommu_group_remove_device --> Decrease group->device_kobj ref count by 1. After arm_smmu_remove_device, the ref count of group->device_kobj is not 0. So I think need to add iommu_group_put after iommu_group_add_device. If I am wrong, please correct me. Just code inspection, not have a platform to test this. Regards, Peng. > >Will >_______________________________________________ >iommu mailing list >iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org >https://lists.linuxfoundation.org/mailman/listinfo/iommu --