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: 9494641 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 2E146606A9 for ; Tue, 3 Jan 2017 08:51:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2660520008 for ; Tue, 3 Jan 2017 08:51:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A4AE2679B; Tue, 3 Jan 2017 08:51:20 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E86F20008 for ; Tue, 3 Jan 2017 08:51:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cOKoQ-0000bZ-Pz; Tue, 03 Jan 2017 08:51:18 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cOKnu-0000Ep-UX; Tue, 03 Jan 2017 08:50:48 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170103_005047_198406_3BDD0B41 X-CRM114-Status: GOOD ( 16.69 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Douglas Anderson , Catalin Marinas , Shawn Lin , Will Deacon , Adrian Hunter , Nicolas Boichat , Javier Martinez Canillas , Chaotian Jing , Chunfeng Yun , Russell King , Linus Walleij , devicetree@vger.kernel.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , Eddie Huang , linux-arm-kernel@lists.infradead.org, srv_heupstream@mediatek.com, Baolin Wang , Greg Kroah-Hartman , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, yong mao , Philipp Zabel Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.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--;