From: Anand Moon <linux.amoon@gmail.com>
To: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Troy Mitchell" <troy.mitchell@linux.spacemit.com>,
"Andi Shyti" <andi.shyti@kernel.org>,
"Sebastian Reichel" <sre@kernel.org>,
"Yixun Lan" <dlan@kernel.org>,
"Radim Krčmář" <rkrcmar@ventanamicro.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE),
linux-kernel@vger.kernel.org (open list),
linux-i2c@vger.kernel.org (open list:I2C SUBSYSTEM HOST DRIVERS),
linux-pm@vger.kernel.org (open list:SYSTEM RESET/SHUTDOWN
DRIVERS),
spacemit@lists.linux.dev (open list:RISC-V SPACEMIT SoC Support)
Cc: Anand Moon <linux.amoon@gmail.com>, Alex Elder <elder@riscstar.com>
Subject: [PATCH v2 1/3] i2c: spacemit: Avoid sleeping during bus reset in atomic context
Date: Wed, 18 Nov 2026 16:19:13 +0530 [thread overview]
Message-ID: <20261118104935.1716-1-linux.amoon@gmail.com> (raw)
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.
Fixes: 5dd75dac1b35 ("i2c: spacemit: introduce pio for k1")
Cc: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Cc: Alex Elder <elder@riscstar.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
v1: https://lore.kernel.org/all/20261110061429.2036-1-linux.amoon@gmail.com/
collected all te reviewed-by
---
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: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca
--
2.56.0
WARNING: multiple messages have this Message-ID (diff)
From: Anand Moon <linux.amoon@gmail.com>
To: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Troy Mitchell" <troy.mitchell@linux.spacemit.com>,
"Andi Shyti" <andi.shyti@kernel.org>,
"Sebastian Reichel" <sre@kernel.org>,
"Yixun Lan" <dlan@kernel.org>,
"Radim Krčmář" <rkrcmar@ventanamicro.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE),
linux-kernel@vger.kernel.org (open list),
linux-i2c@vger.kernel.org (open list:I2C SUBSYSTEM HOST DRIVERS),
linux-pm@vger.kernel.org (open list:SYSTEM RESET/SHUTDOWN
DRIVERS),
spacemit@lists.linux.dev (open list:RISC-V SPACEMIT SoC Support)
Cc: Alex Elder <elder@riscstar.com>
Subject: [PATCH v2 1/3] i2c: spacemit: Avoid sleeping during bus reset in atomic context
Date: Wed, 18 Nov 2026 16:19:13 +0530 [thread overview]
Message-ID: <20261118104935.1716-1-linux.amoon@gmail.com> (raw)
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.
Fixes: 5dd75dac1b35 ("i2c: spacemit: introduce pio for k1")
Cc: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Cc: Alex Elder <elder@riscstar.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
v1: https://lore.kernel.org/all/20261110061429.2036-1-linux.amoon@gmail.com/
collected all te reviewed-by
---
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: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca
--
2.56.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2026-11-18 10:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 10:49 Anand Moon [this message]
2026-11-18 10:49 ` [PATCH v2 1/3] i2c: spacemit: Avoid sleeping during bus reset in atomic context Anand Moon
2026-11-18 10:49 ` [PATCH v2 2/3] riscv: sbi: Register SRST handlers with firmware priority Anand Moon
2026-11-18 10:49 ` Anand Moon
2026-11-18 10:49 ` [PATCH v2 3/3] power: reset: Remove SpacemiT P1 reboot driver Anand Moon
2026-11-18 10:49 ` Anand Moon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118104935.1716-1-linux.amoon@gmail.com \
--to=linux.amoon@gmail.com \
--cc=alex@ghiti.fr \
--cc=andi.shyti@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=aurelien@aurel32.net \
--cc=dlan@kernel.org \
--cc=elder@riscstar.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=rkrcmar@ventanamicro.com \
--cc=spacemit@lists.linux.dev \
--cc=sre@kernel.org \
--cc=troy.mitchell@linux.spacemit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.