All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: ziniu.wang_1@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v5 6/8] mmc: sdhci-esdhc-imx: use pm_runtime_resume_and_get() in suspend
Date: Tue, 07 Jul 2026 11:12:49 +0000	[thread overview]
Message-ID: <20260707111249.F38781F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707110303.3779799-7-ziniu.wang_1@oss.nxp.com>

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

Pre-existing issues:
- [High] The exact same unchecked pm_runtime_get_sync() bug that this patch fixes in sdhci_esdhc_suspend() is present in sdhci_esdhc_imx_remove().
- [High] Ignoring pm_runtime_force_resume() failure in sdhci_esdhc_resume() can lead to unclocked register access and a kernel panic.
--

--- Patch [6]: [PATCH v5 6/8] mmc: sdhci-esdhc-imx: use pm_runtime_resume_and_get() in suspend ---
commit 96d8d6ad1f0e2f2a06d51f1a48050880d936f2ca
Author: Luke Wang <ziniu.wang_1@nxp.com>

mmc: sdhci-esdhc-imx: use pm_runtime_resume_and_get() in suspend

Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() to
simplify error handling. pm_runtime_resume_and_get() automatically
drops the usage counter on failure, avoiding the need for a separate
pm_runtime_put_noidle() call. If it fails, the device is unclocked and
accessing hardware registers would cause a kernel panic, so return the
error immediately.

> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index d980dea9cad1f..7818f351a58ae 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -2061,7 +2061,9 @@ static int sdhci_esdhc_suspend(struct device *dev)
>  	 * 2, make sure the pm_runtime_force_resume() in sdhci_esdhc_resume() really
>  	 *    invoke its ->runtime_resume callback (needs_force_resume = 1).
>  	 */
> -	pm_runtime_get_sync(dev);
> +	ret = pm_runtime_resume_and_get(dev);
> +	if (ret)
> +		return ret;
>  
>  	if ((imx_data->socdata->flags & ESDHC_FLAG_STATE_LOST_IN_LPMODE) &&
>  		(host->tuning_mode != SDHCI_TUNING_MODE_1)) {

[Severity: High]
This is a pre-existing issue, but I noticed similar unchecked runtime PM calls
in this driver that could lead to the same unclocked register access panics
mentioned in the commit message.

In sdhci_esdhc_imx_remove(), the return value of pm_runtime_get_sync() is
ignored immediately before performing a hardware register read:

drivers/mmc/host/sdhci-esdhc-imx.c:sdhci_esdhc_imx_remove() {
	...
	pm_runtime_get_sync(&pdev->dev);
	dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
	...
}

If pm_runtime_get_sync() fails to resume the device (for example, due to
clk_prepare_enable() failing) during driver unbind, it returns an error. Does
ignoring this error and immediately reading SDHCI_INT_STATUS cause a
synchronous external abort that crashes the system?

[Severity: High]
This isn't a bug introduced by this patch, but a similar issue exists in the
system resume path.

In sdhci_esdhc_resume(), pm_runtime_force_resume() is called and its error is
ignored immediately before hardware register initialization:

drivers/mmc/host/sdhci-esdhc-imx.c:sdhci_esdhc_resume() {
	...
	pm_runtime_force_resume(dev);

	ret = mmc_gpio_set_cd_wake(host->mmc, false);
	if (ret)
		return ret;

	/* re-initialize hw state in case it's lost in low power mode */
	sdhci_esdhc_imx_hwinit(host);
	...
}

If pm_runtime_force_resume() fails and returns an error, the driver
proceeds to call sdhci_esdhc_imx_hwinit(), which writes to hardware
registers like ESDHC_WTMK_LVL. Could accessing these registers while
clocks are gated off cause a synchronous external abort on i.MX platforms?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707110303.3779799-1-ziniu.wang_1@oss.nxp.com?part=6

  reply	other threads:[~2026-07-07 11:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 11:02 [PATCH v5 0/8] mmc: sdhci-esdhc-imx: fix SDIO suspend/resume issues ziniu.wang_1
2026-07-07 11:02 ` [PATCH v5 1/8] mmc: sdhci-esdhc-imx: remove unnecessary mmc_card_wake_sdio_irq check for tuning save/restore ziniu.wang_1
2026-07-07 11:02 ` [PATCH v5 2/8] mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume ziniu.wang_1
2026-07-07 11:15   ` sashiko-bot
2026-07-07 11:02 ` [PATCH v5 3/8] mmc: sdhci-esdhc-imx: fix esdhc_change_pinstate() to allow default state restore ziniu.wang_1
2026-07-07 11:17   ` sashiko-bot
2026-07-07 19:02   ` Frank Li
2026-07-08  6:38     ` Luke Wang (OSS)
2026-07-07 11:02 ` [PATCH v5 4/8] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume ziniu.wang_1
2026-07-07 11:16   ` sashiko-bot
2026-07-07 11:03 ` [PATCH v5 5/8] mmc: sdhci-esdhc-imx: disable irq during suspend to fix unhandled interrupt ziniu.wang_1
2026-07-07 11:03 ` [PATCH v5 6/8] mmc: sdhci-esdhc-imx: use pm_runtime_resume_and_get() in suspend ziniu.wang_1
2026-07-07 11:12   ` sashiko-bot [this message]
2026-07-07 11:03 ` [PATCH v5 7/8] mmc: sdhci-esdhc-imx: make non-fatal errors non-blocking " ziniu.wang_1
2026-07-07 11:14   ` sashiko-bot
2026-07-07 11:03 ` [PATCH v5 8/8] mmc: sdhci-esdhc-imx: fix resume error handling ziniu.wang_1
2026-07-07 11:16   ` sashiko-bot
2026-07-08  5:58     ` Luke Wang (OSS)
2026-07-10 13:19 ` [PATCH v5 0/8] mmc: sdhci-esdhc-imx: fix SDIO suspend/resume issues Ulf Hansson
2026-07-13  4:40   ` Luke Wang (OSS)

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=20260707111249.F38781F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ziniu.wang_1@oss.nxp.com \
    /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.