public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc_spi: use EILSEQ for possible transmission errors
@ 2009-05-14 11:24 Wolfgang Mües
  2009-05-19 11:29 ` Matt Fleming
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Mües @ 2009-05-14 11:24 UTC (permalink / raw)
  To: Pierre Ossman
  Cc: Andrew Morton, Matt Fleming, David Brownell, Mike Frysinger,
	linux-kernel

From: Wolfgang Muees <wolfgang.mues@auerswald.de>

o This patch changes the reported error code for the responses
  to a command from EINVAL/EIO to EILSEQ, as EINVAL is reserved
  for non-recoverable host errors, and the responses from
  the SD/MMC card may be because of recoverable transmission
  errors in the command or in the response. Response codes
  are NOT protected by a checksum, so don't trust them.

Signed-off-by: Wolfgang Muees <wolfgang.mues@auerswald.de>

---
diff -uprN 2_6_29_rc7_patch_wearout_speedup/drivers/mmc/host/mmc_spi.c 2_6_29_rc7_patch_EILSEQ/drivers/mmc/host/mmc_spi.c
--- 2_6_29_rc7_patch_wearout_speedup/drivers/mmc/host/mmc_spi.c	2009-04-08 11:11:20.000000000 +0200
+++ 2_6_29_rc7_patch_EILSEQ/drivers/mmc/host/mmc_spi.c	2009-05-14 12:49:42.000000000 +0200
@@ -334,17 +334,18 @@ checkstatus:
 	cmd->error = 0;

 	/* Status byte: the entire seven-bit R1 response.  */
-	if (cmd->resp[0] != 0) {
-		if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS
-				      | R1_SPI_ILLEGAL_COMMAND)
-				& cmd->resp[0])
-			value = -EINVAL;
-		else if (R1_SPI_COM_CRC & cmd->resp[0])
-			value = -EILSEQ;
-		else if ((R1_SPI_ERASE_SEQ | R1_SPI_ERASE_RESET)
-				& cmd->resp[0])
-			value = -EIO;
-		/* else R1_SPI_IDLE, "it's resetting" */
+	/*
+	 * Note that we have a problem here: as the response is NOT protected
+	 * by a CRC or checksum, a transmission error in the response will
+	 * be interpreted as an error code. So we map all error codes to
+	 * EILSEQ here, to allow for the upper layer to retry the command.
+	 * If one of these error codes is a non-recoverable error, retries
+	 * will do no harm.
+	 */
+
+	/* Allow only 0 and R1_SPI_IDLE here */
+	if (cmd->resp[0] & ~R1_SPI_IDLE) {
+		value = -EILSEQ;
 	}

 	switch (mmc_spi_resp_type(cmd)) {
---
regards

i. A. Wolfgang Mües
-- 
Auerswald GmbH & Co. KG
Hardware Development
Telefon: +49 (0)5306 9219 0
Telefax: +49 (0)5306 9219 94 
E-Mail: Wolfgang.Mues@Auerswald.de
Web: http://www.auerswald.de
 
--------------------------------------------------------------
Auerswald GmbH & Co. KG, Vor den Grashöfen 1, 38162 Cremlingen
Registriert beim AG Braunschweig HRA 13289
p.h.G Auerswald Geschäftsführungsges. mbH
Registriert beim AG Braunschweig HRB 7463
Geschäftsführer: Dipl-Ing. Gerhard Auerswald

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

end of thread, other threads:[~2009-06-13 10:57 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-14 11:24 [PATCH] mmc_spi: use EILSEQ for possible transmission errors Wolfgang Mües
2009-05-19 11:29 ` Matt Fleming
2009-05-19 11:47   ` Wolfgang Mües
2009-05-20  7:53     ` Matt Fleming
2009-05-20  4:49   ` David Brownell
2009-05-20  8:35     ` Wolfgang Mües
2009-05-20  9:20       ` David Brownell
2009-05-20 10:08         ` Pierre Ossman
2009-05-21  2:02           ` David Brownell
2009-05-25  9:04             ` Wolfgang Mües
2009-05-25  9:43               ` David Brownell
2009-05-25 10:18                 ` Wolfgang Mües
2009-05-25 11:50                   ` Pierre Ossman
2009-05-25 14:59                     ` Wolfgang Mües
2009-06-09 18:07                       ` Pierre Ossman
2009-06-10  7:29                         ` Wolfgang Mües
2009-06-10  7:37                           ` Matt Fleming
2009-06-13 10:57                           ` Pierre Ossman
2009-05-25 11:48             ` Pierre Ossman
2009-05-20 10:31         ` Wolfgang Mües

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox