All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/6] mmc: Fix OCR polling and splitted initialization
@ 2015-03-19 12:44 Andrew Gabbasov
  2015-03-19 12:44 ` [U-Boot] [PATCH 1/6] mmc: Fix typo in MMC type checking macro Andrew Gabbasov
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Andrew Gabbasov @ 2015-03-19 12:44 UTC (permalink / raw)
  To: u-boot

Patch 4 contains a fix for a problem that really occures with some
MMC cards, that are capable to get to ready state within a single
polling call.

Patch 6 is a fix for an error, that may be not so important and is not
visible at the moment, since no platform does actually use pre-initialization.
However, it still makes sense to fix it. It also makes the code more
clean, straightforward, and understandable.

Patch 5 eliminates some unneeded delays in polling loops, thus improving
overall performance.

Patches 2 and 3 clean up the code, making it simpler and more correct.

Patch 1 is actually not directly related to the patched code area, but just
uses the occasion to fix the typo.

This is a series of patches, the next patch depending on previous ones,
so that should be applied in order, on top of previous ones.

Andrew Gabbasov (6):
  mmc: Fix typo in MMC type checking macro
  mmc: Avoid extra duplicate entry in mmc device structure
  mmc: Do not pass external mmc_cmd structure to mmc_send_op_cond_iter()
  mmc: Continue polling MMC card for OCR only if it is still not ready
  mmc: Restructure polling loops to avoid extra delays
  mmc: Fix splitting device initialization

 drivers/mmc/mmc.c | 90 ++++++++++++++++++++++++++++++-------------------------
 include/mmc.h     |  6 ++--
 2 files changed, 51 insertions(+), 45 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if it is still not ready
@ 2015-03-20  7:19 Andrew Gabbasov
  0 siblings, 0 replies; 22+ messages in thread
From: Andrew Gabbasov @ 2015-03-20  7:19 UTC (permalink / raw)
  To: u-boot

Hi Peng,

> From: Peng.Fan at freescale.com [Peng.Fan at freescale.com]
> Sent: Friday, March 20, 2015 03:51
> To: Gabbasov, Andrew; u-boot at lists.denx.de
> Subject: RE: [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR
only if        it is still not ready
> 
> Hi, Andrew
> 
> There is already a patch to fix this issue.
> Patchwork: https://patchwork.ozlabs.org/patch/451775/
> 
> Regards,
> Peng.

Yes, I noticed it just after I sent this series. ;-)
Unfortunately, the patch, that you mention, has some drawback that I
described
in a separate message (in response to the patch). Basically, it leaves the
code
in some not quite correct state.
This series hopefully does not have this drawback and besides fixing the
issue
has some more useful changes in a single complex.

Thanks.

Best regards,
Andrew


-----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;
--
2.1.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 22+ messages in thread
* [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if it is still not ready
@ 2015-03-23  7:38 Andrew Gabbasov
  2015-03-23 20:08 ` Troy Kisky
  0 siblings, 1 reply; 22+ messages in thread
From: Andrew Gabbasov @ 2015-03-23  7:38 UTC (permalink / raw)
  To: u-boot

Hi Troy,

> From: Troy Kisky [mailto:troy.kisky at boundarydevices.com]
> Sent: Friday, March 20, 2015 9:39 PM
> To: Peng.Fan at freescale.com; Gabbasov, Andrew; u-boot at lists.denx.de
> Cc: Eric Nelson
> Subject: Re: [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR
> only if it is still not ready
> 
> [skipped]
> 
> 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 have a couple of doubts regarding that patch.

First, my personal taste objects to such duplicating of the code
(I mean setting of version, ocr, rca, etc fields of mmc structure).
If we'll have to change or add anything to these settings, we'll have to
make
the same change in 2 different place, which is error-prone and extremely
inconvenient from maintenance point of view.

Second, what about SPI mode? Doesn't this patch skip retrieving of OCR
register
with a special command for SPI host case (thus setting ocr field
incorrectly),
if the card comes to ready state with the first attempt?

Thanks.

Best regards,
Andrew

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-05-05  9:10 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.