diff mbox series

[v1,1/2] mmc: sdhci: Return true only when timeout exceeds capacity of the HW timer

Message ID 20210917172727.26834-2-huobean@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/2] mmc: sdhci: Return true only when timeout exceeds capacity of the HW timer | expand

Commit Message

Bean Huo Sept. 17, 2021, 5:27 p.m. UTC
From: Bean Huo <beanhuo@micron.com>

Clean up sdhci_calc_timeout() a bit,  and let it set too_big to be true only
when the timeout value required by the eMMC device exceeds the capability of
the host hardware timer.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/mmc/host/sdhci.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

Comments

Adrian Hunter Sept. 24, 2021, 6:32 a.m. UTC | #1
On 17/09/21 8:27 pm, Bean Huo wrote:
> From: Bean Huo <beanhuo@micron.com>
> 
> Clean up sdhci_calc_timeout() a bit,  and let it set too_big to be true only
> when the timeout value required by the eMMC device exceeds the capability of
> the host hardware timer.
> 
> Signed-off-by: Bean Huo <beanhuo@micron.com>

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

> ---
>  drivers/mmc/host/sdhci.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 7ae398f8d4d3..357b365bf0ec 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -930,7 +930,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  	struct mmc_data *data;
>  	unsigned target_timeout, current_timeout;
>  
> -	*too_big = true;
> +	*too_big = false;
>  
>  	/*
>  	 * If the host controller provides us with an incorrect timeout
> @@ -941,7 +941,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
>  		return host->max_timeout_count;
>  
> -	/* Unspecified command, asume max */
> +	/* Unspecified command, assume max */
>  	if (cmd == NULL)
>  		return host->max_timeout_count;
>  
> @@ -968,17 +968,14 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>  	while (current_timeout < target_timeout) {
>  		count++;
>  		current_timeout <<= 1;
> -		if (count > host->max_timeout_count)
> +		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 = host->max_timeout_count;
> +			*too_big = true;
>  			break;
> -	}
> -
> -	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 = host->max_timeout_count;
> -	} else {
> -		*too_big = false;
> +		}
>  	}
>  
>  	return count;
>
Ulf Hansson Sept. 27, 2021, 10:31 p.m. UTC | #2
On Fri, 17 Sept 2021 at 19:27, Bean Huo <huobean@gmail.com> wrote:
>
> From: Bean Huo <beanhuo@micron.com>
>
> Clean up sdhci_calc_timeout() a bit,  and let it set too_big to be true only
> when the timeout value required by the eMMC device exceeds the capability of
> the host hardware timer.
>
> Signed-off-by: Bean Huo <beanhuo@micron.com>

Applied for next (deferring patch2), thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 7ae398f8d4d3..357b365bf0ec 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -930,7 +930,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>         struct mmc_data *data;
>         unsigned target_timeout, current_timeout;
>
> -       *too_big = true;
> +       *too_big = false;
>
>         /*
>          * If the host controller provides us with an incorrect timeout
> @@ -941,7 +941,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>         if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
>                 return host->max_timeout_count;
>
> -       /* Unspecified command, asume max */
> +       /* Unspecified command, assume max */
>         if (cmd == NULL)
>                 return host->max_timeout_count;
>
> @@ -968,17 +968,14 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
>         while (current_timeout < target_timeout) {
>                 count++;
>                 current_timeout <<= 1;
> -               if (count > host->max_timeout_count)
> +               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 = host->max_timeout_count;
> +                       *too_big = true;
>                         break;
> -       }
> -
> -       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 = host->max_timeout_count;
> -       } else {
> -               *too_big = false;
> +               }
>         }
>
>         return count;
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7ae398f8d4d3..357b365bf0ec 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -930,7 +930,7 @@  static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	struct mmc_data *data;
 	unsigned target_timeout, current_timeout;
 
-	*too_big = true;
+	*too_big = false;
 
 	/*
 	 * If the host controller provides us with an incorrect timeout
@@ -941,7 +941,7 @@  static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
 		return host->max_timeout_count;
 
-	/* Unspecified command, asume max */
+	/* Unspecified command, assume max */
 	if (cmd == NULL)
 		return host->max_timeout_count;
 
@@ -968,17 +968,14 @@  static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 	while (current_timeout < target_timeout) {
 		count++;
 		current_timeout <<= 1;
-		if (count > host->max_timeout_count)
+		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 = host->max_timeout_count;
+			*too_big = true;
 			break;
-	}
-
-	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 = host->max_timeout_count;
-	} else {
-		*too_big = false;
+		}
 	}
 
 	return count;