Skip to contentSkip to conversation

Introduce new quirk to use reserved timeout

PATCH In review Sarthak Garg 3 participants 8 messages May 6, 2020 – May 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Introduce new quirk to use reserved timeout

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

Sarthak Garg (2):
mmc: sdhci: Introduce new quirk to use reserved timeout
mmc: sdhci-msm: Use maximum possible data timeout value

 drivers/mmc/host/sdhci-msm.c | 3 ++-
 drivers/mmc/host/sdhci.c     | 3 ++-
 drivers/mmc/host/sdhci.h     | 5 +++++
 3 files changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 mmc: sdhci: Introduce new quirk to use reserved timeout

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

---
 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +2 -1
index 1bb6b67..07528a9 100644
@@ -967,7 +967,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	}
 
 	if (count >= 0xF) {
-		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) ||
+		!(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))
 			DBG("Too large timeout 0x%x requested for CMD%d!\n",
 			    count, cmd->opcode);
 		count = 0xE;
drivers/mmc/host/sdhci.h +5 -0
index 8d2a096..02f8779 100644
@@ -476,6 +476,11 @@ struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
+/*
+ * Some controllers define the usage of 0xF in data timeout counter
+ * register (0x2E) which is actually a reserved bit as per specification.
+ */
+#define SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT		(1<<19)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH V1 1/2] mmc: sdhci: Introduce new quirk to use reserved timeout

Quoted 16 lines · Sarthak Garg

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

---
 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +0 -0
index 1bb6b67..07528a9 100644

drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd, · line 971

Quoted 6 lines
drivers/mmc/host/sdhci.c +2 -1
@@ -967,7 +967,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        }
 
        if (count >= 0xF) {
-               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) ||
+               !(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))

I don't quite get how this can make your variant use 0xF rather than 0xE?

To me it looks like an updated conditional check to print a debug message, no?

Quoted 20 lines
drivers/mmc/host/sdhci.c +0 -0
                        DBG("Too large timeout 0x%x requested for CMD%d!\n",
                            count, cmd->opcode);
                count = 0xE;
drivers/mmc/host/sdhci.h +5 -1
index 8d2a096..02f8779 100644
@@ -476,6 +476,11 @@ struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT                 (1<<18)
+/*
+ * Some controllers define the usage of 0xF in data timeout counter
+ * register (0x2E) which is actually a reserved bit as per specification.
+ */
+#define SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT          (1<<19)
 
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
--
Quoted 2 lines

2.7.4

Kind regards
Uffe

maintainer
#3 lore raw

Re: [PATCH V1 1/2] mmc: sdhci: Introduce new quirk to use reserved timeout

Quoted 19 lines · Ulf Hansson
Quoted 18 lines · Sarthak Garg

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

---
 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +0 -0
index 1bb6b67..07528a9 100644
@@ -967,7 +967,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        }
 
Quoted 8 lines

drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd, · line 971

Quoted 4 lines
drivers/mmc/host/sdhci.c +2 -1
        if (count >= 0xF) {
-               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) ||
+               !(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))

I don't quite get how this can make your variant use 0xF rather than 0xE?

To me it looks like an updated conditional check to print a debug message, no?

Probably need to introduce host->max_timeout_count, set it to 0xE in sdhci_alloc_host(), and change sdhci_calc_timeout() to use it in place of all the 0xE and 0xF constants.

Quoted 27 lines
Quoted 21 lines
drivers/mmc/host/sdhci.c +0 -0
                        DBG("Too large timeout 0x%x requested for CMD%d!\n",
                            count, cmd->opcode);
                count = 0xE;
drivers/mmc/host/sdhci.h +5 -1
index 8d2a096..02f8779 100644
@@ -476,6 +476,11 @@ struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT                 (1<<18)
+/*
+ * Some controllers define the usage of 0xF in data timeout counter
+ * register (0x2E) which is actually a reserved bit as per specification.
+ */
+#define SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT          (1<<19)
 
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
--
Quoted 2 lines

2.7.4

Kind regards
Uffe

#4 lore raw

Re: [PATCH V1 1/2] mmc: sdhci: Introduce new quirk to use reserved timeout

Quoted 28 lines · Adrian Hunter
Quoted 26 lines · Ulf Hansson
Quoted 16 lines · Sarthak Garg

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

---
 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +0 -0
index 1bb6b67..07528a9 100644

drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd, · line 971

Quoted 6 lines
drivers/mmc/host/sdhci.c +2 -1
@@ -967,7 +967,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        }
 
        if (count >= 0xF) {
-               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) ||
+               !(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))

I don't quite get how this can make your variant use 0xF rather than 0xE?

Quoted 5 lines
Quoted 1 line

To me it looks like an updated conditional check to print a debug message, no?

Probably need to introduce host->max_timeout_count, set it to 0xE in sdhci_alloc_host(), and change sdhci_calc_timeout() to use it in place of all the 0xE and 0xF constants.

Yep, that seems like a reasonable approach to me as well.

[...]

Kind regards
Uffe

#5 lore raw

Re: [PATCH V1 1/2] mmc: sdhci: Introduce new quirk to use reserved timeout

Quoted 35 lines · Ulf Hansson
Quoted 28 lines · Adrian Hunter
Quoted 26 lines · Ulf Hansson
Quoted 16 lines · Sarthak Garg

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

---
 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +0 -0
index 1bb6b67..07528a9 100644

drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd, · line 971

Quoted 6 lines
drivers/mmc/host/sdhci.c +2 -1
@@ -967,7 +967,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        }
 
        if (count >= 0xF) {
-               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) ||
+               !(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))

I don't quite get how this can make your variant use 0xF rather than 0xE?

Quoted 5 lines
Quoted 1 line

To me it looks like an updated conditional check to print a debug message, no?

Probably need to introduce host->max_timeout_count, set it to 0xE in sdhci_alloc_host(), and change sdhci_calc_timeout() to use it in place of all the 0xE and 0xF constants.

Quoted 6 lines

Yep, that seems like a reasonable approach to me as well.

[...]

Kind regards
Uffe

Resending the mail again as can't see my comment on the https://patchwork.kernel.org/ page. Sorry for the mistake just want to update the logic as below.
- count = 0xE;
+ if(!(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))
+ count = 0xE;

maintainer
#6 lore raw

Re: [PATCH V1 1/2] mmc: sdhci: Introduce new quirk to use reserved timeout

Quoted 45 lines · On 19/05/20 5:08 pm, [email protected] wrote:
Quoted 37 lines · Ulf Hansson
Quoted 27 lines · Adrian Hunter
Quoted 12 lines · Ulf Hansson
Quoted 11 lines · Sarthak Garg

Introduce a new quirk for letting vendor drivers to use reserved timeout value (0xF) in timeout control register.

---
  drivers/mmc/host/sdhci.c | 3 ++-
  drivers/mmc/host/sdhci.h | 5 +++++

  2 files changed, 7 insertions(+), 1 deletion(-)
Quoted 5 lines

drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host

Quoted 5 lines
drivers/mmc/host/sdhci.c +0 -0
index 1bb6b67..07528a9 100644
@@ -967,7 +967,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host

*host, struct mmc_command *cmd,

Quoted 7 lines
Quoted 6 lines
drivers/mmc/host/sdhci.c +2 -1
          }
 
          if (count >= 0xF) {
-               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) ||
+               !(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT))
Quoted 8 lines
Quoted 3 lines

I don't quite get how this can make your variant use 0xF rather than 0xE?

To me it looks like an updated conditional check to print a debug

message, no?

Probably need to introduce host->max_timeout_count, set it to 0xE in sdhci_alloc_host(), and change sdhci_calc_timeout() to use it in place of all the 0xE and 0xF constants.

Quoted 6 lines

Yep, that seems like a reasonable approach to me as well.

[...]

Kind regards
Uffe

Quoted 6 lines

Resending the mail again as can't see my comment on the
https://patchwork.kernel.org/ page.
Sorry for the mistake just want to update the logic as below.
-               count = 0xE;
+               if(!(host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT)) +                       count = 0xE;

I think it is conceptually simpler to define SDHCI constants as variables and let vendor drivers change them if need be. In other words, what I wrote above. It changes more code, but the overall result is more consistent.

#7 lore raw

PATCH 2/2 mmc: sdhci-msm: Use maximum possible data timeout value

In reply to Sarthak Garg

The MSM SD controller defines the usage of 0xF in data timeout counter register (0x2E) which is actually a reserved bit as per specification. This would result in maximum of 21.26 secs timeout value.

Some SDcard taking more time than 2.67secs (timeout value corresponding to 0xE) and with that observed data timeout errors.
So increasing the timeout value to max possible timeout.

---
 drivers/mmc/host/sdhci-msm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-msm.c +2 -1
index 8a055dd..909855b 100644
@@ -1888,7 +1888,8 @@ static const struct sdhci_pltfm_data sdhci_msm_pdata = {
 		  SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN |
 		  SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12,
 
-	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
+		SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT,
 	.ops = &sdhci_msm_ops,
 };
 
Signature · 1 line
2.7.4