All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Joerg Roedel <joro@8bytes.org>,
	"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>, "Rix, Tom" <trix@redhat.com>,
	Will Deacon <will@kernel.org>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Subject: Re: [PATCH v4 16/17] iommu: Remove __iommu_group_for_each_dev()
Date: Thu, 20 Apr 2023 10:01:09 -0300	[thread overview]
Message-ID: <ZEE3lQOfQPE6mDk8@nvidia.com> (raw)
In-Reply-To: <BL1PR11MB5271BBE89526DA4E3DBEEF2F8C639@BL1PR11MB5271.namprd11.prod.outlook.com>

On Thu, Apr 20, 2023 at 08:06:17AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Wednesday, April 12, 2023 9:52 PM
> > 
> > @@ -1858,7 +1843,15 @@ int bus_iommu_probe(struct bus_type *bus)
> >  			return ret;
> >  		}
> >  		mutex_unlock(&group->mutex);
> > -		__iommu_group_dma_finalize(group);
> > +
> > +		/*
> > +		 * Mis-locked because the ops->probe_finalize() call-back of
> 
> I guess this comment is trying to explain why the following code is
> executed out of lock. In that case it reads clearer to me to start
> with "Avoid mis-lock ..." and put it before mutex_unlock().

Iit is not avoiding anything, this is deliberately locked wrong.

We are iterating over for_each_group_device() without holding the
required group->mutex and hope&pray nothing bad happens. We do this
because of some bad ARM32 driver implementations of
ops->probe_finalize that recurse into the lock.

Thanks,
Jason

  reply	other threads:[~2023-04-20 14:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 13:51 [PATCH v4 00/17] Consolidate the error handling around device attachment Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 01/17] iommu: Replace iommu_group_device_count() with list_count_nodes() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 02/17] iommu: Add for_each_group_device() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 03/17] iommu: Make __iommu_group_set_domain() handle error unwind Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 04/17] iommu: Use __iommu_group_set_domain() for __iommu_attach_group() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 05/17] iommu: Use __iommu_group_set_domain() in iommu_change_dev_def_domain() Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 06/17] iommu: Replace __iommu_group_dma_first_attach() with set_domain Jason Gunthorpe
2023-04-13  2:35   ` Baolu Lu
2023-04-20  7:25   ` Tian, Kevin
2023-04-20 12:59     ` Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 07/17] iommu: Remove iommu_group_do_dma_first_attach() from iommu_group_add_device() Jason Gunthorpe
2023-04-20  7:26   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 08/17] iommu: Replace iommu_group_do_dma_first_attach with __iommu_device_set_domain Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 09/17] iommu: Fix iommu_probe_device() to attach the right domain Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 10/17] iommu: Do iommu_group_create_direct_mappings() before attach Jason Gunthorpe
2023-04-20  7:29   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 11/17] iommu: Remove the assignment of group->domain during default domain alloc Jason Gunthorpe
2023-04-12 13:51 ` [PATCH v4 12/17] iommu: Consolidate the code to calculate the target default domain type Jason Gunthorpe
2023-04-20  7:30   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 13/17] iommu: Revise iommu_group_alloc_default_domain() Jason Gunthorpe
2023-04-13  2:47   ` Baolu Lu
2023-04-20  7:54   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 14/17] iommu: Consolidate the default_domain setup to one function Jason Gunthorpe
2023-04-20  7:57   ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 15/17] iommu: Allow IOMMU_RESV_DIRECT to work on ARM Jason Gunthorpe
2023-04-20  8:00   ` Tian, Kevin
2023-04-26 13:36     ` Jason Gunthorpe
2023-04-26 23:48       ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 16/17] iommu: Remove __iommu_group_for_each_dev() Jason Gunthorpe
2023-04-20  8:06   ` Tian, Kevin
2023-04-20 13:01     ` Jason Gunthorpe [this message]
2023-04-21  3:05       ` Tian, Kevin
2023-04-12 13:51 ` [PATCH v4 17/17] iommu: Tidy the control flow in iommu_group_store_type() Jason Gunthorpe
2023-04-20  8:07   ` Tian, Kevin
2023-05-01 22:01 ` [PATCH v4 00/17] Consolidate the error handling around device attachment Heiko Stübner

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=ZEE3lQOfQPE6mDk8@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolinc@nvidia.com \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=trix@redhat.com \
    --cc=will@kernel.org \
    /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.