diff mbox series

[05/19] mmc: usdhi6rol0: Inform the mmc core about the maximum busy timeout

Message ID 20200414161413.3036-6-ulf.hansson@linaro.org
State New
Headers show
Series mmc: Improve host driver's support for R1B responses | expand

Commit Message

Ulf Hansson April 14, 2020, 4:13 p.m. UTC
Some commands uses R1B responses, which means the card may assert the DAT0
line to signal busy for a period of time, after it has received the
command. The mmc core normally specifies the busy period for the command in
the cmd->busy_timeout. Ideally the driver should respect it, but that
requires quite some update of the code, so let's defer that to someone with
the HW at hand.

Instead, let's inform the mmc core about the maximum supported busy timeout
in ->max_busy_timeout during ->probe(). This value corresponds to the fixed
4s timeout used by usdhi6rol0. In this way, we let the mmc core validate
the needed timeout, which may lead to that it converts from a R1B into a R1
response and then use CMD13 to poll for busy completion.

In other words, this change enables support for commands with longer busy
periods than 4s, like erase (CMD38) for example.

Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Lars Persson <lars.persson@axis.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/mmc/host/usdhi6rol0.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

-- 
2.20.1

Comments

Jesper Nilsson April 15, 2020, 6:34 a.m. UTC | #1
On Tue, Apr 14, 2020 at 06:13:59PM +0200, Ulf Hansson wrote:
> Some commands uses R1B responses, which means the card may assert the DAT0
> line to signal busy for a period of time, after it has received the
> command. The mmc core normally specifies the busy period for the command in
> the cmd->busy_timeout. Ideally the driver should respect it, but that
> requires quite some update of the code, so let's defer that to someone with
> the HW at hand.
> 
> Instead, let's inform the mmc core about the maximum supported busy timeout
> in ->max_busy_timeout during ->probe(). This value corresponds to the fixed
> 4s timeout used by usdhi6rol0. In this way, we let the mmc core validate
> the needed timeout, which may lead to that it converts from a R1B into a R1
> response and then use CMD13 to poll for busy completion.
> 
> In other words, this change enables support for commands with longer busy
> periods than 4s, like erase (CMD38) for example.

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>

> Cc: Lars Persson <lars.persson@axis.com>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/host/usdhi6rol0.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> index 9a0b1e4e405d..369b8dee2e3d 100644
> --- a/drivers/mmc/host/usdhi6rol0.c
> +++ b/drivers/mmc/host/usdhi6rol0.c
> @@ -136,6 +136,8 @@
>  
>  #define USDHI6_MIN_DMA 64
>  
> +#define USDHI6_REQ_TIMEOUT_MS 4000
> +
>  enum usdhi6_wait_for {
>  	USDHI6_WAIT_FOR_REQUEST,
>  	USDHI6_WAIT_FOR_CMD,
> @@ -1763,7 +1765,12 @@ static int usdhi6_probe(struct platform_device *pdev)
>  	host		= mmc_priv(mmc);
>  	host->mmc	= mmc;
>  	host->wait	= USDHI6_WAIT_FOR_REQUEST;
> -	host->timeout	= msecs_to_jiffies(4000);
> +	host->timeout	= msecs_to_jiffies(USDHI6_REQ_TIMEOUT_MS);
> +	/*
> +	 * We use a fixed timeout of 4s, hence inform the core about it. A
> +	 * future improvement should instead respect the cmd->busy_timeout.
> +	 */
> +	mmc->max_busy_timeout = USDHI6_REQ_TIMEOUT_MS;
>  
>  	host->pinctrl = devm_pinctrl_get(&pdev->dev);
>  	if (IS_ERR(host->pinctrl)) {
> -- 
> 2.20.1
> 

/^JN - Jesper Nilsson
diff mbox series

Patch

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 9a0b1e4e405d..369b8dee2e3d 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -136,6 +136,8 @@ 
 
 #define USDHI6_MIN_DMA 64
 
+#define USDHI6_REQ_TIMEOUT_MS 4000
+
 enum usdhi6_wait_for {
 	USDHI6_WAIT_FOR_REQUEST,
 	USDHI6_WAIT_FOR_CMD,
@@ -1763,7 +1765,12 @@  static int usdhi6_probe(struct platform_device *pdev)
 	host		= mmc_priv(mmc);
 	host->mmc	= mmc;
 	host->wait	= USDHI6_WAIT_FOR_REQUEST;
-	host->timeout	= msecs_to_jiffies(4000);
+	host->timeout	= msecs_to_jiffies(USDHI6_REQ_TIMEOUT_MS);
+	/*
+	 * We use a fixed timeout of 4s, hence inform the core about it. A
+	 * future improvement should instead respect the cmd->busy_timeout.
+	 */
+	mmc->max_busy_timeout = USDHI6_REQ_TIMEOUT_MS;
 
 	host->pinctrl = devm_pinctrl_get(&pdev->dev);
 	if (IS_ERR(host->pinctrl)) {