Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Peter Chen <peter.chen@oss.qualcomm.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Johan Hovold <johan@kernel.org>,
	Fenglin Wu <fenglin.wu@oss.qualcomm.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Jack Pham <jack.pham@oss.qualcomm.com>,
	Wesley Cheng <wesley.cheng@oss.qualcomm.com>
Subject: Re: [PATCH v2] iommu: Hold group references across bus_iommu_probe()
Date: Tue, 24 Nov 2026 08:49:33 -0400	[thread overview]
Message-ID: <20261124124933.GA8680@nvidia.com> (raw)
In-Reply-To: <awU4DyS7irT1a-nu@hu-petche-lv.qualcomm.com>

On Mon, Nov 23, 2026 at 11:09:03PM -0800, Peter Chen wrote:
> The glue driver does what upstream dwc3-imx8mp.c does in
> dwc3_imx8mp_probe():
> 
> 	of_platform_populate(node, NULL, NULL, dev);
> 	pdev = of_find_device_by_node(dwc3_np);
> 	dwc = platform_get_drvdata(pdev);
> 	if (!dwc) {
> 		/* core probe deferred, e.g. its SMMU is not there yet */
> 		ret = -EPROBE_DEFER;
> 		goto depopulate;	/* -> platform_device_unregister() */
> 	}

That's not how EPROBE_DEFER is supposed to be handled :(

The driver core is already setup to reprobe the child driver later
inside of_platform_populate()

Your issue is it is quite wrong to try to synchronously reach into a
probed driver's like this from outside. Then when it fails tearing
down the device means you defeat the natural EPROBE_DEFER.

This should be asynchronous, then you won't have ordering problems.

But OK, it is clear how you get into this situation.

> > > @@ -1951,6 +1955,18 @@ static void iommu_group_do_probe_finalize(struct device *dev)
> > >  		ops->probe_finalize(dev);
> > >  }
> > >  
> > > +static void iommu_group_list_put(struct list_head *group_list)
> > > +{
> > > +	struct iommu_group *group, *next;
> > > +
> > > +	list_for_each_entry_safe(group, next, group_list, entry) {
> > > +		mutex_lock(&group->mutex);
> > > +		list_del_init(&group->entry);
> > > +		mutex_unlock(&group->mutex);
> > > +		iommu_group_put(group);
> > 
> > What is the mutex for? The group_list is a stack head so what are we
> > protecting list del against?
> > 
> 
> Yes, the list head is on the stack, but group->entry is in the
> shared group. "Is group->entry empty" is the de-dup flag that
> __iommu_probe_device() tests and sets under group->mutex:
> 
> 	if (list_empty(&group->entry))
> 		list_add_tail(&group->entry, group_list);

A small comment might help. The lock seems necessary

Jason

      reply	other threads:[~2026-11-24 12:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 11:07 [PATCH v2] iommu: Hold group references across bus_iommu_probe() Peter Chen
2026-11-20 20:53 ` Jason Gunthorpe
2026-11-24  7:09   ` Peter Chen
2026-11-24 12:49     ` Jason Gunthorpe [this message]

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=20261124124933.GA8680@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=fenglin.wu@oss.qualcomm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jack.pham@oss.qualcomm.com \
    --cc=johan@kernel.org \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.chen@oss.qualcomm.com \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=wesley.cheng@oss.qualcomm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox