Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linus Walleij" <linusw@kernel.org>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 2/2] mfd: arizona: Convert GPIO IRQ handling to descriptors
Date: Wed, 27 May 2026 13:38:55 +0000	[thread overview]
Message-ID: <20260527133855.94A031F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260527-mfd-arizona-irq-v5-2-ebeda2e925da@kernel.org>

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

New issues:
- [High] Migration from legacy gpio to gpiod incorrectly replaces physical line reads with logical value reads, breaking IRQ polling logic for active-low GPIOs.

Pre-existing issues:
- [High] Negative error codes from GPIO reads are implicitly treated as boolean true, causing an infinite loop in the IRQ thread on read failure.
--

commit 2b527ef2c7b9b60397ceb6125cd15341ac4e28ff
Author: Linus Walleij <linusw@kernel.org>

mfd: arizona: Convert GPIO IRQ handling to descriptors

This commit converts the arizona polling GPIO handling to use a GPIO descriptor
instead of passing a global GPIO number as platform data.

> diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c
> index 544016d420fe2..cf8e42662585a 100644
> --- a/drivers/mfd/arizona-irq.c
> +++ b/drivers/mfd/arizona-irq.c
> @@ -136,21 +136,19 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)
[ ... ]
>  		if (!arizona->irq_gpiod) {
>  			break;
>  		} else if (arizona->pdata.irq_flags & IRQF_TRIGGER_RISING &&
> -			   gpio_get_value_cansleep(arizona->pdata.irq_gpio)) {
> +			   gpiod_get_value_cansleep(arizona->irq_gpiod)) {

[Severity: High]
Does this incorrectly check the logical value of the GPIO instead of the raw
physical state?

The legacy gpio_get_value_cansleep() returned the raw physical state of the
pin. The new gpiod_get_value_cansleep() returns the logical state, which
incorporates the ACTIVE_LOW flag from the devicetree or software node.

Because the IRQ trigger flags describe physical voltage transitions, comparing
these physical flags against a logical value might be incorrect. For example,
if a user defines irq-gpios with GPIO_ACTIVE_LOW for a falling edge interrupt,
a physically low line becomes logically 1, causing the polling condition
!gpiod_get_value_cansleep() to evaluate to 0, which fails to poll when the
interrupt is active.

Conversely, when the line is idle, it evaluates to 1, causing the IRQ handler
to poll infinitely.

Should this use gpiod_get_raw_value_cansleep() to preserve the original
physical semantics?

[Severity: High]
This is a pre-existing issue, but can this loop forever if the GPIO read
returns a negative error code?

gpiod_get_value_cansleep() (and its legacy predecessor) can return a negative
error code (e.g., -EIO) if reading the GPIO state fails over the bus. Since
negative values are non-zero, this evaluates to true for IRQF_TRIGGER_RISING,
setting poll = true and causing an infinite loop in the IRQ handler thread if
the read continues to fail.

Conversely, for IRQF_TRIGGER_FALLING, !(-EIO) evaluates to false, which
immediately aborts the poll.

Could the return value be stored in an integer and explicitly checked for
negative errors before evaluating it as a boolean?

>  			poll = true;
>  		} else if (arizona->pdata.irq_flags & IRQF_TRIGGER_FALLING &&
> -			   !gpio_get_value_cansleep(arizona->pdata.irq_gpio)) {
> +			   !gpiod_get_value_cansleep(arizona->irq_gpiod)) {
>  			poll = true;
>  		}
>  	} while (poll);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260527-mfd-arizona-irq-v5-0-ebeda2e925da@kernel.org?part=2

  reply	other threads:[~2026-05-27 13:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 13:05 [PATCH v5 0/2] mfd: arizona: Move IRQ GPIO to GPIO descriptor Linus Walleij
2026-05-27 13:05 ` [PATCH v5 1/2] dt-bindings: mfd: wlf,arizona: Add irq-gpios Linus Walleij
2026-05-27 13:05 ` [PATCH v5 2/2] mfd: arizona: Convert GPIO IRQ handling to descriptors Linus Walleij
2026-05-27 13:38   ` sashiko-bot [this message]
2026-06-11  8:20   ` Lee Jones
2026-06-11  9:03     ` Charles Keepax

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=20260527133855.94A031F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linusw@kernel.org \
    --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