From patchwork Wed Nov 16 10:51:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 82477 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp82450qge; Wed, 16 Nov 2016 02:51:48 -0800 (PST) X-Received: by 10.55.143.199 with SMTP id r190mr2729862qkd.72.1479293508400; Wed, 16 Nov 2016 02:51:48 -0800 (PST) Return-Path: Received: from mail-qt0-x229.google.com (mail-qt0-x229.google.com. [2607:f8b0:400d:c0d::229]) by mx.google.com with ESMTPS id n3si6650472qta.222.2016.11.16.02.51.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 02:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:400d:c0d::229 as permitted sender) client-ip=2607:f8b0:400d:c0d::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:400d:c0d::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-qt0-x229.google.com with SMTP id c47so95941474qtc.2 for ; Wed, 16 Nov 2016 02:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DMpqEriBm0jJutm1vadTP9kNCtDSeuHx4n2XTWYKKUw=; b=FCMGHB55M14kSGMYxWDBn0/7M0VPzwWk/kjaGw9euyz7VtVBgpTN/4wjZ5jh+U766r nFwfP+fBt3MqBdNnmrUs8M2uAyekpPnWZHvG+F+qC3Ewh0POitHMYJRhVyxRLaQ5qfAF /amYUwFk82Nd56nelMoE439sj5rm3cnmSnMvc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DMpqEriBm0jJutm1vadTP9kNCtDSeuHx4n2XTWYKKUw=; b=MFVU0EM27znYMLIXOB3Onn1Y0YQgSnkj1UAbKvrMbg53CHO+Ipgl9qfHHv3hqs+edc WPd95gXlXoaN8a1A9mIJ9/BqGCsZk2dLarHKqrk6Wet2/U7FjS1IhkjpbtMmL1GGBe1k L+0b/AmBECY4vtU6vgP/15BnPUFpTHDVA51FJz9BWdVZc/QgAkml73kchJ9uBmokGt7C R3MC/7+Eg4z9/65ZnXsB4oTlJETzZGVOM5H97NWFlHzb15mFX16y0062SW5/vUJQeUOe 7JfJrDhss7of1gXXry9r3gEXjyHS2I/J1DkodxGj8F200LsuemnNtXatTIWhLayp/vGz hfLQ== X-Gm-Message-State: ABUngvcSAaF8bRJ+MgIs3M1f+4JZY1jhuoAeINnDePEW44rffw84Gtr5rtRrmQxfCEmfljkhb0U= X-Received: by 10.25.193.8 with SMTP id r8mr906791lff.148.1479293508039; Wed, 16 Nov 2016 02:51:48 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 34sm7711369lja.25.2016.11.16.02.51.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Nov 2016 02:51:46 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij , Chaotian Jing , Stephen Boyd , Michael Walle , Yong Mao , Shawn Lin Subject: [PATCH 9/9] mmc: core: Allow CMD13 polling when switch to HS400ES mode Date: Wed, 16 Nov 2016 11:51:21 +0100 Message-Id: <1479293481-20186-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479293481-20186-1-git-send-email-ulf.hansson@linaro.org> References: <1479293481-20186-1-git-send-email-ulf.hansson@linaro.org> In cases when the mmc host doesn't support HW busy detection, polling for busy by using CMD13 is beneficial. The reasons have already been explained in earlier change logs. Moreover, when polling with CMD13 during bus timing changes, we should retry instead of fail when we get CRC errors. Switching to HS400ES includes several steps, where each step changes the bus speed timing. Let's improve the behaviour during these sequences, by allowing CMD13 polling for each of the step. Let's also make sure the CMD13 polling becomes retried, while receiving a CRC error. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 24b9e72..b6f0035 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1227,31 +1227,24 @@ static int mmc_select_hs400es(struct mmc_card *card) goto out_err; /* Switch card to HS mode */ - err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS, - card->ext_csd.generic_cmd6_time, 0, - true, false, true); + err = mmc_select_hs(card); if (err) { pr_err("%s: switch to hs for hs400es failed, err:%d\n", mmc_hostname(host), err); goto out_err; } - mmc_set_timing(host, MMC_TIMING_MMC_HS); - err = mmc_switch_status(card); - if (err) - goto out_err; - mmc_set_clock(host, card->ext_csd.hs_max_dtr); - /* Switch card to DDR with strobe bit */ + /* Switch card to HS DDR with strobe bit */ val = EXT_CSD_DDR_BUS_WIDTH_8 | EXT_CSD_BUS_WIDTH_STROBE; - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_BUS_WIDTH, - val, - card->ext_csd.generic_cmd6_time); + err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_BUS_WIDTH, val, + card->ext_csd.generic_cmd6_time, + MMC_TIMING_MMC_DDR52, + true, true, true); if (err) { - pr_err("%s: switch to bus width for hs400es failed, err:%d\n", + pr_err("%s: switch to hs ddr for hs400es failed, err:%d\n", mmc_hostname(host), err); goto out_err; } @@ -1261,26 +1254,20 @@ static int mmc_select_hs400es(struct mmc_card *card) card->drive_strength << EXT_CSD_DRV_STR_SHIFT; err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, val, - card->ext_csd.generic_cmd6_time, 0, - true, false, true); + card->ext_csd.generic_cmd6_time, + MMC_TIMING_MMC_HS400, + true, true, true); if (err) { pr_err("%s: switch to hs400es failed, err:%d\n", mmc_hostname(host), err); goto out_err; } - /* Set host controller to HS400 timing and frequency */ - mmc_set_timing(host, MMC_TIMING_MMC_HS400); - /* Controller enable enhanced strobe function */ host->ios.enhanced_strobe = true; if (host->ops->hs400_enhanced_strobe) host->ops->hs400_enhanced_strobe(host, &host->ios); - err = mmc_switch_status(card); - if (err) - goto out_err; - return 0; out_err: