From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v9 6/6] spmi: apple: Add interrupt functionality
Date: Tue, 01 Sep 2026 10:40:14 +0000 [thread overview]
Message-ID: <20260901104014.923E61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-t603x-spmi-v9-6-09e702e3b153@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Race between command timeout recovery and delayed interrupt handler causes spurious command failures (-EIO).
--
commit b173ce6913a5026fc32908944fd6149c07832b2c
Author: Alba Mendez <me@alba.sh>
spmi: apple: Add interrupt functionality
Add support for interrupts sent by slave devices and use IRQ for
RX FIFO if possible, reducing latency compared to polling.
> diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c
> index fabccd25aa0da..2390174452ab4 100644
> --- a/drivers/spmi/spmi-apple-controller.c
> +++ b/drivers/spmi/spmi-apple-controller.c
[ ... ]
> @@ -84,8 +165,10 @@ static int spmi_raw_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid, u16 param,
>
> if (spmi->prev_fail) {
> writel(SPMI_ACT_FIFO_FLUSH, spmi->regs + SPMI_ACT_REG);
> + apple_spmi_irq_ack_raw(spmi, SPMI_IRQ_NOTIFY);
> spmi->prev_fail = false;
> }
> + reinit_completion(&spmi->fifo_rx);
>
> writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
[Severity: High]
Could this sequence lead to a race condition with a delayed interrupt?
If a previous command times out, setting spmi->prev_fail = true, but the
hardware responds shortly after, the NOTIFY interrupt might be raised.
If spmi_raw_cmd() is then called for the next command, it runs concurrently
with apple_spmi_irq_handler() on another CPU. The handler reads the NOTIFY
bit and commits to calling complete():
apple_spmi_irq_handler() {
...
if (val & BIT(SPMI_IRQ_NOTIFY % 32)) {
apple_spmi_irq_ack_raw(spmi, SPMI_IRQ_NOTIFY);
complete(&spmi->fifo_rx);
handled = true;
}
}
Concurrently, the thread clears the hardware IRQ state and calls
reinit_completion(&spmi->fifo_rx) here without synchronizing against the
IRQ handler (as the handler does not take fifo_lock).
If complete() executes after or concurrently with reinit_completion(), it
leaves fifo_rx signaled. The new command's wait_for_completion_timeout()
will return immediately, see an empty FIFO, and fail with -EIO.
Additionally, reinit_completion() performs a non-atomic update which races
with the spinlock operations inside complete().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-t603x-spmi-v9-0-09e702e3b153@chaosmail.tech?part=6
prev parent reply other threads:[~2026-09-01 10:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 10:28 [PATCH v9 0/6] spmi: apple: Additional commands and interrupt support Sasha Finkelstein
2026-09-01 10:29 ` [PATCH v9 1/6] dt-bindings: spmi: apple,spmi: Add t603x and t8122 Sasha Finkelstein
2026-09-01 10:39 ` sashiko-bot
2026-09-01 17:41 ` Conor Dooley
2026-09-01 18:24 ` Sasha Finkelstein
2026-09-02 17:02 ` Conor Dooley
2026-09-01 10:29 ` [PATCH v9 2/6] spmi: apple: Validate FIFO state Sasha Finkelstein
2026-09-01 10:29 ` [PATCH v9 3/6] spmi: apple: check transaction status Sasha Finkelstein
2026-09-01 10:29 ` [PATCH v9 4/6] spmi: apple: Implement remaining commands Sasha Finkelstein
2026-09-01 10:40 ` sashiko-bot
2026-09-01 10:29 ` [PATCH v9 5/6] spmi: apple: lock around FIFOs Sasha Finkelstein
2026-09-01 10:29 ` [PATCH v9 6/6] spmi: apple: Add interrupt functionality Sasha Finkelstein
2026-09-01 10:40 ` 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=20260901104014.923E61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=k@chaosmail.tech \
--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 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.