From patchwork Tue Nov 6 22:42:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 993968 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42qPgf2fN3z9sBk for ; Wed, 7 Nov 2018 09:42:22 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D845BC2277F; Tue, 6 Nov 2018 22:42:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DD899C222A2; Tue, 6 Nov 2018 22:42:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0CF3BC223E9; Tue, 6 Nov 2018 22:42:15 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 9D749C222A2 for ; Tue, 6 Nov 2018 22:42:14 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42qPgV295qz1qx9h; Tue, 6 Nov 2018 23:42:14 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42qPgV1v3Kz1qr2J; Tue, 6 Nov 2018 23:42:14 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id hzSOTX0Nt47x; Tue, 6 Nov 2018 23:42:13 +0100 (CET) X-Auth-Info: MRPmaseK5Sn4oSdwY9Q43k2e10PU7yjZAsuUNCg3XI4= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 6 Nov 2018 23:42:13 +0100 (CET) From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 6 Nov 2018 23:42:11 +0100 Message-Id: <20181106224211.13537-1-marex@denx.de> X-Mailer: git-send-email 2.18.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH] mmc: dw_mmc: Add RCRC handling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Cc: Heiko Stuebner Cc: Philipp Tomsich --- drivers/mmc/dw_mmc.c | 4 ++++ include/dwmmc.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 3c702b3ed8..7544b84ab6 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -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; } diff --git a/include/dwmmc.h b/include/dwmmc.h index 0f9d51b557..4ceda5e43c 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -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)