From patchwork Tue Jan 3 08:49:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Mao X-Patchwork-Id: 9494631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 119E2606A9 for ; Tue, 3 Jan 2017 08:50:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0872120008 for ; Tue, 3 Jan 2017 08:50:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE9942679B; Tue, 3 Jan 2017 08:50:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B19D20008 for ; Tue, 3 Jan 2017 08:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933267AbdACIuV (ORCPT ); Tue, 3 Jan 2017 03:50:21 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:37703 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756262AbdACIuU (ORCPT ); Tue, 3 Jan 2017 03:50:20 -0500 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 228446120; Tue, 03 Jan 2017 16:50:14 +0800 Received: from mhfsdcap03.localdomain (10.17.3.153) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Tue, 3 Jan 2017 16:50:13 +0800 From: Yong Mao To: Ulf Hansson CC: Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , Matthias Brugger , Chunfeng Yun , Eddie Huang , Greg Kroah-Hartman , Philipp Zabel , Adrian Hunter , Shawn Lin , Baolin Wang , Russell King , Linus Walleij , Chaotian Jing , Douglas Anderson , Nicolas Boichat , Javier Martinez Canillas , yong mao , , , , , , Subject: [PATCH v2 1/2] mmc: core: Fix CMD6 timeout issue Date: Tue, 3 Jan 2017 16:49:56 +0800 Message-ID: <1483433397-11756-2-git-send-email-yong.mao@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1483433397-11756-1-git-send-email-yong.mao@mediatek.com> References: <1483433397-11756-1-git-send-email-yong.mao@mediatek.com> MIME-Version: 1.0 X-MTK: N Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: yong mao When initializing EMMC, after switch to HS400, it will issue CMD6 to change ext_csd, if first CMD6 got CRC error, the repeat CMD6 may get timeout, that's because card is not back to transfer state immediately. For resolving this issue, it need check if card is busy before sending repeat CMD6. Not only CMD6 here has this issue, but also other R1B CMD has the same issue. Signed-off-by: Yong Mao Signed-off-by: Chaotian Jing --- drivers/mmc/core/core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 1076b9d..8674dbb 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -566,6 +566,25 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) mmc_retune_recheck(host); + /* + * If a R1B CMD such as CMD6 occur CRC error, + * it will retry 3 times here. + * But before retrying, it must ensure card is in + * transfer state. + * Otherwise, the next retried CMD will got TMO error. + */ + if (mmc_resp_type(cmd) == MMC_RSP_R1B && host->ops->card_busy) { + int tries = 500; /* Wait aprox 500ms at maximum */ + + while (host->ops->card_busy(host) && --tries) + mmc_delay(1); + + if (tries == 0) { + cmd->error = -EBUSY; + break; + } + } + pr_debug("%s: req failed (CMD%u): %d, retrying...\n", mmc_hostname(host), cmd->opcode, cmd->error); cmd->retries--;