[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aN1h9UKA+MmapzX1@Asurada-Nvidia>
Date: Wed, 1 Oct 2025 10:16:37 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: <will@...nel.org>, <robin.murphy@....com>, <joro@...tes.org>,
<jean-philippe@...aro.org>, <miko.lenczewski@....com>, <balbirs@...dia.com>,
<peterz@...radead.org>, <smostafa@...gle.com>, <kevin.tian@...el.com>,
<praan@...gle.com>, <linux-arm-kernel@...ts.infradead.org>,
<iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
<patches@...ts.linux.dev>
Subject: Re: [PATCH rfcv2 6/8] iommu/arm-smmu-v3: Populate smmu_domain->invs
when attaching masters
On Wed, Oct 01, 2025 at 01:25:16PM -0300, Jason Gunthorpe wrote:
> On Tue, Sep 30, 2025 at 01:19:29PM -0700, Nicolin Chen wrote:
> > I see a cleaner way of handling this is to update invs->num_invs
> > inside arm_smmu_invs_unref():
> > ----------------------------------------------------------------
> > @@ -1209,6 +1216,13 @@ size_t arm_smmu_invs_unref(struct arm_smmu_invs *invs,
> > j++;
> > }
> > }
> > +
> > + /* The lock is required to fence concurrent ATS operations. */
> > + write_lock_irqsave(&invs->rwlock, flags);
> > + /* Trim the size by removing tailing trash entries */
> > + WRITE_ONCE(invs->num_invs, num_invs);
> > + write_unlock_irqrestore(&invs->rwlock, flags);
>
> That seems Ok
>
> It means the arm_smmu_invs_unref() becomes the fence that guarentees
> the ATS is stopped for anything marked as trash.
>
> Then the next steps can just be normal RCU and don't need rwlocking.
Yea. The "old" flag could be dropped too:
while (true) {
invs = rcu_dereference(smmu_domain->invs);
/*
* Avoid locking unless ATS is being used. No ATS invalidate can
* be going on after a domain is detached.
*/
locked = false;
- if (invs->has_ats || READ_ONCE(invs->old)) {
+ if (invs->has_ats) {
read_lock(&invs->rwlock);
- if (invs->old) {
- read_unlock(&invs->rwlock);
- continue;
- }
locked = true;
}
break;
}
Thanks
Nicolin
Powered by blists - more mailing lists