Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp104962imj; Wed, 13 Feb 2019 05:29:15 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib3lzyE5mGxyf0HmfkUhvTJ4aeoBk3vVPWOVlg2oKRvs2tA6/SU/irPFqHTZivxuZn2SUn2 X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr541937plo.67.1550064555574; Wed, 13 Feb 2019 05:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550064555; cv=none; d=google.com; s=arc-20160816; b=k1i4tesZsFSTuYfzpn0CV4WwKTwnRRZ441Tm2DwlDR4857aYNdLtWgz/6MWQoQ56RK Nuqe6xVRGJpiH6LbNjO+mB6TbFtg3F9BZvwDH1P9FOnS14Ubnc8YAZQxSRpNnMAsacLU U1traXd4cIMB2AvRp7WyFmPu1pRYnHy+5DUdYtxHskreANq6yKX2ZS+P1ye4RjhJ2OmW /rcmvyAKvmTSjcoFGuulVsLZO60hu0Gk+p31MohqyYVY41YOcv8LqdW4v2YCzWS/0Ztj jG+XMY9VV/+RwTk6hxA6k/RuYqwcp04317qPZwD7XNo7/UmbEkl+fViQmn9zWrAW+cmL ynnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=sz3QJ+FSht5Jbecmry7KrA05p8G5DGOLUhubsa8jgSs=; b=eLs+BtMNzFW/7p6Nz8qFXdhhsjiBruTMcEO5Jz6eLLVqQxKZGtTgA+7hAxeGVF1GLB KpdPHfnlX+hmZ0g9kDbVmf2r6I1U7rRw9vUvehdBPn/vhrG9/lhL1E/aSRn2+Lnc4svB pk1T8kV4I+/dFSngFwL8pFeT78RuBH2DRHy09j3vAi5dQcg37iUre6IgNxZwvh7F4C0W uxxeXFJ8chMArzDIDJ55s5Rs7tmSiD7o6WG7pN/N+zTPyVtYc29XkEymY2Ey3Dgbf4ZD 64zmHNUoewLJJSPfllhHaIC50lM0DQ0osKXAuoEzswcIVKKAiv9xqAy2VTdNEruzVN0o e5TQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c139si3079658pfb.281.2019.02.13.05.28.49; Wed, 13 Feb 2019 05:29:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391281AbfBMJHH (ORCPT + 99 others); Wed, 13 Feb 2019 04:07:07 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:5247 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727954AbfBMJHH (ORCPT ); Wed, 13 Feb 2019 04:07:07 -0500 X-UUID: 7bcd46a362e948fb83ece4cec05995db-20190213 X-UUID: 7bcd46a362e948fb83ece4cec05995db-20190213 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2061458422; Wed, 13 Feb 2019 17:06:59 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 13 Feb 2019 17:06:56 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 13 Feb 2019 17:06:56 +0800 From: Chaotian Jing To: Ulf Hansson CC: Matthias Brugger , Shawn Lin , Simon Horman , Chaotian Jing , Kyle Roeschley , Hongjie Fang , Harish Jenny K N , , , , , , Adrian Hunter Subject: [PATCH v1] mmc: mmc: Fix HS setting in mmc_hs400_to_hs200() Date: Wed, 13 Feb 2019 17:06:52 +0800 Message-ID: <1550048812-29068-1-git-send-email-chaotian.jing@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 68645DB28F340A99640835A4B7B41D19430DCE141EC0F639AD3442A3CDA9D7072000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + err = mmc_switch_status(card); if (err) goto out_err; -- 1.8.1.1.dirty