All of lore.kernel.org
 help / color / mirror / Atom feed
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 4/7] spmi: apple: Implement remaining commands
Date: Sat, 25 Jul 2026 14:02:02 +0000	[thread overview]
Message-ID: <20260725140203.190DD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725-t603x-spmi-v1-4-e1a29fcd2d38@chaosmail.tech>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Concurrent SPMI commands from different contexts will interleave I/O register accesses, corrupting the hardware FIFO.
--

--- Patch [4]: [PATCH 4/7] spmi: apple: Implement remaining commands ---
commit 98224e3bba3190837586da097a367e28d4210468
Author: Alba Mendez <me@alba.sh>

spmi: apple: Implement remaining commands

Add support for zero write and power management commands to the Apple SPMI
controller.

> diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c
> index 4678a9e5270aa..d69d16665ce85 100644
> --- a/drivers/spmi/spmi-apple-controller.c
> +++ b/drivers/spmi/spmi-apple-controller.c

[ ... ]

> @@ -63,18 +63,27 @@ static int apple_spmi_wait_rx_not_empty(struct spmi_controller *ctrl)
>  	return 0;
>  }
>  
> -static int spmi_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
> -			 u16 saddr, u8 *buf, size_t len)
> +static int spmi_raw_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
> +			 u16 param, const u8 *buf, size_t len, u8 *ibuf, size_t ilen)
>  {
>  	struct apple_spmi *spmi = spmi_controller_get_drvdata(ctrl);
> -	u32 spmi_cmd = apple_spmi_pack_cmd(opc, sid, saddr, len);
> +	u32 spmi_cmd = apple_spmi_pack_cmd(opc, sid, param);
>  	u32 reply, rsp;
>  	size_t len_read = 0;
> -	u8 i;
> +	size_t i = 0, j;
>  	int ret;
>  
>  	writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
>  
> +	while (i < len) {
> +		j = 0;
> +		spmi_cmd = 0;
> +		while ((j < 4) & (i < len))
> +			spmi_cmd |= buf[i++] << (j++ * 8);
> +
> +		writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
> +	}

[Severity: High]
This is a pre-existing issue, but can concurrent SPMI commands from different
contexts interleave I/O register accesses here and corrupt the hardware FIFO?

Multiple client drivers registered on the same SPMI bus might perform
concurrent reads and writes using their own regmap instances.

Because spmi_raw_cmd() is entered concurrently by multiple threads, it issues
multiple sequential writel() and readl() calls to the shared hardware FIFOs 
without holding a bus-level spinlock or mutex.

Could this lead to malformed SPMI bus transactions if thread writes get
interleaved in this loop?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260725-t603x-spmi-v1-0-e1a29fcd2d38@chaosmail.tech?part=4

  reply	other threads:[~2026-07-25 14:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25 13:47 [PATCH 0/7] spmi: apple: Additional commands and interrupt support Sasha Finkelstein
2026-07-25 13:47 ` [PATCH 1/7] dt-bindings: spmi: apple,spmi: Add t603x Sasha Finkelstein
2026-07-25 13:52   ` sashiko-bot
2026-07-25 13:47 ` [PATCH 2/7] spmi: apple: Validate FIFO state Sasha Finkelstein
2026-07-25 14:00   ` sashiko-bot
2026-07-25 13:48 ` [PATCH 3/7] spmi: apple: check transaction status Sasha Finkelstein
2026-07-25 14:02   ` sashiko-bot
2026-07-25 13:48 ` [PATCH 4/7] spmi: apple: Implement remaining commands Sasha Finkelstein
2026-07-25 14:02   ` sashiko-bot [this message]
2026-07-25 13:48 ` [PATCH 5/7] spmi: apple: lock around FIFOs Sasha Finkelstein
2026-07-25 14:01   ` sashiko-bot
2026-07-25 13:48 ` [PATCH 6/7] spmi: apple: use IRQ for RX FIFO if possible Sasha Finkelstein
2026-07-25 14:00   ` sashiko-bot
2026-07-25 13:48 ` [PATCH 7/7] spmi: apple: interrupt controller functionality Sasha Finkelstein
2026-07-25 13:59   ` 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=20260725140203.190DD1F000E9@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.