From patchwork Thu Dec 27 14:55:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 1913231 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id AD0F8DF2A2 for ; Thu, 27 Dec 2012 14:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752999Ab2L0O43 (ORCPT ); Thu, 27 Dec 2012 09:56:29 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:48015 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752971Ab2L0O40 (ORCPT ); Thu, 27 Dec 2012 09:56:26 -0500 Received: by mail-wi0-f169.google.com with SMTP id hq12so4616304wib.0 for ; Thu, 27 Dec 2012 06:56:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=x3SPZLvJhpWxmI9a0tNpQepOZYqWb+EQopSZ1rcEeNU=; b=g+56J1DOfUuoaaI2SnEZfFiNw1X/mwJk8+p+h77N//gAXTq7ISakcp2ALyNplIZ1ov FxRpl6TOQ4UzBLtDLhNg7BjXrxAB4LZbWXF2tT5n7VsjzNas0suttzpu/3Z+IBTygtln BQdGjNKwMrznBABG6rqYrbvsz15AZ4vKi5anWBI1xAiReFzANwZtHNV/gTjGBTk2i8vv fehvEsydBtvg7zW3LbrYwjYfnkgctyO20Gu0JPJpvhQojtHWnfZGEogn/TIlYS7RzL9k 1dJpEo/TMKMf5zxKIgPndqYdIHTmLxRSU2eNMqyotVIqq9SPPY6SiViAF9Sl8FnZ88Rc mbtw== X-Received: by 10.180.95.135 with SMTP id dk7mr40804779wib.29.1356620185348; Thu, 27 Dec 2012 06:56:25 -0800 (PST) Received: from localhost ([2a01:2029:1:11e3:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id hg17sm57677946wib.1.2012.12.27.06.56.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Dec 2012 06:56:24 -0800 (PST) From: Fabio Baltieri To: "Rafael J. Wysocki" , cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Cc: Linus Walleij , linux-kernel@vger.kernel.org, Fabio Baltieri Subject: [PATCH 2/5] cpufreq: star/stop cpufreq timers on cpu hotplug Date: Thu, 27 Dec 2012 15:55:39 +0100 Message-Id: <1356620142-8680-3-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1356620142-8680-1-git-send-email-fabio.baltieri@linaro.org> References: <1356620142-8680-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQngs+YWlqpdE9xTjp4v0A1tZ8iVkKhtK5LIXSMYIWH8yJExr2jxe28PFWHF5PUHxPXM0YgZ Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a CPU notifier to start and stop individual core timers on CPU hotplug events when running on CPUs with SW coordinated frequency. Signed-off-by: Fabio Baltieri --- drivers/cpufreq/cpufreq_governor.c | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index b0e4506..e881250 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -25,9 +25,12 @@ #include #include #include +#include #include "cpufreq_governor.h" +static DEFINE_PER_CPU(struct dbs_data *, cpu_cur_dbs); + static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) { u64 idle_time; @@ -185,6 +188,46 @@ static inline void dbs_timer_exit(struct cpu_dbs_common_info *cdbs) cancel_delayed_work_sync(&cdbs->work); } +static int __cpuinit cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) +{ + unsigned int cpu = (unsigned long)hcpu; + struct device *cpu_dev = get_cpu_device(cpu); + struct dbs_data *dbs_data = per_cpu(cpu_cur_dbs, cpu); + struct cpu_dbs_common_info *cpu_cdbs = dbs_data->get_cpu_cdbs(cpu); + unsigned int sampling_rate; + + if (dbs_data->governor == GOV_CONSERVATIVE) { + struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; + sampling_rate = cs_tuners->sampling_rate; + } else { + struct od_dbs_tuners *od_tuners = dbs_data->tuners; + sampling_rate = od_tuners->sampling_rate; + } + + if (cpu_dev) { + switch (action) { + case CPU_ONLINE: + case CPU_ONLINE_FROZEN: + case CPU_DOWN_FAILED: + case CPU_DOWN_FAILED_FROZEN: + dbs_timer_init(dbs_data, cpu_cdbs, + sampling_rate, cpu); + break; + case CPU_DOWN_PREPARE: + case CPU_DOWN_PREPARE_FROZEN: + dbs_timer_exit(cpu_cdbs); + break; + } + } + + return NOTIFY_OK; +} + +static struct notifier_block __refdata ondemand_cpu_notifier = { + .notifier_call = cpu_callback, +}; + int cpufreq_governor_dbs(struct dbs_data *dbs_data, struct cpufreq_policy *policy, unsigned int event) { @@ -296,7 +339,11 @@ second_time: j_cdbs = dbs_data->get_cpu_cdbs(j); dbs_timer_init(dbs_data, j_cdbs, *sampling_rate, j); + + per_cpu(cpu_cur_dbs, j) = dbs_data; } + + register_hotcpu_notifier(&ondemand_cpu_notifier); } else { dbs_timer_init(dbs_data, cpu_cdbs, *sampling_rate, cpu); } @@ -307,11 +354,15 @@ second_time: cs_dbs_info->enable = 0; if (dbs_sw_coordinated_cpus(cpu_cdbs)) { + unregister_hotcpu_notifier(&ondemand_cpu_notifier); + for_each_cpu(j, policy->cpus) { struct cpu_dbs_common_info *j_cdbs; j_cdbs = dbs_data->get_cpu_cdbs(j); dbs_timer_exit(j_cdbs); + + per_cpu(cpu_cur_dbs, j) = NULL; } } else { dbs_timer_exit(cpu_cdbs);