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 8/8] mmc: sdhci-esdhc-imx: fix resume error handling
Date: Mon, 13 Jul 2026 04:50:54 +0000	[thread overview]
Message-ID: <20260713045055.166F31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713043904.4144172-9-ziniu.wang_1@oss.nxp.com>

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

New issues:
- [High] Returning early on resume failure leaks the PM usage counter and desyncs the IRQ depth, causing a permanent device lockup.

Pre-existing issues:
- [High] Missing synchronize_irq() in runtime suspend causes a race condition with the threaded IRQ handler, leading to a kernel panic.
--

--- Patch [8]: [PATCH v6 8/8] mmc: sdhci-esdhc-imx: fix resume error handling ---
commit 656597a370f7029432d32936bfe95d2095dee2e6
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 the
resume path. It returns immediately on failure to prevent accessing hardware
registers on an unclocked device, while skipping enable_irq() and IRQ wakeup
teardown.

> 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
> @@ -2126,12 +2126,12 @@ static int sdhci_esdhc_resume(struct device *dev)
[ ... ]
> -	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: High]
Will returning early here leak the PM usage counter and leave the IRQ
permanently disabled?

sdhci_esdhc_suspend() increments the PM usage counter via
pm_runtime_resume_and_get() and the IRQ disable depth via disable_irq().

If pm_runtime_force_resume() fails and we return early, we skip the calls
to enable_irq() and pm_runtime_put_autosuspend() at the end of the function.

On subsequent suspend/resume cycles, disable_irq() and
pm_runtime_resume_and_get() would be called again, stacking the counters.
Even if the hardware failure is transient, a subsequent successful resume
would only decrement the counters once, potentially leaving the device IRQ
disabled until reboot.

Is there a way to balance the suspend operations even when resume fails?

[ ... ]
> @@ -2158,7 +2158,7 @@ static int sdhci_esdhc_resume(struct device *dev)
>  
>  	pm_runtime_put_autosuspend(dev);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  static int sdhci_esdhc_runtime_suspend(struct device *dev)
>  {
[ ... ]
>  	sdhci_runtime_suspend_host(host);
>  
>  	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
>  		mmc_retune_needed(host->mmc);
>  
>  	imx_data->actual_clock = host->mmc->actual_clock;
>  	esdhc_pltfm_set_clock(host, 0);
>  	clk_disable_unprepare(imx_data->clk_per);

[Severity: High]
This is a pre-existing issue, but does this runtime suspend path need to
wait for threaded IRQ handlers to finish before disabling hardware clocks?

The core requests the interrupt with IRQF_SHARED and a threaded handler
(sdhci_thread_irq). sdhci_runtime_suspend_host() masks interrupts at the
controller and calls synchronize_hardirq(), but it does not wait for the
threaded handler to complete.

If a card event triggers the threaded handler just before suspend, it
can run concurrently and read hardware registers (for example via
sdhci_card_event() calling sdhci_get_cd()). 

Because the clocks are disabled shortly after, a concurrent register read
by the threaded handler could cause a kernel panic.

Should synchronize_irq() be called here before powering down the clocks?

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

  reply	other threads:[~2026-07-13  4:50 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
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 [this message]
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=20260713045055.166F31F000E9@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.