From: Guenter Roeck <linux@roeck-us.net>
To: Brian Norris <briannorris@chromium.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
stable@vger.kernel.org, Arindam Nath <arindam.nath@amd.com>,
Chris Ball <cjb@laptop.org>, Philip Rakity <prakity@marvell.com>,
Zhangfei Gao <zhangfei.gao@marvell.com>,
linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org
Subject: Re: [PATCH] mmd: core: Terminate infinite loop in SD-UHS voltage switch
Date: Wed, 14 Sep 2022 03:16:08 -0700 [thread overview]
Message-ID: <20220914101608.GA1325043@roeck-us.net> (raw)
In-Reply-To: <20220914014010.2076169-1-briannorris@chromium.org>
On Tue, Sep 13, 2022 at 06:40:10PM -0700, Brian Norris wrote:
> This loop intends to retry a max of 10 times, with some implicit
> termination based on the SD_{R,}OCR_S18A bit. Unfortunately, the
> termination condition depends on the value reported by the SD card
> (*rocr), which may or may not correctly reflect what we asked it to do.
>
> Needless to say, it's not wise to rely on the card doing what we expect;
> we should at least terminate the loop regardless. So, check both the
> input and output values, so we ensure we will terminate regardless of
> the SD card behavior.
>
> Note that SDIO learned a similar retry loop in commit 0797e5f1453b
> ("mmc: core: Fixup signal voltage switch"), but that used the 'ocr'
> result, and so the current pre-terminating condition looks like:
>
> rocr & ocr & R4_18V_PRESENT
>
> (i.e., it doesn't have the same bug.)
>
> This addresses a number of crash reports seen on ChromeOS that look
> like the following:
>
> ... // lots of repeated: ...
> <4>[13142.846061] mmc1: Skipping voltage switch
> <4>[13143.406087] mmc1: Skipping voltage switch
> <4>[13143.964724] mmc1: Skipping voltage switch
> <4>[13144.526089] mmc1: Skipping voltage switch
> <4>[13145.086088] mmc1: Skipping voltage switch
> <4>[13145.645941] mmc1: Skipping voltage switch
> <3>[13146.153969] INFO: task halt:30352 blocked for more than 122 seconds.
> ...
>
> Fixes: f2119df6b764 mmc: sd: add support for signal voltage switch procedure
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
>
> drivers/mmc/core/sd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 06aa62ce0ed1..3662bf5320ce 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -870,7 +870,8 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
> * 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 & SD_ROCR_S18A)) {
> + if (!mmc_host_is_spi(host) && (ocr & SD_OCR_S18R) &&
> + rocr && (*rocr & SD_ROCR_S18A)) {
> err = mmc_set_uhs_voltage(host, pocr);
> if (err == -EAGAIN) {
> retries--;
> --
> 2.37.2.789.g6183377224-goog
>
next prev parent reply other threads:[~2022-09-14 10:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 1:40 [PATCH] mmd: core: Terminate infinite loop in SD-UHS voltage switch Brian Norris
2022-09-14 10:16 ` Guenter Roeck [this message]
2022-09-21 12:49 ` 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=20220914101608.GA1325043@roeck-us.net \
--to=linux@roeck-us.net \
--cc=arindam.nath@amd.com \
--cc=briannorris@chromium.org \
--cc=cjb@laptop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=prakity@marvell.com \
--cc=stable@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=zhangfei.gao@marvell.com \
/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