Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: rk3x: Do not sleep in atomic polling transfers
@ 2026-11-27 12:33 Sebastian Reichel
  2026-11-27 12:46 ` Heiko Stübner
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Reichel @ 2026-11-27 12:33 UTC (permalink / raw)
  To: Heiko Stuebner, Andi Shyti, Wolfram Sang, Jensen Huang
  Cc: linux-arm-kernel, linux-rockchip, linux-i2c, kernel, stable,
	Sebastian Reichel

On the RK3576 Sige5 during shutdown the following trace appears on
kernels with multi-core support and lockdep enabled:

[  167.961946] WARNING: kernel/irq_work.c:296 at irq_work_sync
...
[  167.963902] Hardware name: ArmSoM Sige5 (DT)
...
[  167.972228] Call trace:
[  167.972445]  irq_work_sync+0xe8/0xf8 (P)
[  167.972796]  disable_irq+0x44/0x60
[  167.973101]  rk3x_i2c_xfer_common.isra.0+0x254/0x708
[  167.973544]  rk3x_i2c_xfer_polling+0x20/0xa0
[  167.973925]  __i2c_transfer+0x180/0x9d8
[  167.974269]  i2c_transfer+0xc4/0x180
[  167.974589]  regmap_i2c_read+0x64/0xc0
[  167.974924]  _regmap_raw_read+0x120/0x468
[  167.975283]  _regmap_bus_read+0x4c/0xa8
[  167.975626]  _regmap_read+0x6c/0x260
[  167.975945]  _regmap_update_bits+0x104/0x160
[  167.976325]  regmap_update_bits_base+0x5c/0x90
[  167.976720]  rk808_power_off+0x70/0x110
...

Avoid waiting for a handler from another CPU to finish to fix the
problem. At shutdown time this won't happen as the other CPUs are
already stopped. Apart from that disable_irq_nosync() still prevents new
invocations of the handler, which is what avoids the spinlock recursion.
A handler already running on another CPU is serialized against the poll
loop via i2c->lock.

Cc: stable@vger.kernel.org
Fixes: 19cde9c92b8d ("i2c: rk3x: fix potential spinlock recursion on poll")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/i2c/busses/i2c-rk3x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index 9ec3beced9f9..a07c60ab07b4 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -1096,7 +1096,7 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
 			time_left = wait_event_timeout(i2c->wait, !i2c->busy,
 						       msecs_to_jiffies(WAIT_TIMEOUT));
 		} else {
-			disable_irq(i2c->irq);
+			disable_irq_nosync(i2c->irq);
 			rk3x_i2c_start(i2c);
 
 			time_left = rk3x_i2c_wait_xfer_poll(i2c);

---
base-commit: eeb63983deb23d68ddc47e5d1944a7d64acdaf22
change-id: 20261127-rk3x-atomic-transfer-fix-23f2d43c38b6

Best regards,
--  
Sebastian Reichel <sebastian.reichel@collabora.com>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i2c: rk3x: Do not sleep in atomic polling transfers
  2026-11-27 12:33 [PATCH] i2c: rk3x: Do not sleep in atomic polling transfers Sebastian Reichel
@ 2026-11-27 12:46 ` Heiko Stübner
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stübner @ 2026-11-27 12:46 UTC (permalink / raw)
  To: Andi Shyti, Wolfram Sang, Jensen Huang, Sebastian Reichel
  Cc: linux-arm-kernel, linux-rockchip, linux-i2c, kernel, stable,
	Sebastian Reichel

Am Freitag, 27. November 2026, 13:33:05 Mitteleuropäische Normalzeit schrieb Sebastian Reichel:
> On the RK3576 Sige5 during shutdown the following trace appears on
> kernels with multi-core support and lockdep enabled:
> 
> [  167.961946] WARNING: kernel/irq_work.c:296 at irq_work_sync
> ...
> [  167.963902] Hardware name: ArmSoM Sige5 (DT)
> ...
> [  167.972228] Call trace:
> [  167.972445]  irq_work_sync+0xe8/0xf8 (P)
> [  167.972796]  disable_irq+0x44/0x60
> [  167.973101]  rk3x_i2c_xfer_common.isra.0+0x254/0x708
> [  167.973544]  rk3x_i2c_xfer_polling+0x20/0xa0
> [  167.973925]  __i2c_transfer+0x180/0x9d8
> [  167.974269]  i2c_transfer+0xc4/0x180
> [  167.974589]  regmap_i2c_read+0x64/0xc0
> [  167.974924]  _regmap_raw_read+0x120/0x468
> [  167.975283]  _regmap_bus_read+0x4c/0xa8
> [  167.975626]  _regmap_read+0x6c/0x260
> [  167.975945]  _regmap_update_bits+0x104/0x160
> [  167.976325]  regmap_update_bits_base+0x5c/0x90
> [  167.976720]  rk808_power_off+0x70/0x110
> ...
> 
> Avoid waiting for a handler from another CPU to finish to fix the
> problem. At shutdown time this won't happen as the other CPUs are
> already stopped. Apart from that disable_irq_nosync() still prevents new
> invocations of the handler, which is what avoids the spinlock recursion.
> A handler already running on another CPU is serialized against the poll
> loop via i2c->lock.
> 
> Cc: stable@vger.kernel.org
> Fixes: 19cde9c92b8d ("i2c: rk3x: fix potential spinlock recursion on poll")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

With CONFIG_DEBUG_ATOMIC_SLEEP activated, this should also already
already warn from the might_sleep() in disable_irq(), I think.



> ---
>  drivers/i2c/busses/i2c-rk3x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
> index 9ec3beced9f9..a07c60ab07b4 100644
> --- a/drivers/i2c/busses/i2c-rk3x.c
> +++ b/drivers/i2c/busses/i2c-rk3x.c
> @@ -1096,7 +1096,7 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
>  			time_left = wait_event_timeout(i2c->wait, !i2c->busy,
>  						       msecs_to_jiffies(WAIT_TIMEOUT));
>  		} else {
> -			disable_irq(i2c->irq);
> +			disable_irq_nosync(i2c->irq);
>  			rk3x_i2c_start(i2c);
>  
>  			time_left = rk3x_i2c_wait_xfer_poll(i2c);
> 
> ---
> base-commit: eeb63983deb23d68ddc47e5d1944a7d64acdaf22
> change-id: 20261127-rk3x-atomic-transfer-fix-23f2d43c38b6
> 
> Best regards,
> --  
> Sebastian Reichel <sebastian.reichel@collabora.com>
> 
> 






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 12:33 [PATCH] i2c: rk3x: Do not sleep in atomic polling transfers Sebastian Reichel
2026-11-27 12:46 ` Heiko Stübner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox