* Re: [PATCH 1/2] gpio: mvebu: restore suspend-time irq masks under gc->lock
[not found] ` <20261203225820.83277-2-rosenp@gmail.com>
@ 2026-12-03 23:14 ` sashiko-bot
0 siblings, 0 replies; only message in thread
From: sashiko-bot @ 2026-12-03 23:14 UTC (permalink / raw)
To: Rosen Penev; +Cc: linux-gpio, linux-rt-devel, linux-kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-03 23:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261203225820.83277-1-rosenp@gmail.com>
[not found] ` <20261203225820.83277-2-rosenp@gmail.com>
2026-12-03 23:14 ` [PATCH 1/2] gpio: mvebu: restore suspend-time irq masks under gc->lock sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox