Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp867673yba; Wed, 24 Apr 2019 10:54:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLIa8GTBiWoptM4/urWJbsVrxVOXcxHeRrvcwL+5CY76NUfLW4wFLuOc1k2sf3n9uaG7o4 X-Received: by 2002:a62:e411:: with SMTP id r17mr34790805pfh.127.1556128457233; Wed, 24 Apr 2019 10:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556128457; cv=none; d=google.com; s=arc-20160816; b=ZbzewEdS80Z4FvXvJ0jU/NLfsa0oJG6DrUJMTEcX+DPQLdB6WzdNLuDrPJfR02dNUa 91IKYP/EyT7fMrlOzgKwyvMA9zhl9KY4zj/h5H8HRCocSvnlRrh2W5VvQJD9kvV2GORe QO4Q1weVyYRqf10rjPD13LYqJn6E2dSWMLFkk6hBOo5QEmMuhJ+z2PmiXBBM0xTbMdFi oHR1mrfMf69DsN8iVcg4BQp5pMq7cVbD1AvGwv2tMHO9Urk0U551ifyyOxSQKBZWElE7 iZH4oIh9dpsvE8ixHCkO6MMIDMU9/AW7M25WgdUb4c2NGELw7gmpcjoO6Xben9wjyuWx f3Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EH5o9IVHK0LugPUrsIqM5nh6BYRLpKC8q1l4NSnLBPQ=; b=SUS5eLMqWJPFuMAXxdRrjwi1WaymhtPcrIArcwdd2owT1RSgtzROcAJKExz4RcyOJT EKPZO7JHUixa+0o2FM3LDBFM0sFqMMW8uyFevcgy7L++xrEwG6TjsOXxKgUZTxdBPwdW xt8OYyfhx9Gin01kxAk6VUqTL5p1Own9CWj0u3wEvQSJT+IHF/tjqGkkyR5GQV8W8Hcw nrCQn8E8X8cJnUgx2Lyu7P29+Q5t7C4249+OQR/qScqT4SEnhM0PjKjwd87bmEwxYaBK VCRnlxyWpOi1vvMAREcqhew5d4tqhhkggPWHlROoAOKSZKjsbqy4NrpPRzeayDE3DVUH yG5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b2RL213C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e192si18253063pgc.222.2019.04.24.10.54.01; Wed, 24 Apr 2019 10:54:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b2RL213C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390539AbfDXRw0 (ORCPT + 99 others); Wed, 24 Apr 2019 13:52:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:54100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390530AbfDXR17 (ORCPT ); Wed, 24 Apr 2019 13:27:59 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC8DB21904; Wed, 24 Apr 2019 17:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126878; bh=uyNgKVx5hRUPgu/kO84SUp15/rEGiTmVGpS4ESVmXyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2RL213C0C7XtZIOb89t3Thsv7zF70naZ7lhoC82iuM2sNqj/hWeBrWYvZCyaAfgH Ga0jFQBHdVAbQmv0ZFYEw0OZFEDtcyV4SkwlMHgKVLPlvlJRwIqauatEwdGWnwzWqd BK1WKdO7xxlF9ZFQvZxLOeLPd33M6eyXeZayAYnE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Ulf Hansson , Sasha Levin Subject: [PATCH 4.14 49/70] mmc: sdhci: Fix data command CRC error handling Date: Wed, 24 Apr 2019 19:10:09 +0200 Message-Id: <20190424170916.651683565@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170906.751869122@linuxfoundation.org> References: <20190424170906.751869122@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 4bf780996669280171c9cd58196512849b93434e ] Existing data command CRC error handling is non-standard and does not work with some Intel host controllers. Specifically, the assumption that the host controller will continue operating normally after the error interrupt, is not valid. Change the driver to handle the error in the same manner as a data CRC error, taking care to ensure that the data line reset is done for single or multi-block transfers, and it is done before unmapping DMA. Signed-off-by: Adrian Hunter Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/sdhci.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0edcc2763f3c..2d59b0389567 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1002,8 +1002,7 @@ static bool sdhci_needs_reset(struct sdhci_host *host, struct mmc_request *mrq) return (!(host->flags & SDHCI_DEVICE_DEAD) && ((mrq->cmd && mrq->cmd->error) || (mrq->sbc && mrq->sbc->error) || - (mrq->data && ((mrq->data->error && !mrq->data->stop) || - (mrq->data->stop && mrq->data->stop->error))) || + (mrq->data && mrq->data->stop && mrq->data->stop->error) || (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))); } @@ -1055,6 +1054,16 @@ static void sdhci_finish_data(struct sdhci_host *host) host->data = NULL; host->data_cmd = NULL; + /* + * The controller needs a reset of internal state machines upon error + * conditions. + */ + if (data->error) { + if (!host->cmd || host->cmd == data_cmd) + sdhci_do_reset(host, SDHCI_RESET_CMD); + sdhci_do_reset(host, SDHCI_RESET_DATA); + } + if ((host->flags & (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) == (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) sdhci_adma_table_post(host, data); @@ -1079,17 +1088,6 @@ static void sdhci_finish_data(struct sdhci_host *host) if (data->stop && (data->error || !data->mrq->sbc)) { - - /* - * The controller needs a reset of internal state machines - * upon error conditions. - */ - if (data->error) { - if (!host->cmd || host->cmd == data_cmd) - sdhci_do_reset(host, SDHCI_RESET_CMD); - sdhci_do_reset(host, SDHCI_RESET_DATA); - } - /* * 'cap_cmd_during_tfr' request must not use the command line * after mmc_command_done() has been called. It is upper layer's @@ -2560,7 +2558,7 @@ static void sdhci_timeout_data_timer(unsigned long data) * * \*****************************************************************************/ -static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) +static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p) { if (!host->cmd) { /* @@ -2583,20 +2581,12 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) else host->cmd->error = -EILSEQ; - /* - * If this command initiates a data phase and a response - * CRC error is signalled, the card can start transferring - * data - the card may have received the command without - * error. We must not terminate the mmc_request early. - * - * If the card did not receive the command or returned an - * error which prevented it sending data, the data phase - * will time out. - */ + /* Treat data command CRC error the same as data CRC error */ if (host->cmd->data && (intmask & (SDHCI_INT_CRC | SDHCI_INT_TIMEOUT)) == SDHCI_INT_CRC) { host->cmd = NULL; + *intmask_p |= SDHCI_INT_DATA_CRC; return; } @@ -2824,7 +2814,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) } if (intmask & SDHCI_INT_CMD_MASK) - sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK); + sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK, &intmask); if (intmask & SDHCI_INT_DATA_MASK) sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK); -- 2.19.1