From patchwork Wed Nov 16 10:51:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 82469 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp82348qge; Wed, 16 Nov 2016 02:51:34 -0800 (PST) X-Received: by 10.55.146.130 with SMTP id u124mr2737034qkd.176.1479293494303; Wed, 16 Nov 2016 02:51:34 -0800 (PST) Return-Path: Received: from mail-qt0-x235.google.com (mail-qt0-x235.google.com. [2607:f8b0:400d:c0d::235]) by mx.google.com with ESMTPS id n71si21332598qka.65.2016.11.16.02.51.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 02:51:34 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:400d:c0d::235 as permitted sender) client-ip=2607:f8b0:400d:c0d::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:400d:c0d::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-qt0-x235.google.com with SMTP id p16so95517983qta.0 for ; Wed, 16 Nov 2016 02:51:34 -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=Ei3l2PaXqKM6x39CzhZgkY77qOXm2fAwNedba3RVxoqpd2CJ948883lhQfcqlAG0tr roeQ1Hl7SrNbZucNEGGpyTbPHpmi0ig8OI+8jf0cY9ZrxJ3nXll0P+d3AvtaaHAwQYqE uA8Fh6MEUmdI4MbPMS+V/2tBhsCQuIkggDgag= 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=DsWZnWBSwmJyAeF/NOpGYcyn+8zYVGfFZgxZd/+yJeG6L2cm5ktH6MgNMe9sG3EtSg IOOqJv3g/De7aEukel48eVZ+Knqh4rf0MtV2CEBy1jZ9ifECJcCSPuxjYldgrLIK3a/l oGBzWk0q2p+4ETqneYQAgR7Aq0ZUUb0NHXpbi4GcStZ4tp2gW42oP686J/SweUE1CZIE heYhkX5MvrHAjMwMain/QxpTKpxxMblaAn7SaByxx5lu42YvKkMO7FMd3shiHGE+q0uE xhOFAqmwiiQwaCeM/k+bzv9YLZqmaxP7rBhNbk+8mKWrQEwrd5T8cIUoRmsS4RRx1slm DRTw== X-Gm-Message-State: ABUngves1yFn8jIg6FM2mUxKnm1/2ACaR/ZWsbxn6EumDUUR5+ah8GUN938oEM5OHwLPAFSqzCA= X-Received: by 10.25.93.84 with SMTP id p20mr920074lfj.151.1479293493947; Wed, 16 Nov 2016 02:51:33 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 34sm7711369lja.25.2016.11.16.02.51.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Nov 2016 02:51:32 -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 1/9] mmc: core: Retry instead of ignore at CRC errors when polling for busy Date: Wed, 16 Nov 2016 11:51:13 +0100 Message-Id: <1479293481-20186-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479293481-20186-1-git-send-email-ulf.hansson@linaro.org> References: <1479293481-20186-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. */