Thread (34 messages) 34 messages, 7 authors, 2023-08-09

Re: [PATCH v2 02/10] iommu: Add a lockdep assertion for remaining dev->iommu_group reads

From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2023-08-08 16:55:19
Also in: linux-iommu, linux-rockchip, linux-sunxi

On Tue, Aug 08, 2023 at 05:22:55PM +0100, Robin Murphy wrote:
Oh, the things that happen if I take holiday... :)

On 31/07/2023 6:50 pm, Jason Gunthorpe wrote:
quoted
The remaining reads are all in functions called under ops->device_group.

Broadly these functions are walking around the device tree (eg going up
the PCI bus tree) and are trying to de-duplicate group allocations
according to their logic.

Since these functions don't hold any particular per-device locks their
reads to dev->iommu_group are being locked by the caller's
iommu_probe_device_lock, and this explains why iommu_probe_device_lock
needs to be a global lock.
This confuzzles me. iommu_probe_device_lock is a global (but tightly-scoped)
lock because its sole purpose is as a point hack to serialise calls to
iommu_probe_device(), 
Well, that may have been the intention, but as a side effect it turns
out that it is the only thing that locks the access to the
dev->iommu_group as well. This is some other bug that I suppose nobody
noticed.
concurrently for the same device, but due to the long-standing "replay"
hacks, currently can. It is not meant to have anything to do with groups,
and expanding its scope is a really really terrible idea.
Regardless, it does serialize the group stuff so what I did here is
recognize that as its main purpose and made the probe serialization a
secondary thing, which is eventually entirely removed.

I could have constructed this the other way and said that the group
locking is missing and added another global lock, but that seems
equally confusing since it isn't missing, it is just mis-named :)
I finally now have some time to work on IOMMU gubbins again, so I'll be
updating the bus ops removal series ASAP, then the next step after that is
some bus_type callback surgery to pull the {of,acpi}_iommu_configure()
parsing and ops->of_xlate calls to the proper point in the core
iommu_probe_device() path, and all this mess finally goes away for good.
That is great, but it won't address the dev->group locking.

I'm not sure there is further value in trying to remove the
device_lock() around probe, but cleaning up the iommu_configure stuff
would be nice.

Jason

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help