mbox series

[0/8] Remove adis_initial_startup usage

Message ID 20221102141843.122182-1-ramona.bolboaca@analog.com (mailing list archive)
Headers show
Series Remove adis_initial_startup usage | expand

Message

Ramona Bolboaca Nov. 2, 2022, 2:18 p.m. UTC
Remove adis_initial_startup usage due to the fact that it leads to a deadlock.
The same mutex is acquired twice, without releasing it, once inside
adis_initial_startup and once inside adis_enable_irq.
Instead of adis_initial_startup, use __adis_initial_startup.

Ramona Bolboaca (8):
  iio: accel: adis16201: Fix deadlock in probe
  iio: accel: adis16209: Fix deadlock in probe
  iio: gyro: adis16136: Fix deadlock in probe
  iio: gyro: adis16260: Fix deadlock in probe
  iio: imu: adis16400: Fix deadlock in probe
  staging: iio: accel: adis16203: Fix deadlock in probe
  staging: iio: accel: adis16240: Fix deadlock in probe
  iio: imu: adis: Remove adis_initial_startup function

 drivers/iio/accel/adis16201.c         |  2 +-
 drivers/iio/accel/adis16209.c         |  2 +-
 drivers/iio/gyro/adis16136.c          |  2 +-
 drivers/iio/gyro/adis16260.c          |  2 +-
 drivers/iio/imu/adis16400.c           |  2 +-
 drivers/staging/iio/accel/adis16203.c |  2 +-
 drivers/staging/iio/accel/adis16240.c |  2 +-
 include/linux/iio/imu/adis.h          | 12 ------------
 8 files changed, 7 insertions(+), 19 deletions(-)

Comments

Nuno Sá Nov. 2, 2022, 3:27 p.m. UTC | #1
On Wed, 2022-11-02 at 16:18 +0200, Ramona Bolboaca wrote:
> Remove adis_initial_startup usage due to the fact that it leads to a
> deadlock.
> The same mutex is acquired twice, without releasing it, once inside
> adis_initial_startup and once inside adis_enable_irq.
> Instead of adis_initial_startup, use __adis_initial_startup.
> 

Auchhhh!!! Thanks for catching this... However, the Fixes tag is
pointing to the wrong place. I'm fairly sure I introduced this bug in 

commit b600bd7eb3335 ("iio: adis: do not disabe IRQs in 'adis_init()'")

This was where the call to adis_enable_irq() was moved to
__adis_initial_startup() and effectively creating the deadlock for some
devices (adis->data->unmasked_drdy is not set)...


I guess I did not saw this when bringing in the change because I
probably tested the full series on some device supported by adis16475.c
where this won't trigger.

From a quick look I think it's safe to drop adis_initial_startup() as
it is always called during probe() before registering the IIO device.
We could also just create an unlocked version of adis_enable_irq()
(since we don't need to grab the lock in this path) but likely not
worth the trouble.

- Nuno Sá