From patchwork Mon Dec 6 12:19:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gao, Yunpeng" X-Patchwork-Id: 378032 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB6ClBiD029246 for ; Mon, 6 Dec 2010 12:47:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751254Ab0LFMrK (ORCPT ); Mon, 6 Dec 2010 07:47:10 -0500 Received: from mga09.intel.com ([134.134.136.24]:32927 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751032Ab0LFMrJ (ORCPT ); Mon, 6 Dec 2010 07:47:09 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 06 Dec 2010 04:47:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,305,1288594800"; d="scan'208,223";a="684318182" Received: from unknown (HELO intel.com) ([172.16.118.85]) by orsmga001.jf.intel.com with ESMTP; 06 Dec 2010 04:47:08 -0800 Date: Mon, 6 Dec 2010 20:19:42 +0800 From: Yunpeng Gao To: linux-mmc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3]mmc: enable runtime PM support for block driver Message-ID: <20101206121941.GB30654@intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Dec 2010 12:47:12 +0000 (UTC) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 217f820..1bd707a 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -560,14 +561,24 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) { + struct mmc_blk_data *md = mq->data; + struct mmc_card *card = md->queue.card; + int ret; + + pm_runtime_get_sync(&card->dev); + if (req->cmd_flags & REQ_DISCARD) { if (req->cmd_flags & REQ_SECURE) - return mmc_blk_issue_secdiscard_rq(mq, req); + ret = mmc_blk_issue_secdiscard_rq(mq, req); else - return mmc_blk_issue_discard_rq(mq, req); + ret = mmc_blk_issue_discard_rq(mq, req); } else { - return mmc_blk_issue_rw_rq(mq, req); + ret = mmc_blk_issue_rw_rq(mq, req); } + + pm_runtime_put_autosuspend(&card->dev); + + return ret; } static inline int mmc_blk_readonly(struct mmc_card *card) @@ -709,6 +720,14 @@ static int mmc_blk_probe(struct mmc_card *card) mmc_set_drvdata(card, md); add_disk(md->disk); + + /* Indicate to runtime PM core that our device is active */ + pm_runtime_set_active(&card->dev); + pm_runtime_enable(&card->dev); + + /* Set its autosuspend_delay to 100ms */ + pm_runtime_set_autosuspend_delay(&card->dev, 100); + return 0; out: @@ -732,6 +751,8 @@ static void mmc_blk_remove(struct mmc_card *card) mmc_blk_put(md); } mmc_set_drvdata(card, NULL); + + pm_runtime_disable(&card->dev); } #ifdef CONFIG_PM