All of lore.kernel.org
 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 v6 4/8] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume
Date: Mon, 13 Jul 2026 05:02:15 +0000	[thread overview]
Message-ID: <20260713050216.025A61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713043904.4144172-5-ziniu.wang_1@oss.nxp.com>

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

New issues:
- [Medium] Spurious pinctrl warnings on every system resume for platforms without pinctrl configuration.

Pre-existing issues:
- [Critical] Unchecked return value of pm_runtime_force_resume() may lead to unclocked register access and system crash.
- [High] Error paths in system suspend and resume callbacks fail to balance the runtime PM usage counter.
- [High] esdhc_change_pinstate() uses IS_ERR() instead of IS_ERR_OR_NULL(), leading to a potential NULL pointer dereference on misconfigured DTs.
--

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

mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume

SDIO devices such as WiFi may keep power during suspend, so the MMC core
skips full card re-initialization on resume and directly restores the host
controller's ios timing to match the card. This patch restores the pinctrl
state based on current timing mode before pm_runtime_force_resume() is
called.

> 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);

[Severity: High]
This is a pre-existing issue, but does esdhc_change_pinstate() fail to
catch a NULL pointer on misconfigured device trees?

In esdhc_change_pinstate(), it uses IS_ERR() instead of IS_ERR_OR_NULL():

	case MMC_TIMING_UHS_DDR50:
		if (IS_ERR(imx_data->pins_100mhz))
			return -EINVAL;
		pinctrl = imx_data->pins_100mhz;

If a misconfigured device tree forces UHS capabilities, the MMC core
enables UHS timings, but pins_100mhz may remain NULL. Since IS_ERR(NULL)
evaluates to false, it assigns NULL to pinctrl.

This NULL pointer is directly passed to the pinctrl subsystem:

	return pinctrl_select_state(imx_data->pinctrl, pinctrl);

This causes a panic when dereferenced by pinctrl_commit_state().

> +		if (ret)
> +			dev_warn(dev, "Failed to restore pinctrl state\n");

[Severity: Medium]
Is this warning going to trigger on every system resume for platforms
without pinctrl?

Platforms without pinctrl correctly initialize imx_data->pinctrl to an
ERR_PTR in probe(), treating it as non-fatal.

When esdhc_change_pinstate() is called, it returns -EINVAL if pinctrl
is an ERR_PTR:

	if (IS_ERR(imx_data->pinctrl))
		return -EINVAL;

This causes dev_warn() to spam the kernel log on unaffected hardware on
every system resume.

> +	}
> +
>  	pm_runtime_force_resume(dev);

[Severity: Critical]
This is a pre-existing issue, but does ignoring the return value of
pm_runtime_force_resume() risk an unclocked register access?

If the runtime resume callback fails to enable hardware clocks, the error
is returned but completely ignored here.

The driver then proceeds to access memory-mapped registers unconditionally
in sdhci_esdhc_imx_hwinit(). Accessing peripheral registers without clocks
enabled on i.MX platforms causes a Synchronous External Abort,
deterministically crashing the system.

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

[Severity: High]
This is a pre-existing issue, but do the error paths in the system suspend
and resume callbacks fail to balance the runtime PM usage counter?

In sdhci_esdhc_resume(), if mmc_gpio_set_cd_wake() fails, the function
returns early:

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

This bypasses pm_runtime_put_autosuspend(), leaking the usage counter
incremented during suspend.

Similarly, in sdhci_esdhc_suspend(), if pinctrl_pm_select_sleep_state()
fails, it returns early without calling pm_runtime_put() to balance
the preceding pm_runtime_get_sync().

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

  reply	other threads:[~2026-07-13  5:02 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
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 [this message]
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=20260713050216.025A61F000E9@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.