From patchwork Thu Apr 4 16:41:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15934 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 40863277E2 for ; Thu, 4 Apr 2013 16:42:12 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id jz10sf4504713veb.4 for ; Thu, 04 Apr 2013 09:42:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=vEPGihFF6CCmYqo8XH/ekqCUs2Exo43P8rvX3n72bjQ=; b=bXIL1VfC7NsdMqpwrumzKgsFPODml4U1J6zUrmCsu6+bffXFXonduecBDCt0YN9p9o k27Eyztq6rl21mUY57kzudMLCshAbV5irqvQRRwH0CdLjp+ULsu9mh1hgsKvFBne4ULy 7Tv350aaZv5QkfFnir8VBuboTv07TYQzcVGTwXyswR4qVshHsgoO3oRwlsGyd2J6NMXa BDNmP7ekSYpnUbalxTLGBAece6tOwv7/UGoaeeM6baBY48YpGV/ZCEs9HCaF8a6BiJ6M Xr+3OhruxgMu+EbQ7xqTi1snOYdm+01sFqXOov5Em/JSB6bSzfW4z9eMrugS7I2N7dI/ bTPQ== X-Received: by 10.236.102.200 with SMTP id d48mr3043815yhg.3.1365093726361; Thu, 04 Apr 2013 09:42:06 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.42.38 with SMTP id k6ls517887qel.4.gmail; Thu, 04 Apr 2013 09:42:06 -0700 (PDT) X-Received: by 10.220.143.196 with SMTP id w4mr5254642vcu.62.1365093726240; Thu, 04 Apr 2013 09:42:06 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id os3si8625780vcb.69.2013.04.04.09.42.06 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 09:42:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.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.220.177; Received: by mail-vc0-f177.google.com with SMTP id ia10so2487100vcb.22 for ; Thu, 04 Apr 2013 09:42:06 -0700 (PDT) X-Received: by 10.59.4.101 with SMTP id cd5mr5433534ved.14.1365093725813; Thu, 04 Apr 2013 09:42:05 -0700 (PDT) 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.58.85.136 with SMTP id h8csp223719vez; Thu, 4 Apr 2013 09:42:04 -0700 (PDT) X-Received: by 10.15.22.197 with SMTP id f45mr12027637eeu.46.1365093724411; Thu, 04 Apr 2013 09:42:04 -0700 (PDT) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com [207.126.144.139]) by mx.google.com with SMTP id z49si13069262eep.16.2013.04.04.09.42.01 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Apr 2013 09:42:04 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.139; Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKUV2tV4JmTLlQbP6i08pu5yvb+5iR8wGD@postini.com; Thu, 04 Apr 2013 16:42:04 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 9285744; Thu, 4 Apr 2013 16:40:56 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id D6C594D; Thu, 4 Apr 2013 10:04:04 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 2583124C07C; Thu, 4 Apr 2013 18:41:40 +0200 (CEST) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Thu, 4 Apr 2013 18:41:48 +0200 From: Ulf Hansson To: , Chris Ball Cc: Ulf Hansson Subject: [PATCH V2 2/2] mmc: block: Enable runtime pm for mmc blkdevice Date: Thu, 4 Apr 2013 18:41:38 +0200 Message-ID: <1365093698-6367-3-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1365093698-6367-1-git-send-email-ulf.hansson@stericsson.com> References: <1365093698-6367-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlaas5SwyizcFH16Wt1XLfgLhRlm9N0gplEUrGQEpWOS1cFxHSzaCHARU0RzWNl2mkx2FPq X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.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: , From: Ulf Hansson Once the mmc blkdevice is being probed, runtime pm will be enabled. By using runtime autosuspend, the power save operations can be done when request inactivity occurs for a certain time. Right now the selected timeout value is set to 3 s. Moreover, when the blk device is being suspended, we make sure the device will be runtime resumed. The reason for doing this is that we what the host suspend sequence to be unaware of any runtime power save operations, so it can just handle the suspend as the device is fully powerered from a runtime perspective. This patch is preparing to make it possible to move BKOPS handling into the runtime callbacks for the mmc bus_ops. Thus IDLE BKOPS can be accomplished. Signed-off-by: Ulf Hansson Acked-by: Maya Erez Acked-by: Arnd Bergmann Acked-by: Kevin Liu --- drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index e12a03c..536331a 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -222,6 +223,7 @@ static ssize_t power_ro_lock_store(struct device *dev, md = mmc_blk_get(dev_to_disk(dev)); card = md->queue.card; + pm_runtime_get_sync(&card->dev); mmc_claim_host(card->host); ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, @@ -234,6 +236,8 @@ static ssize_t power_ro_lock_store(struct device *dev, card->ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN; mmc_release_host(card->host); + pm_runtime_mark_last_busy(&card->dev); + pm_runtime_put_autosuspend(&card->dev); if (!ret) { pr_info("%s: Locking boot partition ro until next power on\n", @@ -492,6 +496,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, mrq.cmd = &cmd; + pm_runtime_get_sync(&card->dev); mmc_claim_host(card->host); err = mmc_blk_part_switch(card, md); @@ -560,6 +565,8 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, cmd_rel_host: mmc_release_host(card->host); + pm_runtime_mark_last_busy(&card->dev); + pm_runtime_put_autosuspend(&card->dev); cmd_done: mmc_blk_put(md); @@ -1894,9 +1901,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) struct mmc_host *host = card->host; unsigned long flags; - if (req && !mq->mqrq_prev->req) + if (req && !mq->mqrq_prev->req) { + pm_runtime_get_sync(&card->dev); /* claim host only for the first request */ mmc_claim_host(card->host); + } ret = mmc_blk_part_switch(card, md); if (ret) { @@ -1933,7 +1942,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out: if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || - (req && (req->cmd_flags & MMC_REQ_SPECIAL_MASK))) + (req && (req->cmd_flags & MMC_REQ_SPECIAL_MASK))) { /* * Release host when there are no more requests * and after special request(discard, flush) is done. @@ -1941,6 +1950,10 @@ out: * the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_release_host(card->host); + pm_runtime_mark_last_busy(&card->dev); + pm_runtime_put_autosuspend(&card->dev); + } + return ret; } @@ -2337,6 +2350,12 @@ static int mmc_blk_probe(struct mmc_card *card) if (mmc_add_disk(part_md)) goto out; } + + pm_runtime_set_active(&card->dev); + pm_runtime_set_autosuspend_delay(&card->dev, 3000); + pm_runtime_use_autosuspend(&card->dev); + pm_runtime_enable(&card->dev); + return 0; out: @@ -2350,9 +2369,12 @@ static void mmc_blk_remove(struct mmc_card *card) struct mmc_blk_data *md = mmc_get_drvdata(card); mmc_blk_remove_parts(card, md); + pm_runtime_get_sync(&card->dev); mmc_claim_host(card->host); mmc_blk_part_switch(card, md); mmc_release_host(card->host); + pm_runtime_disable(&card->dev); + pm_runtime_put_noidle(&card->dev); mmc_blk_remove_req(md); mmc_set_drvdata(card, NULL); } @@ -2364,6 +2386,7 @@ static int mmc_blk_suspend(struct mmc_card *card) struct mmc_blk_data *md = mmc_get_drvdata(card); if (md) { + pm_runtime_get_sync(&card->dev); mmc_queue_suspend(&md->queue); list_for_each_entry(part_md, &md->part, part) { mmc_queue_suspend(&part_md->queue); @@ -2387,6 +2410,7 @@ static int mmc_blk_resume(struct mmc_card *card) list_for_each_entry(part_md, &md->part, part) { mmc_queue_resume(&part_md->queue); } + pm_runtime_put(&card->dev); } return 0; }