[PATCH 1/3] mmc: mmci: do not count a data CRC error as a complete transfer
Mateusz Nowicki
mateusz.nowicki at posteo.net
Sat Oct 31 05:07:11 PDT 2026
With datacnt_useless (STM32 variants) success is 0 on a data error and
a CRC error subtracts one from it. bytes_xfered becomes 0xfffffe00 and
mmc_blk completes the whole request as successful, although the
controller stopped at the failing block. Reads return stale data and
writes are lost without any error.
Tested on the STM32MP257F-DK eMMC in HS200 with a forced bad tuning:
without this change 5 of 14 reads returned zeros, with it all 10 reads
were correct.
Fixes: b79220b3e0af ("mmc: mmci: add variant property to not read datacnt")
Cc: stable at vger.kernel.org
Signed-off-by: Mateusz Nowicki <mateusz.nowicki at posteo.net>
---
drivers/mmc/host/mmci.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 416bdb184ed4..10eb0439fc52 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1422,8 +1422,9 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ, status 0x%08x at 0x%08x\n",
status_err, success);
if (status_err & MCI_DATACRCFAIL) {
- /* Last block was not successful */
- success -= 1;
+ /* Last block was not successful, nothing counted when DATACNT is useless */
+ if (success)
+ success -= 1;
data->error = -EILSEQ;
} else if (status_err & MCI_DATATIMEOUT) {
data->error = -ETIMEDOUT;
--
2.56.0
More information about the linux-arm-kernel
mailing list