Re: [PATCH v8 11/12] iommu: Refine locking for per-device fault data management

From: Jason Gunthorpe
Date: Mon Dec 11 2023 - 09:50:30 EST


On Thu, Dec 07, 2023 at 02:43:07PM +0800, Lu Baolu wrote:
> The per-device fault data is a data structure that is used to store
> information about faults that occur on a device. This data is allocated
> when IOPF is enabled on the device and freed when IOPF is disabled. The
> data is used in the paths of iopf reporting, handling, responding, and
> draining.
>
> The fault data is protected by two locks:
>
> - dev->iommu->lock: This lock is used to protect the allocation and
> freeing of the fault data.
> - dev->iommu->fault_parameter->lock: This lock is used to protect the
> fault data itself.
>
> Apply the locking mechanism to the fault reporting and responding paths.
>
> The fault_parameter->lock is also added in iopf_queue_discard_partial().
> It does not fix any real issue, as iopf_queue_discard_partial() is only
> used in the VT-d driver's prq_event_thread(), which is a single-threaded
> path that reports the IOPFs.
>
> Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
> Tested-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
> Tested-by: Longfang Liu <liulongfang@xxxxxxxxxx>
> ---
> drivers/iommu/io-pgfault.c | 61 +++++++++++++++++++-------------------
> 1 file changed, 30 insertions(+), 31 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason