From patchwork Thu Oct 8 06:41:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaotian Jing X-Patchwork-Id: 7349161 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03638BEEA4 for ; Thu, 8 Oct 2015 06:41:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8A7C20601 for ; Thu, 8 Oct 2015 06:41:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD19420570 for ; Thu, 8 Oct 2015 06:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752316AbbJHGla (ORCPT ); Thu, 8 Oct 2015 02:41:30 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:41480 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751736AbbJHGl3 (ORCPT ); Thu, 8 Oct 2015 02:41:29 -0400 X-Listener-Flag: 11101 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1431728767; Thu, 08 Oct 2015 14:41:16 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Thu, 8 Oct 2015 14:41:14 +0800 From: Chaotian Jing To: Ulf Hansson CC: Matthias Brugger , Jaehoon Chung , Chaotian Jing , Adrian Hunter , Fabio Estevam , Johan Rudholm , Gwendal Grignou , , , , , , Sascha Hauer Subject: [PATCH] mmc: core: Fix init_card in 52Mhz Date: Thu, 8 Oct 2015 14:41:02 +0800 Message-ID: <1444286462-23571-1-git-send-email-chaotian.jing@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Suppose that we got a data crc error, and it triggers the mmc_reset. mmc_reset will call mmc_send_status to see if HW reset was supported. before issue CMD13, it will do retune, and if EMMC was in HS400 mode, it will reduce frequency to 52Mhz firstly, then results in card init was doing at 52Mhz. The mmc_send_status was originally only done for mmc_test, so if retune needed, do not call mmc_send_status, and move it to mmc_test code. Signed-off-by: Chaotian Jing Suggested-by: Adrian Hunter --- drivers/mmc/card/mmc_test.c | 10 ++++++++++ drivers/mmc/core/mmc.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index b78cf5d..7b105b9 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test) if (!mmc_card_mmc(card) || !mmc_can_reset(card)) return RESULT_UNSUP_CARD; + err = mmc_send_status(card, NULL); + if (err) + return err; + + if (host->need_retune) { + pr_info("%s: cannot test hw reset because retune needed\n", + mmc_hostname(test->card->host)); + return RESULT_FAIL; + } + err = mmc_hw_reset(host); if (!err) return RESULT_OK; diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e726903..647c96d 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host) host->ops->hw_reset(host); /* If the reset has happened, then a status command will fail */ - if (!mmc_send_status(card, &status)) { + if (!host->need_retune && !mmc_send_status(card, &status)) { mmc_host_clk_release(host); return -ENOSYS; }