From patchwork Fri Mar 20 07:19:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabbasov, Andrew" X-Patchwork-Id: 452500 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 341F71401AB for ; Fri, 20 Mar 2015 18:19:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B2C844B615; Fri, 20 Mar 2015 08:19:56 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wMnXlh51M8z4; Fri, 20 Mar 2015 08:19:56 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 61CBB4A03C; Fri, 20 Mar 2015 08:19:56 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 742674A032 for ; Fri, 20 Mar 2015 08:19:52 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P_TAwq0s-JqU for ; Fri, 20 Mar 2015 08:19:52 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by theia.denx.de (Postfix) with ESMTP id 065074A02F for ; Fri, 20 Mar 2015 08:19:50 +0100 (CET) Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-03.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YYrDg-0007Vm-Dn from Andrew_Gabbasov@mentor.com ; Fri, 20 Mar 2015 00:19:48 -0700 Received: from RUMGABBASOVW7 (137.202.0.76) by SVR-IES-FEM-03.mgc.mentorg.com (137.202.0.108) with Microsoft SMTP Server id 14.3.224.2; Fri, 20 Mar 2015 07:19:47 +0000 From: Andrew Gabbasov To: , Date: Fri, 20 Mar 2015 10:19:43 +0300 Message-ID: <000101d062de$3d2b6420$b7822c60$@mentor.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdBi3jFC7o6+CUryRZ+tRJad6QjgNg== Content-Language: en-us Subject: Re: [U-Boot] [PATCH 4/6] mmc: Continue polling MMC card for OCR only if it is still not ready X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Hi Peng, > From: Peng.Fan@freescale.com [Peng.Fan@freescale.com] > Sent: Friday, March 20, 2015 03:51 > To: Gabbasov, Andrew; u-boot@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@lists.denx.de] On Behalf Of Andrew Gabbasov Sent: Thursday, March 19, 2015 8:44 PM 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 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 --- drivers/mmc/mmc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) -- 2.1.0 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;