summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Boot <bootc@bootc.net>2018-10-08 17:07:30 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-18 09:18:19 +0200
commit3df1331f63cd4cf5de66ca5a46ec61edacbe63e5 (patch)
tree602c2b62ba4ad9e78ffc5aedc8172f9c4cbcb36b
parent7088776eb06a8000c1a6360ccd47d6925ad0120d (diff)
downloadlinux-stable-3df1331f63cd4cf5de66ca5a46ec61edacbe63e5.tar.gz
linux-stable-3df1331f63cd4cf5de66ca5a46ec61edacbe63e5.tar.bz2
linux-stable-3df1331f63cd4cf5de66ca5a46ec61edacbe63e5.zip
mmc: block: avoid multiblock reads for the last sector in SPI mode
commit 41591b38f5f8f78344954b68582b5f00e56ffe61 upstream. On some SD cards over SPI, reading with the multiblock read command the last sector will leave the card in a bad state. Remove last sectors from the multiblock reading cmd. Signed-off-by: Chris Boot <bootc@bootc.net> Signed-off-by: Clément Péron <peron.clem@gmail.com> Cc: stable@vger.kernel.org # v4.10+ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/mmc/core/block.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index a0b9102c4c6e..e201ccb3fda4 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1371,6 +1371,16 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq,
if (brq->data.blocks > 1) {
/*
+ * Some SD cards in SPI mode return a CRC error or even lock up
+ * completely when trying to read the last block using a
+ * multiblock read command.
+ */
+ if (mmc_host_is_spi(card->host) && (rq_data_dir(req) == READ) &&
+ (blk_rq_pos(req) + blk_rq_sectors(req) ==
+ get_capacity(md->disk)))
+ brq->data.blocks--;
+
+ /*
* After a read error, we redo the request one sector
* at a time in order to accurately determine which
* sectors can be read successfully.