Re: [PATCH v2] iommu: Hold group references across bus_iommu_probe()

From: Jason Gunthorpe

Date: Tue Nov 24 2026 - 07:49:46 EST


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