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

Nicolin Chen nicolinc at nvidia.com
Mon Oct 20 12:05:43 PDT 2025


On Mon, Oct 20, 2025 at 09:12:25AM -0300, Jason Gunthorpe wrote:
> 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;

Hmm, sparse warns this:

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3257:33: warning: incorrect type in assignment (different address spaces)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3257:33:    expected struct arm_smmu_invs *[noderef] __rcu *invs_ptr
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3257:33:    got struct arm_smmu_invs [noderef] __rcu **
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3275:33: warning: incorrect type in assignment (different address spaces)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3275:33:    expected struct arm_smmu_invs *[noderef] __rcu *invs_ptr
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3275:33:    got struct arm_smmu_invs [noderef] __rcu **
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3296:9: error: incompatible types in comparison expression (different address spaces):
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3296:9:    struct arm_smmu_invs [noderef] __rcu *
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3296:9:    struct arm_smmu_invs *
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3354:9: error: incompatible types in comparison expression (different address spaces):
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3354:9:    struct arm_smmu_invs [noderef] __rcu *
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3354:9:    struct arm_smmu_invs *

3257: invst->invs_ptr = &new_smmu_domain->invs;
3296: rcu_assign_pointer(*invst->invs_ptr, invst->new_invs);
3354: rcu_assign_pointer(*invst->invs_ptr, new_invs);

But no warning with "struct arm_smmu_invs __rcu **invs_ptr".

Thanks
Nicolin



More information about the linux-arm-kernel mailing list