Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp542419ybh; Tue, 10 Mar 2020 03:46:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vthNlYIczedLniuvikwC9oTj0yTfdUzSr3/LnlAe0bMX8L6fxg+ypEg4XC7xrIzmsd+/rdl X-Received: by 2002:a05:6830:c5:: with SMTP id x5mr3129929oto.302.1583837185890; Tue, 10 Mar 2020 03:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583837185; cv=none; d=google.com; s=arc-20160816; b=mOxVYc6fZJrJALryNS3BvWa9/Km02PrelHA2VI0oLpafj1XNXTLptx/trmPJMyU9Ul FxKKxf6vggkIjvtp02OLqWenWEOI/7QnbzECXsyX8YOlBwvPRsRAp1AbnamuXxiyOE3g HucDKqucrJHTgfK17syVkqLhlIPIXMkFVR1vNisbuD+TykoSz2QwVCx3MrqTIkplynCE kwp+cUzTkfsybDexdkdo7WFIV79XKv7z4jphPM4M77E5y6Nu3BM1sylTndo/KH21KyXW pFBqVzxdoBo5GXz+22UGI4pRk2+LCmRRZkRadR5yTUNyKoFYcQZd/s86fowDm+4BG4Fv yQsg== 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=vmIj3EqV5f2xXmIpptFqj/PfZ9n34jIn3cPmb1fTBOo=; b=EUTxLWfhka5ejEryADY0uQpep8TYClvtw0/9zkIc2bWfxy1Sl3asH7Zz4/wO6kyjkK JZX+tztEVP46NtIwm2+N6b+KJxaJtu0zkXcDxycopC8+6IA778qIIMEqRPiV9HKSz16T EYHxYm+7mT+APAxGbakS/Q21Ds12Px0mzLfihvBjiIUH4SSky/UmdOZG3+PmR4snqHH5 2t3FXAAiu8IXYFtF6Tp8lLRWKrA4Xy0qahiNfcpHNscFAWmmW/rS7Id6kTQ3x8O3gIsf wl7LZoRWogsbp3gC+peUCL+vYPaNtQGCJAYhT2bzWw2Sl8D63AhdOztEA3Xm7ys9kTRs N0sA== 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 c85si5013219oig.225.2020.03.10.03.46.13; Tue, 10 Mar 2020 03:46:25 -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 S1726258AbgCJKow (ORCPT + 99 others); Tue, 10 Mar 2020 06:44:52 -0400 Received: from mga01.intel.com ([192.55.52.88]:10392 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbgCJKow (ORCPT ); Tue, 10 Mar 2020 06:44:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Mar 2020 03:44:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,536,1574150400"; d="scan'208";a="415149407" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.167]) ([10.237.72.167]) by orsmga005.jf.intel.com with ESMTP; 10 Mar 2020 03:44:49 -0700 Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc To: Ulf Hansson , "Seo, Kyungmin" Cc: Chaotian Jing , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List References: <20200212024220.GA32111@seokyung-mobl1> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <5f3b8cb9-5e55-ee47-46e5-af019d6328b6@intel.com> Date: Tue, 10 Mar 2020 12:44:04 +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 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. 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 > >> >> Thanks >> >> -----Original Message----- >> From: Ulf Hansson >> Sent: Friday, March 6, 2020 12:18 AM >> To: Seo, Kyungmin ; Hunter, Adrian ; Chaotian Jing >> Cc: linux-mmc@vger.kernel.org; Linux Kernel Mailing List >> Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc >> >> + Adrian, Chaotian >> >> On Thu, 5 Mar 2020 at 09:57, Seo, Kyungmin wrote: >>> >>> The mmc_hs400_to_hs200 function is called only in HS400 mode. >>> I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform. >>> >>> I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. >>> First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock. >> >> I had a vague memory that we have discussed a similar problem as your are pointing out on the mailing list already. And I was right. >> >> Please read up on the below references, [1], [2] for the earlier discussions. I suggested a solution for Chaotian to try, but it seems like he never managed to give it a go, as I don't recall new patch being posted. >> >> Perhaps you can pick up were Chaotian left and see if you can implement the suggested solution(s). My main concern is breaking other host drivers, as that seems quite likely to happen, if we aren't careful about this. >> >> Kind regards >> Uffe >> >> [1] >> https://lore.kernel.org/linux-mmc/1548921212-5219-1-git-send-email-chaotian.jing@mediatek.com/ >> [2] >> https://lore.kernel.org/linux-mmc/CAPDyKFquyyXx1MqNLVXuFxcEDB9nKzN8LGGNUP2yxoVMQrWiUg@mail.gmail.com/ >> >> >> >>> >>> Thanks >>> KM >>> >>> -----Original Message----- >>> From: Ulf Hansson >>> Sent: Wednesday, March 4, 2020 8:09 PM >>> To: Seo, Kyungmin >>> Cc: linux-mmc@vger.kernel.org; Linux Kernel Mailing List >>> >>> Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in >>> mmc >>> >>> On Wed, 12 Feb 2020 at 03:40, Kyungmin Seo wrote: >>>> >>>> The clock has to be changed after sending CMD6 for HS mode selection >>>> in >>>> mmc_hs400_to_hs200() function. >>>> >>>> The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to >>>> enable the the high speed mode timing in the Device, before chaning >>>> the clock frequency to a frequency between 26MHz and 52MHz. >>> >>> I think that is based upon the assumption that you are using a lower frequency to start with. >>> >>> For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate. >>> >>> mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me. >>> >>> Kind regards >>> Uffe >>> >>>> >>>> Signed-off-by: Kyungmin Seo >>>> --- >>>> drivers/mmc/core/mmc.c | 8 ++++---- >>>> 1 file changed, 4 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index >>>> 3486bc7fbb64..98640b51c73e 100644 >>>> --- a/drivers/mmc/core/mmc.c >>>> +++ b/drivers/mmc/core/mmc.c >>>> @@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card) >>>> int err; >>>> u8 val; >>>> >>>> - /* Reduce frequency to HS */ >>>> - max_dtr = card->ext_csd.hs_max_dtr; >>>> - mmc_set_clock(host, max_dtr); >>>> - >>>> /* Switch HS400 to HS DDR */ >>>> val = EXT_CSD_TIMING_HS; >>>> err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, >>>> EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int >>>> mmc_hs400_to_hs200(struct mmc_card *card) >>>> >>>> mmc_set_timing(host, MMC_TIMING_MMC_DDR52); >>>> >>>> + /* Reduce frequency to HS */ >>>> + max_dtr = card->ext_csd.hs_max_dtr; >>>> + mmc_set_clock(host, max_dtr); >>>> + >>>> err = mmc_switch_status(card); >>>> if (err) >>>> goto out_err; >>>> -- >>>> 2.17.1 >>>>