[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250930121200.GG2942991@nvidia.com>
Date: Tue, 30 Sep 2025 09:12:00 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...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 Mon, Sep 29, 2025 at 01:52:30PM -0700, Nicolin Chen wrote:
> > > + if (!new_invs) {
> > > + size_t new_num = old_invs->num_invs;
> > > +
> > > + /*
> > > + * OOM. Couldn't make a copy. Leave the array unoptimized. But
> > > + * trim its size if some tailing entries are marked as trash.
> > > + */
> > > + while (new_num != 0) {
> > > + if (refcount_read(&old_invs->inv[new_num - 1].users))
> > > + break;
> > > + new_num--;
> > > + }
> >
> > Would be nicer to have arm_smmu_invs_unref return the new size so we
> > don't need this loop
>
> The "new size" must be invs->num_invs subtracting the number of
> the tailing trash entries. So, arm_smmu_invs_unref() would have
> to have the same loop validating the tailing entries, right?
It doesn't need another loop, it just need to record the index of the
last valid entry while it is doing its own loop. If it reaches
invs->num_invs then that will be the new length.
Jason
Powered by blists - more mailing lists