[PATCH v10 10/10] iommu/arm-smmu-v3: Add stall support for platform devices

Jean-Philippe Brucker jean-philippe at linaro.org
Fri Jan 22 03:51:20 EST 2021


On Thu, Jan 21, 2021 at 07:12:36PM +0000, Jonathan Cameron wrote:
> > @@ -2502,6 +2647,7 @@ static void arm_smmu_release_device(struct device *dev)
> >  
> >  	master = dev_iommu_priv_get(dev);
> >  	WARN_ON(arm_smmu_master_sva_enabled(master));
> > +	iopf_queue_remove_device(master->smmu->evtq.iopf, dev);
> >  	arm_smmu_detach_dev(master);
> >  	arm_smmu_disable_pasid(master);
> >  	arm_smmu_remove_master(master);
> 
> The lack of symmetry here bothers me a bit, but it's already true, so I guess
> this case is fine as well.

Normally the device driver calls iommu_dev_feat_disable(SVA) which does
iopf_queue_remove_device(). This is just a safety net in case the device
gets removed without the driver properly cleaning up (which will WARN as
well) 

> 
> ...
> >  
> > @@ -2785,6 +2946,7 @@ static int arm_smmu_cmdq_init(struct arm_smmu_device *smmu)
> >  static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
> >  {
> >  	int ret;
> > +	bool sva = smmu->features & ARM_SMMU_FEAT_STALLS;
> 
> FEAT_SVA?

Ugh yes, thanks. I left this as a bool instead of moving into the test
below because the PRI patch reuses it, but I think I'll just move it down
when resending.

Thanks,
Jean

> 
> >  
> >  	/* cmdq */
> >  	ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, ARM_SMMU_CMDQ_PROD,
> > @@ -2804,6 +2966,12 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
> >  	if (ret)
> >  		return ret;
> >  
> > +	if (sva && smmu->features & ARM_SMMU_FEAT_STALLS) {
> 
> Isn't this checking same thing twice?
> 
> > +		smmu->evtq.iopf = iopf_queue_alloc(dev_name(smmu->dev));
> > +		if (!smmu->evtq.iopf)
> > +			return -ENOMEM;
> > +	}
> > +
> >  	/* priq */
> >  	if (!(smmu->features & ARM_SMMU_FEAT_PRI))
> >  		return 0;
> > @@ -3718,6 +3886,7 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
> >  	iommu_device_unregister(&smmu->iommu);
> >  	iommu_device_sysfs_remove(&smmu->iommu);
> >  	arm_smmu_device_disable(smmu);
> > +	iopf_queue_free(smmu->evtq.iopf);
> >  
> >  	return 0;
> >  }
> 



More information about the linux-arm-kernel mailing list