Linux kernel and device drivers for NXP i.MX platforms
 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 8/8] mmc: sdhci-esdhc-imx: fix resume error handling
Date: Tue, 07 Jul 2026 11:16:13 +0000	[thread overview]
Message-ID: <20260707111613.D88AD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707110303.3779799-9-ziniu.wang_1@oss.nxp.com>

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

New issues:
- [High] The early return delays a kernel panic because the MMC core is not notified that the device is dead, leading to subsequent unclocked hardware accesses.
- [Medium] The card detect GPIO IRQ is incorrectly left configured as a system wake source on the error path.

Pre-existing issues:
- [High] The driver ignores the return value of `pm_runtime_get_sync()` in the unbind/remove path, leading to a kernel panic.
--

--- Patch [8]: [PATCH v5 8/8] mmc: sdhci-esdhc-imx: fix resume error handling ---
commit eb59f1a91caafc261d97666e5d0b0450cef19279
Author: Luke Wang <ziniu.wang_1@nxp.com>

mmc: sdhci-esdhc-imx: fix resume error handling

This commit adds a return value check for pm_runtime_force_resume() in
sdhci_esdhc_resume(). If it fails, it returns early to prevent unclocked
hardware accesses. It also simplifies the return value handling on success.

> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 6cb84690fde4e..f4bfb14423e4d 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -2126,12 +2126,12 @@ static int sdhci_esdhc_resume(struct device *dev)
>  			dev_warn(dev, "Failed to restore pinctrl state\n");
>  	}
>  
> -	pm_runtime_force_resume(dev);
> -
> -	ret = mmc_gpio_set_cd_wake(host->mmc, false);
> +	ret = pm_runtime_force_resume(dev);
>  	if (ret)
>  		return ret;

[Severity: High]
If we return early here without setting host->flags |= SDHCI_DEVICE_DEAD,
will the MMC core still attempt to access unclocked hardware?

The PM core will continue system resume and eventually invoke
mmc_resume_host() on the child MMC device. The MMC core would then call host
operations like sdhci_set_ios(), which attempt to read and write SDHCI
hardware registers on an unclocked controller. Could this trigger a
synchronous external abort and result in a kernel panic?

[Severity: Medium]
Does this early return skip the GPIO CD wake IRQ cleanup, leaving the
wake source configured?

During sdhci_esdhc_suspend(), the card detect IRQ is configured as a wake
source via mmc_gpio_set_cd_wake(..., true). Because the card detect
configuration interacts with the GPIO controller and has no dependency on
SDHCI clocks, should it be executed on the error path to avoid leaking the
wake source configuration?

>  
> +	mmc_gpio_set_cd_wake(host->mmc, false);
> +
>  	/* re-initialize hw state in case it's lost in low power mode */
>  	sdhci_esdhc_imx_hwinit(host);

[ ... ]

[Severity: High]
This isn't a bug introduced by this patch, but does ignoring the return
value of pm_runtime_get_sync() in sdhci_esdhc_imx_remove() lead to the same
kernel panic on unclocked hardware access?

In 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 the device is in an error state and clocks fail to enable,
pm_runtime_get_sync() returns a negative error. By immediately executing
readl(host->ioaddr + SDHCI_INT_STATUS) on an unclocked device, could this
trigger a synchronous external abort when the device is unbound?

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

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

Thread overview: 16+ 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-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
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 [this message]

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=20260707111613.D88AD1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox