From patchwork Thu Feb 25 14:54:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Gautier X-Patchwork-Id: 12104211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14807C433E0 for ; Thu, 25 Feb 2021 14:57:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EB8264ECE for ; Thu, 25 Feb 2021 14:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EB8264ECE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=huwN6dhDvrehfRN7SQ3/PVXij+rL9M1BVGTc2dIocNU=; b=eP08zZeuLSrG9gXDTh0mpi6Jku uBOvoTjTquY+j0/d/GLqpqolJUJDCkZgmFyu5+sjZ3yLGBIfRMQ6LBpAriOuk8/k9ewIYwYyAiBwj /otkOsCf7UqIf+INU+NX5+iIGPILfspfcwFZHCVkSmmKsrpjGxjt2JMK8Dh9EmNn8kQhjDakKkUTt zxSkt1aLAAhQ0uh5xAPcYDh8QgAGqemFdn8SZWxDuI8BEDRQa5zoFMmVTkGrqdHwIjZjw8EVIZRNh FBi67ViXjTEKwj0prwTwXM2ybJZwDYX5ELZYZ5/Sv4qdmIpZjfHVhvUb6JdAszGlEd7WfpPqisNV+ Hzfk/muQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFI3U-0003FY-Ul; Thu, 25 Feb 2021 14:55:52 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFI3Q-0003FE-Sx for linux-arm-kernel@lists.infradead.org; Thu, 25 Feb 2021 14:55:50 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11PEr8uX015318; Thu, 25 Feb 2021 15:55:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=selector1; bh=qCrvlMRtCkTQFfJ0RxV1KE9Dy1D6noU5d5mt7t050ao=; b=5HJnUrTYv0tTf8bCqKENBWH3CnTWsFuCgp+wStuf4hd4fVGMXm95EpbzxL8tSTVtBitW Duf5ZO/jBMIyV9Mctefm51Pvl3h/AqyO/P+zA+JKuHVXeXeLPBlMiCCQpSxfNvq1YcaH 7P8YyhCbqqttvdWHNvrdjwfsxw9H3/QyDeYNLGnhHqg5zFqxNfJVDfSJA8rYVDAYcdgc CbWv9PaoPP6w3hexZ+WWXkGrO8q4T+O1Q58XrHLEjVKRIH5DC0Y2HCd37WbmI4E1ltvi prmVz28kdBTRm1Plpf+4rLMVELhiL5hXnqwEchn2d2Tbe9yp+5JX7AvDCGj0r/zmxtOg Rg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36w66u6jjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Feb 2021 15:55:35 +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 03DD9100034; Thu, 25 Feb 2021 15:55:33 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id BD585236FDD; Thu, 25 Feb 2021 15:55:33 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 25 Feb 2021 15:55:33 +0100 From: Yann Gautier To: , Subject: [PATCH v2] mmc: mmci: manage MMC_CAP_NEED_RSP_BUSY for stm32 variant Date: Thu, 25 Feb 2021 15:54:54 +0100 Message-ID: <20210225145454.12780-1-yann.gautier@foss.st.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-02-25_09:2021-02-24, 2021-02-25 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210225_095549_366268_4C799BEF X-CRM114-Status: GOOD ( 16.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marex@denx.de, alexandre.torgue@st.com, gregkh@linuxfoundation.org, linus.walleij@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, yann.gautier@foss.st.com, mcoquelin.stm32@gmail.com, u.kleine-koenig@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, ludovic.barre@st.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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) + 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; base_dlyb = devm_of_iomap(mmc_dev(host->mmc), np, 1, NULL); if (IS_ERR(base_dlyb))