linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mmc_block: print better data error message after timeout
@ 2008-10-16 13:26 Adrian Hunter
  2008-10-26 11:11 ` Pierre Ossman
  0 siblings, 1 reply; 9+ messages in thread
From: Adrian Hunter @ 2008-10-16 13:26 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: LKML

In particular, if the card gets an ECC error it will
timeout, in which case it is much more helpful to see
an ECC error rather than a timeout error.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
---
 drivers/mmc/card/block.c |   47 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 24c97d3..d121462 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -210,6 +210,47 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
 	return blocks;
 }
 
+static void print_data_error(struct mmc_blk_request *brq, struct mmc_card *card,
+			     struct request *req)
+{
+	struct mmc_command cmd;
+	char *emsg;
+	u32 status;
+	int status_err = 0;
+
+	if (brq->data.error != -ETIMEDOUT || mmc_host_is_spi(card->host))
+		goto out_print;
+
+	if (brq->mrq.stop)
+		/* 'Stop' response contains card status */
+		status = brq->mrq.stop->resp[0];
+	else {
+		cmd.opcode = MMC_SEND_STATUS;
+		cmd.arg = card->rca << 16;
+		cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
+		status_err = mmc_wait_for_cmd(card->host, &cmd, 0);
+		if (status_err)
+			goto out_print;
+		status = cmd.resp[0];
+	}
+
+	emsg = (status & R1_CARD_ECC_FAILED) ? "ECC" : "I/O";
+
+	printk(KERN_ERR "%s: %s error transferring data, sector %u, "
+	       "card status %#x\n", req->rq_disk->disk_name, emsg,
+	       (unsigned)req->sector, status);
+
+	return;
+
+out_print:
+	printk(KERN_ERR "%s: error %d transferring data, sector %u, nr %u\n",
+	       req->rq_disk->disk_name, brq->data.error, (unsigned)req->sector,
+	       (unsigned)req->nr_sectors);
+	if (status_err)
+		printk(KERN_ERR "%s: error %d requesting card status\n",
+		       req->rq_disk->disk_name, status_err);
+}
+
 static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 {
 	struct mmc_blk_data *md = mq->data;
@@ -281,10 +322,8 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 			       req->rq_disk->disk_name, brq.cmd.error);
 		}
 
-		if (brq.data.error) {
-			printk(KERN_ERR "%s: error %d transferring data\n",
-			       req->rq_disk->disk_name, brq.data.error);
-		}
+		if (brq.data.error)
+			print_data_error(&brq, card, req);
 
 		if (brq.stop.error) {
 			printk(KERN_ERR "%s: error %d sending stop command\n",
-- 
1.5.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-12-21 14:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-16 13:26 [PATCH 1/2] mmc_block: print better data error message after timeout Adrian Hunter
2008-10-26 11:11 ` Pierre Ossman
2008-10-27 15:33   ` Adrian Hunter
2008-10-29 10:29   ` Adrian Hunter
2008-11-10  8:20     ` Adrian Hunter
2008-11-10  9:53       ` Pierre Ossman
2008-11-30 18:48     ` Pierre Ossman
2008-12-04 13:35       ` Adrian Hunter
2008-12-21 14:22         ` Pierre Ossman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).