From: sashiko-bot@kernel.org
To: "Runyu Xiao" <runyu.xiao@seu.edu.cn>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH 1/2] gpio: sch: use raw_spinlock_t in the irq startup path
Date: Wed, 17 Jun 2026 20:21:02 +0000 [thread overview]
Message-ID: <20260617202102.ABFD71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260617154035.1199948-2-runyu.xiao@seu.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Read-Modify-Write cycle on the Write-1-to-Clear (W1C) status register causes lost interrupts.
--
commit 088444fdf19ac3925d66a59ae9e74b003c72c066
Author: Runyu Xiao <runyu.xiao@seu.edu.cn>
gpio: sch: use raw_spinlock_t in the irq startup path
This patch converts the SCH controller lock from spinlock_t to
raw_spinlock_t to prevent a sleep-in-invalid-context bug on PREEMPT_RT.
The lock is acquired in the non-sleepable IRQ startup path.
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index 966d16a6d5157..5e361742a11ad 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
[ ... ]
> @@ -215,9 +215,9 @@ static void sch_irq_ack(struct irq_data *d)
> irq_hw_number_t gpio_num = irqd_to_hwirq(d);
> unsigned long flags;
>
> - spin_lock_irqsave(&sch->lock, flags);
> + raw_spin_lock_irqsave(&sch->lock, flags);
> sch_gpio_reg_set(sch, gpio_num, GTS, 1);
[Severity: High]
This isn't a bug introduced by this patch, but does this cause lost
interrupts due to a read-modify-write on a write-1-to-clear register?
sch_irq_ack() acknowledges a GPIO interrupt by calling
sch_gpio_reg_set() for the GTS register.
Looking at sch_gpio_reg_set():
drivers/gpio/gpio-sch.c:sch_gpio_reg_set() {
...
reg_val = ioread8(sch->regs + offset);
if (val)
reg_val |= BIT(bit);
else
reg_val &= ~BIT(bit);
iowrite8(reg_val, sch->regs + offset);
}
And sch_gpio_gpe_handler() demonstrates that GTS returns the status of
pending interrupts when read:
drivers/gpio/gpio-sch.c:sch_gpio_gpe_handler() {
...
core_status = ioread32(sch->regs + CORE_BANK_OFFSET + GTS);
...
}
Because GTS is a write-1-to-clear status register, the ioread8() in
sch_gpio_reg_set() returns 1s for all currently pending interrupts.
When those 1s are written back via iowrite8(), won't it inadvertently
clear all pending interrupts in that bank, instead of just the specific
gpio_num being acknowledged?
> - spin_unlock_irqrestore(&sch->lock, flags);
> + raw_spin_unlock_irqrestore(&sch->lock, flags);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260617154035.1199948-1-runyu.xiao@seu.edu.cn?part=1
next prev parent reply other threads:[~2026-06-17 20:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 15:40 [PATCH 0/2] gpio: use raw spinlocks in irq startup paths Runyu Xiao
2026-06-17 15:40 ` [PATCH 1/2] gpio: sch: use raw_spinlock_t in the irq startup path Runyu Xiao
2026-06-17 15:57 ` Andy Shevchenko
2026-06-17 20:21 ` sashiko-bot [this message]
2026-06-17 15:40 ` [PATCH 2/2] gpio: eic-sprd: " Runyu Xiao
2026-06-17 20:32 ` sashiko-bot
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=20260617202102.ABFD71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=runyu.xiao@seu.edu.cn \
--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.