From patchwork Wed Nov 16 10:51:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 82473 Delivered-To: patches@linaro.org Received: by 10.140.97.165 with SMTP id m34csp82399qge; Wed, 16 Nov 2016 02:51:40 -0800 (PST) X-Received: by 10.55.16.147 with SMTP id 19mr2354915qkq.255.1479293500923; Wed, 16 Nov 2016 02:51:40 -0800 (PST) Return-Path: Received: from mail-qt0-x22c.google.com (mail-qt0-x22c.google.com. [2607:f8b0:400d:c0d::22c]) by mx.google.com with ESMTPS id z47si6661391qtb.204.2016.11.16.02.51.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 02:51:40 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2607:f8b0:400d:c0d::22c as permitted sender) client-ip=2607:f8b0:400d:c0d::22c; 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::22c as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-qt0-x22c.google.com with SMTP id w33so95825599qtc.3 for ; Wed, 16 Nov 2016 02:51:40 -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=09ikq94kowsggwzbH/Yi7rGLFSSD68O9m68+GPYPQtQ=; b=E1wWW4lmFvRhodw77w3cjeGWK4iG/DrUuVcdeoj+vh5LuTl9Qftukeoni38VJGmA3Z A+DDLRt7Aih4WQ/H3GPtWdM48uAMwbSG0MWKynR+CrOYrPSBVmnx8JRksQ3nQREj0jZh OJdVwpZKD5BZlc5L0pHkzzzfN3AXDi0bWWmj0= 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=09ikq94kowsggwzbH/Yi7rGLFSSD68O9m68+GPYPQtQ=; b=MPGNOdqs1mcllWrr6ogCWnf6cy0WaU3AEaunaojyTe9r5Gdbi6BP7Su0x17PpvwE8p WXkS1xlxeJNh5E1epPjeZf3uDH5u0RC6tFCKdPVFlzBqWxw6ssJCDzVreA/08W5jV8aZ yw1frLg8kmuhatBJcCakWVOpEZNwYstjv27N1G0InSGwE9da8t8LAPJw2hcXDA+K89is CbwNU2ANc+O7KSnhngsrqWi6gnLF9AvUhyzn+exBKEmF4YXVDpRCxHiZ1oDfQxJ5SgWm 3x+VbKiWh6GzTxjCR4uUfN9izZ86Kvqq3BE/PyGBMiOI7elC6paVKXlI92fx5OQgx6P/ bWpA== X-Gm-Message-State: ABUngvehZwIByuo4hYijVb0GTMdwnbejO2cWmLhgaD2jHoE27DzzLgrRMreHb+rhLspBFMEbuwA= X-Received: by 10.25.153.75 with SMTP id b72mr868680lfe.85.1479293500519; Wed, 16 Nov 2016 02:51:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Nov 2016 02:51:39 -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 5/9] mmc: core: Allow CMD13 polling when switching to HS mode for mmc Date: Wed, 16 Nov 2016 11:51:17 +0100 Message-Id: <1479293481-20186-6-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 a card being busy by using CMD13 is beneficial. That is because, instead of waiting a fixed amount of time, 500ms or the generic CMD6 time from EXT_CSD, we find out a lot sooner when the card stops signaling busy. This leads to a significant decreased total initialization time for the mmc card. However, to allow polling with CMD13 during a bus timing change operation, such as switching to HS mode, we first need to update the mmc host's bus timing before starting to poll. Deal with that, simply by providing MMC_TIMING_MMC_HS as the timing parameter to __mmc_switch() from mmc_select_hs(). By telling __mmc_switch() to allow polling with CMD13, also makes it validate the CMD6 status, thus we can remove the corresponding checks. When switching to HS400ES, the mmc_select_hs() function is called in one of the intermediate steps. To still prevent CMD13 polling for HS400ES, let's call the __mmc_switch() function in this path as it enables us to keep using the existing method. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index cb1cf4e..15dd51c 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1012,13 +1012,8 @@ static int mmc_select_hs(struct mmc_card *card) 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); - if (!err) { - mmc_set_timing(card->host, MMC_TIMING_MMC_HS); - err = mmc_switch_status(card); - } - + card->ext_csd.generic_cmd6_time, MMC_TIMING_MMC_HS, + true, true, true); if (err) pr_warn("%s: switch to high-speed failed, err:%d\n", mmc_hostname(card->host), err); @@ -1268,16 +1263,23 @@ static int mmc_select_hs400es(struct mmc_card *card) goto out_err; /* Switch card to HS mode */ - err = mmc_select_hs(card); - if (err) + 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); + if (err) { + pr_err("%s: switch to hs for hs400es failed, err:%d\n", + mmc_hostname(host), err); goto out_err; + } - mmc_set_clock(host, card->ext_csd.hs_max_dtr); - + 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 */ val = EXT_CSD_DDR_BUS_WIDTH_8 | EXT_CSD_BUS_WIDTH_STROBE; err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,