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 8/8] mmc: sdhci-esdhc-imx: fix resume error handling
Date: Wed, 15 Jul 2026 07:41:53 +0000 [thread overview]
Message-ID: <20260715074154.0E0C11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715071818.272318-9-ziniu.wang_1@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Medium] Early return on clock enable failure leaks IRQ wake and disable depths for the host IRQ.
- [Medium] Unnecessary PM runtime usage counter leak on the error path.
Pre-existing issues:
- [Critical] The fix to prevent a kernel panic on unclocked register accesses is incomplete, leaving the unclocked device exposed to child MMC accesses.
- [High] Missing return value check for pm_runtime_get_sync() in sdhci_esdhc_imx_remove() leads to unclocked hardware register access and a kernel panic.
--
--- Patch [8]: [PATCH v7 8/8] mmc: sdhci-esdhc-imx: fix resume error handling ---
commit 2ddb161f38e3bf1f1836d2167b881e211d1fa57f
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() to avoid unclocked hardware register access on failure.
It returns early if clock enablement fails, purposefully skipping IRQ
enablement. Additionally, it removes a redundant return check for
mmc_gpio_set_cd_wake() and explicitly returns 0 on success.
> The early return intentionally skips enable_irq() and
> sdhci_disable_irq_wakeups() because the IRQ handler reads
> SDHCI_INT_STATUS, which would also fault without clocks. The PM runtime
> usage counter leak only affects this already-broken device instance and
> is an acceptable tradeoff to preserve system stability.
[Severity: Medium]
Could this usage counter leak be avoided entirely? Since the standard
kernel API pm_runtime_put_noidle() drops the usage counter without invoking
any idle callbacks or accessing hardware, would it be cleaner to use it
here instead of leaking the counter on the error path?
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 0824f598bf598..6ab59d3e346f9 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -2123,12 +2123,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: Medium]
Does this early return bypass software-level cleanup of IRQ wake and
disable states? If pm_runtime_force_resume() fails, the function returns
early, bypassing enable_irq(host->irq) and sdhci_disable_irq_wakeups(host).
Because the PM core does not abort system resume on a device resume failure,
a subsequent system suspend will call the suspend callback again.
This unconditionally calls disable_irq() and sdhci_enable_irq_wakeups().
Can this cause the IRQ disable depth and wake depth to accumulate unbounded
on subsequent suspends?
[Severity: Critical]
This isn't a bug introduced by this patch, but does the early return leave
the unclocked device exposed to child MMC accesses?
Returning an error from a parent's system resume callback does not abort
the system resume process for children. The PM core continues and invokes
the resume callback for the child mmc_card device, which unconditionally
triggers sdhci_set_ios() on the host controller and accesses hardware
registers.
Because the SDHCI_DEVICE_DEAD flag is not set before returning early,
sdhci_set_ios() does not abort and accesses the unclocked hardware
registers, potentially triggering the same kernel panic this patch was
intended to fix. Would setting host->flags |= SDHCI_DEVICE_DEAD; before
returning prevent this?
[ ... ]
This isn't a bug introduced by this patch, but looking at
sdhci_esdhc_imx_remove() in the same file:
pm_runtime_get_sync(&pdev->dev);
dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
[Severity: High]
Does this code ignore the return value of pm_runtime_get_sync()?
If resuming the device fails, the clocks remain disabled. The immediate
next instruction accesses SDHCI_INT_STATUS. Can this trigger a kernel panic
due to unclocked hardware access, similar to the one being fixed in the
resume path?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260715071818.272318-1-ziniu.wang_1@oss.nxp.com?part=8
next prev parent reply other threads:[~2026-07-15 7:41 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
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 [this message]
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=20260715074154.0E0C11F000E9@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