[PATCH v4 2/7] iommu/arm-smmu-v3: Factor out a common arm_smmu_domain_alloc()

Shameerali Kolothum Thodi shameerali.kolothum.thodi at huawei.com
Wed Jun 5 08:19:09 PDT 2024



> -----Original Message-----
> From: Jason Gunthorpe <jgg at nvidia.com>
> Sent: Saturday, June 1, 2024 10:07 PM
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi at huawei.com>
> Cc: iommu at lists.linux.dev; linux-arm-kernel at lists.infradead.org;
> robin.murphy at arm.com; will at kernel.org; joro at 8bytes.org;
> ryan.roberts at arm.com; kevin.tian at intel.com; nicolinc at nvidia.com;
> mshavit at google.com; eric.auger at redhat.com; joao.m.martins at oracle.com;
> jiangkunkun <jiangkunkun at huawei.com>; zhukeqian
> <zhukeqian1 at huawei.com>; Linuxarm <linuxarm at huawei.com>
> Subject: Re: [PATCH v4 2/7] iommu/arm-smmu-v3: Factor out a common
> arm_smmu_domain_alloc()
> 
> On Tue, May 28, 2024 at 08:18:26AM +0100, Shameer Kolothum wrote:
> 
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
> > @@ -648,7 +648,7 @@ static int arm_smmu_sva_set_dev_pasid(struct
> iommu_domain *domain,
> >
> >  static void arm_smmu_sva_domain_free(struct iommu_domain *domain)
> >  {
> > -	kfree(domain);
> > +	kfree(to_smmu_domain(domain));
> >  }
> 
> 
> > @@ -659,13 +659,16 @@ static const struct iommu_domain_ops
> arm_smmu_sva_domain_ops = {
> >  struct iommu_domain *arm_smmu_sva_domain_alloc(struct device *dev,
> >  					       struct mm_struct *mm)
> >  {
> > -	struct iommu_domain *domain;
> > +	struct arm_smmu_master *master = dev_iommu_priv_get(dev);
> > +	struct arm_smmu_device *smmu = master->smmu;
> > +	struct arm_smmu_domain *smmu_domain;
> >
> > -	domain = kzalloc(sizeof(*domain), GFP_KERNEL);
> > -	if (!domain)
> > -		return ERR_PTR(-ENOMEM);
> > -	domain->type = IOMMU_DOMAIN_SVA;
> > -	domain->ops = &arm_smmu_sva_domain_ops;
> > +	smmu_domain = arm_smmu_domain_alloc();
> > +	if (IS_ERR(smmu_domain))
> > +		return ERR_CAST(smmu_domain);
> > +	smmu_domain->domain.type = IOMMU_DOMAIN_SVA;
> > +	smmu_domain->domain.ops = &arm_smmu_sva_domain_ops;
> > +	smmu_domain->smmu = smmu;
> >
> > -	return domain;
> > +	return &smmu_domain->domain;
> >  }
> 
> If you drop these two hunks you can drop the first patch as well. There
> is no need to touch SVA in this series

That is right. I will make those changes and re-spin soon.

Thanks,
SHameer



More information about the linux-arm-kernel mailing list