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 v2 5/7] spmi: apple: lock around FIFOs
Date: Tue, 28 Jul 2026 09:37:34 +0000 [thread overview]
Message-ID: <20260728093734.EE69F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728-t603x-spmi-v2-5-f43e5f10e583@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver does not drain or flush the RX FIFO during initialization or after error conditions, leading to cascading transaction failures and state desynchronization.
--
--- Patch [5]: [PATCH v2 5/7] spmi: apple: lock around FIFOs ---
commit 0e8d4d322dfd8a19a861bdcc1b9aefd06ad5b239
Author: Alba Mendez <me@alba.sh>
spmi: apple: lock around FIFOs
The driver adds a mutex to provide locking around register interactions.
> --- a/drivers/spmi/spmi-apple-controller.c
> +++ b/drivers/spmi/spmi-apple-controller.c
[ ... ]
> @@ -86,7 +90,7 @@ static int spmi_raw_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
>
> ret = apple_spmi_wait_rx_not_empty(ctrl);
> if (ret)
> - return ret;
> + goto out;
[Severity: High]
This is a pre-existing issue, but if a transaction times out here and the
hardware eventually replies, does the unread data remain in the hardware
RX FIFO? If the FIFO isn't explicitly drained on errors, the next
transaction could incorrectly consume the stale data as its own response,
leading to persistent state desynchronization.
>
> reply = readl(spmi->regs + SPMI_RSP_REG);
>
[ ... ]
> @@ -107,6 +112,8 @@ static int spmi_raw_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
> if (!(readl(spmi->regs + SPMI_STATUS_REG) & SPMI_RX_FIFO_EMPTY))
> dev_warn(&ctrl->dev, "FIFO has extra data\n");
>
> + mutex_unlock(&spmi->fifo_lock);
> +
[Severity: High]
This is also a pre-existing issue, but when extra data is detected here,
should the driver drain the remaining words from the FIFO? Leaving the
unexpected data inside the FIFO instead of reading it out could corrupt
the state synchronization of the next command on the bus.
[ ... ]
> @@ -181,6 +192,7 @@ static int apple_spmi_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> spmi = spmi_controller_get_drvdata(ctrl);
> + mutex_init(&spmi->fifo_lock);
>
> spmi->regs = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(spmi->regs))
[Severity: High]
This is a pre-existing issue, but does apple_spmi_probe() need to flush
or drain the RX FIFO during initialization? There could be stale data
left over from bootloader or firmware interactions before the controller
is fully registered and mapped.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260728-t603x-spmi-v2-0-f43e5f10e583@chaosmail.tech?part=5
next prev parent reply other threads:[~2026-07-28 9:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 9:28 [PATCH v2 0/7] spmi: apple: Additional commands and interrupt support Sasha Finkelstein
2026-07-28 9:28 ` [PATCH v2 1/7] dt-bindings: spmi: apple,spmi: Add t603x Sasha Finkelstein
2026-07-28 9:33 ` sashiko-bot
2026-07-28 9:28 ` [PATCH v2 2/7] spmi: apple: Validate FIFO state Sasha Finkelstein
2026-07-28 9:41 ` sashiko-bot
2026-07-28 9:28 ` [PATCH v2 3/7] spmi: apple: check transaction status Sasha Finkelstein
2026-07-28 9:41 ` sashiko-bot
2026-07-28 9:28 ` [PATCH v2 4/7] spmi: apple: Implement remaining commands Sasha Finkelstein
2026-07-28 9:46 ` sashiko-bot
2026-07-28 9:28 ` [PATCH v2 5/7] spmi: apple: lock around FIFOs Sasha Finkelstein
2026-07-28 9:37 ` sashiko-bot [this message]
2026-07-28 9:28 ` [PATCH v2 6/7] spmi: apple: use IRQ for RX FIFO if possible Sasha Finkelstein
2026-07-28 9:42 ` sashiko-bot
2026-07-28 9:28 ` [PATCH v2 7/7] spmi: apple: interrupt controller functionality Sasha Finkelstein
2026-07-28 9:40 ` 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=20260728093734.EE69F1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox