[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250211182040.GL3754072@nvidia.com>
Date: Tue, 11 Feb 2025 14:20:40 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: kevin.tian@...el.com, eric.auger@...hat.com, baolu.lu@...ux.intel.com,
yi.l.liu@...el.com, patches@...ts.linux.dev, joro@...tes.org,
will@...nel.org, robin.murphy@....com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 1/2] iommufd: Make attach_handle generic than fault
specific
On Mon, Feb 03, 2025 at 09:00:54PM -0800, Nicolin Chen wrote:
> "attach_handle" was added exclusively for the iommufd_fault_iopf_handler()
> used by IOPF/PRI use cases. Now, both the MSI and PASID series require to
> reuse the attach_handle for non-fault cases.
>
> Add a set of new attach/detach/replace helpers that does the attach_handle
> allocation/releasing/replacement in the common path and also handles those
> fault specific routines such as iopf enabling/disabling and auto response.
>
> This covers both non-fault and fault cases in a clean way, replacing those
> inline helpers in the header. The following patch will clean up those old
> helpers in the fault.c file.
>
> Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
> ---
> drivers/iommu/iommufd/iommufd_private.h | 33 +-------
> drivers/iommu/iommufd/device.c | 101 ++++++++++++++++++++++++
> drivers/iommu/iommufd/fault.c | 8 +-
> 3 files changed, 109 insertions(+), 33 deletions(-)
I am going to add some lockdeps to this:
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 360ba3ed85455e..0786290b4056df 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -360,6 +360,8 @@ static int iommufd_hwpt_attach_device(struct iommufd_hw_pagetable *hwpt,
struct iommufd_attach_handle *handle;
int rc;
+ lockdep_assert_held(&idev->igroup->lock);
+
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
if (!handle)
return -ENOMEM;
@@ -391,6 +393,8 @@ iommufd_device_get_attach_handle(struct iommufd_device *idev)
{
struct iommu_attach_handle *handle;
+ lockdep_assert_held(&idev->igroup->lock);
+
handle =
iommu_attach_handle_get(idev->igroup->group, IOMMU_NO_PASID, 0);
if (IS_ERR(handle))
I think the one in get_attach_handle is important to discourage misuse
of that ..
Thanks,
Jason
Powered by blists - more mailing lists