Re: [PATCH v2 RFC] i2c: Fix deadlock on adapter removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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é




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux