Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp957487pxb; Wed, 3 Mar 2021 22:29:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwT9/rgvPAdeEPCKPrVpnybcZ3HFk9HWu2AscgGW/4xELE2BrDcbGkB0dGlyV2lMAbNSYu8 X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr2552515ejo.247.1614839395930; Wed, 03 Mar 2021 22:29:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614839395; cv=none; d=google.com; s=arc-20160816; b=Jr5f+DFK/e5aX9ocUnJ9lxjQAYw4xaV9mrNf5wEtgn6jXasmjGV3FyosUKyGnYe0Yg KirN2ERdCfb1Wo329pJ1+/i/RdEQbYJp/zkbLNo6KcL1s2ivrQo9tE5uZ3VJNIf6B0WA uPfEXW1ZR50OfTBQZMR9+BN6PSeExpH3H2Vxv5JiZbofSyAoe9eDwSSKl7Yt5zA9H1L7 /BpoUm7AePXOVf9VFRCXpWHX+fw2l+TrLVvegZcJ8OYI1Z7xwmLdTF19bAnC5UtACz8C qRB0qUxZW2W3eSOre0iNbgeqEamsOuTp7+ntZiQ8Q7E7D/mqfYgtcRaukw7uhs0Ap2Le /J6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=B/YQiWDteqAy1if94IzoLqwuQ5Yxhjv54jSJ587Pt5c=; b=F/njSmneS/ZxGvE+PiqgsTVya49n88a66cBGGZAcW3XELqMOsnkDeyezZmUzJhQZvT b0uDHPUIvPTvMeWgv3EBvBnHUYYUtXpnV9UGQD17d6QjL/unrcLDErpA62tt+kS6oWQ2 F6rU+1bjgk23q3C+9odz44kB+OT2z8M0SvygsBJsoSUpKVtxRwFNjn98uaHYXum55YkB atDex4kpiugmB2ARdYY4CfenDMni2Ejko6YuRXcCYmApB2Q5hp/zbvaanUfEafkrUzHM CW3hs8bn0XnR1gGdhjGnA5vAwMhjud1K5r3ro7oRJ9CTIuBg2I73oI8RUcKPT3UjOHnc S3qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=rrwW2S2e; 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=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k24si9349266eja.161.2021.03.03.22.29.33; Wed, 03 Mar 2021 22:29:55 -0800 (PST) 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=@foss.st.com header.s=selector1 header.b=rrwW2S2e; 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=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1579177AbhCBQ2j (ORCPT + 99 others); Tue, 2 Mar 2021 11:28:39 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:49452 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572986AbhCBOIV (ORCPT ); Tue, 2 Mar 2021 09:08:21 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 122E0rVV003184; Tue, 2 Mar 2021 15:06:54 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=B/YQiWDteqAy1if94IzoLqwuQ5Yxhjv54jSJ587Pt5c=; b=rrwW2S2e16/v+wy9LH7QS1EXJ13aPTwEtUvid3GPu7UE8T3l+XY3bZ7FTCM8Tb9C/cb/ IRQj/0PYDIeNsHQQ4o2Q4ZvqMToglbxMcx6HsmLTjyPtloykSXXAiMRas3VfDkpraHHc bDvHWvlFnRfORTs9DoXmmYXlBu18LK7lznof/puoH31Q5L26DNBFYyIO18mySRcQQBZ8 pc8PBN7wZ9cAKb9kB3a923dq2U/58tknSBofszH3jUq9VH7GjI/0SAtRYGy6xsyIHLtg oGOxmkyquZ8ijP+CAL7kra09+0wO7iHS8fYZeeNHWD7/6YRfLhK/ldLu79GeHkEikofh yA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 370xehqcv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Mar 2021 15:06:54 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BAB51100034; Tue, 2 Mar 2021 15:06:51 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9512923A2E1; Tue, 2 Mar 2021 15:06:51 +0100 (CET) Received: from lmecxl0504.lme.st.com (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 2 Mar 2021 15:06:50 +0100 Subject: Re: [PATCH v2] mmc: mmci: manage MMC_CAP_NEED_RSP_BUSY for stm32 variant To: Ulf Hansson CC: Russell King , Maxime Coquelin , Alexandre Torgue , Ludovic Barre , =?UTF-8?Q?Marek_Va=c5=a1ut?= , Linus Walleij , Greg Kroah-Hartman , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , , Linux ARM References: <20210225145454.12780-1-yann.gautier@foss.st.com> From: Yann Gautier Message-ID: <3c1f963c-e3bf-cedf-307c-dfbc96260e9c@foss.st.com> Date: Tue, 2 Mar 2021 15:06:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-02_06:2021-03-01,2021-03-02 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/2/21 11:40 AM, Ulf Hansson wrote: > On Thu, 25 Feb 2021 at 15:55, Yann Gautier wrote: >> >> To properly manage commands awaiting R1B responses, the capability >> MMC_CAP_NEED_RSP_BUSY is enabled in mmci driver, for stm32 variant. >> The issue was seen on STM32MP157C-EV1 board, with an erase command, >> with secure erase argument, letting the card stuck, possibly waiting >> for 4 hours before timeout. >> >> Fixes: 94fe2580a2f3 ("mmc: core: Enable erase/discard/trim support for all mmc hosts") >> >> Signed-off-by: Yann Gautier >> --- >> This is somehow a v2 for patch [1]. >> Changes: >> - Only apply MMC_CAP_NEED_RSP_BUSY to stm32 variant >> - Cap the used timeout written to MMCIDATATIMER (when using >> MMC_CAP_NEED_RSP_BUSY, cmd->busy_timeout may be greater than >> host->max_busy_timeout) >> >> [1] https://patchwork.kernel.org/project/linux-mmc/patch/20210204120547.15381-2-yann.gautier@foss.st.com/ >> >> drivers/mmc/host/mmci.c | 8 +++++++- >> drivers/mmc/host/mmci_stm32_sdmmc.c | 1 + >> 2 files changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >> index 17dbc81c221e..89e0e9ccfb71 100644 >> --- a/drivers/mmc/host/mmci.c >> +++ b/drivers/mmc/host/mmci.c >> @@ -1242,7 +1242,13 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c) >> if (!cmd->busy_timeout) >> cmd->busy_timeout = 10 * MSEC_PER_SEC; >> >> - clks = (unsigned long long)cmd->busy_timeout * host->cclk; >> + if (host->mmc->caps & MMC_CAP_NEED_RSP_BUSY && >> + host->mmc->max_busy_timeout && >> + cmd->busy_timeout > host->mmc->max_busy_timeout) > > We are already within "if (host->variant->busy_timeout ....", a few > lines above, which means this can be simplified into: > > 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); >> } >> diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c >> index 51db30acf4dc..2ad577618324 100644 >> --- a/drivers/mmc/host/mmci_stm32_sdmmc.c >> +++ b/drivers/mmc/host/mmci_stm32_sdmmc.c >> @@ -522,6 +522,7 @@ void sdmmc_variant_init(struct mmci_host *host) >> >> host->ops = &sdmmc_variant_ops; >> host->pwr_reg = readl_relaxed(host->base + MMCIPOWER); >> + host->mmc->caps |= MMC_CAP_NEED_RSP_BUSY; > > To make it more clear that this is for variants having the > ->busy_timeout flag set, I suggest to move this into mmci_probe(). > >> >> base_dlyb = devm_of_iomap(mmc_dev(host->mmc), np, 1, NULL); >> if (IS_ERR(base_dlyb)) >> -- >> 2.17.1 >> > > Well, I decided to help out a bit. I have amend the patch according to > the above and extended the commit message with some valuable > information, based upon our earlier discussions. > > Patch is applied at my fixes branch with a stable tag, please have a > look, test and shout at me if there is something that looks wrong! > > Thanks and kind regards > Uffe > Hi Ulf, Thanks a lot for the updated patch. I've tested it on STM32MP157C-EV1. The MMC_TEST full campaigns for both SD-card and eMMC run OK. Best regards, Yann