From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org,
linux-arm-kernel@lists.infradead.orglinux-mmc@vger.kernel.orglinux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] MMC: add checking of r/w command response
Date: Mon, 20 Jun 2011 20:10:49 +0100 [thread overview]
Message-ID: <E1QYjs1-000806-20@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20110620190945.GK26089@n2100.arm.linux.org.uk>
Check the status bits in the r/w command response for any errors.
If error bits are set, then we won't have seen any data transferred,
so its pointless doing any further checking.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/mmc/card/block.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index aa074c8..e5d1c8a 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -812,6 +812,14 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
}
}
+#define CMD_ERRORS \
+ (R1_OUT_OF_RANGE | /* Command argument out of range */ \
+ R1_ADDRESS_ERROR | /* Misaligned address */ \
+ R1_BLOCK_LEN_ERROR | /* Transferred block length incorrect */\
+ R1_WP_VIOLATION | /* Tried to write to protected block */ \
+ R1_CC_ERROR | /* Card controller error */ \
+ R1_ERROR) /* General/unknown error */
+
static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
{
struct mmc_blk_data *md = mq->data;
@@ -967,6 +975,22 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
}
}
+ /*
+ * Check for errors relating to the execution of the
+ * initial command - such as address errors. No data
+ * has been transferred.
+ */
+ if (brq.cmd.resp[0] & CMD_ERRORS) {
+ pr_err("%s: r/w command failed, status = %#x\n",
+ req->rq_disk->disk_name, brq.cmd.resp[0]);
+ goto cmd_abort;
+ }
+
+ /*
+ * Everything else is either success, or a data error of some
+ * kind. If it was a write, we may have transitioned to
+ * program mode, which we have to wait for it to complete.
+ */
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
u32 status;
do {
@@ -986,7 +1010,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
}
if (brq.data.error) {
- pr_err("%s: error %d transferring data, sector %u nr %u, cmd response %#x card status %#x\n",
+ pr_err("%s: error %d transferring data, sector %u, nr %u, cmd response %#x, card status %#x\n",
req->rq_disk->disk_name, brq.data.error,
(unsigned)blk_rq_pos(req),
(unsigned)blk_rq_sectors(req),
--
1.7.4.4
next prev parent reply other threads:[~2011-06-20 19:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-20 19:09 [PATCH 0/3] Improve MMC error handling (3rd rev) Russell King - ARM Linux
2011-06-20 19:10 ` [PATCH 1/3] MMC: allow get_card_status() to return error status Russell King - ARM Linux
2011-06-20 19:10 ` [PATCH 2/3] MMC: improve error recovery from command channel errors Russell King - ARM Linux
2011-06-20 19:10 ` Russell King - ARM Linux [this message]
2011-06-20 19:34 ` [PATCH 0/3] Improve MMC error handling (3rd rev) Linus Walleij
2011-06-21 13:38 ` Pawel Moll
2011-06-21 16:23 ` Chris Ball
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=E1QYjs1-000806-20@rmk-PC.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=cjb@laptop.org \
--cc=linux-arm-kernel@lists.infradead.orglinux-mmc \
--cc=linux-mmc@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox