linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Christian Löhle" <CLoehle@hyperstone.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>
Cc: "pali@kernel.org" <pali@kernel.org>,
	"huyue2@yulong.com" <huyue2@yulong.com>,
	"tiantao6@hisilicon.com" <tiantao6@hisilicon.com>
Subject: [PATCH v2] mmc: enable UHS voltage switch for SDSC if supported
Date: Wed, 12 May 2021 16:03:24 +0000	[thread overview]
Message-ID: <CWXP265MB26803AE79E0AD5ED083BF2A6C4529@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CWXP265MB2680766F673A99D2F296B878C4469@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM>

Ignore the reported capacity if the card otherwise reports UHS support.

Let SDSC cards reporting UHS support (except for the CCS) attempt the
voltage switch.
Up until now such cards would be initialized as UHS,
supporting UHS features SDSC cards are otherwise barred from,
but skip the voltage switch.
While strictly speaking a SDSC card cannot support UHS in compliance
with the standard, there is no good reason to throttle them that way.
Especially for pSLCs in practice such cards benefit greatly,
as they can be new and UHS supporting, but must not lie about their CCS.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/core/sd.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 2c48d6504101..62d02f1dc924 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -847,11 +847,17 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
 		return err;
 
 	/*
-	 * In case CCS and S18A in the response is set, start Signal Voltage
+	 * In case S18A in the response is set, start Signal Voltage
 	 * Switch procedure. SPI mode doesn't support CMD11.
+	 * Strictly speaking, S18A is not valid if CCS is not set (= not SDSC),
+	 * so one would have to OCR for 0x41000000.
+	 * We choose to ignore this as SDSC cards that report UHS voltage
+	 * support should not be throttled artificially by the standard this
+	 * way.
+	 * SDSC cards that 'accidentally' reporting UHS support by setting the
+	 * reserved bits don't seem to be an issue in practice.
 	 */
-	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--;
@@ -1109,7 +1115,14 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 		}
 	}
 
-	/* Initialization sequence for UHS-I cards */
+	/* Initialization sequence for UHS-I cards
+	 * Strictly speaking, S18A in the OCR is only valid if CCS is set, too.
+	 * So SDSC cards should be excluded. We choose to deviate from the
+	 * standard here to allow SDSC cards to utilize UHS if they report
+	 * supporting it.
+	 * Fortunately, SDSC cards reporting S18A and the related bus speed
+	 * modes on accident, by setting reserved bits, don't seem to exist.
+	 */
 	if (rocr & SD_ROCR_S18A && mmc_host_uhs(host)) {
 		err = mmc_sd_init_uhs_card(card);
 		if (err)
-- 
2.31.1

Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


  parent reply	other threads:[~2021-05-12 17:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 13:18 [PATCH] mmc: enable UHS voltage switch for SDSC if supported Christian Löhle
2021-04-23  1:34 ` [PATCH] mmc: enable UHS voltage switch for SDSC if supported【请注意,邮件由linux-mmc-owner@vger.kernel.org代发】 Shawn Lin
2021-04-23  6:38   ` Christian Löhle
2021-04-23  6:51     ` Shawn Lin
2021-04-30 10:45 ` [PATCH] mmc: enable UHS voltage switch for SDSC if supported Christian Löhle
2021-05-05 10:09 ` Ulf Hansson
2021-05-05 12:12   ` Christian Löhle
2021-05-05 14:20     ` Ulf Hansson
2021-05-06  8:34       ` Christian Löhle
2021-05-06 13:54         ` Ulf Hansson
2021-05-12 16:03 ` Christian Löhle [this message]
2021-06-04 12:10   ` [PATCH v2] " Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CWXP265MB26803AE79E0AD5ED083BF2A6C4529@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM \
    --to=cloehle@hyperstone.com \
    --cc=huyue2@yulong.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=tiantao6@hisilicon.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).