Re: [PATCH v9 14/14] iommu: Track iopf group instead of last fault

From: Baolu Lu
Date: Tue Jan 09 2024 - 01:01:29 EST


On 1/6/24 1:53 AM, Jason Gunthorpe wrote:
On Wed, Dec 20, 2023 at 09:23:32AM +0800, Lu Baolu wrote:
/**
- * iommu_handle_iopf - IO Page Fault handler
- * @fault: fault event
- * @iopf_param: the fault parameter of the device.
+ * iommu_report_device_fault() - Report fault event to device driver
+ * @dev: the device
+ * @evt: fault event data
*
- * Add a fault to the device workqueue, to be handled by mm.
+ * Called by IOMMU drivers when a fault is detected, typically in a threaded IRQ
+ * handler. When this function fails and the fault is recoverable, it is the
+ * caller's responsibility to complete the fault.
This patch seems OK for what it does so:

Reviewed-by: Jason Gunthorpe<jgg@xxxxxxxxxx>

However, this seems like a strange design, surely this function should
just call ops->page_response() when it can't enqueue the fault?

It is much cleaner that way, so maybe you can take this into a
following patch (along with the driver fixes to accomodate. (and
perhaps iommu_report_device_fault() should return void too)

Also iopf_group_response() should return void (another patch!),
nothing can do anything with the failure. This implies that
ops->page_response() must also return void - which is consistent with
what the drivers do, the failure paths are all integrity validations
of the fault and should be WARN_ON'd not return codes.

Make sense. I will integrate the code in the next version and convert
iommu_report_device_fault() to return void.

Best regards,
baolu