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

Jason Gunthorpe
2023-12-11T14:50:24Z

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@linux.intel.com>
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> Tested-by: Yan Zhao <yan.y.zhao@intel.com>
> Tested-by: Longfang Liu <liulongfang@huawei.com>
> ---
> drivers/iommu/io-pgfault.c | 61 +++++++++++++++++++-------------------
> 1 file changed, 30 insertions(+), 31 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason