mmc: block: improve error recovery from command channel errors
authorRussell King - ARM Linux <linux@arm.linux.org.uk>
Mon, 20 Jun 2011 19:10:28 +0000 (20:10 +0100)
committerKen Sumrall <ksumrall@android.com>
Thu, 27 Oct 2011 00:11:38 +0000 (17:11 -0700)
commit91d56b5cb51ceeb06c88e7557f7181827d721d0d
tree25cace9d55c592004e0cb87ddd754c10aae99483
parent6be918e0b229a7eeb81c1c09d5009a78aa88bc4a
mmc: block: improve error recovery from command channel errors

Command channel errors fall into four classes:

1. The command was issued with the card in the wrong state
2. The command failed to be received by the card correctly
3. The cards response failed to be received by the host (CRC error)
4. The card failed to respond to the card

For (1), in theory we should know that the card is in the correct state.
However, a failed stop command (or other failure) may result in the card
remaining in a data transfer state from the previous command.  If we
detect this condition, we try to recover by sending a stop command.

For the initial commands (set block count and the read/write command)
no data will have been transferred.  All that we need deal with is
retrying at this point.  A failed stop command can be remedied as
above.

If we are unable to recover the card (eg, the card ignores our requests
for status, or we don't recognise the error code) then we immediately
fail the request.

Change-Id: Ief109a57fd21a247381b38f1164c22f0344f0284
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/card/block.c