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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 22 Jan 2021 09:51:20 +0100
Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx> wrote:

> 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) 

Ah makes sense.  Maybe it's worth a comment in the code for future generations
of tired code readers?

> 
> > 
> > ...  
> > >  
> > > @@ -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.

Makes sense.

> 
> 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;
> > >  }  
> >   




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux