Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528124pxf; Mon, 15 Mar 2021 11:33:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5bwUP/3A2qZSZME9SaE2Bq2hl1RbSjg0dXAMoeOL9ZnvAyZ2zGKpO54Ampw7rY3q957ll X-Received: by 2002:a17:906:8308:: with SMTP id j8mr24555540ejx.339.1615833214959; Mon, 15 Mar 2021 11:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833214; cv=none; d=google.com; s=arc-20160816; b=eiAxdNCI0LC1GAxArKF+uBN6DGgxaqZPsWDhdIs/wg6RAoC1n10hDdw723lTLTowOA QGSJEHLjyS4q0o0DboS4XwgG31O+AiH3lhz2livAMRXyFgyAvf9T2GoOrVZYjKAvISmZ 1jcX4S2J95qba30g8WxJqztoI8bIdgl75Ty1+AUdnA8Ajtx11qkMSR/QYz8WFO8p9CAc u8TWsLHg3KKFZ951jDAgMOOsySoYPGpKrFF7qAj9SMlWjOKFrFgbnE8hfCL1IPbUQAbF 551A9Fghnp5ofjWkVoemml5xykjqG3XABomB4XivA5kwZbIv9mOVKqrRtzQPndtkrFl9 +ZmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VfKLbbWz2AdwrKVNjNBL76HArdbZ0ZTU0tZhd+SAfvM=; b=sq3oPVyWtu7ouZno0nOlmh5GVKXMxwdfNig4Rhb4m8igf4HW92JQTWGYlwrM+qB1K4 VkVmliIhqfen6oi6ML/YjSwJLCLfC1xdObOevWMor+3SfieXbCpMJvX0tDKB1ADZ8dl/ CbGsVz5IQZSV2QVw4hSJJq411jG69zoLLzkJSS4Dlh+FnMbDGZGU0OnA5xx1w6+z3KzN RNcsgyHuXCVlaFSKxWw1dWG37MYk5YcDGtWvWo01YMyEYA8yjqu3hgtDqNA5HZ/47zPt o3n/oPrkAKZtKPZPT8UTsElDKQoSbkw/8ah8071I+plIxkgoI+81VRWTUDg+zobHH5ln YxHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CQX9wdgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v18si11973941ejy.223.2021.03.15.11.33.12; Mon, 15 Mar 2021 11:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CQX9wdgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237322AbhCOOka (ORCPT + 99 others); Mon, 15 Mar 2021 10:40:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:48792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233660AbhCOOCR (ORCPT ); Mon, 15 Mar 2021 10:02:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5532D64F19; Mon, 15 Mar 2021 14:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816929; bh=PTcLLVHr/9HBRIE549YIz8JnuFcy9FkCf0zgoZIqlec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQX9wdgl0eioVzKLnBH+ocT+YtNAdN5XU5G5O0ADh+bVrZhtoZkYjTJhoyXZlMY4b BtZo3M1uUPEzXe8XkC2dqWLFGBrOs5AYC1b0JJljDFt8DpmpWBiGJl8eTGbUmStz+/ 3hpul6gK4Zhi8zJRQehELFf0fHXlPhWoABkZ8vgM= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yann Gautier , Ulf Hansson Subject: [PATCH 5.10 193/290] mmc: mmci: Add MMC_CAP_NEED_RSP_BUSY for the stm32 variants Date: Mon, 15 Mar 2021 14:54:46 +0100 Message-Id: <20210315135548.436575012@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Yann Gautier commit 774514bf977377c9137640a0310bd64eed0f7323 upstream. An issue has been observed on STM32MP157C-EV1 board, with an erase command with secure erase argument, ending up waiting for ~4 hours before timeout. The requested busy timeout from the mmc core ends up with 14784000ms (~4 hours), but the supported host->max_busy_timeout is 86767ms, which leads to that the core switch to use an R1 response in favor of the R1B and polls for busy with the host->card_busy() ops. In this case the polling doesn't work as expected, as we never detects that the card stops signaling busy, which leads to the following message: mmc1: Card stuck being busy! __mmc_poll_for_busy The problem boils done to that the stm32 variants can't use R1 responses in favor of R1B responses, as it leads to an internal state machine in the controller to get stuck. To continue to process requests, it would need to be reset. To fix this problem, let's set MMC_CAP_NEED_RSP_BUSY for the stm32 variant, which prevent the mmc core from switching to R1 responses. Additionally, let's cap the cmd->busy_timeout to the host->max_busy_timeout, thus rely on 86767ms to be sufficient (~66 seconds was need for this test case). Fixes: 94fe2580a2f3 ("mmc: core: Enable erase/discard/trim support for all mmc hosts") Signed-off-by: Yann Gautier Link: https://lore.kernel.org/r/20210225145454.12780-1-yann.gautier@foss.st.com Cc: stable@vger.kernel.org [Ulf: Simplified the code and extended the commit message] Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/mmci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1241,7 +1241,11 @@ mmci_start_command(struct mmci_host *hos if (!cmd->busy_timeout) cmd->busy_timeout = 10 * MSEC_PER_SEC; - clks = (unsigned long long)cmd->busy_timeout * host->cclk; + if (cmd->busy_timeout > host->mmc->max_busy_timeout) + clks = (unsigned long long)host->mmc->max_busy_timeout * host->cclk; + else + clks = (unsigned long long)cmd->busy_timeout * host->cclk; + do_div(clks, MSEC_PER_SEC); writel_relaxed(clks, host->base + MMCIDATATIMER); } @@ -2091,6 +2095,10 @@ static int mmci_probe(struct amba_device mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; } + /* Variants with mandatory busy timeout in HW needs R1B responses. */ + if (variant->busy_timeout) + mmc->caps |= MMC_CAP_NEED_RSP_BUSY; + /* Prepare a CMD12 - needed to clear the DPSM on some variants. */ host->stop_abort.opcode = MMC_STOP_TRANSMISSION; host->stop_abort.arg = 0;