From patchwork Wed Jan 29 22:37:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 23905 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5B6A820300 for ; Wed, 29 Jan 2014 22:38:29 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hu8sf5475908vcb.2 for ; Wed, 29 Jan 2014 14:38:28 -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=1AzmDj7v1PM8yU+spZpUCKUWEkqLkFlLWVXJIKMnjR8=; b=ZT8ZePpxjNVzXxfyvcnIOEbLRjx0IFgeaqWY5e3JdE/xwHaR+SOVrQ3sPw3j7kFF6A mS+prloQukTqh0cUiDydNdoG8Ust/GJddKL9WMk5u50LvpA9u6k7F8Ewg7Gom5yzLgLN TY9duib2W/fRD3vWVARkPGYdGXw8icb2xeJ7RaO6Fv3H5u6LGoVkAd5AvJQir4W1uNn2 Tr+v/JqahhO2rShS9HHY/MNv9g1BgYBJ6w+vmDOEHt0gkvR0U4AEZ4vJB4Fzp9wEuvgf mEIKqF3EOoTctG2fe5EZYcbWCy407Drxlbf3HkVb+PGMFbGiK9ubAR/jqzWyvnvoVpAG 49RA== X-Gm-Message-State: ALoCoQlTmPI2/XK1Z99hl62N+ZDe9ehIxJZNwsa5J5/eAbGkflSc0yD1P4t3pYG2anSdMyxg7VTz X-Received: by 10.52.107.162 with SMTP id hd2mr3431797vdb.7.1391035108589; Wed, 29 Jan 2014 14:38:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.8 with SMTP id 8ls323614qgk.51.gmail; Wed, 29 Jan 2014 14:38:28 -0800 (PST) X-Received: by 10.220.109.1 with SMTP id h1mr8735699vcp.20.1391035108498; Wed, 29 Jan 2014 14:38:28 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id i3si1239976vcp.127.2014.01.29.14.38.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 14:38:28 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id jz11so1633348veb.22 for ; Wed, 29 Jan 2014 14:38:28 -0800 (PST) X-Received: by 10.220.139.136 with SMTP id e8mr3922vcu.34.1391035108163; Wed, 29 Jan 2014 14:38:28 -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 u4csp152469vcz; Wed, 29 Jan 2014 14:38:27 -0800 (PST) X-Received: by 10.112.219.134 with SMTP id po6mr3004519lbc.36.1391035106394; Wed, 29 Jan 2014 14:38:26 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by mx.google.com with ESMTPS id pc5si1962870lbb.150.2014.01.29.14.38.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 14:38:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.172 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id c11so1983140lbj.3 for ; Wed, 29 Jan 2014 14:38:25 -0800 (PST) X-Received: by 10.152.229.225 with SMTP id st1mr7206056lac.2.1391035105812; Wed, 29 Jan 2014 14:38:25 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id wt2sm3998221lbb.2.2014.01.29.14.38.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 14:38:25 -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 07/13] mmc: core: Respect host's max_busy_timeout when sending sleep cmd Date: Wed, 29 Jan 2014 23:37:59 +0100 Message-Id: <1391035085-2747-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391035085-2747-1-git-send-email-ulf.hansson@linaro.org> References: <1391035085-2747-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.128.177 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..d641590 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1359,6 +1359,7 @@ 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); int err; if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD) @@ -1372,7 +1373,19 @@ 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; + /* + * If the max_busy_timeout of the host is specified, validate it against + * the sleep cmd timeout. A failure means we need to prevent the host + * from doing hw busy detection, which is done by converting to a R1 + * response instead of a R1B. + */ + if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) { + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + } else { + cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; + cmd.busy_timeout = timeout_ms; + } + 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 || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) + mmc_delay(timeout_ms); return err; }