lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250601233744.3514795-53-sashal@kernel.org>
Date: Sun,  1 Jun 2025 19:37:30 -0400
From: Sasha Levin <sashal@...nel.org>
To: patches@...ts.linux.dev,
	stable@...r.kernel.org
Cc: Peng Fan <peng.fan@....com>,
	Linus Walleij <linus.walleij@...aro.org>,
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
	Sasha Levin <sashal@...nel.org>,
	brgl@...ev.pl,
	linux-gpio@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH AUTOSEL 6.6 53/66] gpio: xgene-sb: Make irq_chip immutable

From: Peng Fan <peng.fan@....com>

[ Upstream commit 580b3264cb252cae00fa62d58443af09c25f7d61 ]

Kernel warns about mutable irq_chips:
"not an immutable chip, please consider fixing!"

Constify xgene_gpio_sb_irq_chip, flag the irq_chip as IRQCHIP_IMMUTABLE,
add the new helper functions, and call the appropriate gpiolib functions.

Signed-off-by: Peng Fan <peng.fan@....com>
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>
Link: https://lore.kernel.org/r/20250509-gpio-v1-7-639377c98288@nxp.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---

Based on my analysis of the commit and the kernel context, here is my
determination: **YES** This commit should be backported to stable kernel
trees. Here's my extensive analysis: ## Analysis of the Commit ### 1.
**Purpose and Nature of the Change** The commit addresses a kernel
warning about mutable irq_chips by converting the
`xgene_gpio_sb_irq_chip` to be immutable. This is a **bug fix** that
eliminates runtime warnings, not a new feature or architectural change.
### 2. **Code Changes Analysis** The changes are minimal and follow an
established pattern: **Key Changes:** - **Made struct const**: `static
struct irq_chip` → `static const struct irq_chip` - **Added
IRQCHIP_IMMUTABLE flag**: Prevents runtime modification of the irq_chip
- **Added resource helpers**: `GPIOCHIP_IRQ_RESOURCE_HELPERS` macro -
**Replaced direct parent calls with wrapper functions**: -
`irq_chip_mask_parent` → `xgene_gpio_sb_irq_mask` (which calls
`gpiochip_disable_irq` then `irq_chip_mask_parent`) -
`irq_chip_unmask_parent` → `xgene_gpio_sb_irq_unmask` (which calls
`gpiochip_enable_irq` then `irq_chip_unmask_parent`) ### 3. **Comparison
with Similar Commits** This commit follows **exactly the same pattern**
as the similar commits marked "YES" for backporting: - **gpio: vf610:
make irq_chip immutable** (Status: YES) - **gpio: 104-idio-16: Make
irq_chip immutable** (Status: YES) The changes are nearly identical in
structure and purpose to these approved backports. ### 4. **Risk
Assessment** **Very Low Risk:** - **Contained change**: Only affects the
xgene-sb GPIO driver - **Follows established pattern**: The
IRQCHIP_IMMUTABLE pattern has been widely adopted across GPIO drivers
since kernel v5.19 - **No functional behavior change**: The GPIO
operations work exactly the same way - **Well-tested pattern**: Multiple
GPIO drivers have successfully adopted this pattern ### 5. **Backport
Criteria Evaluation** ✅ **Fixes a bug**: Eliminates kernel warning about
mutable irq_chips ✅ **Small and contained**: Only 20 lines changed in a
single driver ✅ **No side effects**: Change is purely about chip
mutability, not functionality ✅ **No architectural changes**: Uses
existing infrastructure introduced in v5.19 ✅ **Follows stable rules**:
Important bugfix with minimal regression risk ✅ **Critical subsystem
consideration**: GPIO is used widely, but change is driver-specific ###
6. **Historical Context** The IRQCHIP_IMMUTABLE pattern and supporting
infrastructure were introduced in linux-kernel v5.19** (commit
36b78aae4bfe). This commit uses the same established APIs
(`gpiochip_enable_irq`, `gpiochip_disable_irq`,
`GPIOCHIP_IRQ_RESOURCE_HELPERS`) that have been stable since then. ###
7. **Warning Elimination** The commit specifically addresses the kernel
warning "not an immutable chip, please consider fixing!" which can be
disruptive in production environments. Eliminating such warnings
improves system stability and reduces noise in kernel logs. ###
Conclusion This is a straightforward bugfix that follows a well-
established, low-risk pattern adopted by numerous GPIO drivers. It
eliminates kernel warnings without changing functional behavior, making
it an ideal candidate for stable tree backporting.

 drivers/gpio/gpio-xgene-sb.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c
index a809609ee9570..6b799c17902c9 100644
--- a/drivers/gpio/gpio-xgene-sb.c
+++ b/drivers/gpio/gpio-xgene-sb.c
@@ -102,12 +102,32 @@ static int xgene_gpio_sb_irq_set_type(struct irq_data *d, unsigned int type)
 		return irq_chip_set_type_parent(d, IRQ_TYPE_LEVEL_HIGH);
 }
 
-static struct irq_chip xgene_gpio_sb_irq_chip = {
+static void xgene_gpio_sb_irq_mask(struct irq_data *d)
+{
+	struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
+
+	irq_chip_mask_parent(d);
+
+	gpiochip_disable_irq(&priv->gc, d->hwirq);
+}
+
+static void xgene_gpio_sb_irq_unmask(struct irq_data *d)
+{
+	struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
+
+	gpiochip_enable_irq(&priv->gc, d->hwirq);
+
+	irq_chip_unmask_parent(d);
+}
+
+static const struct irq_chip xgene_gpio_sb_irq_chip = {
 	.name           = "sbgpio",
 	.irq_eoi	= irq_chip_eoi_parent,
-	.irq_mask       = irq_chip_mask_parent,
-	.irq_unmask     = irq_chip_unmask_parent,
+	.irq_mask       = xgene_gpio_sb_irq_mask,
+	.irq_unmask     = xgene_gpio_sb_irq_unmask,
 	.irq_set_type   = xgene_gpio_sb_irq_set_type,
+	.flags = IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static int xgene_gpio_sb_to_irq(struct gpio_chip *gc, u32 gpio)
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ