Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525445pxf; Mon, 15 Mar 2021 11:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5qEWRoi6Aytw9DePi3xUHSlsLjUMZojWoHLUAYWqpGSoXVH/uBfl50RXv5980jts1vpJy X-Received: by 2002:a17:906:1ecc:: with SMTP id m12mr25061597ejj.4.1615833003882; Mon, 15 Mar 2021 11:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833003; cv=none; d=google.com; s=arc-20160816; b=lgLRjBU8qSuFvN9ACPUT+llOFxGXC+4RVN5hfiA9A7UJfFNVru4qqIrVadOttNthH0 43TB7RMXCleHPUejydhd67uEVj+bQ1oKKioq0Z+2S2zy4eXJoL2Ykt4oPqjaSpQubgqx R0dDeD4R14MKS+H4S3Sl6/InendRIsaa+jYpa0/sRtMBzfOc7aobNndLnRULejk5Q/Oh oSB7qb3CGEDF2/8gRlBDeQI99NwORqPWwTdmWYxc9TY29cScGUvKfRVBK+AaPz6U1J5C EVycMz+iHSTMOwzk3gNhI+I1KJOI9Hp7ebdLXjlNY+9XTcT1/cvHeyFh+WLKQ3wjqwwf GBXQ== 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=E0VnessAyJIS5OY3exAjzWOqIh99OIdC09qNacnDMHYqWcT8byTRQmdksHbdk7yC6r bTFnoN5Q9YPl+e0FwdB5ioQxltaz+Wrs1WsxRN0HBz+50av3aCaav0xcgYtGXnphUW3z nwkPCsqRj8HyKSNF7oFtgXdajegiaDX7BfKA5MEAe/p8t0Mip/J2+3QDExPXtgvoRPvo 87z761IYQ7UrFFcdFdMrg+qXlM6YRoh0FZ9gndQYOwjCczTkcQvGn5TAigwOcb4y09A/ CCdMwjp+DDRYH9JWMUvmlvggwP/GP5MeX0DmyjxRWC8S2CHDb5zQsAZNmd4xLJLRM2mh Zvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TcsH3lXu; 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 r21si11862101edy.321.2021.03.15.11.29.40; Mon, 15 Mar 2021 11:30:03 -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=TcsH3lXu; 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 S236075AbhCOOfX (ORCPT + 99 others); Mon, 15 Mar 2021 10:35:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233464AbhCOOBn (ORCPT ); Mon, 15 Mar 2021 10:01:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 150C864F39; Mon, 15 Mar 2021 14:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816898; bh=PTcLLVHr/9HBRIE549YIz8JnuFcy9FkCf0zgoZIqlec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TcsH3lXuXhvf2WoN/9n1Usq6XyCK6rlZTKRrmlK0Q9dts1qtrYcwIHeb3U5KlFGZ6 v0/SenWoMRFttZuqaZoiImrBCXuTJin196V8s2WsyqUFFbH82ebNHUssrpu6LMmKPp XRBcwk+Ru+bOEzyNUnwH5nHIV258Odeor5sScDQc= 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.11 189/306] mmc: mmci: Add MMC_CAP_NEED_RSP_BUSY for the stm32 variants Date: Mon, 15 Mar 2021 14:54:12 +0100 Message-Id: <20210315135514.001542867@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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;