Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1574058pxb; Thu, 4 Mar 2021 15:14:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvQd5nWVN/T3RtDAs4GUv1rZOzA0SpybuGI3ScY5wkk2zKtaw43kzMB52xy6T64uUEW8Ld X-Received: by 2002:a05:6638:d50:: with SMTP id d16mr6697245jak.140.1614899680448; Thu, 04 Mar 2021 15:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614899680; cv=none; d=google.com; s=arc-20160816; b=CChpSDZ6wfXH94J+sX3BUsJ2Mxm2uht/6YJoJXzS3TI/1dwLJXzy1yKdrnkY/S6bOS YchzwThmibHfb7FjoTeXpDKPdBXkd8NuMta1Koxpe5S8CaYAm59mfJh6RwHThEfnEA6V qVCCvVYNzQfWnOmjQOzFDLew3MRyjlZhfJwWycYKq18B84HbZ17o994ymFjhU3kHfcYe xQpcRjXtzS+WPHGJWcRK9EiJkuqloEAX7vSXwAl2RHfNvqbKQ7vsFyBk8a3OkgaSByHn Jpxm3IUdEu0zLrvFgUNpZEobHiGKC7Jh4lBZIxROr+7Lxdamty03DkVPAtOumqLrUese PN1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qYeQ+NFtTLUpACjemsdiHMG/NCOie4ro9CLEsAjhtuI=; b=BqCjzx40CrXim0EwGrrHB8KFIg3QKmBERndsgbxVFoEUncFJJtLx+NmAacDSMZZnky +ZO5ajMNlDXJTvOzcNEnMwrBI32ixh17c49ly6BIruIcHu+kcMVlHcjhU0YN9+X/hGOd GP7wxhRM0yIrpBxmmiUjtn8320YHUhJSfF1DoH72qmIW73sjYES2yQUQWX1E1HSl/dum 0NLnOH5xO7vihQq6kx8GJ7ZV/fOt4ri7Fz3DFciuC2xrFoPtLY8Bhr7ScOwzuBzDyAfS S71Z06U9de9vjtQviMjnO2rXQeD53Sjl6J1+G14Q78HS05oR77IlEpJOE1FciVLea9w0 V44Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jcFAKEL5; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x1si597548ilg.52.2021.03.04.15.14.27; Thu, 04 Mar 2021 15:14:40 -0800 (PST) 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=@linaro.org header.s=google header.b=jcFAKEL5; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344927AbhCCP6p (ORCPT + 99 others); Wed, 3 Mar 2021 10:58:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350429AbhCCLAi (ORCPT ); Wed, 3 Mar 2021 06:00:38 -0500 Received: from mail-vk1-xa31.google.com (mail-vk1-xa31.google.com [IPv6:2607:f8b0:4864:20::a31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7243CC0617AA for ; Wed, 3 Mar 2021 02:59:58 -0800 (PST) Received: by mail-vk1-xa31.google.com with SMTP id i27so2827225vkp.9 for ; Wed, 03 Mar 2021 02:59:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qYeQ+NFtTLUpACjemsdiHMG/NCOie4ro9CLEsAjhtuI=; b=jcFAKEL534YPyAxFXGKOJVFO2btNyVhC6s5kEAGYFX+670ERVHjaZ33CMDqb+GM/ZJ dQQ9GvY200Q9Q7o0oQqNRVvOHoYqJzk1ZHQ9nxYT8hGZ3/wcc4DWIadFydb6N8HR8p+f oDZ7Y0nCg5PJseN48pPsKbXWrHFuNTLQjoAZmhWuDILwU+Ce28YePQSxnoLfhyEoO7FX SoT11MqTSP16MWfiiJ339biCFDTouJwIaP7Ydbz94Zot1OhsE43ejjVFsW760badaGgW +3caVh/CiRrAwO9YZfOoPnWtL1ZuE0wnuYl4es+eqC5RK15eMUPiF2cHuFWn2A0ePtWf UhWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qYeQ+NFtTLUpACjemsdiHMG/NCOie4ro9CLEsAjhtuI=; b=Vnufm6+WbL/ldq7Hu2usl5XqAsuWY9/tT4vtrHhpWUxngVodcUIdAfB5jgnIGO2xSW i58zN+vD5kb6BGJcswQT37tgJuBuLUm8NmuYpPXzLaDp6uQTTA8RSOIHHIq242rl/SJn nckL8UH1ZhnUUF/TUlGjECdPeKL7B0E0BXm4FolVTjI3LXLhkzNna9H+K8XAS5I9d5nu G/0yRXumWJ37kAgkJ2gfPSvXB0nfbFbt+8dg4W3Obw20ioybMbrSX5XwYDtS0IN0FJwG 8bgrDFhxbBiJhg7cMIR3Asg28XANHGeiVRYUShy7ZXnxRr/tq8CYAL9t5TXMjbrsO/M0 u6dA== X-Gm-Message-State: AOAM533MheC/+25KKrYMQsTscQNK5ZtxfqzxqaO8rWVfCLyB2uzAE2jM asouXg53H1BibTwv0DATORFV6bGwLRSBCA9w7VEHkA== X-Received: by 2002:a1f:a68d:: with SMTP id p135mr5747751vke.6.1614769197495; Wed, 03 Mar 2021 02:59:57 -0800 (PST) MIME-Version: 1.0 References: <20210210045936.7809-1-dh0421.hwang@samsung.com> <01df01d70ff6$bc9dd230$35d97690$@samsung.com> In-Reply-To: <01df01d70ff6$bc9dd230$35d97690$@samsung.com> From: Ulf Hansson Date: Wed, 3 Mar 2021 11:59:19 +0100 Message-ID: Subject: Re: [PATCH] mmc: core: add a power cycle when CMD11 fails To: DooHyun Hwang Cc: "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , Eric Biggers , Wolfram Sang , Satya Tangirala , Ludovic Barre , Linus Walleij , grant.jung@samsung.com, jt77.jang@samsung.com, junwoo80.lee@samsung.com, jangsub.yi@samsung.com, Seunghui Lee , Chanwoo Lee , sh8267.baek@samsung.com, wkon.kim@samsung.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 3 Mar 2021 at 07:30, DooHyun Hwang wrote: > > On Tue, 2 Mar 2021 at 10:38, Ulf Hansson wrote: > >On Wed, 10 Feb 2021 at 06:12, DooHyun Hwang > >wrote: > >> > >> A power cycle is required if CMD11 fails. > >> CMD11 failure should be handled as no response. > >> > >> If there is a timeout error that means no response to the CMD11, do > >> not send the CMD11 again and the power cycle is required. > >> Any other errors for CMD11 are the same because CMD11 failed. > >> > >> On some bad SD Card, CMD11 may fail but the card may have already > >> invoked the voltage switch sequence. > >> In this case, it is necessary to retry without voltage switching after > >> power cycle. > >> > >> Signed-off-by: DooHyun Hwang > > > >Applied for next, thanks! > > > >I took the liberty of updating the commit message a bit, to try to clarify > >things. Moreover, I have tagged this for stable kernels. > > > >BTW, did you try to force the error to -EAGAIN, to keep retrying for a > >couple of times? If so, did it end up with the same kind of errors? > > Thank you for reviewing this. > > Yes. I tested with 2 SD cards. > I think the power cycle is needed before retrying > because SD card doesn't respond SD_ROCR_S18A when retrying without power cycle. Thanks for sharing the logs and the details below! If I understand correctly, forcing the error to -EAGAIN combined with the power cycle when the CMD11 fails, actually makes us succeed with the voltage switch in the second retry. Correct? In that case, it seems like a good idea to extend $subject patch to return -EAGAIN in case we get an error from the CMD11, right? [...] > > #4. SD card responded with SD_ROCR_S18A from ACMD41 after power cycle, and change CMD11's error value to -EAGAIN > // send ACMD41 + with SD_OCR_S18R (bit[24]) > <7>[ 156.884623] [0: kworker/0:1: 7] mmc0: starting CMD41 arg 51040000 flags 000000e1 > // resp ACMD41 + with SD_ROCR_S18A (bit[24]) > <7>[ 156.884975] I[0: highpool[3]: 5440] mmc0: req done (CMD41): 0: c1ff8000 00000000 00000000 00000000 > // send CMD11 and error occurs > <7>[ 156.885051] [0: kworker/0:1: 7] mmc0: starting CMD11 arg 00000000 flags 00000015 > <7>[ 156.885759] I[0: highpool[3]: 5440] mmc0: req done (CMD11): -84: 00000000 00000000 00000000 00000000 > // retry with power cycle (tested with this patch) > <7>[ 156.885834] [0: kworker/0:1: 7] mmc0: Signal voltage switch failed, power cycling card > <7>[ 156.885875] [0: kworker/0:1: 7] mmc0: clock 0Hz busmode 2 powermode 0 cs 0 Vdd 0 width 1 timing 0 > <7>[ 156.920185] [0: kworker/0:1: 7] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 18 width 1 timing 0 > // change CMD11's error value to -EAGAIN > <3>[ 156.932288] [0: kworker/0:1: 7] mmc_sd_get_cid: rocr=0xc1ff8000, retries=10. err=-84 -> -11. > <7>[ 156.932336] [0: kworker/0:1: 7] mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 18 width 1 timing 0 > <7>[ 156.933834] [0: kworker/0:1: 7] mmc0: starting CMD0 arg 00000000 flags 000000c0 > <7>[ 156.934101] I[0:ung.android.mdx:10229] mmc0: req done (CMD0): 0: 00000000 00000000 00000000 00000000 > <7>[ 156.935562] [0: kworker/0:1: 7] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 18 width 1 timing 0 > <7>[ 156.937009] [0: kworker/0:1: 7] mmc0: starting CMD8 arg 000001aa flags 000002f5 > <7>[ 156.937372] I[0:ung.android.mdx:10229] mmc0: req done (CMD8): 0: 000001aa 00000000 00000000 00000000 > // send ACMD41 + with SD_OCR_S18R (bit[24]) > <7>[ 157.044190] [0: kworker/0:1: 7] mmc0: starting CMD55 arg 00000000 flags 000000f5 > <7>[ 157.044924] I[0:ung.android.mdx:10229] mmc0: req done (CMD55): 0: 00000120 00000000 00000000 00000000 > <7>[ 157.045023] [0: kworker/0:1: 7] mmc0: starting CMD41 arg 51040000 flags 000000e1 > // resp ACMD41 + with SD_ROCR_S18A (bit[24]) > <7>[ 157.045389] I[0:ung.android.mdx:10229] mmc0: req done (CMD41): 0: c1ff8000 00000000 00000000 00000000 > // send CMD11 and complete > <7>[ 157.045467] [0: kworker/0:1: 7] mmc0: starting CMD11 arg 00000000 flags 00000015 > <7>[ 157.045855] I[0: Binder:798_2: 805] mmc0: req done (CMD11): 0: 00000320 00000000 00000000 00000000 > > > > > >> --- > >> drivers/mmc/core/core.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index > >> 1136b859ddd8..a6674df2a7bb 100644 > >> --- a/drivers/mmc/core/core.c > >> +++ b/drivers/mmc/core/core.c > >> @@ -1207,7 +1207,7 @@ int mmc_set_uhs_voltage(struct mmc_host *host, > >> u32 ocr) > >> > >> err = mmc_wait_for_cmd(host, &cmd, 0); > >> if (err) > >> - return err; > >> + goto power_cycle; > >> > >> if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR)) > >> return -EIO; > >> -- > >> 2.29.0 > >> Kind regards Uffe