public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Troy Kisky <troy.kisky@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if	it is still not ready
Date: Fri, 20 Mar 2015 11:38:50 -0700	[thread overview]
Message-ID: <550C693A.90501@boundarydevices.com> (raw)
In-Reply-To: <BN1PR0301MB0673FFBC4F236EA744F4BCE2820E0@BN1PR0301MB0673.namprd03.prod.outlook.com>

On 3/19/2015 6:51 PM, Peng.Fan at freescale.com wrote:
> Hi, Andrew
> 
> There is already a patch to fix this issue.
> Patchwork: https://patchwork.ozlabs.org/patch/451775/
> 
> Regards,
> Peng.
> 
> -----Original Message-----
> From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Andrew Gabbasov
> Sent: Thursday, March 19, 2015 8:44 PM
> To: u-boot at lists.denx.de
> Subject: [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if it is still not ready
> 
> Some MMC cards come to ready state quite quickly, so that the respective flag appears to be set in mmc_send_op_cond already. In this case trying to continue polling the card with CMD1 in mmc_complete_op_cond is incorrect and may lead to unpredictable results. So check the flag before polling and skip it appropriately.
> 
> Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
> ---
>  drivers/mmc/mmc.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index d073d79..42af47c 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -403,15 +403,17 @@ static int mmc_complete_op_cond(struct mmc *mmc)
>  	int err;
>  
>  	mmc->op_cond_pending = 0;
> -	start = get_timer(0);
> -	do {
> -		err = mmc_send_op_cond_iter(mmc, 1);
> -		if (err)
> -			return err;
> -		if (get_timer(start) > timeout)
> -			return UNUSABLE_ERR;
> -		udelay(100);
> -	} while (!(mmc->ocr & OCR_BUSY));
> +	if (!(mmc->ocr & OCR_BUSY)) {
> +		start = get_timer(0);
> +		do {
> +			err = mmc_send_op_cond_iter(mmc, 1);
> +			if (err)
> +				return err;
> +			if (get_timer(start) > timeout)
> +				return UNUSABLE_ERR;
> +			udelay(100);
> +		} while (!(mmc->ocr & OCR_BUSY));
> +	}
>  
>  	if (mmc_host_is_spi(mmc)) { /* read OCR for spi */
>  		cmd.cmdidx = MMC_CMD_SPI_READ_OCR;
> --


Here's another patch that solves the problem a little earlier. It has this disadvantage of being
slightly bigger,
though it makes the code look better.


https://github.com/boundarydevices/u-boot-imx6/commit/c0260ca


I'll ack any version as they all seem to solve the problem.

Troy

  reply	other threads:[~2015-03-20 18:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19 12:44 [U-Boot] [PATCH 0/6] mmc: Fix OCR polling and splitted initialization Andrew Gabbasov
2015-03-19 12:44 ` [U-Boot] [PATCH 1/6] mmc: Fix typo in MMC type checking macro Andrew Gabbasov
2015-05-05  9:02   ` Pantelis Antoniou
2015-03-19 12:44 ` [U-Boot] [PATCH 2/6] mmc: Avoid extra duplicate entry in mmc device structure Andrew Gabbasov
2015-05-05  9:02   ` Pantelis Antoniou
2015-03-19 12:44 ` [U-Boot] [PATCH 3/6] mmc: Do not pass external mmc_cmd structure to mmc_send_op_cond_iter() Andrew Gabbasov
2015-05-05  9:03   ` Pantelis Antoniou
2015-03-19 12:44 ` [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if it is still not ready Andrew Gabbasov
2015-03-20  1:51   ` Peng.Fan at freescale.com
2015-03-20 18:38     ` Troy Kisky [this message]
2015-05-05  9:09   ` Pantelis Antoniou
2015-03-19 12:44 ` [U-Boot] [PATCH 5/6] mmc: Restructure polling loops to avoid extra delays Andrew Gabbasov
2015-05-05  9:09   ` Pantelis Antoniou
2015-03-19 12:44 ` [U-Boot] [PATCH 6/6] mmc: Fix splitting device initialization Andrew Gabbasov
2015-05-05  9:10   ` Pantelis Antoniou
  -- strict thread matches above, loose matches on Subject: below --
2015-03-20  7:19 [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if it is still not ready Andrew Gabbasov
2015-03-23  7:38 Andrew Gabbasov
2015-03-23 20:08 ` Troy Kisky
2015-03-24 16:33   ` Andrew Gabbasov
2015-03-24 18:03     ` Troy Kisky
2015-03-24 19:02       ` Andrew Gabbasov
2015-05-05  9:05         ` Pantelis Antoniou

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=550C693A.90501@boundarydevices.com \
    --to=troy.kisky@boundarydevices.com \
    --cc=u-boot@lists.denx.de \
    /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