Re: [PATCH v3 5/7] iommu/arm-smmu-v3: Populate smmu_domain->invs when attaching masters

Jason Gunthorpe
2025-10-20T12:13:30Z

On Fri, Oct 17, 2025 at 02:11:34PM -0700, Nicolin Chen wrote:
> On Sat, Oct 18, 2025 at 12:03:27AM +0800, kernel test robot wrote:
> > sparse warnings: (new ones prefixed by >>)
> > >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3208:33: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct arm_smmu_invs **invs_ptr @@ got struct arm_smmu_invs [noderef] __rcu ** @@
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3208:33: sparse: expected struct arm_smmu_invs **invs_ptr
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3208:33: sparse: got struct arm_smmu_invs [noderef] __rcu **
> ...
> > > 3208 invst->invs_ptr = &new_smmu_domain->invs;
> ...
> > > 3247 rcu_assign_pointer(*invst->invs_ptr, invst->new_invs);
>
> Looks like we need:
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> index 8906c1625f428..398d8beb8f862 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
> @@ -1105,7 +1105,7 @@ static inline bool arm_smmu_master_canwbs(struct arm_smmu_master *master)
> * to_unref argument to an arm_smmu_invs_unref() call
> */
> struct arm_smmu_inv_state {
> - struct arm_smmu_invs **invs_ptr;
> + struct arm_smmu_invs __rcu **invs_ptr;
> struct arm_smmu_invs *old_invs;
> struct arm_smmu_invs *new_invs;
> };

Isn't it:

struct arm_smmu_invs * __rcu *invs_ptr;

This is a pointer to a rcu controlled pointer, not a rcu controlled
pointer to a pointer..

Jason