From patchwork Tue Nov 22 20:56:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 83499 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2310870qge; Tue, 22 Nov 2016 12:56:21 -0800 (PST) X-Received: by 10.194.123.201 with SMTP id mc9mr155256wjb.47.1479848181893; Tue, 22 Nov 2016 12:56:21 -0800 (PST) Return-Path: Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com. [2a00:1450:400c:c09::230]) by mx.google.com with ESMTPS id hb4si27525332wjb.24.2016.11.22.12.56.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2016 12:56:21 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::230 as permitted sender) client-ip=2a00:1450:400c:c09::230; 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::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x230.google.com with SMTP id a197so46215964wmd.0 for ; Tue, 22 Nov 2016 12:56:21 -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=1/4D3ga+50ANV24vWygrXOnO4ilf/oIm0LaS7gRhDfw=; b=hImhyddXDDGIARDKeOSgzjw4hd7mCWTShfas8xHZBXQOZJWcEhVR4UHmoopB4atzUB 9BoiBncEqXLJT7AU9GM/ZY3bGjp6D2bgbFqWEhtWFN26T8NNirURub2n6obTR7MFCY3W pjLH2v9EuiG9K2mQ5YkqqxyBxIl93p51qMUOk= 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=1/4D3ga+50ANV24vWygrXOnO4ilf/oIm0LaS7gRhDfw=; b=SdJ4RBioADMc42KIPgj+7HsUwq4vbRpskRR75r6XyPCX6ATpRYF274K4SCiLuUHeR7 xJ7Wo+NVsLRECFPs00rkkO75SpZoh2KGEOTzKw26P6g4ScCBRrCi/Ry+/yXElkIv/y7J WEF5BCB0d8AG2d9ZhkzyxXI+5/1QN2Qqj+NwMXGMYLvQJdItZVATUNhng2DZWC5eat78 90d0e+uP47tcfk/L//xKW+VvgLm3iV2MBc+LKP/QAW4dq+w2ojy0WLI8cZFF3ojWwXHg IOE9aWnXkk89G49hh1DTEaDLRCeam4e4rsLUHne4uhgVsqJnYEYs3lg+BgjYW/vjdct+ vQMw== X-Gm-Message-State: AKaTC00+HlDiAj7UbQtSIbcJpnUduDJh2JRgUzzgj6GrwCk/deKmaqWzqS2OhTLjQVvl1MvRgZU= X-Received: by 10.25.92.74 with SMTP id q71mr4948622lfb.140.1479848181397; Tue, 22 Nov 2016 12:56:21 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 12:56:20 -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 1/7] mmc: core: Retry instead of ignore at CRC errors when polling for busy Date: Tue, 22 Nov 2016 21:56:07 +0100 Message-Id: <1479848173-20881-2-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> After a CMD6 command has been sent, the __mmc_switch() function might be advised to poll the card for busy by using CMD13 and also by ignoring CRC errors. In the case of ignoring CRC errors, the mmc core tells the mmc host to also ignore these errors via masking the MMC_RSP_CRC response flag. This seems wrong, as it leads to that the mmc host could propagate an unreliable response, instead of a proper error code. What we really want, is not to ignore CRC errors but instead retry the polling attempt. So, let's change this by treating a CRC error as the card is still being busy and thus continue to run the polling loop. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 481bbdb..4773c56 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -503,10 +503,13 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, if (host->ops->card_busy) { busy = host->ops->card_busy(host); } else { - err = __mmc_send_status(card, &status, ignore_crc); - if (err) + err = mmc_send_status(card, &status); + if (ignore_crc && err == -EILSEQ) + busy = true; + else if (err) return err; - busy = R1_CURRENT_STATE(status) == R1_STATE_PRG; + else + busy = R1_CURRENT_STATE(status) == R1_STATE_PRG; } /* Timeout if the device still remains busy. */