From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Lee Jones <lee@kernel.org>
Cc: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
patches@opensource.cirrus.com, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: Re: [PATCH v5 2/2] mfd: arizona: Convert GPIO IRQ handling to descriptors
Date: Thu, 11 Jun 2026 10:03:20 +0100 [thread overview]
Message-ID: <aip52HIwSIWBoE1d@opensource.cirrus.com> (raw)
In-Reply-To: <20260611082000.GL4151951@google.com>
On Thu, Jun 11, 2026 at 09:20:00AM +0100, Lee Jones wrote:
> On Wed, 27 May 2026, Linus Walleij wrote:
> > - 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?
Hmm.. yeah that is a good spot we should probably use the
raw_value version here as we presumably can't trust that the
device trees specify the ACTIVE_LOW/HIGH flags correctly.
> [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?
This is also fair, although given this feature is only really
supporting some quite old things that have been doing this for
ages I would be inclined to not stress too much about this.
Thanks,
Charles
prev parent reply other threads:[~2026-06-11 9:03 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
2026-06-11 8:20 ` Lee Jones
2026-06-11 9:03 ` Charles Keepax [this message]
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=aip52HIwSIWBoE1d@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=robh@kernel.org \
/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.