Skip to content

Commit 3a6ffb3

Browse files
Andreas Koopstorulf
authored andcommitted
mmc: mmc_spi: Enable stable writes
While using the mmc_spi driver occasionally errors like this popped up: mmcblk0: error -84 transferring data end_request: I/O error, dev mmcblk0, sector 581756 I looked on the Internet for occurrences of the same problem and came across a helpful post [1]. It includes source code to reproduce the bug. There is also an analysis about the cause. During transmission data in the supplied buffer is being modified. Thus the previously calculated checksum is not correct anymore. After some digging I found out that device drivers are supposed to report they need stable writes. To fix this I set the appropriate flag at queue initialization if CRC checksumming is enabled for that SPI host. [1] https://groups.google.com/forum/#!msg/sim1/gLlzWeXGFr8/KevXinUXfc8J Signed-off-by: Andreas Koop <[email protected]> [shihpo: Rebase on top of v5.3-rc1] Signed-off-by: ShihPo Hung <[email protected]> Cc: Paul Walmsley <[email protected]> CC: [email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 665e985 commit 3a6ffb3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/mmc/core/queue.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/kthread.h>
1111
#include <linux/scatterlist.h>
1212
#include <linux/dma-mapping.h>
13+
#include <linux/backing-dev.h>
1314

1415
#include <linux/mmc/card.h>
1516
#include <linux/mmc/host.h>
@@ -427,6 +428,10 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
427428
goto free_tag_set;
428429
}
429430

431+
if (mmc_host_is_spi(host) && host->use_spi_crc)
432+
mq->queue->backing_dev_info->capabilities |=
433+
BDI_CAP_STABLE_WRITES;
434+
430435
mq->queue->queuedata = mq;
431436
blk_queue_rq_timeout(mq->queue, 60 * HZ);
432437

0 commit comments

Comments
 (0)