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

Peng Fan b51431 at freescale.com
Tue Nov 3 18:48:28 PST 2015

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 <van.freenix at gmail.com>
>> Cc: Will Deacon <will.deacon at arm.com>
>> Cc: Joerg Roedel <joro at 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.
>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.


>iommu mailing list
>iommu at lists.linux-foundation.org


More information about the linux-arm-kernel mailing list