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: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v7 4/8] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume
Date: Wed, 15 Jul 2026 07:32:58 +0000	[thread overview]
Message-ID: <20260715073258.846921F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715071818.272318-5-ziniu.wang_1@oss.nxp.com>

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

Pre-existing issues:
- [High] The return value of `pm_runtime_get_sync()` is ignored in `sdhci_esdhc_suspend()`, which can lead to a synchronous external abort (kernel panic) if it fails.
- [High] The return value of `pm_runtime_force_resume(dev)` is ignored. If it fails, subsequent register accesses will cause a system crash.
- [High] Runtime PM usage count is leaked on the error paths of `sdhci_esdhc_suspend()` and `sdhci_esdhc_resume()`.
- [High] The IRQ remains permanently disabled if `sdhci_enable_irq_wakeups()` fails during system suspend.
--

--- Patch [4]: [PATCH v7 4/8] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume ---
commit fff04de9eca73d5e5d595f7bfc0d534292f22cd5
Author: Luke Wang <ziniu.wang_1@nxp.com>
mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume

This commit fixes persistent read CRC errors on SDIO devices resuming in DDR
mode. It ensures the pinctrl state is correctly restored for the current timing
before enabling DDR mode during resume. Wakeup devices are skipped as they
keep their active pin state during suspend.

> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 2da5c8ab3e622..bc0864cb22b49 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -2115,6 +2115,12 @@ static int sdhci_esdhc_resume(struct device *dev)
>  	struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
>  	int ret;
>  
> +	if (!device_may_wakeup(dev)) {
> +		ret = esdhc_change_pinstate(host, host->timing);
> +		if (ret)
> +			dev_warn(dev, "Failed to restore pinctrl state\n");
> +	}
> +
>  	pm_runtime_force_resume(dev);

[Severity: High]
This is a pre-existing issue, but the return value of pm_runtime_force_resume()
is ignored here. If it fails, could the subsequent unclocked hardware register
accesses in sdhci_esdhc_imx_hwinit() cause a synchronous external abort?

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

[Severity: High]
This is a pre-existing issue, but if mmc_gpio_set_cd_wake() fails, the early
return skips the required pm_runtime_put_autosuspend() at the end of the
function:

drivers/mmc/host/sdhci-esdhc-imx.c:sdhci_esdhc_resume() {
    ...
	ret = mmc_gpio_set_cd_wake(host->mmc, false);
	if (ret)
		return ret;
    ...
	pm_runtime_put_autosuspend(dev);
	return 0;
}

Could this leak the runtime PM usage count and prevent the device from ever
entering runtime suspend again?


[Severity: High]
This is a pre-existing issue, but could a similar leak happen in the suspend
path if pinctrl_pm_select_sleep_state() fails?

drivers/mmc/host/sdhci-esdhc-imx.c:sdhci_esdhc_suspend() {
	...
	pm_runtime_get_sync(dev);
	...
	} else {
		ret = pinctrl_pm_select_sleep_state(dev);
		if (ret)
			return ret;
	}
	...
}

Does the early return here leak the PM reference acquired by
pm_runtime_get_sync()?


[Severity: High]
This is a pre-existing issue, but the return value of pm_runtime_get_sync()
in sdhci_esdhc_suspend() is completely ignored:

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

	if ((imx_data->socdata->flags & ESDHC_FLAG_STATE_LOST_IN_LPMODE) &&
    ...
}

If pm_runtime_get_sync() fails to enable the clocks, could the subsequent
hardware register accesses via sdhc_esdhc_tuning_save() cause a kernel panic?


[Severity: High]
This is a pre-existing issue, but could the IRQ remain permanently disabled if
sdhci_enable_irq_wakeups() fails during suspend?

In sdhci_esdhc_suspend(), the IRQ is disabled unconditionally when the device
may wake up:

drivers/mmc/host/sdhci-esdhc-imx.c:sdhci_esdhc_suspend() {
    ...
	if (device_may_wakeup(dev)) {
		disable_irq(host->irq);
		ret = sdhci_enable_irq_wakeups(host);
    ...
}

But in sdhci_esdhc_resume(), it is only re-enabled if host->irq_wake_enabled is
true, which requires sdhci_enable_irq_wakeups() to have succeeded:

drivers/mmc/host/sdhci-esdhc-imx.c:sdhci_esdhc_resume() {
    ...
	if (host->irq_wake_enabled) {
		sdhci_disable_irq_wakeups(host);
		enable_irq(host->irq);
	}
    ...
}

If sdhci_enable_irq_wakeups() fails in the suspend path, will the device become
completely unresponsive to interrupts after system resume?

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

  reply	other threads:[~2026-07-15  7:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15  7:18 [PATCH v7 0/8] mmc: sdhci-esdhc-imx: fix SDIO suspend/resume issues ziniu.wang_1
2026-07-15  7:18 ` [PATCH v7 1/8] mmc: sdhci-esdhc-imx: remove unnecessary mmc_card_wake_sdio_irq check for tuning save/restore ziniu.wang_1
2026-07-15  7:29   ` sashiko-bot
2026-07-15  7:18 ` [PATCH v7 2/8] mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume ziniu.wang_1
2026-07-15  7:32   ` sashiko-bot
2026-07-15  7:18 ` [PATCH v7 3/8] mmc: sdhci-esdhc-imx: fix esdhc_change_pinstate() to allow default state restore ziniu.wang_1
2026-07-15  7:18 ` [PATCH v7 4/8] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume ziniu.wang_1
2026-07-15  7:32   ` sashiko-bot [this message]
2026-07-15  7:18 ` [PATCH v7 5/8] mmc: sdhci-esdhc-imx: disable irq during suspend to fix unhandled interrupt ziniu.wang_1
2026-07-15  7:18 ` [PATCH v7 6/8] mmc: sdhci-esdhc-imx: use pm_runtime_resume_and_get() in suspend ziniu.wang_1
2026-07-15  7:29   ` sashiko-bot
2026-07-15  7:18 ` [PATCH v7 7/8] mmc: sdhci-esdhc-imx: make non-fatal errors non-blocking " ziniu.wang_1
2026-07-15  7:27   ` sashiko-bot
2026-07-15  7:18 ` [PATCH v7 8/8] mmc: sdhci-esdhc-imx: fix resume error handling ziniu.wang_1
2026-07-15  7:41   ` sashiko-bot
2026-07-15  9:08 ` [PATCH v7 0/8] mmc: sdhci-esdhc-imx: fix SDIO suspend/resume issues Ulf Hansson

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=20260715073258.846921F000E9@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