From patchwork Fri Jan 13 03:24:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9514551 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 652E560762 for ; Fri, 13 Jan 2017 03:26:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C1292869D for ; Fri, 13 Jan 2017 03:26:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F1742870A; Fri, 13 Jan 2017 03:26:38 +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 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 D192B2869D for ; Fri, 13 Jan 2017 03:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750874AbdAMD0g (ORCPT ); Thu, 12 Jan 2017 22:26:36 -0500 Received: from lucky1.263xmail.com ([211.157.147.134]:37015 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbdAMD0g (ORCPT ); Thu, 12 Jan 2017 22:26:36 -0500 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.201]) by lucky1.263xmail.com (Postfix) with ESMTP id 747CED24; Fri, 13 Jan 2017 11:26:26 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 56E353DB; Fri, 13 Jan 2017 11:26:25 +0800 (CST) X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: ulf.hansson@linaro.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <858f306a57985dcf4aa80eeba33aaaeb> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 3004538W4GU; Fri, 13 Jan 2017 11:26:26 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: Adrian Hunter , Jaehoon Chung , linux-mmc@vger.kernel.org, Shawn Lin Subject: [RFC PATCH] mmc: core: retry polling busy when response timeout occurs Date: Fri, 13 Jan 2017 11:24:55 +0800 Message-Id: <1484277895-94393-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 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 It always assumed that if the card was not ready after finishing switching the mode, we should got a CRC, namely -EILSEQ, from the hosts. But the fact is if the host is in higher speed mode but the eMMC havn't finished the switch, so the host could fail to sample the resp of CMD13 due to the mismatch timing in between. Could it is possible that response timeout was generated instaed of -EILSEQ? It's quite IP specificed. So I don't think we should take the risk of relying on that. In another word, we don't expect to bail out early for timeout errors bounced from hosts when polling the status, no just for explicit CRC. Signed-off-by: Shawn Lin --- drivers/mmc/core/mmc_ops.c | 14 +++++++++----- drivers/mmc/core/mmc_ops.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index db2969f..a352dea 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -451,7 +451,7 @@ int mmc_switch_status(struct mmc_card *card) } static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, - bool send_status, bool retry_crc_err) + bool send_status, bool retry_crc_and_tmo_err) { struct mmc_host *host = card->host; int err; @@ -486,7 +486,8 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, busy = host->ops->card_busy(host); } else { err = mmc_send_status(card, &status); - if (retry_crc_err && err == -EILSEQ) { + if (retry_crc_and_tmo_err && + (err == -EILSEQ || err == -ETIMEDOUT)) { busy = true; } else if (err) { return err; @@ -523,13 +524,15 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, * @timing: new timing to change to * @use_busy_signal: use the busy signal as response type * @send_status: send status cmd to poll for busy - * @retry_crc_err: retry when CRC errors when polling with CMD13 for busy + * @retry_crc_and_tmo_err: retry when CRC errors or response timeout errors + * when polling with CMD13 for busy * * Modifies the EXT_CSD register for selected card. */ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, unsigned int timeout_ms, unsigned char timing, - bool use_busy_signal, bool send_status, bool retry_crc_err) + bool use_busy_signal, bool send_status, + bool retry_crc_and_tmo_err) { struct mmc_host *host = card->host; int err; @@ -590,7 +593,8 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, } /* Let's try to poll to find out when the command is completed. */ - err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err); + err = mmc_poll_for_busy(card, timeout_ms, send_status, + retry_crc_and_tmo_err); out_tim: if (err && timing) diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index abd525e..fad9963 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -31,7 +31,8 @@ int __mmc_switch_status(struct mmc_card *card, bool crc_err_fatal); int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, unsigned int timeout_ms, unsigned char timing, - bool use_busy_signal, bool send_status, bool retry_crc_err); + bool use_busy_signal, bool send_status, + bool retry_crc_and_tmo_err); #endif