All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 6/7] spmi: apple: use IRQ for RX FIFO if possible
Date: Tue, 28 Jul 2026 09:42:13 +0000	[thread overview]
Message-ID: <20260728094214.406911F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728-t603x-spmi-v2-6-f43e5f10e583@chaosmail.tech>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Data race between `reinit_completion()` and `complete()` due to unhandled hardware timeouts, causing completion state corruption.
- [Low] The static function `apple_spmi_irq_mask_raw` is defined but never used, leading to `-Wunused-function` warnings.
--

--- Patch [6]: [PATCH v2 6/7] spmi: apple: use IRQ for RX FIFO if possible ---
commit fa2cb405f77a7400cdbd89375c67fa8b1bc2c296
Author: Alba Mendez <me@alba.sh>

spmi: apple: use IRQ for RX FIFO if possible

This commit modifies the Apple SPMI driver to use an IRQ for the RX FIFO 
when available, instead of relying on a 10ms sleep interval for polling. 
This reduces the latency to process replies to a few microseconds.

> diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c
> index 2cd4ed1803d40..109c5d2c735d4 100644
> --- a/drivers/spmi/spmi-apple-controller.c
> +++ b/drivers/spmi/spmi-apple-controller.c

[ ... ]

> @@ -77,6 +99,8 @@ static int spmi_raw_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
>  
>  	mutex_lock(&spmi->fifo_lock);
>  
> +	reinit_completion(&spmi->fifo_rx);
> +

[Severity: High]
Does this completion handle late interrupts correctly if a previous command
timed out? 

If wait_for_completion_timeout() times out in apple_spmi_wait_rx_not_empty(),
an interrupt could still arrive later. If a delayed interrupt fires while a
subsequent transaction is calling reinit_completion(), could the late
apple_spmi_irq_handler() call complete() and cause the new transaction to
finish prematurely with incorrect data?

>  	writel(spmi_cmd, spmi->regs + SPMI_CMD_REG);
>  
>  	while (i < len) {

[ ... ]

> @@ -181,10 +205,68 @@ static int spmi_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid)
>  	return -EINVAL;
>  }
>  
> +static void apple_spmi_irq_ack_raw(struct apple_spmi *spmi, u32 irq)
> +{
> +	u32 __iomem *reg = spmi->regs + SPMI_IRQ_ACK_BASE + (irq / 32) * 4;
> +
> +	writel(BIT(irq % 32), reg);
> +}
> +
> +static void apple_spmi_irq_mask_raw(struct apple_spmi *spmi, u32 irq)
> +{
> +	u32 __iomem *reg = spmi->regs + SPMI_IRQ_MASK_BASE + (irq / 32) * 4;
> +
> +	writel(readl(reg) & ~BIT(irq % 32), reg);
> +}

[Severity: Low]
Is this function used anywhere in this patch? It looks like it is defined as
a static function but never called, which might trigger a compiler warning
when building with CONFIG_WERROR.

> +
> +static void apple_spmi_irq_unmask_raw(struct apple_spmi *spmi, u32 irq)
> +{
> +	u32 __iomem *reg = spmi->regs + SPMI_IRQ_MASK_BASE + (irq / 32) * 4;
> +
> +	writel(readl(reg) | BIT(irq % 32), reg);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260728-t603x-spmi-v2-0-f43e5f10e583@chaosmail.tech?part=6

  reply	other threads:[~2026-07-28  9:42 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
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 [this message]
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=20260728094214.406911F000E9@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.