Skip to contentSkip to conversation

mmc: sdhci: Fix HISPD bit handling

PATCH Superseded Jagan Teki 4 participants 5 messages Jun 9, 2020 – Jun 10, 2020 2 messages not in the archive

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH v2 1/1 mmc: sdhci: Fix HISPD bit handling

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v2:
- collect Jaehoon R-b

 drivers/mmc/sdhci.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mmc/sdhci.c +15 -8
index 92cc8434af..280b8c88eb 100644
@@ -594,14 +594,21 @@ static int sdhci_set_ios(struct mmc *mmc)
 			ctrl &= ~SDHCI_CTRL_4BITBUS;
 	}
 
-	if (mmc->clock > 26000000)
-		ctrl |= SDHCI_CTRL_HISPD;
-	else
-		ctrl &= ~SDHCI_CTRL_HISPD;
-
-	if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
-	    (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-		ctrl &= ~SDHCI_CTRL_HISPD;
+	if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
+	    !(host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE)) {
+		if (mmc->selected_mode == MMC_HS ||
+		    mmc->selected_mode == SD_HS ||
+		    mmc->selected_mode == MMC_DDR_52 ||
+		    mmc->selected_mode == MMC_HS_200 ||
+		    mmc->selected_mode == MMC_HS_400 ||
+		    mmc->selected_mode == UHS_SDR25 ||
+		    mmc->selected_mode == UHS_SDR50 ||
+		    mmc->selected_mode == UHS_SDR104 ||
+		    mmc->selected_mode == UHS_DDR50)
+			ctrl |= SDHCI_CTRL_HISPD;
+		else
+			ctrl &= ~SDHCI_CTRL_HISPD;
+	}
 
 	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): 20200609140135.131887-1-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org

#2 lore raw
Quoted 39 lines · Jagan Teki

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v2:
- collect Jaehoon R-b

  drivers/mmc/sdhci.c | 23 +++++++++++++++--------
  1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mmc/sdhci.c +0 -0
index 92cc8434af..280b8c88eb 100644
@@ -594,14 +594,21 @@ static int sdhci_set_ios(struct mmc *mmc)
  			ctrl &= ~SDHCI_CTRL_4BITBUS;
  	}

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 597

Quoted 10 lines
drivers/mmc/sdhci.c +1 -8
 
-	if (mmc->clock > 26000000)
-		ctrl |= SDHCI_CTRL_HISPD;
-	else
-		ctrl &= ~SDHCI_CTRL_HISPD;
-
-	if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
-	    (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-		ctrl &= ~SDHCI_CTRL_HISPD;
+	if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

Should that be "&&" rather than "||"? Otherwise this will always evaluate to true unless *both* quirks are set, which isn't equivalent to the check being removed above.

Robin.

Quoted 18 lines
drivers/mmc/sdhci.c +14 -0
+	    !(host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE)) {
+		if (mmc->selected_mode == MMC_HS ||
+		    mmc->selected_mode == SD_HS ||
+		    mmc->selected_mode == MMC_DDR_52 ||
+		    mmc->selected_mode == MMC_HS_200 ||
+		    mmc->selected_mode == MMC_HS_400 ||
+		    mmc->selected_mode == UHS_SDR25 ||
+		    mmc->selected_mode == UHS_SDR50 ||
+		    mmc->selected_mode == UHS_SDR104 ||
+		    mmc->selected_mode == UHS_DDR50)
+			ctrl |= SDHCI_CTRL_HISPD;
+		else
+			ctrl &= ~SDHCI_CTRL_HISPD;
+	}
 
  	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
#3 lore raw
Quoted 43 lines · Robin Murphy
Quoted 42 lines · Jagan Teki

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v2:
- collect Jaehoon R-b

  drivers/mmc/sdhci.c | 23 +++++++++++++++--------

  1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mmc/sdhci.c +0 -2
index 92cc8434af..280b8c88eb 100644
@@ -594,14 +594,21 @@ static int sdhci_set_ios(struct mmc *mmc)
               ctrl &= ~SDHCI_CTRL_4BITBUS;
       }
   -    if (mmc->clock > 26000000)
-        ctrl |= SDHCI_CTRL_HISPD;
-    else
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 597

Quoted 6 lines
drivers/mmc/sdhci.c +1 -5
-        ctrl &= ~SDHCI_CTRL_HISPD;
-
-    if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
-        (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-        ctrl &= ~SDHCI_CTRL_HISPD;
+    if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

Should that be "&&" rather than "||"? Otherwise this will always evaluate to true unless *both* quirks are set, which isn't equivalent to the check being removed above.

You're right.

Quoted 20 lines

Robin.

Quoted 16 lines
drivers/mmc/sdhci.c +14 -0
+        !(host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE)) {
+        if (mmc->selected_mode == MMC_HS ||
+            mmc->selected_mode == SD_HS ||
+            mmc->selected_mode == MMC_DDR_52 ||
+            mmc->selected_mode == MMC_HS_200 ||
+            mmc->selected_mode == MMC_HS_400 ||
+            mmc->selected_mode == UHS_SDR25 ||
+            mmc->selected_mode == UHS_SDR50 ||
+            mmc->selected_mode == UHS_SDR104 ||
+            mmc->selected_mode == UHS_DDR50)
+            ctrl |= SDHCI_CTRL_HISPD;
+        else
+            ctrl &= ~SDHCI_CTRL_HISPD;
+    }
         sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);

A message that is not in the archive (sent off-list or not yet received): b46fe992-89d4-4a5f-fdb3-e2ec53de2b11-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org

Tested-by
#5 lore raw
Quoted 56 lines · On Wed, 10 Jun 2020 12:45:33 +0900 Jaehoon Chung <[email protected]> wrote:
Quoted 45 lines · Robin Murphy
Quoted 44 lines · Jagan Teki

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v2:
- collect Jaehoon R-b

  drivers/mmc/sdhci.c | 23 +++++++++++++++--------

  1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mmc/sdhci.c +0 -4
index 92cc8434af..280b8c88eb 100644
@@ -594,14 +594,21 @@ static int sdhci_set_ios(struct mmc *mmc)
               ctrl &= ~SDHCI_CTRL_4BITBUS;
       }
   -    if (mmc->clock > 26000000)
-        ctrl |= SDHCI_CTRL_HISPD;
-    else
-        ctrl &= ~SDHCI_CTRL_HISPD;
-
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 597

Quoted 4 lines
drivers/mmc/sdhci.c +1 -3
-    if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
-        (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-        ctrl &= ~SDHCI_CTRL_HISPD;
+    if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||  

Should that be "&&" rather than "||"? Otherwise this will always evaluate to true unless *both* quirks are set, which isn't equivalent to the check being removed above.

Quoted 1 line

You're right.

It'd be great if you could respin this patch quickly and get it merged, as it just helped me getting my NanoPC-T4 up and running.

FWIW:

	M.
Signature · 6 lines
Jazz is not dead. It just smells funny...

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author
#6 lore raw
In reply to Robin Murphy
Quoted 42 lines · Robin Murphy
Quoted 40 lines · Jagan Teki

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v2:
- collect Jaehoon R-b

  drivers/mmc/sdhci.c | 23 +++++++++++++++--------
  1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mmc/sdhci.c +0 -0
index 92cc8434af..280b8c88eb 100644
@@ -594,14 +594,21 @@ static int sdhci_set_ios(struct mmc *mmc)
                      ctrl &= ~SDHCI_CTRL_4BITBUS;
      }
 
Quoted 13 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 597

Quoted 9 lines
drivers/mmc/sdhci.c +1 -8
-     if (mmc->clock > 26000000)
-             ctrl |= SDHCI_CTRL_HISPD;
-     else
-             ctrl &= ~SDHCI_CTRL_HISPD;
-
-     if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
-         (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-             ctrl &= ~SDHCI_CTRL_HISPD;
+     if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

Should that be "&&" rather than "||"? Otherwise this will always evaluate to true unless *both* quirks are set, which isn't equivalent to the check being removed above.

Correct, thanks for the catch. I have updated ib v3.

Jagan.