From patchwork Fri Mar 22 15:44:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10866137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E286139A for ; Fri, 22 Mar 2019 15:47:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F9C92A8C0 for ; Fri, 22 Mar 2019 15:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 038372A8C1; Fri, 22 Mar 2019 15:47:42 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 550352A8BE for ; Fri, 22 Mar 2019 15:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbfCVPr1 (ORCPT ); Fri, 22 Mar 2019 11:47:27 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:37727 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbfCVPr1 (ORCPT ); Fri, 22 Mar 2019 11:47:27 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MXY6b-1hUrZP1Wvv-00Z2OT; Fri, 22 Mar 2019 16:47:04 +0100 From: Arnd Bergmann To: stable@vger.kernel.org, Ulf Hansson , hongjiefang , Simon Horman , Kyle Roeschley , Jennifer Dahm , Yinbo Zhu , Avri Altman Cc: Dong Aisheng , Arnd Bergmann , Shawn Lin , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.4.y 11/25] mmc: core: fix using wrong io voltage if mmc_select_hs200 fails Date: Fri, 22 Mar 2019 16:44:02 +0100 Message-Id: <20190322154425.3852517-12-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de> References: <20190322154425.3852517-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:AUdmkZ5z4T+73YX5eDFD7nmt0VVn8VFjTyPcIjAgXkBryoY38Sj KEcTEgx2j4b1CAowPC21uD6NWeJPhVix5lXJxvPisKKZMMLTRUE+GzTDFNAGLXmNC8CW03q hA9kqPKM+DHGYRHZj4/ktdzzz1eL9xENAZSY5XspO741kft7ouFaXIbZ8zfzPdrUBfZPUA1 FuaD1Hf2yB4JzAoLOtEdg== X-UI-Out-Filterresults: notjunk:1;V03:K0:h6UQKPJz7PE=:vYowmL9ByE7hVEvss4ayn1 woXB+qzcoNA4PzL6YY12oOviTzsKDgsrlF34hj39WmZUFmSY6On06LDxDrPDOKCBIfDkMAFtq HLJSFNaiA2hOdOSewbr2iwec/BeWTm9kPHClLEV+f+c7Q701UFG7LbZqkG2ZKmMEeKs4QpgUz exfXn1hgSeC4MgoaBmcL+MjJtNkdnuef75gmhAP1yiAdAGHy5YMCzRzVcEgOFHIOim8FOd1/4 xMiykaSEwBU3rRAffLXAHHxbE/jveSdkvTdWXIc2Blo8pd+8fTk/UOHEzoTta0Lqw8YMMvFuN OVeqbyXS5F/TPP9hY1Dk5BtfCxFdD6F6ZhidQuz9RoywmB2iebJnD0Rdej6NRT6YJv9wKpTqQ hqCpId7RBpXo79BJmMpFb4GJQZMUiev4zYKwUcWY+78KLGydZekwr2X6BRbpr44yrY+W8+8OA p91HpFRUM+1SqFKeGY6VpZZskmPa2UVOMrBF3mm1hITPng52DP3ae1feG01mwMkVogwBMLMID g2kdgPOzp1WB7RqrulQ6EvhoCny8JjZF9APCS6M13VJjwTdVLTriswhrOYR/8YdgvVsrKxX2k vle3P1ivlGvmfwSDvIyX/CKvE8C9Sd2ONVQPzrBlS+aPLHYtD2qi6NRatqAXEolm/IPkioaMf qY+YxXeLpfQzhUvR5tViimndJoFOa6whKUyUea+irh/yxewFbP+xmDYJKDZRSdC/sQqDyH6pp OshfE9+T4JLKngiDterlyd3CkYuTG8mAMtUE5g== 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: Dong Aisheng Currently MMC core will keep going if HS200/HS timing switch failed with -EBADMSG error by the assumption that the old timing is still valid. However, for mmc_select_hs200 case, the signal voltage may have already been switched. If the timing switch failed, we should fall back to the old voltage in case the card is continue run with legacy timing. If fall back signal voltage failed, we explicitly report an EIO error to force retry during the next power cycle. Signed-off-by: Dong Aisheng Signed-off-by: Ulf Hansson (cherry picked from commit e51534c806609c806d81bfb034f02737461f855c) Signed-off-by: Arnd Bergmann --- drivers/mmc/core/mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 7286d0d324e1..7844baecf306 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1251,10 +1251,11 @@ static int mmc_select_hs200(struct mmc_card *card) { struct mmc_host *host = card->host; bool send_status = true; - unsigned int old_timing; + unsigned int old_timing, old_signal_voltage; int err = -EINVAL; u8 val; + old_signal_voltage = host->ios.signal_voltage; if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V) err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); @@ -1263,7 +1264,7 @@ static int mmc_select_hs200(struct mmc_card *card) /* If fails try again during next card power cycle */ if (err) - goto err; + return err; mmc_select_driver_type(card); @@ -1297,9 +1298,14 @@ static int mmc_select_hs200(struct mmc_card *card) } } err: - if (err) + if (err) { + /* fall back to the old signal voltage, if fails report error */ + if (__mmc_set_signal_voltage(host, old_signal_voltage)) + err = -EIO; + pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), __func__, err); + } return err; }