Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1606443imj; Thu, 14 Feb 2019 09:04:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJT9rjqZ95OZWxGjNVgD/D1DkcVc5vIBcOZ51xp5X8fJjJj8rqayc294HPbZUlPtV+Cs89 X-Received: by 2002:a63:6881:: with SMTP id d123mr823135pgc.10.1550163881976; Thu, 14 Feb 2019 09:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550163881; cv=none; d=google.com; s=arc-20160816; b=c1DwhfxG7zDAyDDYb1ug22ZBczO6FN+elKu9gLTTK5D9yTjqgYIsib1ShvXO++3yMh kF48Z2fdsswQrpBBlGATbr9L+8yfVb7bIxXSmx3o7SeNn2S9IExYZVjcMFGT2RVwJKZE ELIlpNC7geddQytQIG9LgaZYnmf06afVCWpG7PK7n6fkVSb1IGYO2IeeXfBrELpCmQcL fVgC30ToYcBlOyrJUWBnrNw0CJLYsPcDDULmk3RdY7lSTN6mf2o3IwOnN8HNWjoBJnKQ +Bp9MCMAq7GXgsjmMtOFXr+lKIXMURgMTK7Na/dtCBmiWw8+lv8Jknw68GJWw9GdNqNg JqfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q1vSlE9Et3cfPY2F1A8sGnwrhCQsNEoL0FUxEug8lZc=; b=Jry6sUXFVtTiQlvsIc/GXA2c9nrhJyGRl0yblddJeLd/ZB+MWBAjqXLRGfQveMAhmy NtSI5hHT6CHQUaoiclxTfD0l/4Jw3Q3u15Q0RyXIueXUzgbdOT8MmQSVU62dXy/sTKam sf+0bCLYDr9aWD4NzDOPhlYq5PcrEAx1gVOCOUEtyQAddYs/2TzrpGKmVI7MdOriNLXW sti1qlMTB76fiisFYcY/8s+CsmTFwhjYraZlSSTbGjd04zk731gNSdUzm2s7j4KKqTPR WxhIMJmYr6vmyq4+O9PzeLVvpYUh5U/ux91V1jLV1iw55KyoDWP9kAuViPGA4H2D+sVk 2IeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xBBa4RXz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 206si2812272pga.240.2019.02.14.09.04.23; Thu, 14 Feb 2019 09:04:41 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=xBBa4RXz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394538AbfBNIPR (ORCPT + 99 others); Thu, 14 Feb 2019 03:15:17 -0500 Received: from mail-vs1-f66.google.com ([209.85.217.66]:44531 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394478AbfBNIPR (ORCPT ); Thu, 14 Feb 2019 03:15:17 -0500 Received: by mail-vs1-f66.google.com with SMTP id r201so3094485vsc.11 for ; Thu, 14 Feb 2019 00:15:16 -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=Q1vSlE9Et3cfPY2F1A8sGnwrhCQsNEoL0FUxEug8lZc=; b=xBBa4RXz1IjzdL6Lt4V26sxhE7+GX/cw0HWxWUzg2kgnlpVjgh+xAr7uWx4CLoeQ/3 5mYnSHXELr3tAZ26gQsVJnMg9651fkcMU/yCKYUIlk013OlDP8tXaHc+EkMA9viA7YfD 6p+fscpw5PI7bsP1fdiH7SzSDXFdbiSjEmqg1HASKmCup7vWPBizYvaRIpW13bbpo86b WDowb8IV51W4bnn4Hq+AiEAMswOXGiR+6VIPcTHuDWpeR2uqYvERYkNiTH5XlW+lek9N GfjaDa2jeUZwKfbxg1LAXvw+0n1qUqdXcijXTS6Lz6pnVEsuckPlqr58iaiWx2Y4Gq1s 6+OQ== 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=Q1vSlE9Et3cfPY2F1A8sGnwrhCQsNEoL0FUxEug8lZc=; b=YjTMKMc4p4xfhsERQJyrnllthWknAv0JiwRh7c9rM8SimqRwoFYsO25Vqjqb5yeBiV d0CH0d+nS02FubnzWjqVCKPhEvNe/eNvD8FxZedQjAxWqvUawskzpNN/9u122Ut+r0yy E4EbhfY0g4Ut6vE3ZYjO2+HW/EgPt1uaRSbcx4iVpGRB5HNnFMJPlxETXVP3bpCv4/5J OTVZ2R0Ef3HQnffSMhSPa/JaK2cHUAthNwZQWuuSUdXHzmoG+nI84RI63Sl/ec1CpkY2 8tbr7d+9KlZV6td1/0wnfFc++WlsBgzTKiSTaOprGOalq5jiSV1oLlR1Twey1dkD7u0C 19Fg== X-Gm-Message-State: AHQUAuY24BUhFhHPshs2UEH6DfPjGvJGoV6z6Pu5k780SnBo4g/cPr2p EhwCOoo4fbGc+h3Jhx+YsV3DWmynvvRQC/mJlUDZ5w== X-Received: by 2002:a67:b003:: with SMTP id z3mr1479418vse.200.1550132115847; Thu, 14 Feb 2019 00:15:15 -0800 (PST) MIME-Version: 1.0 References: <1550048812-29068-1-git-send-email-chaotian.jing@mediatek.com> <1550110458.16070.30.camel@mhfsdcap03> In-Reply-To: <1550110458.16070.30.camel@mhfsdcap03> From: Ulf Hansson Date: Thu, 14 Feb 2019 09:14:39 +0100 Message-ID: Subject: Re: [PATCH v1] mmc: mmc: Fix HS setting in mmc_hs400_to_hs200() To: Chaotian Jing Cc: Matthias Brugger , Shawn Lin , Simon Horman , Kyle Roeschley , Hongjie Fang , Harish Jenny K N , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , Linux ARM , linux-mediatek@lists.infradead.org, srv_heupstream , Adrian Hunter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Feb 2019 at 03:14, Chaotian Jing wrote: > > On Wed, 2019-02-13 at 13:08 +0100, Ulf Hansson wrote: > > On Wed, 13 Feb 2019 at 10:07, Chaotian Jing wrote: > > > > > > mmc_hs400_to_hs200() begins with the card and host in HS400 mode. > > > Therefore, any commands sent to the card should use HS400 timing. > > > reduce clock frequency to 50Mhz but without host timming change > > > may cause CMD6 response CRC error. because host still running at > > > hs400 mode, and it's hard to find a suitable setting for all eMMC > > > cards when clock frequency reduced to 50Mhz but card & host still > > > in hs400 mode. > > > this patch refers to mmc_select_hs400(), make the reduce clock frequency > > > after card timing change. > > > > > > Signed-off-by: Chaotian Jing > > > Fixes: ef3d232245ab ("mmc: mmc: Relax checking for switch errors after HS200 switch") > > > --- > > > drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++------ > > > 1 file changed, 23 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > > > index 09c688f..00adc2d 100644 > > > --- a/drivers/mmc/core/mmc.c > > > +++ b/drivers/mmc/core/mmc.c > > > @@ -1239,20 +1239,37 @@ 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, > > > val, card->ext_csd.generic_cmd6_time, 0, > > > true, false, true); > > > - if (err) > > > - goto out_err; > > > + /* > > > + * as we are on the way to do re-tune, so if the CMD6 got response CRC > > > + * error, do not treat it as error. > > > + */ > > > + if (err) { > > > + if (err == -EILSEQ) { > > > + /* > > > + * card will busy after sending out response and host > > > + * driver may not wait busy de-assert when get > > > + * response CRC error. so just wait enough time to > > > + * ensure card leave busy state. > > > + */ > > > + mmc_delay(card->ext_csd.generic_cmd6_time); > > > + pr_debug("%s: %s switch to HS got CRC error\n", > > > + mmc_hostname(host), __func__); > > > + } else { > > > + goto out_err; > > > + } > > > + } > > > > > > 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); > > > + > > > > What Adrian suggested was to not to move this part, but instead, only > > allow CRC errors from the CMD6 as above. > > > > I guess it didn't work for you? > > > It should work for me. another issue is CMD6 will be sent 3 times at max Alright, let's give it a try then. > err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); Yeah, that one have I thought about earlier as well. > > if the first CMD6 got response CRC error, then Host driver must wait > busy signal de-assert before send the next CMD6. > > So that it really make sense to issue CMD6(R1B) for 3 times ? if host > driver did not handle the first CMD6 response CRC error and send second > CMD6 directly, then this CMD6 will get timeout due to card still in busy > state. I fully agree with you, I don't think it makes sense to retry - not even for any CMD6, because of the busy signalling the card may raise afterwards. Perhaps we should start with a simple oneliner patch, giving zero instead of MMC_CMD_RETRIES to mmc_wait_for_cmd() and see how that plays. Then on top we can add the special error handling of the CRC errors, along the lines of what you suggest. Does it make sense? [...] Kind regards Uffe