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: 3554961 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 223799F2E9 for ; Wed, 29 Jan 2014 22:38:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 406AA2017A for ; Wed, 29 Jan 2014 22:38:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52BC520170 for ; Wed, 29 Jan 2014 22:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbaA2Wi1 (ORCPT ); Wed, 29 Jan 2014 17:38:27 -0500 Received: from mail-la0-f48.google.com ([209.85.215.48]:57413 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751398AbaA2Wi1 (ORCPT ); Wed, 29 Jan 2014 17:38:27 -0500 Received: by mail-la0-f48.google.com with SMTP id mc6so1983390lab.35 for ; Wed, 29 Jan 2014 14:38:25 -0800 (PST) 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=1AzmDj7v1PM8yU+spZpUCKUWEkqLkFlLWVXJIKMnjR8=; b=DFOpf0aLE2xf59KUvSL78iT/BdDtNK5ZSQQRTma4iDOW+ebh0BxTq233QHfV4ltfUa naJy7nLzGjpqNMFU2VO84nwvlUoR8iHT7ZpPlsX3t9bfIQVoZFyiFxMcE8ZsBv7U30dw e6DvFXnt8uHN1Fyb1WUrT0664PGfFtOUQq27Yz4HzHPJgddJvOSbeTk0UD9vvbN6YOTD 9cl0L/1mJpmiz/JLcO4nAvwzIAkxF0yfqjo4pfco3cd3V1lxtgpx8kq66HpWe1Bgc0KX XL3HlrQp76XJ5tRkEbNcxX5Ov1xg6H70GLQpG9JT1bxmcw9I9Tbdp/a40A8KZ4ZW2qsg EIzA== X-Gm-Message-State: ALoCoQm64ggF4vQnIl9RZ4iidaWtqIMQ9T+1ccOUgn32NRx1qV3qGj19Ske/ADKOvb53gG+68jWy 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> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }