Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiawen Liu" <1298662399@qq.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 2/4] spi: bcmbca-hsspi: return error from failed controller suspend
Date: Sat, 20 Jun 2026 08:54:17 +0000	[thread overview]
Message-ID: <20260620085417.AC7D61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_54F5634545908FBA724E758054BF03953808@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Propagating the error from `spi_controller_suspend()` leaves the SPI controller permanently wedged in a suspended state.
--

commit 4a5c38a8fabc327922f122498eb97084160abb1e
Author: Jiawen Liu <1298662399@qq.com>

spi: bcmbca-hsspi: return error from failed controller suspend

This commit updates bcmbca_hsspi_suspend to check the return value of
spi_controller_suspend. If stopping the queue fails, it propagates the error
back to the PM core to prevent disabling the clocks while transfers are active.

> diff --git a/drivers/spi/spi-bcmbca-hsspi.c b/drivers/spi/spi-bcmbca-hsspi.c
> index 09c1472ae4fa1..af88ce04948b7 100644
> --- a/drivers/spi/spi-bcmbca-hsspi.c
> +++ b/drivers/spi/spi-bcmbca-hsspi.c
> @@ -568,8 +568,12 @@ static int bcmbca_hsspi_suspend(struct device *dev)
>  {
>  	struct spi_controller *host = dev_get_drvdata(dev);
>  	struct bcmbca_hsspi *bs = spi_controller_get_devdata(host);
> +	int ret;
> +
> +	ret = spi_controller_suspend(host);
> +	if (ret)
> +		return ret;

[Severity: High]
Does returning the error directly here leave the SPI controller permanently
stuck in a suspended state?

Looking at how spi_controller_suspend() handles errors, it unconditionally
marks the controller as suspended before returning:

drivers/spi/spi.c:spi_controller_suspend() {
	if (ctlr->queued) {
		ret = spi_stop_queue(ctlr);
		if (ret)
			dev_err(&ctlr->dev, "queue stop failed\n");
	}

	__spi_mark_suspended(ctlr);
	return ret;
}

If bcmbca_hsspi_suspend() returns this error to the PM core, the system
suspend is aborted. Because the device's suspend failed, the PM core considers
the device to be active and will not invoke its resume callback during the
PM abort recovery phase.

Since spi_controller_resume() is never called, the controller remains
flagged as suspended, meaning all future SPI transfers will fail with
-ESHUTDOWN until a subsequent successful suspend/resume cycle.

Should we explicitly call spi_controller_resume(host) to unwind the
internal suspend state before returning the error?

>  
> -	spi_controller_suspend(host);
>  	clk_disable_unprepare(bs->pll_clk);
>  	clk_disable_unprepare(bs->clk);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260620083931.1120616-1-1298662399@qq.com?part=2

  reply	other threads:[~2026-06-20  8:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260620083931.1120616-1-1298662399@qq.com>
2026-06-20  8:39 ` [PATCH 1/4] spi: atcspi200: return error from failed controller suspend Jiawen Liu
2026-06-20  8:57   ` sashiko-bot
2026-06-20  8:39 ` [PATCH 2/4] spi: bcmbca-hsspi: " Jiawen Liu
2026-06-20  8:54   ` sashiko-bot [this message]
2026-06-20  8:39 ` [PATCH 3/4] spi: fsl-dspi: clean up after failed suspend and resume Jiawen Liu
2026-06-20  8:53   ` sashiko-bot
2026-06-20  8:39 ` [PATCH 4/4] spi: nxp-fspi: disable runtime PM on probe failures Jiawen Liu
2026-06-20  8:57   ` sashiko-bot
2026-06-20 14:09   ` Frank Li

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=20260620085417.AC7D61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=1298662399@qq.com \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --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