From patchwork Tue Feb 19 23:22:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 10820857 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D46AE6CB for ; Tue, 19 Feb 2019 23:28:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD6EC2C598 for ; Tue, 19 Feb 2019 23:28:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE58928D89; Tue, 19 Feb 2019 23:28:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_RP_RNBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D40F28D89 for ; Tue, 19 Feb 2019 23:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbfBSX2H (ORCPT ); Tue, 19 Feb 2019 18:28:07 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:63351 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbfBSX2F (ORCPT ); Tue, 19 Feb 2019 18:28:05 -0500 Received: from 79.184.254.15.ipv4.supernova.orange.pl (79.184.254.15) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id ab6004f183a040c8; Wed, 20 Feb 2019 00:28:03 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar Subject: [PATCH 1/4] cpufreq: Add kerneldoc comments for two core functions Date: Wed, 20 Feb 2019 00:22:51 +0100 Message-ID: <3161414.QiNJczLRHX@aspire.rjw.lan> In-Reply-To: <11668536.bBDtnvkYQE@aspire.rjw.lan> References: <11668536.bBDtnvkYQE@aspire.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki Add kerneldoc comments describing cpufreq_set_policy() and cpufreq_update_policy() as they have not been properly documented so far and they really need to be documented. While at it, fix white space around the cpufreq_set_policy() header. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -2218,12 +2218,25 @@ int cpufreq_get_policy(struct cpufreq_po } EXPORT_SYMBOL(cpufreq_get_policy); -/* - * policy : current policy. - * new_policy: policy to be set. +/** + * cpufreq_set_policy - Modify cpufreq policy parameters. + * @policy: Policy object to modify. + * @new_policy: New policy data. + * + * Pass @new_policy to the cpufreq driver's ->verify() callback, run the + * installed policy notifiers for it with the CPUFREQ_ADJUST value, pass it to + * the driver's ->verify() callback again and run the notifiers for it again + * with the CPUFREQ_NOTIFY value. Next, copy the min and max parameters + * of @new_policy to @policy and either invoke the driver's ->setpolicy() + * callback (if present) or carry out a governor update for @policy. That is, + * run the current governor's ->limits() callback (if the governor field in + * @new_policy points to the same object as the one in @policy) or replace the + * governor for @policy with the new one stored in @new_policy. + * + * The cpuinfo part of @policy is not updated by this function. */ static int cpufreq_set_policy(struct cpufreq_policy *policy, - struct cpufreq_policy *new_policy) + struct cpufreq_policy *new_policy) { struct cpufreq_governor *old_gov; int ret; @@ -2319,11 +2332,14 @@ static int cpufreq_set_policy(struct cpu } /** - * cpufreq_update_policy - re-evaluate an existing cpufreq policy - * @cpu: CPU which shall be re-evaluated + * cpufreq_update_policy - Re-evaluate an existing cpufreq policy. + * @cpu: CPU to re-evaluate the policy for. * - * Useful for policy notifiers which have different necessities - * at different times. + * Update the current frequency for the cpufreq policy of @cpu and use + * cpufreq_set_policy() to re-apply the min and max limits saved in the + * user_policy sub-structure of that policy, which triggers the evaluation + * of policy notifiers and the cpufreq driver's ->verify() callback for the + * policy in question, among other things. */ void cpufreq_update_policy(unsigned int cpu) { From patchwork Tue Feb 19 23:24:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 10820861 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F12941399 for ; Tue, 19 Feb 2019 23:28:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBC7728D89 for ; Tue, 19 Feb 2019 23:28:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D03EE2C5E4; Tue, 19 Feb 2019 23:28:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_RP_RNBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 850DC28D89 for ; Tue, 19 Feb 2019 23:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730037AbfBSX2V (ORCPT ); Tue, 19 Feb 2019 18:28:21 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:49637 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728409AbfBSX2E (ORCPT ); Tue, 19 Feb 2019 18:28:04 -0500 Received: from 79.184.254.15.ipv4.supernova.orange.pl (79.184.254.15) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id 2348b037af8b512f; Wed, 20 Feb 2019 00:28:02 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar Subject: [PATCH 2/4] cpufreq: Reorder and simplify cpufreq_update_policy() Date: Wed, 20 Feb 2019 00:24:25 +0100 Message-ID: <12123959.u3IqJzSc3J@aspire.rjw.lan> In-Reply-To: <11668536.bBDtnvkYQE@aspire.rjw.lan> References: <11668536.bBDtnvkYQE@aspire.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki In cpufreq_update_policy(), instead of updating new_policy.cur separately, which is kind of confusing, because cpufreq_set_policy() doesn't take that value into account directly anyway, make the copy of the existing policy after calling cpufreq_update_current_freq(). No intentional changes of behavior. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -2354,23 +2354,18 @@ void cpufreq_update_policy(unsigned int if (policy_is_inactive(policy)) goto unlock; - pr_debug("updating policy for CPU %u\n", cpu); - memcpy(&new_policy, policy, sizeof(*policy)); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; - /* * BIOS might change freq behind our back * -> ask driver for current freq and notify governors about a change */ - if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { - if (cpufreq_suspended) - goto unlock; + if (cpufreq_driver->get && !cpufreq_driver->setpolicy && + (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy)))) + goto unlock; - new_policy.cur = cpufreq_update_current_freq(policy); - if (WARN_ON(!new_policy.cur)) - goto unlock; - } + pr_debug("updating policy for CPU %u\n", cpu); + memcpy(&new_policy, policy, sizeof(*policy)); + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; cpufreq_set_policy(policy, &new_policy); From patchwork Tue Feb 19 23:25:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 10820863 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE2541399 for ; Tue, 19 Feb 2019 23:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8B8828D89 for ; Tue, 19 Feb 2019 23:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D10F2C5E4; Tue, 19 Feb 2019 23:28:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_RP_RNBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5752828D89 for ; Tue, 19 Feb 2019 23:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729861AbfBSX2E (ORCPT ); Tue, 19 Feb 2019 18:28:04 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:59927 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728084AbfBSX2E (ORCPT ); Tue, 19 Feb 2019 18:28:04 -0500 Received: from 79.184.254.15.ipv4.supernova.orange.pl (79.184.254.15) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id ea03d70d688a5585; Wed, 20 Feb 2019 00:28:02 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar Subject: [PATCH 3/4] cpufreq: Fix two debug messages in cpufreq_set_policy() Date: Wed, 20 Feb 2019 00:25:18 +0100 Message-ID: <2486777.RhoGZOM3Wg@aspire.rjw.lan> In-Reply-To: <11668536.bBDtnvkYQE@aspire.rjw.lan> References: <11668536.bBDtnvkYQE@aspire.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki Remove the redundant "cpufreq:" prefix from two debug messages in cpufreq_set_policy(). Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -2290,7 +2290,7 @@ static int cpufreq_set_policy(struct cpu } if (new_policy->governor == policy->governor) { - pr_debug("cpufreq: governor limits update\n"); + pr_debug("governor limits update\n"); cpufreq_governor_limits(policy); return 0; } @@ -2311,7 +2311,7 @@ static int cpufreq_set_policy(struct cpu if (!ret) { ret = cpufreq_start_governor(policy); if (!ret) { - pr_debug("cpufreq: governor change\n"); + pr_debug("governor change\n"); sched_cpufreq_governor_change(policy, old_gov); return 0; } From patchwork Tue Feb 19 23:26:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 10820855 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1361B6CB for ; Tue, 19 Feb 2019 23:28:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F284528D89 for ; Tue, 19 Feb 2019 23:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2E102C5E4; Tue, 19 Feb 2019 23:28:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_RP_RNBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 748A228D89 for ; Tue, 19 Feb 2019 23:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728217AbfBSX2D (ORCPT ); Tue, 19 Feb 2019 18:28:03 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:50642 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbfBSX2D (ORCPT ); Tue, 19 Feb 2019 18:28:03 -0500 Received: from 79.184.254.15.ipv4.supernova.orange.pl (79.184.254.15) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id dce9d06b5f8238e3; Wed, 20 Feb 2019 00:28:01 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar Subject: [PATCH 4/4] cpufreq: Pass updated policy to driver ->setpolicy() callback Date: Wed, 20 Feb 2019 00:26:30 +0100 Message-ID: <1982548.ex0OEcQ4PI@aspire.rjw.lan> In-Reply-To: <11668536.bBDtnvkYQE@aspire.rjw.lan> References: <11668536.bBDtnvkYQE@aspire.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki The invocation of the ->setpolicy() cpufreq driver callback should be equivalent to calling cpufreq_governor_limits(policy) for drivers with internal governors, but in fact it isn't so, because the temporary new_policy object is passed to it instead of the updated policy. That is a bit confusing, so make cpufreq_set_policy() pass the updated policy to the driver ->setpolicy() callback. No intentional changes of behavior. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -2286,7 +2286,7 @@ static int cpufreq_set_policy(struct cpu if (cpufreq_driver->setpolicy) { policy->policy = new_policy->policy; pr_debug("setting range\n"); - return cpufreq_driver->setpolicy(new_policy); + return cpufreq_driver->setpolicy(policy); } if (new_policy->governor == policy->governor) {