Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp629732ybh; Wed, 11 Mar 2020 07:46:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuNrXniBqvXarA9wh/j18HvtQo0AVALN+TzbREi4WnkSrJNCU0b3z0R5FRk0tlqRYQgysEx X-Received: by 2002:a05:6830:114f:: with SMTP id x15mr2626637otq.306.1583937983880; Wed, 11 Mar 2020 07:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583937983; cv=none; d=google.com; s=arc-20160816; b=GNcecBQQ7INgcFMtUYiIWA1SthIzA7aX7nkQohS6XqZwM4x5zHk+CTXvqeWmITmA4S iQWsVwRbDMSLLau7jlPHuxSuLV0r6by4YyIqm9m92Kq6YzRaeDXU+S2oSQu6D7IM4SlT hp1L38719ys4X4dbNXsIOaQEOgjvScdAvOLXLo4neAAeXzdI1LBn6OZ5VWWmOEyUWD/G JQ2zwKZnMviVUtboUn/wlYs9OKmj6enGdrRJfiEkRZUSE1RDHbGmC+mD6/8rOhEhtttc 5ywS6AwoxnTPOqbYaRNDJnS/i2Dt8/h1XmrTinSJX4l/SCoMSwxycaWyFxX41wDu/sPw FsuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=gXw68F39O5swANn5YWTjQausl+UUeuDsto355z7Ad00=; b=gC+frfQi3bf6MFyNT7LgX2Zg/fUvP7Rw7JVK+PHaYgLbWqYLNihKnk7GQnQu03HJwN L0q8Cz8KVWwPMboRTDhLjUOLfLmSQ8csqZ2C4kFeNORq8qQMHCNp0YWGTSlJ2RpBz8FY rGegwt1do8WWYvJN6mNmOG3Q2CgWpK3ePzKoXs9Egprr6XVnQVlTlpmyVgp7awpSgqzp SdwjO3xqzcfUUCnek+AqcgtYaeEXJpXSqEfrmQ9mjoRyJfMzkHXCZIG66JLFb9hR9nMp L0Roh8OfLx9nlT099b4rZYgPopMUkpPx5BZQ/viff2vG6PtTGmYVslb2KMRG1ayd6l/0 WJiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l25si1203855otq.76.2020.03.11.07.46.09; Wed, 11 Mar 2020 07:46:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729845AbgCKOoa (ORCPT + 99 others); Wed, 11 Mar 2020 10:44:30 -0400 Received: from mga18.intel.com ([134.134.136.126]:8344 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729198AbgCKOo3 (ORCPT ); Wed, 11 Mar 2020 10:44:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 07:44:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,541,1574150400"; d="scan'208";a="441701450" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.167]) ([10.237.72.167]) by fmsmga005.fm.intel.com with ESMTP; 11 Mar 2020 07:44:26 -0700 Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc To: Ulf Hansson Cc: Chaotian Jing , "Seo, Kyungmin" , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List References: <20200212024220.GA32111@seokyung-mobl1> <5f3b8cb9-5e55-ee47-46e5-af019d6328b6@intel.com> <1583892806.24941.7.camel@mhfsdcap03> <053fc1c1-465a-e68a-39cb-796addf808e0@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Wed, 11 Mar 2020 16:43:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/03/20 4:06 pm, Ulf Hansson wrote: > On Wed, 11 Mar 2020 at 11:00, Adrian Hunter wrote: >> >> On 11/03/20 10:57 am, Ulf Hansson wrote: >>> On Wed, 11 Mar 2020 at 03:13, Chaotian Jing wrote: >>>> >>>> On Tue, 2020-03-10 at 16:41 +0100, Ulf Hansson wrote: >>>>> On Tue, 10 Mar 2020 at 11:44, Adrian Hunter wrote: >>>>>> >>>>>> On 10/03/20 11:05 am, Ulf Hansson wrote: >>>>>>> On Tue, 10 Mar 2020 at 05:28, Seo, Kyungmin wrote: >>>>>>>> >>>>>>>> I read the link and patch of Chaotian Jing. >>>>>>>> I also point out what Chaotian said. >>>>>>>> Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock. >>>>>>>> >>>>>>>> If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. >>>>>>>> In order to make robust sdhci driver, I think the patch needs to be considered. >>>>>>> >>>>>>> I have, but I am not picking it up in its current form. >>>>>>> >>>>>>>> Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration. >>>>>>> >>>>>>> Yes, but not for all cases, as I said in my reply in those email-threads. >>>>>>> >>>>>>> What I had in mind, is that I I think we should inform >>>>>>> mmc_hs400_to_hs200() about under what situation it's getting called. >>>>>>> Depending on that, we should either decrease the clock rate before or >>>>>>> after we send the CMD6. >>>>>>> >>>>>>> Would that work for your case? >>>>>> >>>>>> Ulf, would you consider a new call back e.g. >>>>> >>>>> That could work, but I am not sure what's best, honestly. >>>>> >>>>> The problem may be generic or it could be specific to some host >>>>> controller? I think we need to answer that question first. >>>>> >>>>> What do you think? >>>>> >>>>> Br >>>>> Uffe >>>>> >>>> When start to send CMD6 to switch to HS mode, both Host & eMMC device >>>> are working on HS400 mode, so the timing used is MUST at HS400 mode and >>>> the clock MUST keep at current clock(usually 200Mhz). after received the >>>> response of CMD6, Never use CMD13 to polling card status for timing >>>> switch. if host has ops->card_busy() or caps WAIT_WHILE_BUSY, then use >>>> it, if not,just do mmc_delay() for specific time. >>> >>> The CMD13 is currently not used when polling, because we set the >>> send_status parameter to false in the calls to __mmc_switch(). So this >>> should already be covered, according to your suggestions. Right? >>> >>> When it comes to keeping the clock rate as is, before sending the CMD6 >>> - I fully agree that it's a good idea when doing a periodic retuning. >>> As you would expect things to work as they are. >>> >>> The problem is, when you have received a CRC error and the re-tuning >>> is being triggered because of that. In that case it may be a better >>> option to decrease the clock rate, at least that is what I recall >>> Adrian needs for his cases. Adrian? >> >> It seems hardware supports HS400 only at the expected 200MHz frequency. > > Yes, that's my understanding as well. > >> The assumption then is that the command will be seen by the card but the >> response may have a CRC error. So we would need to ignore CRC errors, but >> it would also be worth waiting the timeout if the card is still busy whether >> or not there is an error. > > Alright, so you're saying that keeping the clock rate to HS400 speed > (decrease it after CMD6) could be fine, if we implement the above > instead? Yes, but I would like to try adding a simple retry at the lower frequency as well and see how well that works. I will test that tomorrow. > >> >> The only way to mitigate errors then is to increase the number of retries. > > We already use MMC_CMD_RETRIES for CMD6. Is that sufficient you think > (again assuming we implement to allow CRC errors for these CMD6 > commands)? That is only 3. If the CRC errors are random, then trying more times might help. > > Or are you suggesting we may need a re-try of the hole re-tune thing? > Maybe a better option is then to simply bail out and do full re-init > of the card? The block driver will try that at some point. I will see if I can test how well that works in this case. > >> >>> >>> What will happen when you receive a CRC error and there is re-tuning >>> triggered, is that something you have seen happening on you boards? >>> >>>> >>>> the next step is that call mmc_set_ios() to set current timing to HS >>>> mode and clock to 50Mhz to let Host driver that eMMC device has been >>>> switched to HS mode and Host can switch to HS mode at 50Mhz(may apply >>>> parameters for this low speed). >>> >>> Yep, makes sense. >>> >>>>>> >>>>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c >>>>>> index c2abd417a84a..1bc18fe2632f 100644 >>>>>> --- a/drivers/mmc/core/mmc.c >>>>>> +++ b/drivers/mmc/core/mmc.c >>>>>> @@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card) >>>>>> >>>>>> /* Reduce frequency to HS */ >>>>>> max_dtr = card->ext_csd.hs_max_dtr; >>>>>> - mmc_set_clock(host, max_dtr); >>>>>> + if (host->ops->hs400_to_hs200_prep) >>>>>> + host->ops->hs400_to_hs200_prep(host, max_dtr); >>>>>> + else >>>>>> + mmc_set_clock(host, max_dtr); >>>>>> >>>>>> /* Switch HS400 to HS DDR */ >>>>>> val = EXT_CSD_TIMING_HS; >>>>>> >>>>>> > > Kind regards > Uffe >