Skip to contentSkip to conversation

mmc: sdhci-esdhc-imx: fix the mask for tuning start point

PATCH In review [email protected] 3 participants 6 messages May 26, 2020 – Dec 2, 2022

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/2 mmc: sdhci-esdhc-imx: fix the mask for tuning start point

From: Haibo Chen <[email protected]>

According the RM, the bit[6~0] of register ESDHC_TUNING_CTRL is TUNING_START_TAP, bit[7] of this register is to disable the command CRC check for standard tuning. So fix it here.

Fixes d87fc9663688 ("mmc: sdhci-esdhc-imx: support setting tuning start point")
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 7af9d87d4245..2cf7fa59270e 100644
@@ -90,7 +90,7 @@
 #define ESDHC_STD_TUNING_EN		(1 << 24)
 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
 #define ESDHC_TUNING_START_TAP_DEFAULT	0x1
-#define ESDHC_TUNING_START_TAP_MASK	0xff
+#define ESDHC_TUNING_START_TAP_MASK	0x7f
 #define ESDHC_TUNING_STEP_MASK		0x00070000
 #define ESDHC_TUNING_STEP_SHIFT		16
 
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 2/2 mmc: sdhci-esdhc-imx: disable the CMD CRC check for standard tuning

From: Haibo Chen <[email protected]>

In current code, we add 1ms dealy after each tuning command for standard tuning method. Adding this 1ms dealy is because USDHC default check the CMD CRC and DATA line. If detect the CMD CRC, USDHC standard tuning IC logic do not wait for the tuning data sending out by the card, trigger the buffer read ready interrupt immediately, and step to next cycle. So when next time the new tuning command send out by USDHC, card may still not send out the tuning data of the upper command,then some eMMC cards may stuck, can't response to any command, block the whole tuning procedure.

If do not check the CMD CRC for tuning, then do not has this issue. USDHC will wait for the tuning data of each tuning command and check them. If the tuning data pass the check, it also means the CMD line also okay for tuning.

So this patch disable the CMD CRC check for tuning, save some time for the whole tuning procedure.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +13 -2
index 2cf7fa59270e..b0ddf3db440f 100644
@@ -91,6 +91,7 @@
 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
 #define ESDHC_TUNING_START_TAP_DEFAULT	0x1
 #define ESDHC_TUNING_START_TAP_MASK	0x7f
+#define ESDHC_TUNING_CMD_CRC_CHECK_DISABLE	(1 << 7)
 #define ESDHC_TUNING_STEP_MASK		0x00070000
 #define ESDHC_TUNING_STEP_SHIFT		16
 
@@ -1316,6 +1317,18 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
 				tmp |= imx_data->boarddata.tuning_step
 					<< ESDHC_TUNING_STEP_SHIFT;
 			}
+
+			/* Disable the CMD CRC check for tuning, if not, need to
+			 * add some delay after every tuning command, because
+			 * hardware standard tuning logic will directly go to next
+			 * step once it detect the CMD CRC error, will not wait for
+			 * the card side to finally send out the tuning data, trigger
+			 * the buffer read ready interrupt immediately. If usdhc send
+			 * the next tuning command some eMMC card will stuck, can't
+			 * response, block the tuning procedure or the first command
+			 * after the whole tuning procedure always can't get any response.
+			 */
+			 tmp |= ESDHC_TUNING_CMD_CRC_CHECK_DISABLE;
 			writel(tmp, host->ioaddr + ESDHC_TUNING_CTRL);
 		} else if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
 			/*
@@ -1661,8 +1674,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	if (err)
 		goto disable_ahb_clk;
 
-	host->tuning_delay = 1;
-
 	sdhci_esdhc_imx_hwinit(host);
 
 	err = sdhci_add_host(host);
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/2] mmc: sdhci-esdhc-imx: disable the CMD CRC check for standard tuning

Quoted 12 lines · On Tue, 26 May 2020 at 12:32, <[email protected]> wrote:

From: Haibo Chen <[email protected]>

In current code, we add 1ms dealy after each tuning command for standard tuning method. Adding this 1ms dealy is because USDHC default check the CMD CRC and DATA line. If detect the CMD CRC, USDHC standard tuning IC logic do not wait for the tuning data sending out by the card, trigger the buffer read ready interrupt immediately, and step to next cycle. So when next time the new tuning command send out by USDHC, card may still not send out the tuning data of the upper command,then some eMMC cards may stuck, can't response to any command, block the whole tuning procedure.

Quoted 8 lines

If do not check the CMD CRC for tuning, then do not has this issue. USDHC will wait for the tuning data of each tuning command and check them. If the tuning data pass the check, it also means the CMD line also okay for tuning.

So this patch disable the CMD CRC check for tuning, save some time for the whole tuning procedure.

Applied for next, thanks!

Kind regards
Uffe

Quoted 47 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +13 -3
index 2cf7fa59270e..b0ddf3db440f 100644
@@ -91,6 +91,7 @@
 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
 #define ESDHC_TUNING_START_TAP_DEFAULT 0x1
 #define ESDHC_TUNING_START_TAP_MASK    0x7f
+#define ESDHC_TUNING_CMD_CRC_CHECK_DISABLE     (1 << 7)
 #define ESDHC_TUNING_STEP_MASK         0x00070000
 #define ESDHC_TUNING_STEP_SHIFT                16
 
@@ -1316,6 +1317,18 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
                                tmp |= imx_data->boarddata.tuning_step
                                        << ESDHC_TUNING_STEP_SHIFT;
                        }
+
+                       /* Disable the CMD CRC check for tuning, if not, need to
+                        * add some delay after every tuning command, because
+                        * hardware standard tuning logic will directly go to next
+                        * step once it detect the CMD CRC error, will not wait for
+                        * the card side to finally send out the tuning data, trigger
+                        * the buffer read ready interrupt immediately. If usdhc send
+                        * the next tuning command some eMMC card will stuck, can't
+                        * response, block the tuning procedure or the first command
+                        * after the whole tuning procedure always can't get any response.
+                        */
+                        tmp |= ESDHC_TUNING_CMD_CRC_CHECK_DISABLE;
                        writel(tmp, host->ioaddr + ESDHC_TUNING_CTRL);
                } else if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
                        /*
@@ -1661,8 +1674,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
        if (err)
                goto disable_ahb_clk;
 
-       host->tuning_delay = 1;
-
        sdhci_esdhc_imx_hwinit(host);
 
        err = sdhci_add_host(host);
--

2.17.1

#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Tue, 26 May 2020 at 12:32, <[email protected]> wrote:

From: Haibo Chen <[email protected]>

According the RM, the bit[6~0] of register ESDHC_TUNING_CTRL is TUNING_START_TAP, bit[7] of this register is to disable the command CRC check for standard tuning. So fix it here.

Fixes d87fc9663688 ("mmc: sdhci-esdhc-imx: support setting tuning start point")

Applied for next, thanks!

Should we add a stable tag or it doesn't matter?

Kind regards
Uffe

Quoted 20 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -2
index 7af9d87d4245..2cf7fa59270e 100644
@@ -90,7 +90,7 @@
 #define ESDHC_STD_TUNING_EN            (1 << 24)
 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
 #define ESDHC_TUNING_START_TAP_DEFAULT 0x1
-#define ESDHC_TUNING_START_TAP_MASK    0xff
+#define ESDHC_TUNING_START_TAP_MASK    0x7f
 #define ESDHC_TUNING_STEP_MASK         0x00070000
 #define ESDHC_TUNING_STEP_SHIFT                16
 
--

2.17.1

#4 lore raw
In reply to [email protected]
Quoted 3 lines · On 2020-05-26 06:22, [email protected] wrote:

According the RM, the bit[6~0] of register ESDHC_TUNING_CTRL is TUNING_START_TAP, bit[7] of this register is to disable the command CRC check for standard tuning. So fix it here.

Which RM? I just checked imx6sl, imx7s and imx8mm reference manuals and they all show bits 7~0 is for TUNING_START_TAP.

I have been experiencing some infrequent hard to reproduce communication errors with an SDIO WiFi module on imx8mm and wondered if this could be related.

For example:
ath10k_sdio mmc2:0001:1: failed to write to address 0x129ec: -84

Kevin

author maintainer
#5 lore raw
Quoted 11 lines

-----Original Message-----
From: Kevin Groeneveld <[email protected]>
Sent: 2022年12月2日 1:34
To: Bough Chen <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Aisheng Dong <[email protected]>; Y.B. Lu <[email protected]>
Subject: Re: [PATCH 1/2] mmc: sdhci-esdhc-imx: fix the mask for tuning start point

Quoted 7 lines
Quoted 3 lines · On 2020-05-26 06:22, [email protected] wrote:

According the RM, the bit[6~0] of register ESDHC_TUNING_CTRL is TUNING_START_TAP, bit[7] of this register is to disable the command CRC check for standard tuning. So fix it here.

Which RM? I just checked imx6sl, imx7s and imx8mm reference manuals and they all show bits 7~0 is for TUNING_START_TAP.

Please refer to the latest imx93 RM, I just confirm that this RM already correct this info.

Quoted 4 lines

I have been experiencing some infrequent hard to reproduce communication errors with an SDIO WiFi module on imx8mm and wondered if this could be related.

This should related to the auto tuning bit setting, usdhc has an IC bug of the auto tuning method for SDIO device which has a interrupt input. Please refer to https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/
I will continue to upstream this these weeks.

Best Regards
Haibo Chen

Quoted 6 lines

For example:
ath10k_sdio mmc2:0001:1: failed to write to address 0x129ec: -84

Kevin