Hi Heiner, Cc Thomas and Luca On Wed, 5 Feb 2025 14:49:46 +0100 Heiner Kallweit <hkallweit1@xxxxxxxxx> wrote: > i2c_del_adapter() can be called recursively if it has an i2c mux on > the bus. This results in a deadlock. > We use the lock to protect from parallel unregistering of clients in > case driver and adapter are removed at the same time. > The fix approach is based on the fact that the used iterators are > klist-based. So it's safe to remove list elements during the iteration, > and we don't have to acquire the core lock. > As a result we just have to prevent that i2c_unregister_device() is > executed in parallel for the same client. Use an atomic bit op for this > purpose. > > Fixes: 56a50667cbcf ("i2c: Replace list-based mechanism for handling auto-detected clients") > Reported-by: Herve Codina <herve.codina@xxxxxxxxxxx> > Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx> Tested on my side with the exact same command I used to report the issue # echo 30a40000.i2c > /sys/bus/platform/drivers/imx-i2c/unbind The deadlock is no more present. The crash present in v1 is also no more present. Also I rebound the driver # echo 30a40000.i2c > /sys/bus/platform/drivers/imx-i2c/bind Devices re-appeared and work correctly. It's ok on my side, thanks for this fix! Tested-by: Herve Codina <herve.codina@xxxxxxxxxxx> Best regards Hervé