All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	linux-mmc@vger.kernel.org, Shawn Guo <shawnguo@kernel.org>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Subject: Re: [PATCH v2] mmc: block: prevent propagating R1_OUT_OF_RANGE for open-ending mode
Date: Tue, 15 Aug 2017 11:16:19 +0200	[thread overview]
Message-ID: <20170815091618.ydnwlqx5ahwvn33e@ninjato> (raw)
In-Reply-To: <f4f100a0-9edd-db13-1c21-9f986345c733@rock-chips.com>

[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]

Hi Shawn,

> So that implies we only need to care about open-ending mode.

I see. Thanks for the explanation.

> I could fold in the description from the spec see explain why
> we don't need to check this for the CMD23 cases.

That would be great.

> Does all the above sound goot to you?

Basically, yes. If we need to check for CMD23 then, I wonder if why we
really need to do (md->flags & MMC_BLK_CMD23) or if we can't simply
check the presence of brq->mrq.sbc? That could then lead to the
following refactorization which is a lot easier to read IMO (but only
compile tested, just to give you an idea what I had in mind):

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index f1bbfd389367ff..1cf905d0e88e77 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1371,12 +1371,17 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
 	 R1_CC_ERROR |		/* Card controller error */		\
 	 R1_ERROR)		/* General/unknown error */
 
-static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
+/* Map R1 errors to error codes */
+static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq)
 {
-	if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
-		cmd->error = -EIO;
+	u32 val;
 
-	return cmd->error;
+	/* If there is no error yet, check R1 response */
+	if (!brq->stop.error) {
+		val = brq->stop.resp[0] & CMD_ERRORS;
+		if (val && !(val & R1_OUT_OF_RANGE && brq->mrq.sbc))
+			brq->stop.error = -EIO;
+	}
 }
 
 static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
@@ -1400,8 +1405,10 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
 	 * stop.error indicates a problem with the stop command.  Data
 	 * may have been transferred, or may still be transferring.
 	 */
-	if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) ||
-	    brq->data.error) {
+
+	mmc_blk_eval_resp_error(brq);
+
+	if (brq->sbc.error || brq->cmd.error || brq->stop.error || brq->data.error) {
 		switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
 		case ERR_RETRY:
 			return MMC_BLK_RETRY;

Regards,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-08-15  9:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-08  0:27 [PATCH v2] mmc: block: prevent propagating R1_OUT_OF_RANGE for open-ending mode Shawn Lin
2017-08-08 10:37 ` Ulf Hansson
2017-08-08 11:47   ` Wolfram Sang
2017-08-08 17:02     ` Ulf Hansson
2017-08-14  0:41 ` Shawn Lin
2017-08-14 17:58 ` Wolfram Sang
2017-08-15  1:43   ` Shawn Lin
2017-08-15  9:16     ` Wolfram Sang [this message]
2017-08-15  9:30       ` Shawn Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170815091618.ydnwlqx5ahwvn33e@ninjato \
    --to=wsa@the-dreams.de \
    --cc=linux-mmc@vger.kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=shawnguo@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.