mmc: dw_mmc: Add RCRC handling
authorMarek Vasut <marex@denx.de>
Tue, 6 Nov 2018 22:42:11 +0000 (23:42 +0100)
committerTom Rini <trini@konsulko.com>
Sat, 10 Nov 2018 13:16:30 +0000 (08:16 -0500)
This patch adds check for command response CRC failure. The driver
is currently ignoring CRC check failure on command resposes which
have CRC atteched to it, which can be potentially dangerous. Even
more grueling problem happens when the command response is followed
by data transfer though, as in that case, the dwmci_data_transfer()
function will spin until it reaches the 240s timeout.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
drivers/mmc/dw_mmc.c
include/dwmmc.h

index 3c702b3..7544b84 100644 (file)
@@ -317,6 +317,10 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
        } else if (mask & DWMCI_INTMSK_RE) {
                debug("%s: Response Error.\n", __func__);
                return -EIO;
+       } else if ((cmd->resp_type & MMC_RSP_CRC) &&
+                  (mask & DWMCI_INTMSK_RCRC)) {
+               debug("%s: Response CRC Error.\n", __func__);
+               return -EIO;
        }
 
 
index 0f9d51b..4ceda5e 100644 (file)
@@ -56,6 +56,7 @@
 #define DWMCI_INTMSK_DTO       (1 << 3)
 #define DWMCI_INTMSK_TXDR      (1 << 4)
 #define DWMCI_INTMSK_RXDR      (1 << 5)
+#define DWMCI_INTMSK_RCRC      (1 << 6)
 #define DWMCI_INTMSK_DCRC      (1 << 7)
 #define DWMCI_INTMSK_RTO       (1 << 8)
 #define DWMCI_INTMSK_DRTO      (1 << 9)