[PATCH rfcv2 6/8] iommu/arm-smmu-v3: Populate smmu_domain->invs when attaching masters

Jason Gunthorpe jgg at nvidia.com
Tue Sep 30 05:12:00 PDT 2025


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



More information about the linux-arm-kernel mailing list