On Thu, 20 Sep 2018 18:00:43 +0100 Jean-Philippe Brucker <jean-philippe.brucker@xxxxxxx> wrote: > + /* > + * When removing a PASID, the device driver tells the device > to stop > + * using it, and flush any pending fault to the IOMMU. In > this flush > + * callback, the IOMMU driver makes sure that there are no > such faults > + * left in the low-level queue. > + */ > + queue->flush(queue->flush_arg, dev, pasid); > + > + /* > + * If at some point the low-level fault queue overflowed and > the IOMMU > + * device had to auto-respond to a 'last' page fault, other > faults from > + * the same Page Request Group may still be stuck in the > partial list. > + * We need to make sure that the next address space using > the PASID > + * doesn't receive them. > + */ Trying to understand the intended use case under queue full condition. 1 model specific iommu driver register a flush callback to handle internal PRQ drain 2 IOMMU HW detects queue full and auto respond with 'SUCCESS' code to all device and PASID, raise interrupt 3 model specific iommu driver detects queue full and call iopf_queue_flush_dev() 4 call queue->flush() callback to drain PRQ in-flight inside IOMMU HW 5.Shoot down partial list for all PASIDs If the above understanding is correct, don't we need to shoot down all partial groups? instead of just one PASID. At least for VT-d, we need to do that. > + mutex_lock(¶m->lock); > + list_for_each_entry_safe(fault, next, > ¶m->iopf_param->partial, head) { > + if (fault->evt.pasid == pasid || pasid == > IOMMU_PASID_INVALID) { > + list_del(&fault->head); > + kfree(fault); > + } > + } > + mutex_unlock(¶m->lock); > + > + flush_workqueue(queue->wq); > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(iopf_queue_flush_dev); > + [Jacob Pan]