linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, Chris Ball <chris@printf.net>,
	Dong Aisheng <b29396@freescale.com>,
	Stephen Warren <swarren@nvidia.com>,
	Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Subject: Re: [PATCH 06/10] mmc: core: Respect host's max_busy_timeout when sending sleep cmd
Date: Thu, 23 Jan 2014 12:23:38 +0200	[thread overview]
Message-ID: <52E0EDAA.7040703@intel.com> (raw)
In-Reply-To: <1390402824-9850-7-git-send-email-ulf.hansson@linaro.org>

On 22/01/14 17:00, Ulf Hansson wrote:
> When sending the sleep command for host drivers supporting
> MMC_CAP_WAIT_WHILE_BUSY, we need to confirm that max_busy_timeout is
> big enough comparing to the sleep timeout specified from card's
> EXT_CSD. If this isn't case, we use a R1 response instead of R1B and
> fallback to use a delay instead.
> 
> Do note that a max_busy_timeout set to zero by the host, is interpreted
> as it can cope with whatever timeout the mmc core provides it with.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/core/mmc.c |   19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 897fdd1..32e1546 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1359,6 +1359,8 @@ static int mmc_sleep(struct mmc_host *host)
>  {
>  	struct mmc_command cmd = {0};
>  	struct mmc_card *card = host->card;
> +	unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000);
> +	unsigned int max_busy_timeout;
>  	int err;
>  
>  	if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
> @@ -1372,7 +1374,18 @@ static int mmc_sleep(struct mmc_host *host)
>  	cmd.arg = card->rca << 16;
>  	cmd.arg |= 1 << 15;
>  
> -	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
> +	/* We interpret unspecified timeouts as the host can cope with all. */
> +	max_busy_timeout = host->max_busy_timeout ?
> +			host->max_busy_timeout : timeout_ms;
> +
> +	if ((host->caps & MMC_CAP_WAIT_WHILE_BUSY) &&
> +		(timeout_ms <= max_busy_timeout)) {
> +		cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
> +		cmd.busy_timeout = timeout_ms;
> +	} else {
> +		cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
> +	}

I do not see why this is related to MMC_CAP_WAIT_WHILE_BUSY.
Why not just:

	if (host->max_busy_timeout && timeout_ms > host->max_busy_timeout) {
		cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
	} else {
		cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
		cmd.busy_timeout = timeout_ms;
	}

> +
>  	err = mmc_wait_for_cmd(host, &cmd, 0);
>  	if (err)
>  		return err;
> @@ -1383,8 +1396,8 @@ static int mmc_sleep(struct mmc_host *host)
>  	 * SEND_STATUS command to poll the status because that command (and most
>  	 * others) is invalid while the card sleeps.
>  	 */
> -	if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
> -		mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000));
> +	if (!cmd.busy_timeout)
> +		mmc_delay(timeout_ms);

And this becomes:

	if (!cmd.busy_timeout || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
		mmc_delay(timeout_ms);

>  
>  	return err;
>  }
> 


  reply	other threads:[~2014-01-23 10:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22 15:00 [PATCH 00/10] mmc: Improve busy detection for MMC_CAP_WAIT_WHILE_BUSY Ulf Hansson
2014-01-22 15:00 ` [PATCH 01/10] mmc: core: Rename max_discard_to to max_busy_timeout Ulf Hansson
2014-01-22 15:00 ` [PATCH 02/10] mmc: core: Rename cmd_timeout_ms to busy_timeout Ulf Hansson
2014-01-22 15:00 ` [PATCH 03/10] mmc: core: Add ignore_crc flag to __mmc_switch Ulf Hansson
2014-01-22 15:00 ` [PATCH 04/10] mmc: core: Fixup busy detection for mmc switch operations Ulf Hansson
2014-01-23 10:10   ` Adrian Hunter
2014-01-23 14:11     ` Ulf Hansson
2014-01-27 10:40       ` Adrian Hunter
2014-01-28 11:37         ` Ulf Hansson
2014-01-22 15:00 ` [PATCH 05/10] mmc: core: Use generic CMD6 time while switching to eMMC HS200 mode Ulf Hansson
2014-01-22 15:00 ` [PATCH 06/10] mmc: core: Respect host's max_busy_timeout when sending sleep cmd Ulf Hansson
2014-01-23 10:23   ` Adrian Hunter [this message]
2014-01-23 14:26     ` Ulf Hansson
2014-01-27 10:46       ` Adrian Hunter
2014-01-28 12:43         ` Ulf Hansson
2014-01-22 15:00 ` [PATCH 07/10] mmc: card: Use R1 responses for stop cmds for read requests Ulf Hansson
2014-01-22 15:00 ` [PATCH 08/10] mmc: card: Use R1 response for the stop cmd at recovery path Ulf Hansson
2014-01-23 10:09   ` Adrian Hunter
2014-01-23 13:21     ` Ulf Hansson
2014-01-23 14:29       ` Adrian Hunter
2014-01-23 14:59         ` Ulf Hansson
2014-01-27 10:40           ` Adrian Hunter
2014-01-28 12:39             ` Ulf Hansson
2014-01-28 14:45               ` Adrian Hunter
2014-01-28 16:11                 ` Ulf Hansson
2014-01-22 15:00 ` [PATCH 09/10] mmc: mmci: Handle CMD irq before DATA irq Ulf Hansson
2014-01-22 15:19   ` Russell King - ARM Linux
2014-01-22 15:43     ` Ulf Hansson
2014-01-22 15:00 ` [PATCH 10/10] mmc: mmci: Enable support for busy detection for ux500 variant Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52E0EDAA.7040703@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=b29396@freescale.com \
    --cc=chris@printf.net \
    --cc=linux-mmc@vger.kernel.org \
    --cc=swarren@nvidia.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vladimir_zapolskiy@mentor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).