On Sun, May 03, 2020 at 01:54:36PM +0800, Lu Baolu wrote: > On 2020/4/30 22:34, Jean-Philippe Brucker wrote: > > When a recoverable page fault is handled by the fault workqueue, find the > > associated mm and call handle_mm_fault. > > > > Signed-off-by: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx> > > --- > > v5->v6: select CONFIG_IOMMU_SVA > > --- > > drivers/iommu/Kconfig | 1 + > > drivers/iommu/io-pgfault.c | 79 +++++++++++++++++++++++++++++++++++++- > > 2 files changed, 78 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > index 4f33e489f0726..1e64ee6592e16 100644 > > --- a/drivers/iommu/Kconfig > > +++ b/drivers/iommu/Kconfig > > @@ -109,6 +109,7 @@ config IOMMU_SVA > > config IOMMU_PAGE_FAULT > > bool > > + select IOMMU_SVA > > It would be better to move this to the previous patch. > [...] > > @@ -104,6 +156,29 @@ static void iopf_handle_group(struct work_struct *work) > > * > > * Add a fault to the device workqueue, to be handled by mm. > > * > > + * This module doesn't handle PCI PASID Stop Marker; IOMMU drivers must discard > > + * them before reporting faults. A PASID Stop Marker (LRW = 0b100) doesn't > > + * expect a response. It may be generated when disabling a PASID (issuing a > > + * PASID stop request) by some PCI devices. > > + * > > + * The PASID stop request is issued by the device driver before unbind(). Once > > + * it completes, no page request is generated for this PASID anymore and > > + * outstanding ones have been pushed to the IOMMU (as per PCIe 4.0r1.0 - 6.20.1 > > + * and 10.4.1.2 - Managing PASID TLP Prefix Usage). Some PCI devices will wait > > + * for all outstanding page requests to come back with a response before > > + * completing the PASID stop request. Others do not wait for page responses, and > > + * instead issue this Stop Marker that tells us when the PASID can be > > + * reallocated. > > + * > > + * It is safe to discard the Stop Marker because it is an optimization. > > + * a. Page requests, which are posted requests, have been flushed to the IOMMU > > + * when the stop request completes. > > + * b. We flush all fault queues on unbind() before freeing the PASID. > > + * > > + * So even though the Stop Marker might be issued by the device *after* the stop > > + * request completes, outstanding faults will have been dealt with by the time > > + * we free the PASID. > > + * > > * Return: 0 on success and <0 on error. > > */ > > int iommu_queue_iopf(struct iommu_fault *fault, void *cookie) > > > > The same for the comments. I think I'll squash both patches, probably doesn't make it harder to review. Thanks, Jean