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(-)
--
2.25.1
Use __adis_initial_startup instead of adis_initial_startup to
avoid deadlock.
When using adis_initial_startup mutex_lock is called twice,
without releasing it (once inside adis_initial_startup and
once inside adis_enable_irq).
Fixes: 100bfa38c8cb ("iio: imu: adis[16480]: group RW into a single lock in adis_enable_irq()")
Signed-off-by: Ramona Bolboaca <[email protected]>
---
drivers/iio/gyro/adis16260.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
index eaf57bd339ed..112d635b7dfd 100644
--- a/drivers/iio/gyro/adis16260.c
+++ b/drivers/iio/gyro/adis16260.c
@@ -395,7 +395,7 @@ static int adis16260_probe(struct spi_device *spi)
return ret;
/* Get the device into a sane initial state */
- ret = adis_initial_startup(&adis16260->adis);
+ ret = __adis_initial_startup(&adis16260->adis);
if (ret)
return ret;
--
2.25.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á