From: sashiko-bot@kernel.org
To: ziniu.wang_1@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH 1/4] mmc: sdhci-esdhc-imx: remove unnecessary mmc_card_wake_sdio_irq check for tuning save/restore
Date: Tue, 23 Jun 2026 07:45:20 +0000 [thread overview]
Message-ID: <20260623074520.EE4A71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623073515.2658205-2-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] Unchecked return values from `pm_runtime_get_sync()` and `pm_runtime_force_resume()` can lead to kernel panics via unclocked hardware register accesses.
- [High] Error paths in system suspend and resume callbacks leak PM runtime usage counters, bypass PM state changes, and leave the host IRQ permanently disabled.
--
commit 3bcc9d5490c53923eb1abbde361cd46732c4aeb4
Author: Luke Wang <ziniu.wang_1@nxp.com>
mmc: sdhci-esdhc-imx: remove unnecessary mmc_card_wake_sdio_irq check for tuning save/restore
This commit removes the mmc_card_wake_sdio_irq() check from the suspend and
resume paths, as tuning values should be preserved when the card keeps power
regardless of the SDIO IRQ wake flag.
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -2064,8 +2064,7 @@ static int sdhci_esdhc_suspend(struct device *dev)
> * to save the tuning delay value just in case the usdhc
> * lost power during system PM.
> */
> - if (mmc_card_keep_power(host->mmc) && mmc_card_wake_sdio_irq(host->mmc) &&
> - esdhc_is_usdhc(imx_data))
> + if (mmc_card_keep_power(host->mmc) && esdhc_is_usdhc(imx_data))
> sdhc_esdhc_tuning_save(host);
[Severity: High]
This is a pre-existing issue, but does the earlier call to
pm_runtime_get_sync() in sdhci_esdhc_suspend() need its return value checked?
If pm_runtime_get_sync() fails, for example due to a clock enable failure, it
returns a negative error code but leaves the device unclocked. When the code
reaches this point and calls sdhc_esdhc_tuning_save(), it will blindly access
hardware registers. On i.MX platforms, accessing an unclocked peripheral
triggers an asynchronous external abort, resulting in a kernel panic.
Additionally, returning early further down in sdhci_esdhc_suspend() if
pinctrl_pm_select_sleep_state() fails:
ret = pinctrl_pm_select_sleep_state(dev);
if (ret)
return ret;
bypasses decrementing the usage counter, leaking the runtime PM reference. It
also leaves the host IRQ permanently disabled because it skips
pm_runtime_force_suspend() and the PM core aborts system suspend, bypassing
the resume callback.
Also, later in this function:
ret = mmc_gpio_set_cd_wake(host->mmc, true);
pm_runtime_force_suspend(dev);
return ret;
If mmc_gpio_set_cd_wake() fails, returning an error here after calling
pm_runtime_force_suspend() seems to break the PM core's state tracking,
confusing the PM core into skipping the resume callback while the device is
fully suspended.
>
> if (device_may_wakeup(dev)) {
[ ... ]
> @@ -2124,8 +2123,7 @@ static int sdhci_esdhc_resume(struct device *dev)
> * restore the saved tuning delay value for the device which keep
> * power during system PM.
> */
> - if (mmc_card_keep_power(host->mmc) && mmc_card_wake_sdio_irq(host->mmc) &&
> - esdhc_is_usdhc(imx_data))
> + if (mmc_card_keep_power(host->mmc) && esdhc_is_usdhc(imx_data))
> sdhc_esdhc_tuning_restore(host);
[Severity: High]
This is a pre-existing issue, but similar to the suspend path, should we
check the return value of pm_runtime_force_resume() called earlier in
sdhci_esdhc_resume()?
If pm_runtime_force_resume() fails, the subsequent calls to
sdhci_esdhc_imx_hwinit() and sdhc_esdhc_tuning_restore() here will blindly
access hardware registers on an unclocked device, which can trigger a kernel
panic.
Also, earlier in this function:
ret = pinctrl_pm_select_default_state(dev);
if (ret)
return ret;
and later:
ret = mmc_gpio_set_cd_wake(host->mmc, false);
if (ret)
return ret;
Returning early on these failures skips enable_irq() and
pm_runtime_put_autosuspend(), which leaves the IRQ permanently disabled and
leaks the PM usage counter.
>
> pm_runtime_put_autosuspend(dev);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623073515.2658205-1-ziniu.wang_1@oss.nxp.com?part=1
next prev parent reply other threads:[~2026-06-23 7:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 7:35 [PATCH 0/4] mmc: sdhci-esdhc-imx: fix SDIO suspend/resume issues ziniu.wang_1
2026-06-23 7:35 ` [PATCH 1/4] mmc: sdhci-esdhc-imx: remove unnecessary mmc_card_wake_sdio_irq check for tuning save/restore ziniu.wang_1
2026-06-23 7:45 ` sashiko-bot [this message]
2026-06-23 7:35 ` [PATCH 2/4] mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume ziniu.wang_1
2026-06-23 7:47 ` sashiko-bot
2026-06-23 7:35 ` [PATCH 3/4] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing " ziniu.wang_1
2026-06-23 7:47 ` sashiko-bot
2026-06-23 7:35 ` [PATCH 4/4] mmc: sdhci-esdhc-imx: disable irq during suspend to fix unhandled interrupt ziniu.wang_1
2026-06-23 7:41 ` 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=20260623074520.EE4A71F000E9@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.