From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8B25295524; Mon, 14 Jul 2025 23:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752534456; cv=none; b=q3mY43F9o3yf+WNBvEt2ib2Qs6UAFUfFXx2TqtY1lq+jAi3kvorcTmRJIDFgUmE4yOWNFLEBp2X08hIkUKJHpg6f7GX3/lbo2HR9ioEeMWmtYzeNilJdKA11Hd55R1q1BcClYEzC5xtldYHEIsZ9j2QAfE/MwndOnasjlwxhkqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752534456; c=relaxed/simple; bh=b2neqRbdg5QZB1fxKDLdHHOY4i64b9TVnVi+nRhU9hg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lmicomyGl/aUEShOOmS+DrtRqhCMgGipgBL/uEsd5ejJmnqfo4CSsdRGUBslWJIpxMlcRm0Us1erAMldMoD2MHdANOc5c1Mhr6DirCBq736h5RYeCohK6SkId5Y/V35zjnownqeEy5K3ylQQ0KeTo7QQl97wPChWGn8GIe3hIaQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u50X6hNI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u50X6hNI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C44C1C4CEED; Mon, 14 Jul 2025 23:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752534455; bh=b2neqRbdg5QZB1fxKDLdHHOY4i64b9TVnVi+nRhU9hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u50X6hNINVC99XJXKintBdsUJBpSAIdVL6Fircd8bB9npCUdo5ZFOXu51zYuWKKpC qxBQeWhKe88WPyxHwmGVX2uT1wLP64CoF0waL/cvYSyBj8aCJCtuONH0Zc/oz3Hdfq pgSArMRkUWftWbvn1jRSNmSFtCq+8ylbfuSkvu3n9TaFq6769iDG7RRlqae/e0ecv1 +vSrvNYRvZlbia0QvW/SDAysWoeVo3Fyv2TbbWzabE/V6hal4VYhEpNUw/V/A9+6nd LOfjaTJd9PXVisBr5vTr2K73FUwky24FRGIZ1mPp0r+DaaHfIAgVHK7a/+dUWv4v0Q dr17bdkNRlftQ== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Milan Krstic , David Bauer , Linus Walleij , Sasha Levin , 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 Message-Id: <20250714230715.3710039-10-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250714230715.3710039-1-sashal@kernel.org> References: <20250714230715.3710039-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.38 Content-Transfer-Encoding: 8bit From: Milan Krstic [ 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 Signed-off-by: Milan Krstic Link: https://lore.kernel.org/20250703143039.5809-1-milan.krstic@gmail.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- 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