From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Milan Krstic <milan.krstic@gmail.com>,
David Bauer <mail@david-bauer.net>,
Linus Walleij <linus.walleij@linaro.org>,
Sasha Levin <sashal@kernel.org>,
brgl@bgdev.pl, linux-gpio@vger.kernel.org
Subject: [PATCH AUTOSEL 6.12 10/12] pinctrl: aw9523: fix can_sleep flag for GPIO chip
Date: Mon, 14 Jul 2025 19:07:13 -0400 [thread overview]
Message-ID: <20250714230715.3710039-10-sashal@kernel.org> (raw)
In-Reply-To: <20250714230715.3710039-1-sashal@kernel.org>
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 1374f30166bc3..1fe01e4cd2107 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;
}
--
2.39.5
prev parent reply other threads:[~2025-07-14 23:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250714230715.3710039-1-sashal@kernel.org>
2025-07-14 23:07 ` [PATCH AUTOSEL 6.12 06/12] gpio: of: initialize local variable passed to the .of_xlate() callback Sasha Levin
2025-07-14 23:07 ` Sasha Levin [this message]
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=20250714230715.3710039-10-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mail@david-bauer.net \
--cc=milan.krstic@gmail.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).