Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp633165pxv; Thu, 15 Jul 2021 12:02:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxSiyPeRFhMIqSJwf4x+FowEeMk60XjTs3sy/0twickSzatNmvqfmC2IVYVZzLucDE57WC X-Received: by 2002:a92:cbc8:: with SMTP id s8mr3425457ilq.193.1626375770871; Thu, 15 Jul 2021 12:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375770; cv=none; d=google.com; s=arc-20160816; b=ZuxZbc0Bf3gUrx6Fg1Ku7emk3EFC5xne/27vDVSPuOmHPOJfgIwbknfFqEWDHwMtLo W4T7JfZJ2PRk7fS/vX9Wdrzj825x1wmed8PIybOP8XNdTzOxrlXBifugZA2ai1hk9BBd 3WlEdl+yKM2e0kbc154/898rwm5gVrDTfb9KgrRAWpuBiGwCmoGjp3JkcLX8rxO9wSmh eTBai+Rz6WxZVpfL1uIjcnf6IJ7tC+vjB8cF6NvKxEaTH8XWkQvjybS2Eg2rLcgypOpw Ek6K25Q/YGEWlwEGgqCVvq2jL7sElZo5xseYqAQFEJmnMt5uI/7SaDWvWAXnoW8tpiqz szmw== 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=gJlWDZkx2n2lYZWZTAANk9Lchp9q1LR3DObBSq5R2Mg=; b=XBIyfErMeUuBghpzJ575+OP73VTNnk4KY8E9sgLPsn+ju09ckKOKyCufuorqEMNo9L NHaUqWD0h7XAu1bbMDdSVhaP7nZglgrN4300YLIjFBl/q64L+4s1+jecMzizFcBqa8Y9 pqRtDSTRx3m1qATm77FbJ5wvMc6zFCrXBWt43/8q3U1Qnglymgk0SMuaCmvB6OvVD6eV F+nwoJJfywV8ZeUjnbFoOIPs6l94rN14YxWSXG2G/UiS6vuJuROp+hEXUJO9aRjnNi8h 5waw1cY+zdAfOlSTkRg02BDBc6W/wA20AYnz1L9JNvWOrIVLjYHCaNcVUwow1S/eFRPQ x53w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TwjE8jSW; 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 c4si7965578jal.120.2021.07.15.12.02.38; Thu, 15 Jul 2021 12:02:50 -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=TwjE8jSW; 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 S238564AbhGOTDP (ORCPT + 99 others); Thu, 15 Jul 2021 15:03:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:59176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242212AbhGOSy4 (ORCPT ); Thu, 15 Jul 2021 14:54:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A80B8613C4; Thu, 15 Jul 2021 18:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375123; bh=ABPESi/tvCvsDdS+Q26E3nZ0CcXREcFW90/hodmz2z0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwjE8jSWtHAB/HfoQTccCDNSjNFFrs5lbIUGPtylMD6nD9Hl51nwIWihA9NEsqTKK VS06c9N/NbFT8eCM8BdEQI839QR/n6FiwGJ/tPD7+BeRd73ZaamkrTt6vI/vHScS0r kQEnnGe1JQKXp6+NBB4ZfbJbPGKfCEHqyoLw+Ccc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Loehle , Ulf Hansson Subject: [PATCH 5.10 169/215] mmc: core: Allow UHS-I voltage switch for SDSC cards if supported Date: Thu, 15 Jul 2021 20:39:01 +0200 Message-Id: <20210715182629.456022986@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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: Christian Löhle commit 09247e110b2efce3a104e57e887c373e0a57a412 upstream. While initializing an UHS-I SD card, the mmc core first tries to switch to 1.8V I/O voltage, before it continues to change the settings for the bus speed mode. However, the current behaviour in the mmc core is inconsistent and doesn't conform to the SD spec. More precisely, an SD card that supports UHS-I must set both the SD_OCR_CCS bit and the SD_OCR_S18R bit in the OCR register response. When switching to 1.8V I/O the mmc core correctly checks both of the bits, but only the SD_OCR_S18R bit when changing the settings for bus speed mode. Rather than actually fixing the code to confirm to the SD spec, let's deliberately deviate from it by requiring only the SD_OCR_S18R bit for both parts. This enables us to support UHS-I for SDSC cards (outside spec), which is actually being supported by some existing SDSC cards. Moreover, this fixes the inconsistent behaviour. Signed-off-by: Christian Loehle Link: https://lore.kernel.org/r/CWXP265MB26803AE79E0AD5ED083BF2A6C4529@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM Cc: stable@vger.kernel.org [Ulf: Rewrote commit message and comments to clarify the changes] Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/sd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -847,11 +847,13 @@ try_again: return err; /* - * In case CCS and S18A in the response is set, start Signal Voltage - * Switch procedure. SPI mode doesn't support CMD11. + * In case the S18A bit is set in the response, let's start the signal + * voltage switch procedure. SPI mode doesn't support CMD11. + * Note that, according to the spec, the S18A bit is not valid unless + * the CCS bit is set as well. We deliberately deviate from the spec in + * regards to this, which allows UHS-I to be supported for SDSC cards. */ - if (!mmc_host_is_spi(host) && rocr && - ((*rocr & 0x41000000) == 0x41000000)) { + if (!mmc_host_is_spi(host) && rocr && (*rocr & 0x01000000)) { err = mmc_set_uhs_voltage(host, pocr); if (err == -EAGAIN) { retries--;