Devicetree
 help / color / mirror / Atom feed
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 v10 19/36] pinctrl: airoha: fix IRQ mask/unmask code
Date: Wed, 05 Aug 2026 13:01:05 +0000	[thread overview]
Message-ID: <20260805130105.A1CFA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805123408.3767648-20-mikhail.kshevetskiy@iopsys.eu>

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

Pre-existing issues:
- [High] The driver incorrectly uses `handle_simple_irq` for all interrupts, leading to interrupt storms for level-triggered interrupts. Additionally, the interrupt handler clears the interrupt status register after executing the specific IRQ handler, creating a race condition where edge-triggered interrupts can be lost. Finally, the irq_chip lacks a proper `.irq_ack` callback.
- [High] The IRQ callbacks and chained handler invoke regmap operations on a syscon regmap that uses a sleepable `spinlock_t`. On PREEMPT_RT, this causes an `rt_mutex` to be acquired in hardirq context and while holding a `raw_spinlock_t`, leading to a Wait-Type Nesting violation and a 'sleeping in atomic context' BUG.
--

--- Patch [19]: [PATCH v10 19/36] pinctrl: airoha: fix IRQ mask/unmask code ---
commit 97f2ae6176e0b5295c8894fb1446d64bc5196ae8
Author: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Subject: pinctrl: airoha: fix IRQ mask/unmask code

This commit updates the IRQ mask and unmask functions to correctly call
gpiochip_disable_irq() and gpiochip_enable_irq() when using
IRQCHIP_IMMUTABLE. This ensures gpiolib sets the GPIOD_FLAG_IRQ_IS_ENABLED
bit, allowing gpiod_direction_output() to realize when a pin is actively
used as an interrupt.

> diff --git a/drivers/pinctrl/airoha/pinctrl-airoha.c b/drivers/pinctrl/airoha/pinctrl-airoha.c
> index f3078f9b14a76..4859fcebac7de 100644
> --- a/drivers/pinctrl/airoha/pinctrl-airoha.c
> +++ b/drivers/pinctrl/airoha/pinctrl-airoha.c
> @@ -2595,6 +2595,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]
This is a pre-existing issue, but does airoha_irq_unmask() safely interact
with the regmap?

The core IRQ subsystem calls airoha_irq_unmask() while holding the raw
irq_desc spinlock with interrupts disabled. However, this function invokes
regmap operations (e.g., regmap_update_bits()) on a syscon regmap that uses
a sleepable spinlock_t (which becomes an rt_mutex on PREEMPT_RT).

Can this cause a 'sleeping in atomic context' BUG and Wait-Type Nesting
violation on PREEMPT_RT kernels?

>  	switch (gpiochip->irq_type[data->hwirq]) {
>  	case IRQ_TYPE_LEVEL_LOW:
>  		val = val << 1;

[ ... ]

> @@ -2629,6 +2630,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);
> +	gpiochip_disable_irq(gc, irqd_to_hwirq(data));
>  }

[Severity: High]
This isn't a bug introduced by this patch, but does the IRQ configuration
in airoha_pinctrl_add_gpiochip() handle level and edge interrupts correctly?

The driver unconditionally uses handle_simple_irq for all interrupts:

drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_pinctrl_add_gpiochip() {
    ...
	girq->handler = handle_simple_irq;
    ...
}

Because handle_simple_irq fails to mask the interrupt while it is being
processed, won't this lead to an infinite interrupt storm for
level-triggered interrupts?

Additionally, does airoha_irq_handler() drop edge interrupts?

drivers/pinctrl/airoha/pinctrl-airoha.c:airoha_irq_handler() {
    ...
		for_each_set_bit(irq, &status, AIROHA_PIN_BANK_SIZE) {
			u32 offset = irq + i * AIROHA_PIN_BANK_SIZE;

			generic_handle_irq(irq_find_mapping(girq->domain,
							    offset));
			regmap_write(pinctrl->regmap,
				     pinctrl->gpiochip.status[i], BIT(irq));
		}
    ...
}

The interrupt status register is cleared after generic_handle_irq() returns.
If a second edge arrives during generic_handle_irq(), won't this clear
operation drop it permanently?

Also, airoha_irq_handler() acquires the same sleepable syscon regmap lock
in hardirq context when calling regmap_read() and regmap_write(). Will this
also cause a 'sleeping in atomic context' BUG on PREEMPT_RT?

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

  reply	other threads:[~2026-08-05 13:01 UTC|newest]

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

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=20260805130105.A1CFA1F000E9@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