From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26ADEC4332F for ; Wed, 23 Nov 2022 08:56:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236842AbiKWI4v (ORCPT ); Wed, 23 Nov 2022 03:56:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236776AbiKWI4i (ORCPT ); Wed, 23 Nov 2022 03:56:38 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DE50FFA8F for ; Wed, 23 Nov 2022 00:56:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 46C1DCE2034 for ; Wed, 23 Nov 2022 08:56:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 076D2C433C1; Wed, 23 Nov 2022 08:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669193792; bh=FGng+i9gTJCZSrk7tG+9y0H3mrmtuTm6uRvhDup/qvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tW3SVOxrg6YE7Ug0RaKng/IuQJaAbvnMmCfpFkGYh5q9DnkM95whxBp7DE546u1fM Uq923n6XZF3NIgPhIgycCO9S/qfINoAl0vy38A4GXHwoW7mKiykmP9iATo4Fnu28ar sFQpD0lhb4aPB/RT+xfqJlVxqgUd5Ceab810TPyk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yann Gautier , Ulf Hansson Subject: [PATCH 4.9 63/76] mmc: core: properly select voltage range without power cycle Date: Wed, 23 Nov 2022 09:51:02 +0100 Message-Id: <20221123084548.818808512@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123084546.742331901@linuxfoundation.org> References: <20221123084546.742331901@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yann Gautier commit 39a72dbfe188291b156dd6523511e3d5761ce775 upstream. In mmc_select_voltage(), if there is no full power cycle, the voltage range selected at the end of the function will be on a single range (e.g. 3.3V/3.4V). To keep a range around the selected voltage (3.2V/3.4V), the mask shift should be reduced by 1. This issue was triggered by using a specific SD-card (Verbatim Premium 16GB UHS-1) on an STM32MP157C-DK2 board. This board cannot do UHS modes and there is no power cycle. And the card was failing to switch to high-speed mode. When adding the range 3.2V/3.3V for this card with the proposed shift change, the card can switch to high-speed mode. Fixes: ce69d37b7d8f ("mmc: core: Prevent violation of specs while initializing cards") Signed-off-by: Yann Gautier Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20221028073740.7259-1-yann.gautier@foss.st.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1641,7 +1641,13 @@ u32 mmc_select_voltage(struct mmc_host * mmc_power_cycle(host, ocr); } else { bit = fls(ocr) - 1; - ocr &= 3 << bit; + /* + * The bit variable represents the highest voltage bit set in + * the OCR register. + * To keep a range of 2 values (e.g. 3.2V/3.3V and 3.3V/3.4V), + * we must shift the mask '3' with (bit - 1). + */ + ocr &= 3 << (bit - 1); if (bit != host->ios.vdd) dev_warn(mmc_dev(host), "exceeding card's volts\n"); }