From: "Luke Wang (OSS)" <ziniu.wang_1@oss.nxp.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
"Luke Wang (OSS)" <ziniu.wang_1@oss.nxp.com>,
"ulfh@kernel.org" <ulfh@kernel.org>,
Bough Chen <haibo.chen@nxp.com>, Frank Li <frank.li@nxp.com>
Cc: "s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
dl-S32 <S32@nxp.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v4 3/7] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing on resume
Date: Mon, 6 Jul 2026 03:25:40 +0000 [thread overview]
Message-ID: <AM7PR04MB6870824EB5AF3561B5D69DEFEDF12@AM7PR04MB6870.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <c1cfc800-f590-454d-9493-55cf6bed938f@intel.com>
> -----Original Message-----
> From: Adrian Hunter <adrian.hunter@intel.com>
> Sent: Sunday, July 5, 2026 4:15 PM
> To: Luke Wang (OSS) <ziniu.wang_1@oss.nxp.com>; ulfh@kernel.org; Bough
> Chen <haibo.chen@nxp.com>; Frank Li <frank.li@nxp.com>
> Cc: s.hauer@pengutronix.de; kernel@pengutronix.de; festevam@gmail.com;
> imx@lists.linux.dev; linux-mmc@vger.kernel.org; dl-S32 <S32@nxp.com>;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v4 3/7] mmc: sdhci-esdhc-imx: restore pinctrl before
> restoring ios timing on resume
>
> On 03/07/2026 13:42, ziniu.wang_1@oss.nxp.com wrote:
> > From: Luke Wang <ziniu.wang_1@nxp.com>
> >
> > 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. For DDR mode,
> > pm_runtime_force_resume() sets DDR_EN before the pin configuration is
> > restored from sleep state.
> >
> > This is related to the SoC IP integration: switching pinctrl setting
> > (changing alt from GPIO to USDHC) impacts the internal loopback path.
> > If pinctrl configures the pad to GPIO function, once DDR_EN is set, the
> > DLL delay will be fixed based on the GPIO function loopback path. When
> > the pinctrl is later changed to USDHC function, the internal loopback
> > path changes, making the original fixed sample point no longer suitable
> > for the current loopback path. This causes persistent read CRC errors on
> > subsequent data transfers.
> >
> > SD/eMMC running in DDR mode are unaffected as they are fully
> > re-initialized from legacy timing after resume.
> >
> > Fix this by restoring the pinctrl state based on current timing mode
> > using esdhc_change_pinstate() before pm_runtime_force_resume(). This
> > ensures the correct pin configuration (e.g., 100/200MHz for UHS modes)
> > is applied before DDR_EN is set. Only restore for non-wakeup devices
> > since wakeup devices kept their active pin state during suspend.
> >
> > Fixes: 676a83855614 ("mmc: host: sdhci-esdhc-imx: refactor the system PM
> logic")
> > Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
> > Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
> > ---
> > drivers/mmc/host/sdhci-esdhc-imx.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-
> esdhc-imx.c
> > index 7230d70e02ae..3b1e63425a19 100644
> > --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> > @@ -2113,6 +2113,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);
> > + if (ret)
> > + dev_warn(dev, "Failed to restore pinctrl state\n");
>
> Sashiko has a point about this dev_warn(). See its first comment in:
>
> https://sashiko.dev/#/patchset/20260703104208.3426374-1-
> ziniu.wang_1%40oss.nxp.com?part=3
Thanks for catching this. It's a real issue.
The root cause is in esdhc_change_pinstate() - the early check for
pins_100mhz/pins_200mhz blocks the default switch case from restoring
pinctrl via pinctrl_select_default_state(), even for timings that don't
need UHS states.
Will send v5 patch fixing this.
Thanks,
Luke
>
> > + }
> > +
> > pm_runtime_force_resume(dev);
> >
> > ret = mmc_gpio_set_cd_wake(host->mmc, false);
next prev parent reply other threads:[~2026-07-06 3:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:42 [PATCH v4 0/7] mmc: sdhci-esdhc-imx: fix SDIO suspend/resume issues ziniu.wang_1
2026-07-03 10:42 ` [PATCH v4 1/7] mmc: sdhci-esdhc-imx: remove unnecessary mmc_card_wake_sdio_irq check for tuning save/restore ziniu.wang_1
2026-07-05 8:48 ` Adrian Hunter
2026-07-03 10:42 ` [PATCH v4 2/7] mmc: sdhci-esdhc-imx: restore DLL override for DDR modes on resume ziniu.wang_1
2026-07-05 8:49 ` Adrian Hunter
2026-07-03 10:42 ` [PATCH v4 3/7] mmc: sdhci-esdhc-imx: restore pinctrl before restoring ios timing " ziniu.wang_1
2026-07-05 8:14 ` Adrian Hunter
2026-07-06 3:25 ` Luke Wang (OSS) [this message]
2026-07-03 10:42 ` [PATCH v4 4/7] mmc: sdhci-esdhc-imx: disable irq during suspend to fix unhandled interrupt ziniu.wang_1
2026-07-05 8:30 ` Adrian Hunter
2026-07-06 6:21 ` Luke Wang (OSS)
2026-07-03 10:42 ` [PATCH v4 5/7] mmc: sdhci-esdhc-imx: use pm_runtime_resume_and_get() in suspend ziniu.wang_1
2026-07-03 10:42 ` [PATCH v4 6/7] mmc: sdhci-esdhc-imx: make non-fatal errors non-blocking " ziniu.wang_1
2026-07-03 10:42 ` [PATCH v4 7/7] mmc: sdhci-esdhc-imx: fix resume error handling ziniu.wang_1
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=AM7PR04MB6870824EB5AF3561B5D69DEFEDF12@AM7PR04MB6870.eurprd04.prod.outlook.com \
--to=ziniu.wang_1@oss.nxp.com \
--cc=S32@nxp.com \
--cc=adrian.hunter@intel.com \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=ulfh@kernel.org \
/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