All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-gpio@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] gpio: mvebu: restore suspend-time irq masks under gc->lock
Date: Thu, 03 Dec 2026 23:14:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-248781@kernel.org> (raw)
In-Reply-To: <20261203225820.83277-2-rosenp@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] gpio: mvebu: mvebu_gpio_resume() nests spinlock_t under raw
  gc->lock
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] gpio: mvebu: dropped unmasked IRQs in mvebu_gpio_resume() [1]
--

commit 2b335edf3e9a01fe8cd24e622c3bca3a7c7c7760
Author: Rosen Penev <rosenp@gmail.com>

gpio: mvebu: restore suspend-time irq masks under gc->lock

This commit moves the suspend-time IRQ mask register restoration in
mvebu_gpio_resume() into a helper called under gc->lock so it cannot race
with concurrent mask or unmask handlers.

> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c2bcc5d749cc..c202b946f595e 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -996,6 +996,45 @@ static const struct of_device_id mvebu_gpio_of_match[] = {
>  	},
>  };
>  
> +static void
> +mvebu_gpio_restore_irq_masks(struct mvebu_gpio_chip *mvchip, u32 level_cache,
> +			     u32 edge_cache)
> +{
> +	int i;
> +
> +	switch (mvchip->soc_variant) {
> +	case MVEBU_GPIO_SOC_VARIANT_ORION:
> +	case MVEBU_GPIO_SOC_VARIANT_A8K:
> +		regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF + mvchip->offset,
> +			     mvchip->edge_mask_regs[0] & edge_cache);
> +		regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF + mvchip->offset,
> +			     mvchip->level_mask_regs[0] & level_cache);
> +		break;

[Severity: High]
This problem wasn't introduced by this patch, but can bitwise-ANDing with
the suspend-time snapshot in [1] silently re-mask an IRQ that was
enabled during early resume?

If a driver disables its IRQ before suspend, the saved mask register
records 0.  If it then calls enable_irq() during resume_noirq, the line is
unmasked and set to 1 in the cache, but mvebu_gpio_resume() later writes
0 & 1 to hardware and silently drops subsequent interrupts.

[ ... ]

> @@ -1069,50 +1105,18 @@ static int mvebu_gpio_resume(struct platform_device *pdev)
>  	 * unmasking one behind its back leaves an asserted level line that
>  	 * nobody masks. Restore only bits the irqchip cache still has set.
>  	 *
> -	 * Snapshot the caches under the raw spinlock, but release it before
> -	 * the regmap writes below: regmap_write() takes a sleepable lock on
> -	 * PREEMPT_RT.
> +	 * Hold gc->lock across the writes so the restore cannot race the
> +	 * mask/unmask handlers, which update the cache and write the mask
> +	 * registers under the same lock.
>  	 */
>  	if (mvchip->domain) {
>  		struct irq_chip_generic *gc;
>  
>  		gc = irq_get_domain_generic_chip(mvchip->domain, 0);
[ ... ]
> +		guard(raw_spinlock_irqsave)(&gc->lock);
> +		mvebu_gpio_restore_irq_masks(mvchip,
> +					     gc->chip_types[0].mask_cache_priv,
> +					     gc->chip_types[1].mask_cache_priv);
>  	}

[Severity: Medium]
Can calling regmap_write() under gc->lock sleep on CONFIG_PREEMPT_RT or
trigger a lockdep invalid wait context splat on Armada 7K/8K?

At this commit, mvebu_gpio_probe_syscon() still uses the parent syscon
regmap, whose syscon_regmap_config does not set use_raw_spinlock.
mvebu_gpio_resume() -> mvebu_gpio_restore_irq_masks() -> regmap_write()
therefore acquires a regular spinlock_t inside raw_spinlock_t gc->lock.

Because commit "gpio: mvebu: use a raw-locked regmap on Armada 7K/8K too"
later in the series switches Armada 7K/8K to a raw-locked MMIO regmap,
ordering that commit before this one would avoid the intermediate
bisection regression.

[1] https://sashiko.dev/#/bug/linux-21cc7884-41c0-4b66-ad75-b626faddba53

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203225820.83277-1-rosenp@gmail.com?part=1

  reply	other threads:[~2026-12-03 23:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 22:58 [PATCH 0/2] gpio: mvebu: resume and PREEMPT_RT irq mask fixes Rosen Penev
2026-12-03 22:58 ` [PATCH 1/2] gpio: mvebu: restore suspend-time irq masks under gc->lock Rosen Penev
2026-12-03 23:14   ` sashiko-bot [this message]
2026-12-04  7:36   ` Sebastian Andrzej Siewior
2026-12-03 22:58 ` [PATCH 2/2] gpio: mvebu: use a raw-locked regmap on Armada 7K/8K too Rosen Penev
2026-12-04  7:49   ` Sebastian Andrzej Siewior

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-248781@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=rosenp@gmail.com \
    --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 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.