1 From 6191e47f23fe4fa13dfbb38dfdda12e567028963 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Fri, 26 Oct 2018 17:29:51 +0100
4 Subject: [PATCH 433/454] mmc/bcm2835-sdhost: Recover from MMC_SEND_EXT_CSD
6 If the user issues an "mmc extcsd read", the SD controller receives
7 what it thinks is a SEND_IF_COND command with an unexpected data block.
8 The resulting operations leave the FSM stuck in READWAIT, a state which
9 persists until the MMC framework resets the controller, by which point
10 the root filesystem is likely to have been unmounted.
12 A less heavyweight solution is to detect the condition and nudge the
13 FSM by asserting the (self-clearing) FORCE_DATA_MODE bit.
15 N.B. This workaround was essentially discovered by accident and without
16 a full understanding the inner workings of the controller, so it is
17 fortunate that the "fix" only modifies error paths.
19 See: https://github.com/raspberrypi/linux/issues/2728
21 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
23 drivers/mmc/host/bcm2835-sdhost.c | 9 +++++++++
24 1 file changed, 9 insertions(+)
26 --- a/drivers/mmc/host/bcm2835-sdhost.c
27 +++ b/drivers/mmc/host/bcm2835-sdhost.c
28 @@ -1244,6 +1244,8 @@ static void bcm2835_sdhost_finish_comman
29 pr_info("%s: ignoring CRC7 error for CMD1\n",
30 mmc_hostname(host->mmc));
34 if (sdhsts & SDHSTS_CMD_TIME_OUT) {
36 pr_warn("%s: command %d timeout\n",
37 @@ -1256,6 +1258,13 @@ static void bcm2835_sdhost_finish_comman
39 host->cmd->error = -EILSEQ;
42 + edm = readl(host->ioaddr + SDEDM);
43 + fsm = edm & SDEDM_FSM_MASK;
44 + if (fsm == SDEDM_FSM_READWAIT ||
45 + fsm == SDEDM_FSM_WRITESTART1)
46 + writel(edm | SDEDM_FORCE_DATA_MODE,
47 + host->ioaddr + SDEDM);
48 tasklet_schedule(&host->finish_tasklet);