All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 16/35] pinctrl: airoha: fix IRQ mask/unmask code
Date: Mon, 27 Jul 2026 18:15:22 +0000	[thread overview]
Message-ID: <20260727181523.22B231F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727174141.664933-17-mikhail.kshevetskiy@iopsys.eu>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] The newly added `gpiochip_enable_irq()` and `gpiochip_disable_irq()` calls will continuously trigger kernel warnings and fail to set their flags because the driver lacks `GPIOCHIP_IRQ_RESOURCE_HELPERS`.

Pre-existing issues:
- [High] Lock nesting violation in IRQ callbacks causing a 'sleeping in atomic context' bug on PREEMPT_RT.
- [High] Race condition leading to permanently lost edge-triggered interrupts.
--

--- Patch [16]: [PATCH v8 16/35] pinctrl: airoha: fix IRQ mask/unmask code ---
commit ccf67b0bce7e44b6db4c8d2e60b3cba3f820c9f4
Author: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>

pinctrl: airoha: fix IRQ mask/unmask code

When using IRQCHIP_IMMUTABLE, airoha_irq_unmask() must manually call
gpiochip_enable_irq() and airoha_irq_mask() must call
gpiochip_disable_irq(). Without these calls, gpiolib never sets the
GPIOD_FLAG_IRQ_IS_ENABLED bit. Because this bit is missing,
gpiod_direction_output() will not realize the pin is actively used
as an interrupt.

> diff --git a/drivers/pinctrl/airoha/pinctrl-airoha.c b/drivers/pinctrl/airoha/pinctrl-airoha.c
> index 3feddec2e29e3..6561f288dbf05 100644
> --- a/drivers/pinctrl/airoha/pinctrl-airoha.c
> +++ b/drivers/pinctrl/airoha/pinctrl-airoha.c
> @@ -2575,6 +2575,7 @@ static void airoha_irq_unmask(struct irq_data *data)
>  	if (WARN_ON_ONCE(data->hwirq >= ARRAY_SIZE(gpiochip->irq_type)))
>  		return;
>  
> +	gpiochip_enable_irq(gc, irqd_to_hwirq(data));

[Severity: High]
Will this cause continuous warning spam on every unmask operation?

The gpiochip_enable_irq() function enforces a WARN_ON check to verify
that GPIOD_FLAG_USED_AS_IRQ is set. Because airoha_gpio_irq_chip specifies
IRQCHIP_IMMUTABLE but omits GPIOCHIP_IRQ_RESOURCE_HELPERS, the
gpiochip_irq_reqres() setup is never invoked. As a result, the required flag
is missing and the flag updates bypass being set entirely.

[ ... ]

> @@ -2609,6 +2610,7 @@ static void airoha_irq_mask(struct irq_data *data)
>  
>  	regmap_clear_bits(pinctrl->regmap, gpiochip->level[index], mask);
>  	regmap_clear_bits(pinctrl->regmap, gpiochip->edge[index], mask);

[Severity: High]
This is a pre-existing issue, but could calling regmap_clear_bits() here
cause a lock nesting violation on PREEMPT_RT systems?

The core IRQ subsystem invokes airoha_irq_mask() with the raw
irq_desc->lock held. The regmap operations use a standard spinlock,
which becomes a sleepable rt_mutex on PREEMPT_RT, leading to a sleep in
atomic context.

> +	gpiochip_disable_irq(gc, irqd_to_hwirq(data));
>  }

[ ... ]

[Severity: High]
This is also a pre-existing issue, but is there a race condition in the
interrupt handler that could cause permanently lost edge-triggered interrupts?

Looking at airoha_irq_handler() in the same file:

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));
	...
}

If a new edge interrupt arrives while generic_handle_irq() is executing,
it is latched by the hardware. The subsequent Write-1-to-Clear via
regmap_write() would then inadvertently clear this newly latched edge
without servicing it. Should the status be cleared before invoking the
handler?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727174141.664933-1-mikhail.kshevetskiy@iopsys.eu?part=16

  reply	other threads:[~2026-07-27 18:15 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 17:41 [PATCH v8 00/35] pinctrl: airoha: split on shared and SoC drivers, add more SoCs Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 01/35] dt-bindings: pinctrl: airoha: en7581: fix misprint in i2s function name Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 02/35] dt-bindings: pinctrl: airoha: en7581: fix pwm pin-groups Mikhail Kshevetskiy
2026-07-27 17:53   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 03/35] dt-bindings: pinctrl: airoha: an7583: fix device tree binding schema Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 04/35] pinctrl: airoha: fix mdio bitfield names Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 05/35] pinctrl: airoha: an7581: fix pinconf of i2c_scl/i2c_sda pins Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 06/35] pinctrl: airoha: an7583: fix I2C0_SDA_PD register bit order Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 07/35] pinctrl: airoha: an7583: there are no muxes to enable i2c buses Mikhail Kshevetskiy
2026-07-27 17:52   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 08/35] dt-bindings: pinctrl: airoha: an7583: remove i2c pin function Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 09/35] pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins Mikhail Kshevetskiy
2026-07-27 17:55   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 10/35] dt-bindings: pinctrl: airoha: en7581: allow configuration of pcie_reset pins as gpio or pwm Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 11/35] pinctrl: airoha: an7583: fix muxing of non-gpio default pins Mikhail Kshevetskiy
2026-07-27 18:00   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 12/35] dt-bindings: pinctrl: airoha: an7583: allow configuration of non-gpio default pins as gpio and pwm Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 13/35] pinctrl: airoha: add missed get_direction() function for gpio_chip Mikhail Kshevetskiy
2026-07-27 18:04   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 14/35] pinctrl: airoha: add set_direction() helper " Mikhail Kshevetskiy
2026-07-27 18:09   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 15/35] pinctrl: airoha: fix getting gpiochip/pinctrl pointers in the IRQ handling code Mikhail Kshevetskiy
2026-07-27 17:56   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 16/35] pinctrl: airoha: fix IRQ mask/unmask code Mikhail Kshevetskiy
2026-07-27 18:15   ` sashiko-bot [this message]
2026-07-27 17:41 ` [PATCH v8 17/35] pinctrl: airoha: add missed IRQ resource helpers Mikhail Kshevetskiy
2026-07-27 18:10   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 18/35] pinctrl: airoha: fix edge-triggered interrupts handling Mikhail Kshevetskiy
2026-07-27 18:03   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 19/35] pinctrl: airoha: remove not needed irq_type[] array Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 20/35] pinctrl: airoha: move common definitions to the separate header Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 21/35] pinctrl: airoha: split driver on shared code and SoC specific drivers Mikhail Kshevetskiy
2026-07-27 18:09   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 22/35] pinctrl: airoha: an7581: remove en7581 prefix from variable names Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 23/35] pinctrl: airoha: an7583: remove an7583 prefix from variable names and definitions Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 24/35] pinctrl: airoha: an7583: rename registers to match its an7583 names Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 25/35] pinctrl: airoha: an7583: add support for npu_uart pinmux Mikhail Kshevetskiy
2026-07-27 18:07   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 26/35] dt-bindings: pinctrl: airoha: an7583: add npu_uart pin group Mikhail Kshevetskiy
2026-07-27 17:41 ` [PATCH v8 27/35] pinctrl: airoha: an7583: add support for pon_alt pinmux Mikhail Kshevetskiy
2026-07-27 18:10   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 28/35] dt-bindings: pinctrl: airoha: an7583: add pon_alt pin group Mikhail Kshevetskiy
2026-07-27 20:14   ` Krzysztof Kozlowski
2026-07-27 17:41 ` [PATCH v8 29/35] pinctrl: airoha: an7583: add support for olt pinmux Mikhail Kshevetskiy
2026-07-27 18:11   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 30/35] dt-bindings: pinctrl: airoha: an7583: add olt function/group Mikhail Kshevetskiy
2026-07-27 20:15   ` Krzysztof Kozlowski
2026-07-27 17:41 ` [PATCH v8 31/35] pinctrl: airoha: add support of en7523 SoC Mikhail Kshevetskiy
2026-07-27 18:15   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 32/35] pinctrl: airoha: try to find chip scu node by phandle first Mikhail Kshevetskiy
2026-07-27 18:11   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 33/35] dt-bindings: pinctrl: airoha: add support of en7523 pin controller Mikhail Kshevetskiy
2026-07-27 18:20   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 34/35] pinctrl: airoha: add support of an7563 SoC Mikhail Kshevetskiy
2026-07-27 18:16   ` sashiko-bot
2026-07-27 17:41 ` [PATCH v8 35/35] dt-bindings: pinctrl: airoha: add support of an7563 pin controller Mikhail Kshevetskiy
2026-07-27 20:12 ` [PATCH v8 00/35] pinctrl: airoha: split on shared and SoC drivers, add more SoCs Krzysztof Kozlowski

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=20260727181523.22B231F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.