From patchwork Wed Sep 30 08:24:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 7293461 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 90C769F1D5 for ; Wed, 30 Sep 2015 08:27:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B73E120678 for ; Wed, 30 Sep 2015 08:27:50 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C96C820644 for ; Wed, 30 Sep 2015 08:27:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhCjt-0002Te-CP; Wed, 30 Sep 2015 08:27:49 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhCjS-00024v-79; Wed, 30 Sep 2015 08:27:23 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 30 Sep 2015 01:27:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,611,1437462000"; d="scan'208";a="571137149" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by FMSMGA003.fm.intel.com with ESMTP; 30 Sep 2015 01:26:57 -0700 Subject: Re: [PATCH] mmc: core: Fix init_card in 52Mhz To: Chaotian Jing , Ulf Hansson References: <1443583688-1952-1-git-send-email-chaotian.jing@mediatek.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <560B9C24.3090209@intel.com> Date: Wed, 30 Sep 2015 11:24:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443583688-1952-1-git-send-email-chaotian.jing@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150930_012722_362880_DDABF1F2 X-CRM114-Status: GOOD ( 20.10 ) X-Spam-Score: -6.9 (------) 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: Gwendal Grignou , srv_heupstream@mediatek.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Sascha Hauer , Matthias Brugger , Johan Rudholm , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On 30/09/15 06:28, Chaotian Jing wrote: > 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, that results in card init > was doing at 52Mhz, So need ensure frequency is lower than 400Khz when > re-init card. The call to mmc_send_status() was originally only done for mmc_test and doesn't belong in a real reset. However the test parameter was removed to simplify the code by: commit 83533ab28380f6957af39a7b322e639e42dbdaf1 Author: Johan Rudholm Date: Mon Jan 12 15:38:04 2015 +0100 mmc: core: always check status after reset Always check if the card is alive after a successful reset. This allows us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only card reset interface. Signed-off-by: Johan Rudholm Signed-off-by: Ulf Hansson IMHO having a test to check whether hw reset actually did reset the card is useful, so I would suggest putting back mmc_hw_reset_check() and removing the check from the non-test path. An alternative is to recognize that we don't want retuning here, and it is unlikely to be needed in the mmc_test case. So if retuning is needed, just skip the call to mmc_send_status() i.e. > > Signed-off-by: Chaotian Jing > --- > drivers/mmc/core/mmc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > index e726903..f2d0c2a 100644 > --- a/drivers/mmc/core/mmc.c > +++ b/drivers/mmc/core/mmc.c > @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host) > > /* Set initial state and call mmc_set_ios */ > mmc_set_initial_state(host); > + mmc_set_clock(host, host->f_init); > mmc_host_clk_release(host); > > return mmc_init_card(host, card->ocr, card); > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f2d0c2ae85b1..c3749ba42739 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; } Could then make mmc_test aware of that: diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index b78cf5d403a3..7b105b97be78 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 f2d0c2ae85b1..c3749ba42739 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; }