From: Milan Krstic milan.krstic@gmail.com
[ Upstream commit 5285b5ed04ab6ad40f7b654eefbccd6ae8cbf415 ]
The GPIO expander is connected via I2C, thus the can_sleep flag has to be set to true. This fixes spurious "scheduling while atomic" bugs in the kernel ringbuffer.
Signed-off-by: David Bauer mail@david-bauer.net Signed-off-by: Milan Krstic milan.krstic@gmail.com Link: https://lore.kernel.org/20250703143039.5809-1-milan.krstic@gmail.com Signed-off-by: Linus Walleij linus.walleij@linaro.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
**YES**
This commit should be backported to stable kernel trees.
## Extensive Explanation:
This is a critical bug fix that addresses a **sleep-in-atomic-context** issue in the aw9523 GPIO expander driver. Here's why this is an excellent candidate for stable backporting:
### 1. **Clear Bug Fix** The commit fixes a concrete bug where the driver incorrectly sets `can_sleep = false` for a GPIO chip that communicates over I2C. As evidenced in the code: - The GPIO operations (`aw9523_gpio_get`, `aw9523_gpio_set`, etc.) all use `mutex_lock(&awi->i2c_lock)` and `regmap` operations - All GPIO operations involve I2C transactions through `regmap_read/write` - I2C operations can sleep and cannot be called from atomic contexts
### 2. **Causes Real User-Visible Issues** The commit message explicitly states this causes "spurious 'scheduling while atomic' bugs in the kernel ringbuffer". These are serious kernel warnings that indicate the system is attempting to sleep in contexts where sleeping is not allowed, which can lead to: - System instability - Kernel warnings flooding the log - Potential deadlocks or system hangs
### 3. **Simple, Low-Risk Fix** The fix is a one-line change from `gc->can_sleep = false;` to `gc->can_sleep = true;`. This is: - Minimal in scope - Only affects the metadata about the GPIO chip - Doesn't change any actual functionality - Just correctly declares the chip's sleeping requirements
### 4. **Similar to Previously Backported Commits** Looking at the similar commits: - Commit #1 (gpio-adp5588): Fixed sleep-in-atomic bugs - **BACKPORTED** - Commit #3 (ltc2992): Fixed the same `can_sleep` flag issue for another I2C GPIO chip - **BACKPORTED**
Both of these commits addressed the exact same class of bug and were deemed suitable for stable backporting.
### 5. **Long-standing Bug** The bug has existed since the driver was initially introduced (commit 576623d70661), meaning all kernel versions with this driver are affected. The original implementation incorrectly set `gc->can_sleep = false`.
### 6. **Meets Stable Kernel Criteria** According to stable kernel rules, this fix: - Fixes a real bug that users can hit - Is already in Linus's tree (merged) - Is small and self-contained - Doesn't add new features - Has minimal risk of regression
The commit is essential for proper operation of systems using the AW9523 GPIO expander, preventing kernel warnings and potential system instability when GPIOs are accessed from non-sleeping contexts.
drivers/pinctrl/pinctrl-aw9523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c index 9bf53de20be87..04afb344e9e58 100644 --- a/drivers/pinctrl/pinctrl-aw9523.c +++ b/drivers/pinctrl/pinctrl-aw9523.c @@ -784,7 +784,7 @@ static int aw9523_init_gpiochip(struct aw9523 *awi, unsigned int npins) gc->set_config = gpiochip_generic_config; gc->parent = dev; gc->owner = THIS_MODULE; - gc->can_sleep = false; + gc->can_sleep = true;
return 0; }