Skip to content

Commit 4afac6d

Browse files
Phil Elwellpelwell
Phil Elwell
authored andcommitted
mmc/bcm2835: Recover from MMC_SEND_EXT_CSD
If the user issues an "mmc extcsd read", the SD controller receives what it thinks is a SEND_IF_COND command with an unexpected data block. The resulting operations leave the FSM stuck in READWAIT, a state which persists until the MMC framework resets the controller, by which point the root filesystem is likely to have been unmounted. A less heavyweight solution is to detect the condition and nudge the FSM by asserting the (self-clearing) FORCE_DATA_MODE bit. N.B. This workaround was essentially discovered by accident and without a full understanding the inner workings of the controller, so it is fortunate that the "fix" only modifies error paths. See: #2728 Signed-off-by: Phil Elwell <[email protected]>
1 parent c8d3194 commit 4afac6d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/mmc/host/bcm2835.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,8 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
772772

773773
if (!(sdhsts & SDHSTS_CRC7_ERROR) ||
774774
(host->cmd->opcode != MMC_SEND_OP_COND)) {
775+
u32 edm, fsm;
776+
775777
if (sdhsts & SDHSTS_CMD_TIME_OUT) {
776778
host->cmd->error = -ETIMEDOUT;
777779
} else {
@@ -780,6 +782,13 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
780782
bcm2835_dumpregs(host);
781783
host->cmd->error = -EILSEQ;
782784
}
785+
edm = readl(host->ioaddr + SDEDM);
786+
fsm = edm & SDEDM_FSM_MASK;
787+
if (fsm == SDEDM_FSM_READWAIT ||
788+
fsm == SDEDM_FSM_WRITESTART1)
789+
/* Kick the FSM out of its wait */
790+
writel(edm | SDEDM_FORCE_DATA_MODE,
791+
host->ioaddr + SDEDM);
783792
bcm2835_finish_request(host);
784793
return;
785794
}

0 commit comments

Comments
 (0)