From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99E30134C7 for ; Mon, 26 Jun 2023 18:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BCC2C433C8; Mon, 26 Jun 2023 18:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687803498; bh=vqIqFnWSJE0E90bomROB1dnMkiZREdqIziRgYD7M7P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yde1389JG6vNeoRPcx/NATa/T8BB0a3ma6ZMv3EJCPC+BOKDg1wSAV5QNTw2Y20ZL 2Yf9z2SDdKC0UkUHA6ojXTG42fk6/wGXJOULxbJsV/UuLNIjUmkns2F/onvO/AYdWN ApmshiSsaAvm9qt4tNCHNy7WFC4tCzex/3Z0GW6Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yann Gautier , Christophe Kerello , Ulf Hansson Subject: [PATCH 6.3 081/199] mmc: mmci: stm32: fix max busy timeout calculation Date: Mon, 26 Jun 2023 20:09:47 +0200 Message-ID: <20230626180809.133109117@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230626180805.643662628@linuxfoundation.org> References: <20230626180805.643662628@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Christophe Kerello commit 47b3ad6b7842f49d374a01b054a4b1461a621bdc upstream. The way that the timeout is currently calculated could lead to a u64 timeout value in mmci_start_command(). This value is then cast in a u32 register that leads to mmc erase failed issue with some SD cards. Fixes: 8266c585f489 ("mmc: mmci: add hardware busy timeout feature") Signed-off-by: Yann Gautier Signed-off-by: Christophe Kerello Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230613134146.418016-1-yann.gautier@foss.st.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/mmci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1735,7 +1735,8 @@ static void mmci_set_max_busy_timeout(st return; if (host->variant->busy_timeout && mmc->actual_clock) - max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC); + max_busy_timeout = U32_MAX / DIV_ROUND_UP(mmc->actual_clock, + MSEC_PER_SEC); mmc->max_busy_timeout = max_busy_timeout; }