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: 46400 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 05C4421597 for ; Fri, 27 Mar 2015 11:15:21 +0000 (UTC) Received: by wgfh4 with SMTP id h4sf10223120wgf.1 for ; Fri, 27 Mar 2015 04:15:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=iRCb1Uiv/tSV30av5VilZyq85U3NWp9T/2gUgxQ5k+E=; b=h4vzu7IMZsnNJo8cy65nsn7B9IycqViwmt/B0zSSvFJ4L64v9HBPCYkkO461STQcUw V3P/e5G6l0piAvYTtuNLT5XPeVfLKBv5kIzZWbn2iRLm+25eADBNz5gFLMm6cCUGLymm zQdDJEOXPa/KrBXlj0z63vvsXkrWTSikyOm6YE9PRkWHe/MdS3pRdfHt9Jwb4R/uVTt4 JLn0Sp1h1OvwzYhEvkZzLGL5It+1UO7hy82fcfNI/vf5h/w9XYR9cpw0A/JIs4D7d46w xgQDiOWbGbFSnQq3Fr2WdBFizRPPxYBnzfqeaXjivjNRyq9RIbEpHL4ZCVrlDCeczaTu KTdg== X-Gm-Message-State: ALoCoQnIXm12SZPsfOwkRN0K8+eqpfGoGDqsaghhskJSqEK8p7pLJta5Gl1knusyYbQjOow77Uei X-Received: by 10.112.180.74 with SMTP id dm10mr4578528lbc.11.1427454920330; Fri, 27 Mar 2015 04:15:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.101 with SMTP id z5ls379823laz.12.gmail; Fri, 27 Mar 2015 04:15:20 -0700 (PDT) X-Received: by 10.112.133.2 with SMTP id oy2mr17640740lbb.124.1427454920192; Fri, 27 Mar 2015 04:15:20 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id v7si1177674lbw.153.2015.03.27.04.15.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 04:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lboc7 with SMTP id c7so4208697lbo.1 for ; Fri, 27 Mar 2015 04:15:20 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr9088373lbh.56.1427454920068; Fri, 27 Mar 2015 04:15:20 -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.112.57.201 with SMTP id k9csp1187715lbq; Fri, 27 Mar 2015 04:15:19 -0700 (PDT) X-Received: by 10.112.38.72 with SMTP id e8mr10258651lbk.99.1427454919701; Fri, 27 Mar 2015 04:15:19 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id jr9si1195742lbc.39.2015.03.27.04.15.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 04:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbug6 with SMTP id ug6so61069310lbb.3 for ; Fri, 27 Mar 2015 04:15:19 -0700 (PDT) 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) 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: , 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 --- 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);