kernel: bump 4.14 to 4.14.93
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.14 / 950-0434-mmc-bcm2835-Recover-from-MMC_SEND_EXT_CSD.patch
1 From c2eae29f6503cf29ac6a204c51132cfed33d203e Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Fri, 26 Oct 2018 17:40:44 +0100
4 Subject: [PATCH 434/454] mmc/bcm2835: Recover from MMC_SEND_EXT_CSD
5
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.
11
12 A less heavyweight solution is to detect the condition and nudge the
13 FSM by asserting the (self-clearing) FORCE_DATA_MODE bit.
14
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.
18
19 See: https://github.com/raspberrypi/linux/issues/2728
20
21 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
22 ---
23 drivers/mmc/host/bcm2835.c | 9 +++++++++
24 1 file changed, 9 insertions(+)
25
26 --- a/drivers/mmc/host/bcm2835.c
27 +++ b/drivers/mmc/host/bcm2835.c
28 @@ -772,6 +772,8 @@ static void bcm2835_finish_command(struc
29
30 if (!(sdhsts & SDHSTS_CRC7_ERROR) ||
31 (host->cmd->opcode != MMC_SEND_OP_COND)) {
32 + u32 edm, fsm;
33 +
34 if (sdhsts & SDHSTS_CMD_TIME_OUT) {
35 host->cmd->error = -ETIMEDOUT;
36 } else {
37 @@ -780,6 +782,13 @@ static void bcm2835_finish_command(struc
38 bcm2835_dumpregs(host);
39 host->cmd->error = -EILSEQ;
40 }
41 + edm = readl(host->ioaddr + SDEDM);
42 + fsm = edm & SDEDM_FSM_MASK;
43 + if (fsm == SDEDM_FSM_READWAIT ||
44 + fsm == SDEDM_FSM_WRITESTART1)
45 + /* Kick the FSM out of its wait */
46 + writel(edm | SDEDM_FORCE_DATA_MODE,
47 + host->ioaddr + SDEDM);
48 bcm2835_finish_request(host);
49 return;
50 }