From patchwork Wed Jan 22 15:00:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 23534 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BFA65218CB for ; Wed, 22 Jan 2014 15:00:42 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id w17sf735477vbj.1 for ; Wed, 22 Jan 2014 07:00:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=gvX2Fvd0/JAgRYBsI7CsUVf+RfQIQsqnQLlP3VURciM=; b=WUiRvBp2P6khTPyvBA/MrHgCe141kv4atic3dcQtoY3Uh7PNNYqRBWwRyG7sOjla+M e8u0j8E4YhUfTr79G2TpXgT82vjvbrOgVo4tnkxXkL3F25bMSJCiSZyY3VbypvF8XMqS G3lRTly84IR4lgBV9SBYL4vhKLwS5HX9zfTaL3iBe4uTH565zQzWK2KnVsmSS+jwsDni JvG2vZXAQnvm5Wwnx30OGmvj4bpEO4voORazZIFfnEAPsfPWoN2/eLsHQdMZ9pKmxutI hJJpTTgkM6W7TEeP55Lo3AYxoOnVOhPHntXnuhUE0b12rjjmkWRnHI5x+7RuOXEcluwD V83g== X-Gm-Message-State: ALoCoQmMSlOnyKw/GezKVjAfcji3Cm4RW97qe6o1L11r0Yq5h0gyGnOMrV/2kWp6kpDwCZ+LTJZV X-Received: by 10.58.154.5 with SMTP id vk5mr739933veb.32.1390402841955; Wed, 22 Jan 2014 07:00:41 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.6 with SMTP id 6ls103525qgy.16.gmail; Wed, 22 Jan 2014 07:00:41 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr1238200vcv.28.1390402841842; Wed, 22 Jan 2014 07:00:41 -0800 (PST) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id uq6si4700498vcb.0.2014.01.22.07.00.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 07:00:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id m10so273325vbh.4 for ; Wed, 22 Jan 2014 07:00:41 -0800 (PST) X-Received: by 10.58.196.211 with SMTP id io19mr1197969vec.9.1390402841746; Wed, 22 Jan 2014 07:00:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp190328vcz; Wed, 22 Jan 2014 07:00:41 -0800 (PST) X-Received: by 10.180.81.38 with SMTP id w6mr3575927wix.27.1390402839810; Wed, 22 Jan 2014 07:00:39 -0800 (PST) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by mx.google.com with ESMTPS id lr14si7040306wic.62.2014.01.22.07.00.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 07:00:39 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.177 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.212.177; Received: by mail-wi0-f177.google.com with SMTP id m19so679307wiv.4 for ; Wed, 22 Jan 2014 07:00:39 -0800 (PST) X-Received: by 10.181.11.201 with SMTP id ek9mr3633025wid.54.1390402839328; Wed, 22 Jan 2014 07:00:39 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id dd3sm15401824wjb.9.2014.01.22.07.00.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 07:00:38 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Dong Aisheng , Stephen Warren , Vladimir Zapolskiy , Adrian Hunter , Ulf Hansson Subject: [PATCH 06/10] mmc: core: Respect host's max_busy_timeout when sending sleep cmd Date: Wed, 22 Jan 2014 16:00:20 +0100 Message-Id: <1390402824-9850-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1390402824-9850-1-git-send-email-ulf.hansson@linaro.org> References: <1390402824-9850-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When sending the sleep command for host drivers supporting MMC_CAP_WAIT_WHILE_BUSY, we need to confirm that max_busy_timeout is big enough comparing to the sleep timeout specified from card's EXT_CSD. If this isn't case, we use a R1 response instead of R1B and fallback to use a delay instead. Do note that a max_busy_timeout set to zero by the host, is interpreted as it can cope with whatever timeout the mmc core provides it with. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 897fdd1..32e1546 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1359,6 +1359,8 @@ static int mmc_sleep(struct mmc_host *host) { struct mmc_command cmd = {0}; struct mmc_card *card = host->card; + unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000); + unsigned int max_busy_timeout; int err; if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD) @@ -1372,7 +1374,18 @@ static int mmc_sleep(struct mmc_host *host) cmd.arg = card->rca << 16; cmd.arg |= 1 << 15; - cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; + /* We interpret unspecified timeouts as the host can cope with all. */ + max_busy_timeout = host->max_busy_timeout ? + host->max_busy_timeout : timeout_ms; + + if ((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && + (timeout_ms <= max_busy_timeout)) { + cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; + cmd.busy_timeout = timeout_ms; + } else { + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + } + err = mmc_wait_for_cmd(host, &cmd, 0); if (err) return err; @@ -1383,8 +1396,8 @@ static int mmc_sleep(struct mmc_host *host) * SEND_STATUS command to poll the status because that command (and most * others) is invalid while the card sleeps. */ - if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) - mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000)); + if (!cmd.busy_timeout) + mmc_delay(timeout_ms); return err; }