RE: [PATCH v4 16/17] iommu: Remove __iommu_group_for_each_dev()

Tian, Kevin
2023-04-21T03:05:48Z

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, April 20, 2023 9:01 PM
>
> 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.
>

Then add a FIXME tag there?