From patchwork Tue Feb 25 08:50:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 25241 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 36FCD20558 for ; Tue, 25 Feb 2014 08:50:26 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id jw12sf138596veb.7 for ; Tue, 25 Feb 2014 00:50:26 -0800 (PST) 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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=lsMs5f6Mk9yjrYxNVpdm0Br05jJfpCmDOU+JFNazYQI=; b=bpweukVDUq8hjnWH3dIOA0ahNkQYeHGG8BtUt/mOw/kgx8H/I5kWu3iJ8wxPtS7dPf lxWk+GxM4dGyi2reTozXbh6prW8zwk6cTxxQ/uNgC0rObZbsNIsJmZVcKcCQJCLtwRXi 6Anz3vD9a9Mh0EQZ5vbxmMwBvlVWMn3DqBbyIgy26lpLjTj07mrGnZZxm1ao8lwsDWZ8 +G+/KQ+8WrcNrpIEvGsLv71JiXAMpMP6F0CglHb8rj60knO0Lu721Sr3i5EvJxr+8TuF 8RM7a/F8B7948fX6V5va5DmI8b63Bl/nYPqWlmWaEToAycB/5SJNOHmU18P2FaJy6bE3 8WbA== X-Gm-Message-State: ALoCoQk71edsrW6CA1DAwEhgvrwvLEKy0OXJozayRMJdMxVQk+HsPmd8A/Rq/IeyKhV54HVS+sUB X-Received: by 10.236.134.174 with SMTP id s34mr1440029yhi.32.1393318225990; Tue, 25 Feb 2014 00:50:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.103 with SMTP id k94ls2301091qgd.39.gmail; Tue, 25 Feb 2014 00:50:25 -0800 (PST) X-Received: by 10.220.182.137 with SMTP id cc9mr114046vcb.62.1393318225300; Tue, 25 Feb 2014 00:50:25 -0800 (PST) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id t20si6644164vek.79.2014.02.25.00.50.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:50:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jx11so84954veb.3 for ; Tue, 25 Feb 2014 00:50:25 -0800 (PST) X-Received: by 10.52.242.167 with SMTP id wr7mr101281vdc.32.1393318225215; Tue, 25 Feb 2014 00:50:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp122278vcz; Tue, 25 Feb 2014 00:50:24 -0800 (PST) X-Received: by 10.68.202.8 with SMTP id ke8mr5292825pbc.86.1393318223926; Tue, 25 Feb 2014 00:50:23 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id on3si2879504pbb.125.2014.02.25.00.50.23; Tue, 25 Feb 2014 00:50:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750818AbaBYIuW (ORCPT + 11 others); Tue, 25 Feb 2014 03:50:22 -0500 Received: from mail-we0-f177.google.com ([74.125.82.177]:34471 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708AbaBYIuV (ORCPT ); Tue, 25 Feb 2014 03:50:21 -0500 Received: by mail-we0-f177.google.com with SMTP id t61so68829wes.22 for ; Tue, 25 Feb 2014 00:50:19 -0800 (PST) X-Received: by 10.194.2.70 with SMTP id 6mr23083962wjs.25.1393318218989; Tue, 25 Feb 2014 00:50:18 -0800 (PST) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id bm8sm48867626wjc.12.2014.02.25.00.50.15 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:50:18 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net, skannan@codeaurora.org Cc: linaro-kernel@lists.linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, srivatsa.bhat@linux.vnet.ibm.com, Viresh Kumar Subject: [PATCH 1/3] cpufreq: move call to __find_governor() to cpufreq_init_policy() Date: Tue, 25 Feb 2014 14:20:09 +0530 Message-Id: <9f9546137135103556c69815c72b81ed93cc1ca2.1393318100.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We call __find_governor() during addition of first CPU of every policy to find the last governor used for this CPU before it was hotplugged-out. After that we call cpufreq_parse_governor() in cpufreq_init_policy() either with this governor or default governor. And right after that policy->governor is set to NULL. So, instead of doing this move the relevant parts to cpufreq_init_policy() policy only and initialize policy->governor to NULL at the beginning. Signed-off-by: Viresh Kumar --- Hi Saravana, I hope only the first two patches would fix things for you but probably you can test all three. @Rafael: We might need to get these in next rc only as these are more or less fixes. drivers/cpufreq/cpufreq.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c755b5f..cc4f244 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -879,18 +879,27 @@ err_out_kobj_put: static void cpufreq_init_policy(struct cpufreq_policy *policy) { + struct cpufreq_governor *gov = NULL; struct cpufreq_policy new_policy; int ret = 0; memcpy(&new_policy, policy, sizeof(*policy)); + /* Update governor of new_policy to the governor used before hotplug */ +#ifdef CONFIG_HOTPLUG_CPU + gov = __find_governor(per_cpu(cpufreq_cpu_governor, policy->cpu)); +#endif + if (gov) + pr_debug("Restoring governor %s for cpu %d\n", + policy->governor->name, policy->cpu); + else + gov = CPUFREQ_DEFAULT_GOVERNOR; + + new_policy.governor = gov; + /* Use the default policy if its valid. */ if (cpufreq_driver->setpolicy) - cpufreq_parse_governor(policy->governor->name, - &new_policy.policy, NULL); - - /* assure that the starting sequence is run in cpufreq_set_policy */ - policy->governor = NULL; + cpufreq_parse_governor(gov->name, &new_policy.policy, NULL); /* set default policy */ ret = cpufreq_set_policy(policy, &new_policy); @@ -944,11 +953,11 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu) unsigned long flags; read_lock_irqsave(&cpufreq_driver_lock, flags); - policy = per_cpu(cpufreq_cpu_data_fallback, cpu); - read_unlock_irqrestore(&cpufreq_driver_lock, flags); + policy->governor = NULL; + return policy; } @@ -1036,7 +1045,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, unsigned long flags; #ifdef CONFIG_HOTPLUG_CPU struct cpufreq_policy *tpolicy; - struct cpufreq_governor *gov; #endif if (cpu_is_offline(cpu)) @@ -1094,7 +1102,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, else policy->cpu = cpu; - policy->governor = CPUFREQ_DEFAULT_GOVERNOR; cpumask_copy(policy->cpus, cpumask_of(cpu)); init_completion(&policy->kobj_unregister); @@ -1179,15 +1186,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, blocking_notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_START, policy); -#ifdef CONFIG_HOTPLUG_CPU - gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu)); - if (gov) { - policy->governor = gov; - pr_debug("Restoring governor %s for cpu %d\n", - policy->governor->name, cpu); - } -#endif - if (!frozen) { ret = cpufreq_add_dev_interface(policy, dev); if (ret)