All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: kevin.tian@intel.com, eric.auger@redhat.com,
	baolu.lu@linux.intel.com, yi.l.liu@intel.com,
	patches@lists.linux.dev, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] iommufd: Make attach_handle generic than fault specific
Date: Tue, 11 Feb 2025 14:20:40 -0400	[thread overview]
Message-ID: <20250211182040.GL3754072@nvidia.com> (raw)
In-Reply-To: <32687df01c02291d89986a9fca897bbbe2b10987.1738645017.git.nicolinc@nvidia.com>

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@nvidia.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

  parent reply	other threads:[~2025-02-11 18:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04  5:00 [PATCH v1 0/2] iommufd: Allocate attach_handle for any HWPT Nicolin Chen
2025-02-04  5:00 ` [PATCH v1 1/2] iommufd: Make attach_handle generic than fault specific Nicolin Chen
2025-02-11  6:47   ` Yi Liu
2025-02-11 18:20   ` Jason Gunthorpe [this message]
2025-02-04  5:00 ` [PATCH v1 2/2] iommufd/fault: Remove iommufd_fault_domain_attach/detach/replace_dev() Nicolin Chen
2025-02-11  6:54   ` Yi Liu
2025-02-11 18:21 ` [PATCH v1 0/2] iommufd: Allocate attach_handle for any HWPT Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250211182040.GL3754072@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=eric.auger@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=patches@lists.linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.