LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH V1 0/2] Introduce max_timeout_count in sdhci_host for vendor needs
@ 2021-07-16 14:03 Sarthak Garg
  2021-07-16 14:03 ` [PATCH V1 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
  2021-07-16 14:03 ` [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  0 siblings, 2 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-07-16 14:03 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count in sdhci_host_struct to let vendor's modify
the max timeout value as per their needs.

Sarthak Garg (2):
  mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
  mmc: sdhci-msm: Use maximum possible data timeout value

 drivers/mmc/host/sdhci-msm.c |  3 +++
 drivers/mmc/host/sdhci.c     | 15 +++++++++------
 drivers/mmc/host/sdhci.h     |  1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V1 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
  2021-07-16 14:03 [PATCH V1 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
@ 2021-07-16 14:03 ` Sarthak Garg
  2021-07-16 14:03 ` [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  1 sibling, 0 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-07-16 14:03 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count variable in the sdhci_host structure
and use in timeout calculation. By default its set to 0xE
(max timeout register value as per SDHC spec). But at the same time
vendors drivers can update it if they support different max timeout
register value than 0xE.

Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci.c | 15 +++++++++------
 drivers/mmc/host/sdhci.h |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index aba6e10..2debda3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -939,16 +939,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	 * timeout value.
 	 */
 	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
-		return 0xE;
+		return host->max_timeout_count;
 
 	/* Unspecified command, asume max */
 	if (cmd == NULL)
-		return 0xE;
+		return host->max_timeout_count;
 
 	data = cmd->data;
 	/* Unspecified timeout, assume max */
 	if (!data && !cmd->busy_timeout)
-		return 0xE;
+		return host->max_timeout_count;
 
 	/* timeout in us */
 	target_timeout = sdhci_target_timeout(host, cmd, data);
@@ -968,15 +968,15 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	while (current_timeout < target_timeout) {
 		count++;
 		current_timeout <<= 1;
-		if (count >= 0xF)
+		if (count > host->max_timeout_count)
 			break;
 	}
 
-	if (count >= 0xF) {
+	if (count > host->max_timeout_count) {
 		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
 			DBG("Too large timeout 0x%x requested for CMD%d!\n",
 			    count, cmd->opcode);
-		count = 0xE;
+		count = host->max_timeout_count;
 	} else {
 		*too_big = false;
 	}
@@ -3940,6 +3940,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 	 */
 	host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1;
 
+	if (!host->max_timeout_count)
+		host->max_timeout_count = 0xE;
+
 	return host;
 }
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 074dc18..e8d04e4 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -517,6 +517,7 @@ struct sdhci_host {
 
 	unsigned int max_clk;	/* Max possible freq (MHz) */
 	unsigned int timeout_clk;	/* Timeout freq (KHz) */
+	u8 max_timeout_count;	/* Vendor specific max timeout count */
 	unsigned int clk_mul;	/* Clock Muliplier value */
 
 	unsigned int clock;	/* Current clock (MHz) */
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value
  2021-07-16 14:03 [PATCH V1 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
  2021-07-16 14:03 ` [PATCH V1 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
@ 2021-07-16 14:03 ` Sarthak Garg
  2021-07-16 23:54   ` Bjorn Andersson
  2021-07-29  4:46   ` [PATCH V2 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
  1 sibling, 2 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-07-16 14:03 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg,
	Andy Gross, Bjorn Andersson

The Qcom 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.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci-msm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index e44b7a6..19e4673 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -2696,6 +2696,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	msm_host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_NEED_RSP_BUSY;
 
+	/* Set the timeout value to max possible */
+	host->max_timeout_count = 0xF;
+
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value
  2021-07-16 14:03 ` [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
@ 2021-07-16 23:54   ` Bjorn Andersson
  2021-07-29  4:46   ` [PATCH V2 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
  1 sibling, 0 replies; 16+ messages in thread
From: Bjorn Andersson @ 2021-07-16 23:54 UTC (permalink / raw)
  To: Sarthak Garg
  Cc: adrian.hunter, ulf.hansson, stummala, linux-mmc, linux-kernel,
	linux-arm-msm, Andy Gross

On Fri 16 Jul 09:03 CDT 2021, Sarthak Garg wrote:

> The Qcom 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.
> 
> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>

The From: of the email says you wrote the patch, but the first person to
certify its origin is Sahitya. Did you perhaps write this together? If
so you should have a:

Co-developed-by: Sahitya

If Sahitya wrote the patch, certifies its origin and then you picks it
up and certify that you got it from Sahitya, then you should write it as
you did - but you should have retained Sahitya as author...

Regards,
Bjorn

> Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
> ---
>  drivers/mmc/host/sdhci-msm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index e44b7a6..19e4673 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -2696,6 +2696,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>  
>  	msm_host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_NEED_RSP_BUSY;
>  
> +	/* Set the timeout value to max possible */
> +	host->max_timeout_count = 0xF;
> +
>  	pm_runtime_get_noresume(&pdev->dev);
>  	pm_runtime_set_active(&pdev->dev);
>  	pm_runtime_enable(&pdev->dev);
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V2 0/2] Introduce max_timeout_count in sdhci_host for vendor
  2021-07-16 14:03 ` [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  2021-07-16 23:54   ` Bjorn Andersson
@ 2021-07-29  4:46   ` Sarthak Garg
  2021-07-29  4:46     ` [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
  2021-07-29  4:46     ` [PATCH V2 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  1 sibling, 2 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-07-29  4:46 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count in sdhci_host_struct to let vendor's modify
the max timeout value as per their needs.

Sahitya Tummala (1):
  mmc: sdhci-msm: Use maximum possible data timeout value

Sarthak Garg (1):
  mmc: sdhci: Introduce max_timeout_count variable in sdhci_host

 drivers/mmc/host/sdhci-msm.c |  3 +++
 drivers/mmc/host/sdhci.c     | 15 +++++++++------
 drivers/mmc/host/sdhci.h     |  1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
  2021-07-29  4:46   ` [PATCH V2 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
@ 2021-07-29  4:46     ` Sarthak Garg
  2021-08-03  8:23       ` Adrian Hunter
                         ` (2 more replies)
  2021-07-29  4:46     ` [PATCH V2 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  1 sibling, 3 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-07-29  4:46 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count variable in the sdhci_host structure
and use in timeout calculation. By default its set to 0xE
(max timeout register value as per SDHC spec). But at the same time
vendors drivers can update it if they support different max timeout
register value than 0xE.

Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci.c | 15 +++++++++------
 drivers/mmc/host/sdhci.h |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index aba6e10..2debda3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -939,16 +939,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	 * timeout value.
 	 */
 	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
-		return 0xE;
+		return host->max_timeout_count;
 
 	/* Unspecified command, asume max */
 	if (cmd == NULL)
-		return 0xE;
+		return host->max_timeout_count;
 
 	data = cmd->data;
 	/* Unspecified timeout, assume max */
 	if (!data && !cmd->busy_timeout)
-		return 0xE;
+		return host->max_timeout_count;
 
 	/* timeout in us */
 	target_timeout = sdhci_target_timeout(host, cmd, data);
@@ -968,15 +968,15 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	while (current_timeout < target_timeout) {
 		count++;
 		current_timeout <<= 1;
-		if (count >= 0xF)
+		if (count > host->max_timeout_count)
 			break;
 	}
 
-	if (count >= 0xF) {
+	if (count > host->max_timeout_count) {
 		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
 			DBG("Too large timeout 0x%x requested for CMD%d!\n",
 			    count, cmd->opcode);
-		count = 0xE;
+		count = host->max_timeout_count;
 	} else {
 		*too_big = false;
 	}
@@ -3940,6 +3940,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 	 */
 	host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1;
 
+	if (!host->max_timeout_count)
+		host->max_timeout_count = 0xE;
+
 	return host;
 }
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 074dc18..e8d04e4 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -517,6 +517,7 @@ struct sdhci_host {
 
 	unsigned int max_clk;	/* Max possible freq (MHz) */
 	unsigned int timeout_clk;	/* Timeout freq (KHz) */
+	u8 max_timeout_count;	/* Vendor specific max timeout count */
 	unsigned int clk_mul;	/* Clock Muliplier value */
 
 	unsigned int clock;	/* Current clock (MHz) */
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V2 2/2] mmc: sdhci-msm: Use maximum possible data timeout value
  2021-07-29  4:46   ` [PATCH V2 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
  2021-07-29  4:46     ` [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
@ 2021-07-29  4:46     ` Sarthak Garg
  1 sibling, 0 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-07-29  4:46 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm,
	Sarthak Garg, Andy Gross, Bjorn Andersson

From: Sahitya Tummala <stummala@codeaurora.org>

The Qcom 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.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci-msm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index e44b7a6..19e4673 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -2696,6 +2696,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	msm_host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_NEED_RSP_BUSY;
 
+	/* Set the timeout value to max possible */
+	host->max_timeout_count = 0xF;
+
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
  2021-07-29  4:46     ` [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
@ 2021-08-03  8:23       ` Adrian Hunter
  2021-08-06  6:51       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
  2021-08-06  6:54       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
  2 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2021-08-03  8:23 UTC (permalink / raw)
  To: Sarthak Garg, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm

On 29/07/21 7:46 am, Sarthak Garg wrote:
> Introduce max_timeout_count variable in the sdhci_host structure
> and use in timeout calculation. By default its set to 0xE
> (max timeout register value as per SDHC spec). But at the same time
> vendors drivers can update it if they support different max timeout
> register value than 0xE.

Looks fine.  A couple of minor comments below.

> 
> Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
> ---
>  drivers/mmc/host/sdhci.c | 15 +++++++++------
>  drivers/mmc/host/sdhci.h |  1 +
>  2 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index aba6e10..2debda3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -939,16 +939,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  	 * timeout value.
>  	 */
>  	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
> -		return 0xE;
> +		return host->max_timeout_count;

Please adjust the comment above this that also refers to 0xE
e.g. "skip the check and use 0xE" -> "skip the check and use the maximum"

>  
>  	/* Unspecified command, asume max */
>  	if (cmd == NULL)
> -		return 0xE;
> +		return host->max_timeout_count;
>  
>  	data = cmd->data;
>  	/* Unspecified timeout, assume max */
>  	if (!data && !cmd->busy_timeout)
> -		return 0xE;
> +		return host->max_timeout_count;
>  
>  	/* timeout in us */
>  	target_timeout = sdhci_target_timeout(host, cmd, data);
> @@ -968,15 +968,15 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  	while (current_timeout < target_timeout) {
>  		count++;
>  		current_timeout <<= 1;
> -		if (count >= 0xF)
> +		if (count > host->max_timeout_count)
>  			break;
>  	}
>  
> -	if (count >= 0xF) {
> +	if (count > host->max_timeout_count) {
>  		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
>  			DBG("Too large timeout 0x%x requested for CMD%d!\n",
>  			    count, cmd->opcode);
> -		count = 0xE;
> +		count = host->max_timeout_count;
>  	} else {
>  		*too_big = false;
>  	}
> @@ -3940,6 +3940,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
>  	 */
>  	host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1;
>  
> +	if (!host->max_timeout_count)

'host' has just been (zero) allocated as part of 'mmc', so the 'if' is redundant here.

> +		host->max_timeout_count = 0xE;
> +
>  	return host;
>  }
>  
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 074dc18..e8d04e4 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -517,6 +517,7 @@ struct sdhci_host {
>  
>  	unsigned int max_clk;	/* Max possible freq (MHz) */
>  	unsigned int timeout_clk;	/* Timeout freq (KHz) */
> +	u8 max_timeout_count;	/* Vendor specific max timeout count */
>  	unsigned int clk_mul;	/* Clock Muliplier value */
>  
>  	unsigned int clock;	/* Current clock (MHz) */
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor
  2021-07-29  4:46     ` [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
  2021-08-03  8:23       ` Adrian Hunter
@ 2021-08-06  6:51       ` Sarthak Garg
  2021-08-06  6:54       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
  2 siblings, 0 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-08-06  6:51 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count in sdhci_host_struct to let vendor's modify
the max timeout value as per their needs.

Sahitya Tummala (1):
  mmc: sdhci-msm: Use maximum possible data timeout value

Sarthak Garg (1):
  mmc: sdhci: Introduce max_timeout_count variable in sdhci_host

 drivers/mmc/host/sdhci-msm.c |  3 +++
 drivers/mmc/host/sdhci.c     | 16 +++++++++-------
 drivers/mmc/host/sdhci.h     |  1 +
 3 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs
  2021-07-29  4:46     ` [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
  2021-08-03  8:23       ` Adrian Hunter
  2021-08-06  6:51       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
@ 2021-08-06  6:54       ` Sarthak Garg
  2021-08-06  6:54         ` [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
                           ` (2 more replies)
  2 siblings, 3 replies; 16+ messages in thread
From: Sarthak Garg @ 2021-08-06  6:54 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count in sdhci_host_struct to let vendor's modify
the max timeout value as per their needs.

Sahitya Tummala (1):
  mmc: sdhci-msm: Use maximum possible data timeout value

Sarthak Garg (1):
  mmc: sdhci: Introduce max_timeout_count variable in sdhci_host

 drivers/mmc/host/sdhci-msm.c |  3 +++
 drivers/mmc/host/sdhci.c     | 16 +++++++++-------
 drivers/mmc/host/sdhci.h     |  1 +
 3 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
  2021-08-06  6:54       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
@ 2021-08-06  6:54         ` Sarthak Garg
  2021-08-06 14:30           ` Adrian Hunter
  2021-08-06  6:55         ` [PATCH V3 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  2021-08-16 13:59         ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Ulf Hansson
  2 siblings, 1 reply; 16+ messages in thread
From: Sarthak Garg @ 2021-08-06  6:54 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm, Sarthak Garg

Introduce max_timeout_count variable in the sdhci_host structure
and use in timeout calculation. By default its set to 0xE
(max timeout register value as per SDHC spec). But at the same time
vendors drivers can update it if they support different max timeout
register value than 0xE.

Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci.c | 16 +++++++++-------
 drivers/mmc/host/sdhci.h |  1 +
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index aba6e10..613e1ab 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -934,21 +934,21 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 
 	/*
 	 * If the host controller provides us with an incorrect timeout
-	 * value, just skip the check and use 0xE.  The hardware may take
+	 * value, just skip the check and use the maximum. The hardware may take
 	 * longer to time out, but that's much better than having a too-short
 	 * timeout value.
 	 */
 	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
-		return 0xE;
+		return host->max_timeout_count;
 
 	/* Unspecified command, asume max */
 	if (cmd == NULL)
-		return 0xE;
+		return host->max_timeout_count;
 
 	data = cmd->data;
 	/* Unspecified timeout, assume max */
 	if (!data && !cmd->busy_timeout)
-		return 0xE;
+		return host->max_timeout_count;
 
 	/* timeout in us */
 	target_timeout = sdhci_target_timeout(host, cmd, data);
@@ -968,15 +968,15 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	while (current_timeout < target_timeout) {
 		count++;
 		current_timeout <<= 1;
-		if (count >= 0xF)
+		if (count > host->max_timeout_count)
 			break;
 	}
 
-	if (count >= 0xF) {
+	if (count > host->max_timeout_count) {
 		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
 			DBG("Too large timeout 0x%x requested for CMD%d!\n",
 			    count, cmd->opcode);
-		count = 0xE;
+		count = host->max_timeout_count;
 	} else {
 		*too_big = false;
 	}
@@ -3940,6 +3940,8 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 	 */
 	host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1;
 
+	host->max_timeout_count = 0xE;
+
 	return host;
 }
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 074dc18..e8d04e4 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -517,6 +517,7 @@ struct sdhci_host {
 
 	unsigned int max_clk;	/* Max possible freq (MHz) */
 	unsigned int timeout_clk;	/* Timeout freq (KHz) */
+	u8 max_timeout_count;	/* Vendor specific max timeout count */
 	unsigned int clk_mul;	/* Clock Muliplier value */
 
 	unsigned int clock;	/* Current clock (MHz) */
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V3 2/2] mmc: sdhci-msm: Use maximum possible data timeout value
  2021-08-06  6:54       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
  2021-08-06  6:54         ` [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
@ 2021-08-06  6:55         ` Sarthak Garg
  2021-08-06 14:31           ` Adrian Hunter
  2021-08-16 13:59         ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Ulf Hansson
  2 siblings, 1 reply; 16+ messages in thread
From: Sarthak Garg @ 2021-08-06  6:55 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm,
	Sarthak Garg, Andy Gross, Bjorn Andersson

From: Sahitya Tummala <stummala@codeaurora.org>

The Qcom 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.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci-msm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index e44b7a6..19e4673 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -2696,6 +2696,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	msm_host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_NEED_RSP_BUSY;
 
+	/* Set the timeout value to max possible */
+	host->max_timeout_count = 0xF;
+
 	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
  2021-08-06  6:54         ` [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
@ 2021-08-06 14:30           ` Adrian Hunter
  0 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2021-08-06 14:30 UTC (permalink / raw)
  To: Sarthak Garg, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm

On 6/08/21 9:54 am, Sarthak Garg wrote:
> Introduce max_timeout_count variable in the sdhci_host structure
> and use in timeout calculation. By default its set to 0xE
> (max timeout register value as per SDHC spec). But at the same time
> vendors drivers can update it if they support different max timeout
> register value than 0xE.
> 
> Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci.c | 16 +++++++++-------
>  drivers/mmc/host/sdhci.h |  1 +
>  2 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index aba6e10..613e1ab 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -934,21 +934,21 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  
>  	/*
>  	 * If the host controller provides us with an incorrect timeout
> -	 * value, just skip the check and use 0xE.  The hardware may take
> +	 * value, just skip the check and use the maximum. The hardware may take
>  	 * longer to time out, but that's much better than having a too-short
>  	 * timeout value.
>  	 */
>  	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
> -		return 0xE;
> +		return host->max_timeout_count;
>  
>  	/* Unspecified command, asume max */
>  	if (cmd == NULL)
> -		return 0xE;
> +		return host->max_timeout_count;
>  
>  	data = cmd->data;
>  	/* Unspecified timeout, assume max */
>  	if (!data && !cmd->busy_timeout)
> -		return 0xE;
> +		return host->max_timeout_count;
>  
>  	/* timeout in us */
>  	target_timeout = sdhci_target_timeout(host, cmd, data);
> @@ -968,15 +968,15 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  	while (current_timeout < target_timeout) {
>  		count++;
>  		current_timeout <<= 1;
> -		if (count >= 0xF)
> +		if (count > host->max_timeout_count)
>  			break;
>  	}
>  
> -	if (count >= 0xF) {
> +	if (count > host->max_timeout_count) {
>  		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
>  			DBG("Too large timeout 0x%x requested for CMD%d!\n",
>  			    count, cmd->opcode);
> -		count = 0xE;
> +		count = host->max_timeout_count;
>  	} else {
>  		*too_big = false;
>  	}
> @@ -3940,6 +3940,8 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
>  	 */
>  	host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1;
>  
> +	host->max_timeout_count = 0xE;
> +
>  	return host;
>  }
>  
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 074dc18..e8d04e4 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -517,6 +517,7 @@ struct sdhci_host {
>  
>  	unsigned int max_clk;	/* Max possible freq (MHz) */
>  	unsigned int timeout_clk;	/* Timeout freq (KHz) */
> +	u8 max_timeout_count;	/* Vendor specific max timeout count */
>  	unsigned int clk_mul;	/* Clock Muliplier value */
>  
>  	unsigned int clock;	/* Current clock (MHz) */
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH V3 2/2] mmc: sdhci-msm: Use maximum possible data timeout value
  2021-08-06  6:55         ` [PATCH V3 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
@ 2021-08-06 14:31           ` Adrian Hunter
  0 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2021-08-06 14:31 UTC (permalink / raw)
  To: Sarthak Garg, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm,
	Andy Gross, Bjorn Andersson

On 6/08/21 9:55 am, Sarthak Garg wrote:
> From: Sahitya Tummala <stummala@codeaurora.org>
> 
> The Qcom 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.
> 
> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
> Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-msm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index e44b7a6..19e4673 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -2696,6 +2696,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>  
>  	msm_host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_NEED_RSP_BUSY;
>  
> +	/* Set the timeout value to max possible */
> +	host->max_timeout_count = 0xF;
> +
>  	pm_runtime_get_noresume(&pdev->dev);
>  	pm_runtime_set_active(&pdev->dev);
>  	pm_runtime_enable(&pdev->dev);
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs
  2021-08-06  6:54       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
  2021-08-06  6:54         ` [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
  2021-08-06  6:55         ` [PATCH V3 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
@ 2021-08-16 13:59         ` Ulf Hansson
  2 siblings, 0 replies; 16+ messages in thread
From: Ulf Hansson @ 2021-08-16 13:59 UTC (permalink / raw)
  To: Sarthak Garg
  Cc: Adrian Hunter, Veerabhadrarao Badiganti, Sahitya Tummala,
	linux-mmc, Linux Kernel Mailing List, linux-arm-msm

On Fri, 6 Aug 2021 at 08:55, Sarthak Garg <sartgarg@codeaurora.org> wrote:
>
> Introduce max_timeout_count in sdhci_host_struct to let vendor's modify
> the max timeout value as per their needs.
>
> Sahitya Tummala (1):
>   mmc: sdhci-msm: Use maximum possible data timeout value
>
> Sarthak Garg (1):
>   mmc: sdhci: Introduce max_timeout_count variable in sdhci_host
>
>  drivers/mmc/host/sdhci-msm.c |  3 +++
>  drivers/mmc/host/sdhci.c     | 16 +++++++++-------
>  drivers/mmc/host/sdhci.h     |  1 +
>  3 files changed, 13 insertions(+), 7 deletions(-)
>
> --
> 2.7.4
>

Applied for next, thanks!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value
  2020-05-06 13:44 [PATCH V1 0/2] Introduce new quirk to use reserved timeout Sarthak Garg
@ 2020-05-06 13:44 ` Sarthak Garg
  0 siblings, 0 replies; 16+ messages in thread
From: Sarthak Garg @ 2020-05-06 13:44 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: vbadigan, stummala, linux-mmc, linux-kernel, linux-arm-msm,
	Sarthak Garg, Andy Gross, Bjorn Andersson

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.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org>
---
 drivers/mmc/host/sdhci-msm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 8a055dd..909855b 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -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,
 };
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-08-16 14:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 14:03 [PATCH V1 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
2021-07-16 14:03 ` [PATCH V1 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
2021-07-16 14:03 ` [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
2021-07-16 23:54   ` Bjorn Andersson
2021-07-29  4:46   ` [PATCH V2 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
2021-07-29  4:46     ` [PATCH V2 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
2021-08-03  8:23       ` Adrian Hunter
2021-08-06  6:51       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor Sarthak Garg
2021-08-06  6:54       ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Sarthak Garg
2021-08-06  6:54         ` [PATCH V3 1/2] mmc: sdhci: Introduce max_timeout_count variable in sdhci_host Sarthak Garg
2021-08-06 14:30           ` Adrian Hunter
2021-08-06  6:55         ` [PATCH V3 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
2021-08-06 14:31           ` Adrian Hunter
2021-08-16 13:59         ` [PATCH V3 0/2] Introduce max_timeout_count in sdhci_host for vendor needs Ulf Hansson
2021-07-29  4:46     ` [PATCH V2 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg
  -- strict thread matches above, loose matches on Subject: below --
2020-05-06 13:44 [PATCH V1 0/2] Introduce new quirk to use reserved timeout Sarthak Garg
2020-05-06 13:44 ` [PATCH V1 2/2] mmc: sdhci-msm: Use maximum possible data timeout value Sarthak Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).