patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Alex Mastro <amastro@fb.com>
Cc: "Christian König" <christian.koenig@amd.com>,
	dri-devel@lists.freedesktop.org, iommu@lists.linux.dev,
	"Joerg Roedel" <joro@8bytes.org>,
	"Kevin Tian" <kevin.tian@intel.com>,
	linaro-mm-sig@lists.linaro.org, linux-kselftest@vger.kernel.org,
	linux-media@vger.kernel.org,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Will Deacon" <will@kernel.org>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Nicolin Chen" <nicolinc@nvidia.com>,
	patches@lists.linux.dev, "Simona Vetter" <simona.vetter@ffwll.ch>,
	"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
	"Xu Yilun" <yilun.xu@linux.intel.com>
Subject: Re: [PATCH 3/8] iommufd: Allow a DMABUF to be revoked
Date: Wed, 5 Nov 2025 15:36:38 -0400	[thread overview]
Message-ID: <20251105193638.GA1363252@nvidia.com> (raw)
In-Reply-To: <aQsDoHM+eGN0uLhk@devgpu015.cco6.facebook.com>

On Tue, Nov 04, 2025 at 11:58:24PM -0800, Alex Mastro wrote:
> On Mon, Oct 27, 2025 at 02:31:02PM -0300, Jason Gunthorpe wrote:
> > @@ -1024,8 +1027,15 @@ static int iopt_fill_domain(struct io_pagetable *iopt,
> >  			continue;
> >  
> >  		mutex_lock(&pages->mutex);
> > +		if (iopt_is_dmabuf(pages)) {
> > +			rc = iopt_dmabuf_track_domain(pages, area, domain);
> > +			if (rc)
> > +				goto out_unfill;
> 
> I think this error path results in locking pages->mutex recursively. Needs a
> mutex_unlock(&pages->mutex)?

Yes, let's use a guard then:

--- a/drivers/iommu/iommufd/io_pagetable.c
+++ b/drivers/iommu/iommufd/io_pagetable.c
@@ -1056,7 +1056,7 @@ static int iopt_fill_domain(struct io_pagetable *iopt,
                if (!pages)
                        continue;
 
-               mutex_lock(&pages->mutex);
+               guard(mutex)(&pages->mutex);
                if (iopt_is_dmabuf(pages)) {
                        rc = iopt_dmabuf_track_domain(pages, area, domain);
                        if (rc)
@@ -1066,7 +1066,6 @@ static int iopt_fill_domain(struct io_pagetable *iopt,
                if (rc) {
                        if (iopt_is_dmabuf(pages))
                                iopt_dmabuf_untrack_domain(pages, area, domain);
-                       mutex_unlock(&pages->mutex);
                        goto out_unfill;
                }
                if (!area->storage_domain) {

Thanks,
Jason

  reply	other threads:[~2025-11-05 19:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27 17:30 [PATCH 0/8] Initial DMABUF support for iommufd Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 1/8] iommufd: Add DMABUF to iopt_pages Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 2/8] iommufd: Do not map/unmap revoked DMABUFs Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 3/8] iommufd: Allow a DMABUF to be revoked Jason Gunthorpe
2025-11-05  7:58   ` Alex Mastro
2025-11-05 19:36     ` Jason Gunthorpe [this message]
2025-10-27 17:31 ` [PATCH 4/8] iommufd: Allow MMIO pages in a batch Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 5/8] iommufd: Have pfn_reader process DMABUF iopt_pages Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 6/8] iommufd: Have iopt_map_file_pages convert the fd to a file Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 7/8] iommufd: Accept a DMABUF through IOMMU_IOAS_MAP_FILE Jason Gunthorpe
2025-10-27 17:31 ` [PATCH 8/8] iommufd/selftest: Add some tests for the dmabuf flow Jason Gunthorpe
2025-10-27 18:34 ` [PATCH 0/8] Initial DMABUF support for iommufd Leon Romanovsky

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=20251105193638.GA1363252@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=amastro@fb.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=leon@kernel.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=patches@lists.linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=shuah@kernel.org \
    --cc=simona.vetter@ffwll.ch \
    --cc=sumit.semwal@linaro.org \
    --cc=vivek.kasireddy@intel.com \
    --cc=will@kernel.org \
    --cc=yilun.xu@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).