From: sashiko-bot@kernel.org
To: "Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v11 19/37] pinctrl: airoha: add missed IRQ resource helpers
Date: Thu, 06 Aug 2026 22:21:34 +0000 [thread overview]
Message-ID: <20260806222134.9D4C81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806220615.4078303-20-mikhail.kshevetskiy@iopsys.eu>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [High] The immutable IRQ chip `airoha_gpio_irq_chip` is missing required `gpiochip_disable_irq()` and `gpiochip_enable_irq()` calls in its `.irq_mask` and `.irq_unmask` callbacks.
- [High] The driver hardcodes `handle_simple_irq` for all GPIO interrupts and incorrectly clears the hardware interrupt status after the handler runs, breaking edge and level interrupt semantics.
- [High] The IRQ handler is requested before the gpiochip is fully initialized, creating a race condition where a shared interrupt can cause a null domain dereference.
- [High] The IRQ chip callbacks use a syscon regmap, which relies on a sleepable spinlock on PREEMPT_RT, while being called under a raw spinlock.
--
--- Patch [19]: [PATCH v11 19/37] pinctrl: airoha: add missed IRQ resource helpers ---
commit b705513e6d14523fbe92901715e6323201dc334f
Author: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
pinctrl: airoha: add missed IRQ resource helpers
Without hooking .irq_request_resources, gpiolib cannot set
GPIOD_FLAG_USED_AS_IRQ. This breaks pin direction locking and can allow
userspace or another driver to reconfigure an active IRQ pin as an output
> diff --git a/drivers/pinctrl/airoha/pinctrl-airoha.c b/drivers/pinctrl/airoha/pinctrl-airoha.c
> index 9b880fd20a1a0..f3078f9b14a76 100644
> --- a/drivers/pinctrl/airoha/pinctrl-airoha.c
> +++ b/drivers/pinctrl/airoha/pinctrl-airoha.c
> @@ -2689,6 +2689,7 @@ static const struct irq_chip airoha_gpio_irq_chip = {
> .irq_mask_ack = airoha_irq_mask,
> .irq_set_type = airoha_irq_type,
> .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
[Severity: High]
This is a pre-existing issue, but missing required gpiochip_disable_irq() and
gpiochip_enable_irq() calls in airoha_irq_mask() and airoha_irq_unmask() means
the GPIOD_FLAG_IRQ_IS_ENABLED flag is never set when an IRQ is unmasked.
Without these calls:
drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_irq_mask() {
...
regmap_clear_bits(pinctrl->regmap, gpiochip->level[index], mask);
regmap_clear_bits(pinctrl->regmap, gpiochip->edge[index], mask);
...
}
Can userspace or another driver incorrectly reconfigure the active IRQ pin as
an output because gpiolib believes the IRQ is masked or disabled?
[Severity: High]
This is a pre-existing issue, but does using syscon regmap inside the IRQ chip
callbacks cause a lock context violation on PREEMPT_RT?
The callbacks are invoked under desc->lock which is a raw spinlock:
drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_irq_mask() {
...
regmap_clear_bits(pinctrl->regmap, gpiochip->level[index], mask);
regmap_clear_bits(pinctrl->regmap, gpiochip->edge[index], mask);
}
However, the regmap is retrieved from the syscon parent in
airoha_pinctrl_probe(), which defaults to standard (sleepable) spinlocks.
Could this result in sleeping in atomic context?
> static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,
[Severity: High]
This isn't a bug introduced by this patch, but is it safe to unconditionally
use handle_simple_irq for all pins and clear the status bit after the handler
finishes?
In airoha_pinctrl_add_gpiochip(), handle_simple_irq is assigned to all pins:
drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_pinctrl_add_gpiochip() {
...
girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_simple_irq;
...
}
However, in airoha_irq_handler(), the hardware status bit is cleared after
generic_handle_irq() returns:
drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_irq_handler() {
...
generic_handle_irq(irq_find_mapping(girq->domain, offset));
regmap_write(pinctrl->regmap,
pinctrl->gpiochip.status[i], BIT(irq));
...
}
For edge-triggered interrupts, clearing the hardware status bit after the
handler returns means that any new edge occurring during handler execution
might be permanently lost. For level-triggered interrupts, handle_simple_irq
does not mask the interrupt line during execution. Can this lead to dropped
interrupts or hard interrupt storms if threaded handlers are used?
[Severity: High]
This is a pre-existing issue, but is there a race condition where a shared
interrupt can cause a NULL domain dereference?
The IRQ is requested with IRQF_SHARED before the gpiochip and its irqdomain
are added:
drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_pinctrl_add_gpiochip() {
...
err = devm_request_irq(dev, irq, airoha_irq_handler, IRQF_SHARED,
dev_name(dev), pinctrl);
if (err) {
dev_err(dev, "error requesting irq %d: %d\n", irq, err);
return err;
}
return devm_gpiochip_add_data(dev, gc, pinctrl);
}
If the shared IRQ line is asserted, the interrupt handler runs immediately.
Will it dereference girq->domain which is still NULL in airoha_irq_handler(),
leading to a kernel crash?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806220615.4078303-1-mikhail.kshevetskiy@iopsys.eu?part=19
next prev parent reply other threads:[~2026-08-06 22:21 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 22:05 [PATCH v11 00/37] pinctrl: airoha: split on shared and SoC drivers, add more SoCs Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 01/37] dt-bindings: pinctrl: airoha: en7581: fix misprint in i2s function name Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 02/37] dt-bindings: pinctrl: airoha: an7583: fix device tree binding schema Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 03/37] pinctrl: airoha: fix mdio bitfield names Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 04/37] pinctrl: airoha: an7581: fix pinconf of i2c_scl/i2c_sda pins Mikhail Kshevetskiy
2026-08-06 22:18 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 05/37] pinctrl: airoha: an7583: fix I2C0_SDA_PD register bit order Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 06/37] dt-bindings: pinctrl: airoha: en7581: allow configuration of pcie_reset pins as gpio or pwm Mikhail Kshevetskiy
2026-08-06 22:31 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 07/37] pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 08/37] dt-bindings: pinctrl: airoha: an7583: allow configuration of non-gpio default pins as gpio and pwm Mikhail Kshevetskiy
2026-08-06 22:26 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 09/37] pinctrl: airoha: an7583: fix muxing of non-gpio default pins Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 10/37] pinctrl: airoha: fix I2C1 pin mux config for AN7581 Mikhail Kshevetskiy
2026-08-06 22:20 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 11/37] dt-bindings: pinctrl: airoha: an7583: add i2c0 group for i2c function Mikhail Kshevetskiy
2026-08-06 22:20 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 12/37] pinctrl: airoha: fix I2C pin mux config for AN7583 Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 13/37] pinctrl: airoha: fix AN7583 MDIO pin mux config Mikhail Kshevetskiy
2026-08-06 22:21 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 14/37] pinctrl: airoha: an7583: fix spi group pins Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 15/37] pinctrl: airoha: add missed get_direction() function for gpio_chip Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 16/37] pinctrl: airoha: add set_direction() helper " Mikhail Kshevetskiy
2026-08-06 22:28 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 17/37] pinctrl: airoha: minor improvements Mikhail Kshevetskiy
2026-08-06 22:21 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 18/37] pinctrl: airoha: fix getting gpiochip/pinctrl pointers in the IRQ handling code Mikhail Kshevetskiy
2026-08-06 22:05 ` [PATCH v11 19/37] pinctrl: airoha: add missed IRQ resource helpers Mikhail Kshevetskiy
2026-08-06 22:21 ` sashiko-bot [this message]
2026-08-06 22:05 ` [PATCH v11 20/37] pinctrl: airoha: fix IRQ mask/unmask code Mikhail Kshevetskiy
2026-08-06 22:24 ` sashiko-bot
2026-08-06 22:05 ` [PATCH v11 21/37] pinctrl: airoha: fix edge-triggered interrupts handling Mikhail Kshevetskiy
2026-08-06 22:23 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 22/37] pinctrl: airoha: remove not needed irq_type[] array Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 23/37] pinctrl: airoha: statically allocate gpio regs structure Mikhail Kshevetskiy
2026-08-06 22:31 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 24/37] pinctrl: airoha: move common definitions to the separate header Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 25/37] pinctrl: airoha: split driver on shared code and SoC specific drivers Mikhail Kshevetskiy
2026-08-06 22:37 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 26/37] pinctrl: airoha: an7581: remove en7581 prefix from variable names Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 27/37] pinctrl: airoha: an7583: remove an7583 prefix from variable names and definitions Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 28/37] pinctrl: airoha: an7583: rename registers to match its an7583 names Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 29/37] dt-bindings: pinctrl: airoha: an7583: add missed features Mikhail Kshevetskiy
2026-08-06 22:26 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 30/37] pinctrl: airoha: an7583: add support for npu_uart pinmux Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 31/37] pinctrl: airoha: an7583: add support for pon_alt pinmux Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 32/37] pinctrl: airoha: an7583: add support for olt pinmux Mikhail Kshevetskiy
2026-08-06 22:06 ` [PATCH v11 33/37] dt-bindings: pinctrl: airoha: add support of en7523 pin controller Mikhail Kshevetskiy
2026-08-06 22:34 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 34/37] pinctrl: airoha: add support of en7523 SoC Mikhail Kshevetskiy
2026-08-06 22:33 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 35/37] pinctrl: airoha: try to find chip scu node by phandle first Mikhail Kshevetskiy
2026-08-06 22:29 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 36/37] dt-bindings: pinctrl: airoha: add support of an7563 pin controller Mikhail Kshevetskiy
2026-08-06 22:34 ` sashiko-bot
2026-08-06 22:06 ` [PATCH v11 37/37] pinctrl: airoha: add support of an7563 SoC Mikhail Kshevetskiy
2026-08-07 16:07 ` [PATCH v11 00/37] pinctrl: airoha: split on shared and SoC drivers, add more SoCs Linus Walleij
2026-08-07 16:17 ` Benjamin Larsson
2026-08-07 16:38 ` Mikhail Kshevetskiy
2026-08-07 17:20 ` Linus Walleij
2026-08-07 17:22 ` Mikhail Kshevetskiy
2026-08-07 18:45 ` Linus Walleij
2026-08-07 19:02 ` Mikhail Kshevetskiy
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=20260806222134.9D4C81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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