From: Adrian Hunter <adrian.hunter@intel.com>
To: <ziniu.wang_1@nxp.com>, <haibo.chen@nxp.com>, <ulf.hansson@linaro.org>
Cc: <shawnguo@kernel.org>, <s.hauer@pengutronix.de>,
<kernel@pengutronix.de>, <festevam@gmail.com>,
<linux-mmc@vger.kernel.org>, <imx@lists.linux.dev>, <s32@nxp.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] mmc: sdhci-esdhc-imx: wait for data transfer completion before reset
Date: Fri, 12 Dec 2025 13:58:41 +0200 [thread overview]
Message-ID: <fc3ffb7b-d2f4-4337-8086-8dcb146bfa07@intel.com> (raw)
In-Reply-To: <20251211075603.533033-1-ziniu.wang_1@nxp.com>
On 11/12/2025 09:56, ziniu.wang_1@nxp.com wrote:
> From: Luke Wang <ziniu.wang_1@nxp.com>
>
> On IMX7ULP platforms, certain SD cards (e.g. Kingston Canvas Go! Plus)
> cause system hangs and reboots during manual tuning. These cards exhibit
> large gaps (~16us) between tuning command response and data transmission.
> When cmd CRC errors occur during tuning, the code assumes data errors even
> tuning data hasn't been fully received and then reset host data circuit.
>
> Per IMX7ULP reference manual, reset operations (RESET_DATA/ALL) need to
> make sure no active data transfers. Previously, resetting while data was
> in-flight would clear data circuit, including ADMA/SDMA address, causing
> data to be transmitted to incorrect memory address. This patch adds
> polling for data transfer completion before executing resets.
>
> Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
> Reviewed-by: Bough Chen <haibo.chen@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> v3: add define for timeout value
> v2: amend commit message
> ---
> drivers/mmc/host/sdhci-esdhc-imx.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index a7a5df673b0f..97461e20425d 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -216,6 +216,8 @@
> #define ESDHC_FLAG_DUMMY_PAD BIT(19)
>
> #define ESDHC_AUTO_TUNING_WINDOW 3
> +/* 100ms timeout for data inhibit */
> +#define ESDHC_DATA_INHIBIT_WAIT_US 100000
>
> enum wp_types {
> ESDHC_WP_NONE, /* no WP, neither controller nor gpio */
> @@ -1453,6 +1455,22 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
>
> static void esdhc_reset(struct sdhci_host *host, u8 mask)
> {
> + u32 present_state;
> + int ret;
> +
> + /*
> + * For data or full reset, ensure any active data transfer completes
> + * before resetting to avoid system hang.
> + */
> + if (mask & (SDHCI_RESET_DATA | SDHCI_RESET_ALL)) {
> + ret = readl_poll_timeout_atomic(host->ioaddr + ESDHC_PRSSTAT, present_state,
> + !(present_state & SDHCI_DATA_INHIBIT), 2,
> + ESDHC_DATA_INHIBIT_WAIT_US);
> + if (ret == -ETIMEDOUT)
> + dev_warn(mmc_dev(host->mmc),
> + "timeout waiting for data transfer completion\n");
> + }
> +
> sdhci_and_cqhci_reset(host, mask);
>
> sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
next prev parent reply other threads:[~2025-12-12 11:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 7:56 [PATCH v3] mmc: sdhci-esdhc-imx: wait for data transfer completion before reset ziniu.wang_1
2025-12-12 11:58 ` Adrian Hunter [this message]
2025-12-15 15:43 ` 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=fc3ffb7b-d2f4-4337-8086-8dcb146bfa07@intel.com \
--to=adrian.hunter@intel.com \
--cc=festevam@gmail.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=s32@nxp.com \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=ziniu.wang_1@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