From patchwork Mon Aug 17 08:34:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 507905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 24014140082; Mon, 17 Aug 2015 18:35:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=fSBWbU5a; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ZRFsh-0006U4-EJ; Mon, 17 Aug 2015 08:34:59 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ZRFsU-0006RT-MD for kernel-team@lists.ubuntu.com; Mon, 17 Aug 2015 08:34:46 +0000 Received: by pawq9 with SMTP id q9so6157211paw.3 for ; Mon, 17 Aug 2015 01:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=yoF6rmbQ0YUxw7rPHAKZ8Wk3/IjQyevoiI7sXlUv+ys=; b=fSBWbU5aNh2gEkO6iREWEnaqawPEjKX0KSi33LinCwn3tlur+K8KA/Jf+irIH1Ro5P zo92lh5W6hSqhX5oBb2vN73A6lFWgwd1z0iMTDdTeu/ceZts0PzQ6nuXEeAMNDsA3jgq c5zBie2XnhGliaw90B306FW+sGb/SFoBqqFEF9XgrSejegE20VN1uR7RB8HgdFlmX3GQ liLMH5bdBfgVfSs/VtKJ9BK7Be52gNnuXrNBZSg3jpt4b9lR1pJXWm5XdU+U1ArG0C/p 34+9yDs+pHqdaqYLIkHlrpYeWSbXMUHnsszaioCgzbXrRv5J5QiLjUHKoxhbsTRK6A+i mgig== X-Received: by 10.66.100.233 with SMTP id fb9mr554228pab.128.1439800486084; Mon, 17 Aug 2015 01:34:46 -0700 (PDT) Received: from localhost ([175.41.48.77]) by smtp.gmail.com with ESMTPSA id zn9sm13807154pac.11.2015.08.17.01.34.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2015 01:34:45 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2] mmc: core: Enable runtime PM management of host devices Date: Mon, 17 Aug 2015 04:34:39 -0400 Message-Id: <1439800479-7928-3-git-send-email-acelan.kao@canonical.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439800479-7928-1-git-send-email-acelan.kao@canonical.com> References: <1439800479-7928-1-git-send-email-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Ulf Hansson 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 (cherry picked from commit 9250aea76bfcbf4c2a7868e5566281bf2bb7af27) Signed-off-by: AceLan Kao Reviewed-by: Wen-chien Jesse Sung --- 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 ad234b9..d06a5ea 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -888,6 +888,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(); @@ -907,13 +908,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); /** @@ -938,6 +944,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);