public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Ball <cjb@laptop.org>
To: "Luis R. Rodriguez" <lrodriguez@atheros.com>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	vmehta@atheros.com, naveen.singh@atheros.com, kvalo@adurom.com,
	j@w1.fi, Naveen Singh <nsingh@atheros.com>,
	Vipin Mehta <Vipin.Mehta@atheros.com>
Subject: Re: [RFC 1/4] sdhci: allow for multiple delays when sending commands
Date: Fri, 18 Mar 2011 19:10:40 -0400	[thread overview]
Message-ID: <m3y64ct47j.fsf@pullcord.laptop.org> (raw)
In-Reply-To: <1300486320-23607-2-git-send-email-lrodriguez@atheros.com> (Luis R. Rodriguez's message of "Fri, 18 Mar 2011 15:11:57 -0700")

Hi Luis,

On Fri, Mar 18 2011, Luis R. Rodriguez wrote:
> This is at least known to be required for the ENE 714.
>
> Cc: Chris Ball <cjb@laptop.org>
> Cc: Kalle Valo <kvalo@adurom.com>
> Cc: Naveen Singh <nsingh@atheros.com>
> Cc: Vipin Mehta <Vipin.Mehta@atheros.com>
> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>

I think this wins cjb's "I've never been so confused about what a patch
author thought they were doing before" award.

> ---
>  drivers/mmc/host/sdhci.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 9e15f41..c95dfc2 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -891,8 +891,8 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
>  
>  	WARN_ON(host->cmd);
>  
> -	/* Wait max 10 ms */
> -	timeout = 10;
> +	/* Wait max this amount of ms */
> +	timeout = (10*256) + 255;
>  
>  	mask = SDHCI_CMD_INHIBIT;
>  	if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY))

Okay, so our original plan is to go through the while loop ten times,
which equals ten mdelay(1)s == 10ms, waiting for the inhibit bit to
become unset.

After this hunk of your patch, we're set to go through the loop 2815
times, which would make for 2.8 seconds.  That seems excessive.

> @@ -913,7 +913,8 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
>  			return;
>  		}
>  		timeout--;
> -		mdelay(1);
> +		if (!(timeout & 0xFF))
> +			mdelay(1);
>  	}
>  
>  	mod_timer(&host->timer, jiffies + 10 * HZ);

But wait, here you decide *not* to call mdelay(1) every time through the
loop, and instead call it only on iterations where the bottom eight bits
are unset.  This disqualifies most of the 2815 values that timeout will
be set to, and leaves the following values triggering the mdelay(1):

0x100 0x200 0x300 0x400 0x500 0x600 0x700 0x800 0x900 0xa00
  256   512   768  1024  1280  1536  1792  2048  2304  2560

The astute observer will notice that there are ten such values.
So you're calling mdelay(1) ten times.  But that's what we were
doing before!  The only difference is that now we spin through
the while loop 2815 times instead of 10, and don't perform any
explicit delay on 2805 of them.  Or am I missing something?

I think you should try:

(a) Reverting the patch and checking that it's actually needed
(b) Leaving the while loop body alone, but increasing the max
    timeout until you bisect to the amount of ms that your controller
    actually takes to release the inhibit bit.
(c) Yelling loudly in the direction that this code came from.  :)

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

  reply	other threads:[~2011-03-18 23:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 22:11 [RFC 0/4] sdhci: few patches for ENE 712 support Luis R. Rodriguez
2011-03-18 22:11 ` [RFC 1/4] sdhci: allow for multiple delays when sending commands Luis R. Rodriguez
2011-03-18 23:10   ` Chris Ball [this message]
2011-03-18 23:52     ` Luis R. Rodriguez
2011-03-18 22:11 ` [RFC 2/4] sdhci: sanity check for triggering interrupts thread Luis R. Rodriguez
2011-03-18 22:11 ` [RFC 3/4] sdhci: cache when the MMC bus width is 4 bits wide Luis R. Rodriguez
2011-03-18 22:12 ` [RFC 4/4] sdhci: add quick for controllers with for CIRQ issues Luis R. Rodriguez
2011-03-18 22:29 ` [RFC 0/4] sdhci: few patches for ENE 712 support Luis R. Rodriguez
2011-03-19  9:15 ` Wolfram Sang
2011-03-30  1:16   ` Luis R. Rodriguez
2011-03-30  7:47     ` Wolfram Sang
2011-08-24 11:02       ` Kalle Valo

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=m3y64ct47j.fsf@pullcord.laptop.org \
    --to=cjb@laptop.org \
    --cc=Vipin.Mehta@atheros.com \
    --cc=j@w1.fi \
    --cc=kvalo@adurom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=lrodriguez@atheros.com \
    --cc=naveen.singh@atheros.com \
    --cc=nsingh@atheros.com \
    --cc=vmehta@atheros.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