From patchwork Tue Nov 22 20:56:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 83502 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2310912qge; Tue, 22 Nov 2016 12:56:27 -0800 (PST) X-Received: by 10.194.149.143 with SMTP id ua15mr192379wjb.48.1479848187402; Tue, 22 Nov 2016 12:56:27 -0800 (PST) Return-Path: Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com. [2a00:1450:400c:c09::234]) by mx.google.com with ESMTPS id e2si27544463wjz.53.2016.11.22.12.56.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2016 12:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::234 as permitted sender) client-ip=2a00:1450:400c:c09::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x234.google.com with SMTP id g23so46236502wme.1 for ; Tue, 22 Nov 2016 12:56:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uhRB37wf1yDKyz7V/wQL/goyios8JqaedbZODbUFQXY=; b=Ah1INx/dOSyUzZpG/lcxC4hYvVXSWVY1+vui79EalSqypSk0gv9uuBn6sMxgQIHBQP I4Jq5W7qBsn1XWxJuD9I6V5Xp28VklB7F9YqF8+Qvof04SB+QASkDDZtLawj7noDVUvO UPKC7ZPveR63lnO2X/azEd2M1PelVAmcajyu8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uhRB37wf1yDKyz7V/wQL/goyios8JqaedbZODbUFQXY=; b=UUV8rO4L8Gs1N12erXh5Y42AIPnjAlnIEtXlwbH3uQ5e/zIMRVV6vasqMQ2Kg/ozFY 4tsg46mMTfRG8Ar3LSb4S5igPFTgJzqtOOAZf121c2EXxTm2vQrPlolMPl1WWjs4pIXV EZUiDAf5dkWHGcfthd5KDWB9uCXGOMtir3YmZD3Le/JbnDb+M5XZctCnVh1H8EwH3V1o CK1qH7RgB2YCOLv9HZC4iHWiyD5j+RuEfu1Bd3W8WEyGMBplbhApQYD9YuEMhLVRQyrc iCh2IJKQE4jYtuKFNygr0uEMOBWlQZSyiyXpT7qiCkVyscOEbBfDAPJ0WBILCH7h/6aq Ln2A== X-Gm-Message-State: AKaTC03tutItVfehLNxpwuxBZp7ZX1Nb/K2AcPn6K+jOydem6vuq83R5O0DRDT3hVrjrRAY1J+A= X-Received: by 10.46.74.17 with SMTP id x17mr1716653lja.16.1479848187010; Tue, 22 Nov 2016 12:56:27 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id 196sm6619988lff.3.2016.11.22.12.56.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 12:56:25 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij , Chaotian Jing , Stephen Boyd , Michael Walle , Yong Mao , Shawn Lin Subject: [PATCH v2 4/7] mmc: core: Check SWITCH_ERROR bit from each CMD13 response when polling Date: Tue, 22 Nov 2016 21:56:10 +0100 Message-Id: <1479848173-20881-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479848173-20881-1-git-send-email-ulf.hansson@linaro.org> References: <1479848173-20881-1-git-send-email-ulf.hansson@linaro.org> According to the JEDEC specification, the SWITCH_ERROR bit in the device status from a R1 response, is an error bit which may be cleared as soon as the response that reports the error is sent. When polling with CMD13 to find out when the card stops signaling busy after a CMD6 has been sent, we currently parse only the last CMD13 response for the SWITCH_ERROR bit. Consequentially we could loose important information about the card. In worst case if the card stops signaling busy within the allowed timeout, we could end up believing that the CMD6 command completed successfully, when in fact it didn't. To improve the behaviour, let's parse each CMD13 response to see if the SWITCH_ERROR bit is set in the device status. In such case, we abort the polling loop and report the error. Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. --- drivers/mmc/core/mmc_ops.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 214e734..fba5d29 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -496,12 +496,16 @@ 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_err && err == -EILSEQ) { busy = true; - else if (err) + } else if (err) { return err; - else + } else { + err = mmc_switch_status_error(host, status); + if (err) + return err; busy = R1_CURRENT_STATE(status) == R1_STATE_PRG; + } } /* Timeout if the device still remains busy. */ @@ -515,7 +519,7 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, if (host->ops->card_busy && send_status) return mmc_switch_status(card); - return mmc_switch_status_error(host, status); + return 0; } /**