linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: mmc_spi: synchronize STOP_TRANSMISSION with next data token during block reads
@ 2014-03-03 19:17 Johnson Thomas
  0 siblings, 0 replies; only message in thread
From: Johnson Thomas @ 2014-03-03 19:17 UTC (permalink / raw)
  To: cjb; +Cc: dbrownell, linux-mmc, linux-kernel, johnsonthomas, jamesnuss

Certain SD cards respond with an invalid response (ie,. response
not defined in the SD protocol) during block reads when the
OUT_OF_RANGE data token is sent back from the card at the same time
as the host sends a STOP_TRANSMISSION command (CMD12). As a result,
the card enters a bad state which leads to rejecting any subsequent
commands until the card is reset.

Synchronize with the subsequent data token for every block read before
issuing a STOP_TRANSMISSION command (CMD12). The synchronization is
done by issuing 0xff bytes until a data token is received.

Signed-off-by: Johnson Thomas <johnsonthomas@nanometrics.ca>
---
 drivers/mmc/host/mmc_spi.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 7c1e16a..7703a15 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -984,6 +984,14 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 		}
 	}
 
+	if (direction == DMA_FROM_DEVICE && multiple) {
+		int status = mmc_spi_readtoken(host, timeout);
+		if (status < 0)
+			dev_dbg(&spi->dev,
+				"read error for data token, returned status: 0x%02x (%d)\n",
+				status, status);
+	}
+
 	/* NOTE some docs describe an MMC-only SET_BLOCK_COUNT (CMD23) that
 	 * can be issued before multiblock writes.  Unlike its more widely
 	 * documented analogue for SD cards (SET_WR_BLK_ERASE_COUNT, ACMD23),
-- 
1.7.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-03-03 19:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-03 19:17 [PATCH] mmc: mmc_spi: synchronize STOP_TRANSMISSION with next data token during block reads Johnson Thomas

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).