From patchwork Fri Mar 1 12:47:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15197 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D82C423F7B for ; Fri, 1 Mar 2013 12:48:09 +0000 (UTC) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by fiordland.canonical.com (Postfix) with ESMTP id 471D1A18399 for ; Fri, 1 Mar 2013 12:48:09 +0000 (UTC) Received: by mail-ve0-f176.google.com with SMTP id cz10so2804304veb.21 for ; Fri, 01 Mar 2013 04:48:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=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:content-type:x-gm-message-state; bh=mObY1OJh8sU9j3CfFyZrMALeCyIQ7+skqJa2FfBffIg=; b=n0jtxivypOuW4bQGSqtVjQ0UBQWHsD3RdB52N+MZbRoRk6PAKAphm7y9TswxgE4N/H n4SNyS2S8CmABm47d6AMihdDcLWqzlC97yjn3oysoDtSpS8ag1uvW8+lrVaPoxKhY8OQ 3zxNaTnM2e3G1+WXSPNo8BuKUObh3RtyzBH0qyj5Nyr7oSq1kgTcxRXA1ss31vWCLa6t T+zuZI/214MD07flyY2oA5X1+WsCMEaxJo7OcFEBra4IgIRaD5Z59Hxv1pkACcBVpVz2 aWK7NAJ9sq/UzZarga02TJm7glXfGTA6a56q35/6Cshd5QwTd+NS2A4W1PMWj4sMRoiW w3Pg== X-Received: by 10.220.214.6 with SMTP id gy6mr3929220vcb.8.1362142088751; Fri, 01 Mar 2013 04:48:08 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp31050veb; Fri, 1 Mar 2013 04:48:08 -0800 (PST) X-Received: by 10.14.184.68 with SMTP id r44mr27489541eem.40.1362142086270; Fri, 01 Mar 2013 04:48:06 -0800 (PST) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com [207.126.144.139]) by mx.google.com with SMTP id r44si18260076eeo.261.2013.03.01.04.48.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 01 Mar 2013 04:48:06 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKUTCjgc23YYHNWHl8/PH90cT+4Ys6pM6E@postini.com; Fri, 01 Mar 2013 12:48:06 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 163D81EC; Fri, 1 Mar 2013 12:47:33 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B790D4DF0; Fri, 1 Mar 2013 12:47:32 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 8EBD3A8072; Fri, 1 Mar 2013 13:47:27 +0100 (CET) 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.83.0; Fri, 1 Mar 2013 13:47:32 +0100 From: Ulf Hansson To: , Chris Ball Cc: Johan Rudholm , Ulf Hansson Subject: [PATCH 3/3] mmc: block: Enable runtime pm for mmc blkdevice Date: Fri, 1 Mar 2013 13:47:15 +0100 Message-ID: <1362142035-8403-4-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1362142035-8403-1-git-send-email-ulf.hansson@stericsson.com> References: <1362142035-8403-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQn6qLBskLj56395AugyI25FJ81PDMIsS2nhKXpk1o9/cpaxCohYFr4q3RGt1Bi+3/4ZFn30 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 --- 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 5bab73b..89d1c39 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) { @@ -1932,9 +1941,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) } out: - if (!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) + if (!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) { /* release host only when there are no more requests */ mmc_release_host(card->host); + pm_runtime_mark_last_busy(&card->dev); + pm_runtime_put_autosuspend(&card->dev); + } + return ret; } @@ -2331,6 +2344,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: @@ -2344,9 +2363,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); } @@ -2358,6 +2380,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); @@ -2381,6 +2404,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; }