From patchwork Fri Mar 27 11:15:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 6105561 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5BC5A9F350 for ; Fri, 27 Mar 2015 11:15:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 617CF203ED for ; Fri, 27 Mar 2015 11:15:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65F69203B7 for ; Fri, 27 Mar 2015 11:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752332AbbC0LPV (ORCPT ); Fri, 27 Mar 2015 07:15:21 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:35897 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbbC0LPU (ORCPT ); Fri, 27 Mar 2015 07:15:20 -0400 Received: by labe2 with SMTP id e2so67548891lab.3 for ; Fri, 27 Mar 2015 04:15:19 -0700 (PDT) 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; bh=iRCb1Uiv/tSV30av5VilZyq85U3NWp9T/2gUgxQ5k+E=; b=mCARdvYeM5CG6Rf4YG1L12CPGzZWH9Ea7zQvCYow3OsdCVIFxqCgQGc9gDzXKvEpgZ uGzuf5SrTXad9B0yIx1NMvMD5tBJHyInObi68oN7XA232RFIhsNHxgVeP9wHaVoqU+xm jE3a+2X6nZYhFA29is2f9SaOYPAbLmn5A+S7xx8CBmW5p+tACiJvSvLPRhRuC5bgmn9l rSyD+eupmh2PDL+0m71jA8n5mZludQDh8noLLa8PilGYCs/V99hkjz+mFRgzNpHv2Qlh rWSF+d0K+m+cz2DwLIoowQgSYb5GUzfkSWkB5gVz06NCDy1H2BHilh6W8jshf0eqMsFn TGAg== X-Gm-Message-State: ALoCoQlZ8mKcLb/jXEBrZnT0VYbPXh+qYMr4LHICrHQneyyg+jp7mY+uF3RhCfSRYWxmu9aV96bM X-Received: by 10.152.6.34 with SMTP id x2mr16791742lax.47.1427454919369; Fri, 27 Mar 2015 04:15:19 -0700 (PDT) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id g19sm290287lbh.13.2015.03.27.04.15.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Mar 2015 04:15:18 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: NeilBrown , Adrian Hunter Subject: [PATCH] mmc: core: Enable runtime PM management of host devices Date: Fri, 27 Mar 2015 12:15:15 +0100 Message-Id: <1427454915-12893-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently those host drivers which have deployed runtime PM, deals with the runtime PM reference counting entirely by themselves. Since host drivers don't know when the core will send the next request through some of the host_ops callbacks, they need to handle runtime PM get/put between each an every request. In quite many cases this has some negative effects, since it leads to a high frequency of scheduled runtime PM suspend operations. That due to the runtime PM reference count will normally reach zero in-between every request. We can decrease that frequency, by enabling the core to deal with runtime PM reference counting of the host device. Since the core often knows that it will send a seqeunce of requests, it makes sense for it to keep a runtime PM reference count during these periods. More exactly, let's increase the runtime PM reference count by invoking pm_runtime_get_sync() from __mmc_claim_host(). Restore that action by invoking pm_runtime_mark_last_busy() and pm_runtime_put_autosuspend() in mmc_release_host(). In this way a runtime PM reference count will be kept during the complete cycle of a claim -> release host. Signed-off-by: Ulf Hansson Acked-by: Adrian Hunter Acked-by: Konstantin Dorfman --- drivers/mmc/core/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 709ada9..c296bc0 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -897,6 +897,7 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) DECLARE_WAITQUEUE(wait, current); unsigned long flags; int stop; + bool pm = false; might_sleep(); @@ -916,13 +917,18 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) host->claimed = 1; host->claimer = current; host->claim_cnt += 1; + if (host->claim_cnt == 1) + pm = true; } else wake_up(&host->wq); spin_unlock_irqrestore(&host->lock, flags); remove_wait_queue(&host->wq, &wait); + + if (pm) + pm_runtime_get_sync(mmc_dev(host)); + return stop; } - EXPORT_SYMBOL(__mmc_claim_host); /** @@ -947,6 +953,8 @@ void mmc_release_host(struct mmc_host *host) host->claimer = NULL; spin_unlock_irqrestore(&host->lock, flags); wake_up(&host->wq); + pm_runtime_mark_last_busy(mmc_dev(host)); + pm_runtime_put_autosuspend(mmc_dev(host)); } } EXPORT_SYMBOL(mmc_release_host);