Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gianfranco Mariotti" <gianfranco.mariotti94@gmail.com>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 5/5] gpio: fxl6408: Add interrupt controller support
Date: Thu, 26 Nov 2026 18:25:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-236017@kernel.org> (raw)
In-Reply-To: <20261126180315.98034-6-gianfranco.mariotti94@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] gpio: fxl6408: level-low IRQ storm and stale INT_STS in
  fxl6408_resume()
- [High] gpio: fxl6408: spurious and lost IRQs on unmask in
  fxl6408_probe()
--

commit 727720e716ae84ca553c153e1d2e86dd4241253c
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

gpio: fxl6408: Add interrupt controller support

This commit adds interrupt controller support for the FXL6408 and
PI4IOE5V6408 GPIO expanders via regmap-irq and gpio-regmap, marks
FXL6408_REG_DEVICE_ID and FXL6408_REG_INT_STS as precious, and clears
RST_INT on resume.

> diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
> index ae9003fc513a1..d503383fb119b 100644
> --- a/drivers/gpio/gpio-fxl6408.c
> +++ b/drivers/gpio/gpio-fxl6408.c

[ ... ]

> @@ -206,12 +276,43 @@ static int fxl6408_probe(struct i2c_client *client)
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to write 'output high Z' register\n");
>  
> +	if (client->irq > 0) {
> +		struct regmap_irq_chip *irq_chip;
> +
> +		irq_chip = devm_kzalloc_obj(dev, *irq_chip);
> +		if (!irq_chip)
> +			return -ENOMEM;
> +
> +		irq_chip->name = dev_name(dev);
> +		irq_chip->status_base = FXL6408_REG_INT_STS;
> +		irq_chip->mask_base = FXL6408_REG_INT_MASK;
> +		irq_chip->config_base = fxl6408_irq_config_base;
> +		irq_chip->num_config_bases = ARRAY_SIZE(fxl6408_irq_config_base);
> +		irq_chip->num_config_regs = 1;
> +		irq_chip->num_regs = 1;
> +		irq_chip->irqs = fxl6408_regmap_irqs;
> +		irq_chip->num_irqs = ARRAY_SIZE(fxl6408_regmap_irqs);
> +		irq_chip->init_ack_masked = true;
> +		irq_chip->clear_on_unmask = true;
> +		irq_chip->set_type_config = fxl6408_irq_set_type_config;

[Severity: High]
Does configuring FXL6408_REG_INPUT_DEFAULT_STATE through config_base
with clear_on_unmask cause spurious interrupts and drop pending ones on
other lines?

In drivers/base/regmap/regmap-irq.c, regmap_irq_sync_unlock() reads and
discards status_base (FXL6408_REG_INT_STS) first, writes mask_base
(FXL6408_REG_INT_MASK) second, and writes config_base
(FXL6408_REG_INPUT_DEFAULT_STATE) last.  When IRQ_TYPE_EDGE_FALLING is
requested on a line that is already low, FXL6408_REG_INT_STS is cleared
while FXL6408_REG_INPUT_DEFAULT_STATE still holds 0, the line is
unmasked, and setting the default state bit to 1 makes hardware latch
an immediate interrupt because the current input (0) differs from the
new default state (1).

In addition, reading FXL6408_REG_INT_STS clears all eight status bits
at once and requires an input to return to its default state before
another interrupt can latch.  When clear_on_unmask discards
FXL6408_REG_INT_STS while enabling one line, any interrupt already
latched on the other seven lines is lost, leaving an active peripheral
on another pin unable to trigger again.

> +
> +		gpio_config.regmap_irq_chip = irq_chip;
> +		gpio_config.regmap_irq_line = client->irq;
> +		gpio_config.regmap_irq_flags = IRQF_ONESHOT | IRQF_SHARED;
> +	}
> +
>  	return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
>  }
>  
>  static int fxl6408_resume(struct device *dev)
>  {
>  	struct regmap *regmap = dev_get_drvdata(dev);
> +	int val, ret;
> +
> +	/* Clear RST_INT in case power was lost during suspend. */
> +	ret = regmap_read(regmap, FXL6408_REG_DEVICE_ID, &val);
> +	if (ret)
> +		return ret;
>  
>  	regcache_mark_dirty(regmap);
>  	return regcache_sync(regmap);

[Severity: High]
Can losing power during suspend trigger an interrupt storm before
fxl6408_resume() runs, and spurious interrupts after regcache_sync()?

On power-on reset, RST_INT in FXL6408_REG_DEVICE_ID asserts the
active-low INT line until register 0x01 is read.  Because fxl6408_pm_ops
has no suspend callback to disable client->irq, resume_device_irqs()
unmasks the parent IRQ in dpm_resume_noirq() before fxl6408_resume()
runs in dpm_resume().  regmap_irq_thread() then wakes repeatedly and
only reads FXL6408_REG_INT_STS, which does not clear RST_INT in
FXL6408_REG_DEVICE_ID.

Furthermore, while FXL6408_REG_INPUT_DEFAULT_STATE and the pull
registers are at their 0x00 reset values (and while regcache_sync()
restores register 0x09 before the pull registers at 0x0b and 0x0d), any
input that is high latches its bit in FXL6408_REG_INT_STS.  Without
reading FXL6408_REG_INT_STS after restoring configuration and before
unmasking FXL6408_REG_INT_MASK, unmasking fires those stale interrupts.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126180315.98034-1-gianfranco.mariotti94@gmail.com?part=5

      reply	other threads:[~2026-11-26 18:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
2026-11-26 18:19   ` sashiko-bot
2026-11-26 18:03 ` [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408 Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 3/5] gpio: fxl6408: Support optional power supplies and reset GPIO Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti
2026-11-26 18:25   ` sashiko-bot [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=sashiko-outbox-236017@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gianfranco.mariotti94@gmail.com \
    --cc=linux-gpio@vger.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