[PATCH v1 1/2] i2c: spacemit: Avoid sleeping during bus reset in atomic context
Anand Moon
linux.amoon at gmail.com
Mon Nov 9 22:14:26 PST 2026
The spacemit_i2c_conditionally_reset_bus() function uses usleep_range()
to wait after triggering a bus reset request. However, this function can
be invoked during atomic I2C transfers (such as power-off or restart
handlers running in atomic notifier chains), where sleeping is illegal.
Replace the sleep operation with the driver's internal helper,
spacemit_i2c_delay(), which conditionally uses udelay() when running in
an atomic context, avoiding "scheduling while atomic" bugs.
Assisted-by: LLM
Cc: Troy Mitchell <troy.mitchell at linux.spacemit.com>
Cc: Alex Elder <elder at riscstar.com>
Signed-off-by: Anand Moon <linux.amoon at gmail.com>
---
drivers/i2c/busses/i2c-k1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index ff32876e24d3..f4b21d7efaaf 100644
--- a/drivers/i2c/busses/i2c-k1.c
+++ b/drivers/i2c/busses/i2c-k1.c
@@ -332,7 +332,7 @@ static void spacemit_i2c_conditionally_reset_bus(struct spacemit_i2c_dev *i2c)
writel(FIELD_PREP(SPACEMIT_RCR_FIELD_RST_CYC, 1),
i2c->base + SPACEMIT_IRCR);
writel(SPACEMIT_CR_RSTREQ, i2c->base + SPACEMIT_ICR);
- usleep_range(20, 30);
+ spacemit_i2c_delay(i2c, 20);
}
/* check sda again here */
base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
--
2.56.0
More information about the linux-riscv
mailing list