From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Ernest Van Hoecke <ernestvanhoecke@gmail.com>
Cc: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>,
Ernest Van Hoecke <ernest.vanhoecke@toradex.com>,
Emanuele Ghidoli <emanuele.ghidoli@toradex.com>,
Francesco Dolcini <francesco.dolcini@toradex.com>,
lakabd <lakabd.work@gmail.com>, Yong Li <yong.b.li@intel.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] gpio: pca953x: handle short interrupt pulses on PCAL devices
Date: Sun, 28 Dec 2025 20:26:03 +0200 [thread overview]
Message-ID: <aVF2O5lVpPtJtoER@smile.fi.intel.com> (raw)
In-Reply-To: <20251217153050.142057-1-ernestvanhoecke@gmail.com>
On Wed, Dec 17, 2025 at 04:30:25PM +0100, Ernest Van Hoecke wrote:
> From: Ernest Van Hoecke <ernest.vanhoecke@toradex.com>
>
> GPIO drivers with latch input support may miss short pulses on input
> pins even when input latching is enabled. The generic interrupt logic in
> the pca953x driver reports interrupts by comparing the current input
> value against the previously sampled one and only signals an event when
> a level change is observed between two reads.
>
> For short pulses, the first edge is captured when the input register is
> read, but if the signal returns to its previous level before the read,
> the second edge is not observed. As a result, successive pulses can
> produce identical input values at read time and no level change is
> detected, causing interrupts to be missed. Below timing diagram shows
> this situation where the top signal is the input pin level and the
> bottom signal indicates the latched value.
>
> ─────┐ ┌──*───────────────┐ ┌──*─────────────────┐ ┌──*───
> │ │ . │ │ . │ │ .
> │ │ │ │ │ │ │ │ │
> └──*──┘ │ └──*──┘ │ └──*──┘ │
> Input │ │ │ │ │ │
> ▼ │ ▼ │ ▼ │
> IRQ │ IRQ │ IRQ │
> . . .
> ─────┐ .┌──────────────┐ .┌────────────────┐ .┌──
> │ │ │ │ │ │
> │ │ │ │ │ │
> └────────*┘ └────────*┘ └────────*┘
> Latched │ │ │
> ▼ ▼ ▼
> READ 0 READ 0 READ 0
> NO CHANGE NO CHANGE
>
> PCAL variants provide an interrupt status register that records which
> pins triggered an interrupt, but the status and input registers cannot
> be read atomically. The interrupt status is only cleared when the input
> port is read, and the input value must also be read to determine the
> triggering edge. If another interrupt occurs on a different line after
> the status register has been read but before the input register is
> sampled, that event will not be reflected in the earlier status
> snapshot, so relying solely on the interrupt status register is also
> insufficient.
>
> Support for input latching and interrupt status handling was previously
> added by [1], but the interrupt status-based logic was reverted by [2]
> due to these issues. This patch addresses the original problem by
> combining both sources of information. Events indicated by the interrupt
> status register are merged with events detected through the existing
> level-change logic. As a result:
>
> * short pulses, whose second edges are invisible, are detected via the
> interrupt status register, and
> * interrupts that occur between the status and input reads are still
> caught by the generic level-change logic.
>
> This significantly improves robustness on devices that signal interrupts
> as short pulses, while avoiding the issues that led to the earlier
> reversion. In practice, even if only the first edge of a pulse is
> observable, the interrupt is reliably detected.
>
> This fixes missed interrupts from an Ilitek touch controller with its
> interrupt line connected to a PCAL6416A, where active-low pulses are
> approximately 200 us long.
>
> [1] commit 44896beae605 ("gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2")
> [2] commit d6179f6c6204 ("gpio: pca953x: Improve interrupt support")
And missed my tag
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2025-12-28 18:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 15:30 [PATCH v1] gpio: pca953x: handle short interrupt pulses on PCAL devices Ernest Van Hoecke
2025-12-28 18:25 ` Andy Shevchenko
2025-12-28 18:26 ` Andy Shevchenko [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=aVF2O5lVpPtJtoER@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=emanuele.ghidoli@toradex.com \
--cc=ernest.vanhoecke@toradex.com \
--cc=ernestvanhoecke@gmail.com \
--cc=francesco.dolcini@toradex.com \
--cc=lakabd.work@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.tomlinson@alliedtelesis.co.nz \
--cc=yong.b.li@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).