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 v6 2/8] mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume
Date: Mon, 13 Jul 2026 05:01:12 +0000	[thread overview]
Message-ID: <20260713050112.AED4D1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260713043904.4144172-3-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] Unbalanced IRQ disable/enable during system suspend/resume when SDIO wakeup fails to enable or is not applicable.
- [Medium] Missing `pm_runtime_put` on error paths in `sdhci_esdhc_suspend()` leads to permanent runtime PM usage count leaks.
--

--- Patch [2]: [PATCH v6 2/8] mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume ---
commit 4b48b54434ffc2d8ee1f13e793a63d33908babc8
Author: Luke Wang <ziniu.wang_1@nxp.com>

mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume
    
Extract the DLL override setup from esdhc_set_uhs_signaling() into
a helper esdhc_set_dll_override(), and call it on the resume path
when the card kept power and is using a DDR timing mode.

> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 6e06b3eeacce9..685e508c61279 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
[ ... ]
> @@ -2123,9 +2131,18 @@ 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) && esdhc_is_usdhc(imx_data))
> +	if (mmc_card_keep_power(host->mmc) && esdhc_is_usdhc(imx_data)) {
>  		sdhc_esdhc_tuning_restore(host);
>  
> +		/*
> +		 * Restore DLL override for DDR modes. hwinit unconditionally
> +		 * clears ESDHC_DLL_CTRL, but the card is still in DDR mode.
> +		 */
> +		if (host->timing == MMC_TIMING_UHS_DDR50 ||
> +		    host->timing == MMC_TIMING_MMC_DDR52)
> +			esdhc_set_dll_override(host);
> +	}
> +
>  	pm_runtime_put_autosuspend(dev);
>  
>  	return ret;

[Severity: High]
This is a pre-existing issue, but I noticed a potential IRQ unbalance during
suspend/resume.

If device_may_wakeup(dev) is true but the controller doesn't support or
successfully enable in-band IRQ wakeups (for example, standard SD cards
using GPIO CD), sdhci_enable_irq_wakeups() returns false and
host->irq_wake_enabled is set to false.

In sdhci_esdhc_suspend(), the device IRQ is unconditionally disabled:

sdhci_esdhc_suspend() {
    ...
    disable_irq(host->irq);
    ret = sdhci_enable_irq_wakeups(host);
    ...
}

If host->irq_wake_enabled is false, will the IRQ remain disabled on resume?
Looking at sdhci_esdhc_resume(), it appears enable_irq() is bypassed if the
wakeup enablement failed:

sdhci_esdhc_resume() {
    ...
    if (host->irq_wake_enabled) {
        sdhci_disable_irq_wakeups(host);
        enable_irq(host->irq);
    }
    ...
}

Could this leave the SDHCI controller's main interrupt permanently disabled
after a suspend/resume cycle, stalling all future MMC/SD card transactions?

[Severity: Medium]
This is another pre-existing issue, but does sdhci_esdhc_suspend() leak the
runtime PM usage counter on error paths?

sdhci_esdhc_suspend() starts by incrementing the PM usage counter:

sdhci_esdhc_suspend() {
    ...
    pm_runtime_get_sync(dev);
    ...

Later, it can return early without dropping the acquired PM reference:

    ...
    ret = pinctrl_pm_select_sleep_state(dev);
    if (ret)
        return ret;
    ...
}

If operations like pinctrl_pm_select_sleep_state() or
mmc_gpio_set_cd_wake() fail, the function returns an error code and system
suspend is aborted. Since the PM core skips the resume callback for devices
whose suspend failed, wouldn't the matching pm_runtime_put_autosuspend() be
skipped, leaving the PM usage counter permanently leaked and preventing the
controller from entering runtime suspend again?

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

  reply	other threads:[~2026-07-13  5:01 UTC|newest]

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

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=20260713050112.AED4D1F00A3D@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