From patchwork Tue Apr 21 14:20:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Dorfman X-Patchwork-Id: 6249381 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C18DABF4A6 for ; Tue, 21 Apr 2015 14:21:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE8E2202F8 for ; Tue, 21 Apr 2015 14:21:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F13D202F0 for ; Tue, 21 Apr 2015 14:21:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751430AbbDUOVN (ORCPT ); Tue, 21 Apr 2015 10:21:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:48905 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbbDUOVM (ORCPT ); Tue, 21 Apr 2015 10:21:12 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 784CF1415BF; Tue, 21 Apr 2015 14:21:11 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 58B691415C1; Tue, 21 Apr 2015 14:21:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lx-kdorfman.mea.qualcomm.com (unknown [185.23.60.4]) (using TLSv1.1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: kdorfman@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 17A9C1415BF; Tue, 21 Apr 2015 14:21:08 +0000 (UTC) From: Konstantin Dorfman To: Ulf Hansson Cc: Chris Ball , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Konstantin Dorfman Subject: [RFC/PATCH] mmc: block: use block layer pm helpers for pm of card device Date: Tue, 21 Apr 2015 17:20:45 +0300 Message-Id: <1429626045-12847-1-git-send-email-kdorfman@codeaurora.org> X-Mailer: git-send-email 2.3.5 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use of block layer runtime PM helpers, implementing the block layer's request-based mechanism, simplifies data path of mmc core layer. It enables to remove synchronous call pm_runtime_get_sync() from mmc core data path. The idea and API is designed by Alan Stern and described here: http://marc.info/?l=linux-scsi&m=133727953625963&w=2 Signed-off-by: Konstantin Dorfman diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 1fa4c80..de5f85d 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2017,7 +2017,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) if (req && !mq->mqrq_prev->req) /* claim host only for the first request */ - mmc_get_card(card); + mmc_claim_host(card->host); ret = mmc_blk_part_switch(card, md); if (ret) { @@ -2060,7 +2060,7 @@ out: * In case sepecial request, there is no reentry to * the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ - mmc_put_card(card); + mmc_release_host(card->host); return ret; } diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index feea926..e12c828 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -213,6 +213,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, if (mmc_can_erase(card)) mmc_queue_setup_discard(mq->queue, card); + if (!subname) { + blk_pm_runtime_init(mq->queue, &card->dev); + card->q = mq->queue; + } + #ifdef CONFIG_MMC_BLOCK_BOUNCE if (host->max_segs == 1) { unsigned int bouncesz; diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index a301a78..bf3f919 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -1814,11 +1815,17 @@ static int mmc_runtime_suspend(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; + err = blk_pre_runtime_suspend(host->card->q); + if (err) + return err; + err = _mmc_suspend(host, true); if (err) pr_err("%s: error %d doing aggessive suspend\n", mmc_hostname(host), err); + blk_post_runtime_suspend(host->card->q, err); + return err; } @@ -1832,12 +1839,16 @@ static int mmc_runtime_resume(struct mmc_host *host) if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM | MMC_CAP_RUNTIME_RESUME))) return 0; + blk_pre_runtime_resume(host->card->q); + err = _mmc_resume(host); if (err) pr_err("%s: error %d doing aggessive resume\n", mmc_hostname(host), err); - return 0; + blk_post_runtime_resume(host->card->q, err); + + return err; } static int mmc_power_restore(struct mmc_host *host) diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index b0692d2..1f4810b 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -244,6 +244,7 @@ struct mmc_part { struct mmc_card { struct mmc_host *host; /* the host this device belongs to */ struct device dev; /* the device */ + struct request_queue *q; u32 ocr; /* the current OCR setting */ unsigned int rca; /* relative card address of device */ unsigned int type; /* card type */