[PATCH v2 5/5] iommu/arm-smmu: Convert to domain_alloc_paging()

Will Deacon will at kernel.org
Tue Dec 12 06:10:23 PST 2023


On Tue, Dec 12, 2023 at 10:03:07AM -0400, Jason Gunthorpe wrote:
> On Tue, Dec 12, 2023 at 01:26:51PM +0000, Will Deacon wrote:
> > > @@ -862,6 +859,18 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
> > >  	mutex_init(&smmu_domain->init_mutex);
> > >  	spin_lock_init(&smmu_domain->cb_lock);
> > >  
> > > +	if (dev)
> > > +		cfg = dev_iommu_priv_get(dev);
> > > +	if (cfg) {
> > > +		int ret;
> > > +
> > > +		ret = arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev);
> > > +		if (ret) {
> > > +			kfree(smmu_domain);
> > > +			return NULL;
> > 
> > If we're just returning NULL, can we drop 'ret'?
> 
> It is waiting to be changed to ERR_PTR. The dependent patches are
> merged to rc5 now, so I can fix it in v3.

Sorry, I missed that. You can leave it as-is, since my SMMU branch is based
on -rc3.

> > > +		}
> > > +	}
> > > +
> > >  	return &smmu_domain->domain;
> > 
> > Why do we need to handle the 'dev && !cfg' case here, instead g
> > returning NULL?
> 
> dev && !cfg is impossible these days, so we can shuffle the if and
> then just crash on that case like the other drivers do.

Thanks, that would simplify it a little.

Will



More information about the linux-arm-kernel mailing list