From patchwork Thu Mar 16 05:29:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95372 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660554qgd; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) X-Received: by 10.98.200.136 with SMTP id i8mr8317052pfk.120.1489642212197; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si4160680pgo.251.2017.03.15.22.30.11; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751328AbdCPFaG (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:06 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:35227 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980AbdCPFaD (ORCPT ); Thu, 16 Mar 2017 01:30:03 -0400 Received: by mail-pg0-f42.google.com with SMTP id b129so19564768pgc.2 for ; Wed, 15 Mar 2017 22:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/4onPWiQOasvHXtTdaEX/Nd90XH8HfBgBVHn2mEivcY=; b=IK9+7zzNFXqmgIgoIB88OX+GSby5Bbu6yStZ+Yf+SnvDwLT5Wkx4dCOGMo8GBSvfby PDkyhjOWE/3HAm+95c7RrtZxa5xOMUFapJYRxZWVuhI2MZ8hHGiRTOElYGfC/uI9xTeC ygQ4cm7RVKr+5CLOlfn8Y+hk/HBu1klwop+Jc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/4onPWiQOasvHXtTdaEX/Nd90XH8HfBgBVHn2mEivcY=; b=KNNAraqPWKfAg7HJIRDnx/aA9odYpEG8Uss8ZHS6+Ge36tc1tfnkQs7oZwEBDOLUHZ Mb2DQGG+M90N7dT79aAk2g2yd3TRfWNv5rY6FbrWxB3iYZswEDYOxk3uCUvrspC8By9f oDqyJvHwVTyzqTv9u5puGcLXJcOKyZi7Qv43HvJqpTMF8SXs/bQllVpE0pkHBpTdnaj4 mbvVjeB4HspzB4PjGEMKpStFYOJ806EW2Vt1yq1uN05xtDeACiH8nxvyji13JbBlGaw2 kSNEmfAPGVl+6CQlKDB2JPRmtibfsGxaFKofXEN7aRwyUVMZ5c8pwrMaQoCirXpj6Cp0 +cyQ== X-Gm-Message-State: AFeK/H0B7aMAnC2KM9avdD9vbilhcZNNt/UxNH54+FRX5VpSdBDIKeXRcklXnaH5Tv17+YUo X-Received: by 10.98.159.149 with SMTP id v21mr8232866pfk.57.1489642202562; Wed, 15 Mar 2017 22:30:02 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id x2sm7403085pfb.49.2017.03.15.22.30.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:01 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 02/17] thermal: cpu_cooling: rearrange globals Date: Thu, 16 Mar 2017 10:59:37 +0530 Message-Id: <2ec1e1f373acb4471db3b15d14207c31b73c372f.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just to make it look better. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 6fd258d62e47..7ce73eee866f 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -105,10 +105,9 @@ struct cpufreq_cooling_device { struct device *cpu_dev; get_static_t plat_get_static_power; }; -static DEFINE_IDA(cpufreq_ida); static unsigned int cpufreq_dev_count; - +static DEFINE_IDA(cpufreq_ida); static DEFINE_MUTEX(cooling_list_lock); static LIST_HEAD(cpufreq_dev_list); From patchwork Thu Mar 16 05:29:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95373 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660555qgd; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) X-Received: by 10.98.76.91 with SMTP id z88mr8013759pfa.14.1489642212573; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si4160680pgo.251.2017.03.15.22.30.12; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751387AbdCPFaK (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:10 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:32897 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980AbdCPFaH (ORCPT ); Thu, 16 Mar 2017 01:30:07 -0400 Received: by mail-pf0-f176.google.com with SMTP id w189so18999785pfb.0 for ; Wed, 15 Mar 2017 22:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=X1nZqVr/4wKv08b9jiq4UoRlnZTes864AeNDFvDY8jk=; b=JiksVsX8Rtolzs793uAeRz+jHqDjlNLZ8T6fZbvy5JBNpKCexysX3xGXf+9/QcnJ6j i7dQUodm1/8pRLnnPBMx6R1UQD/GZ4vpvltbk/sAun3P7ZTIblix8451DHR7Ffc+TOnc kinZe2SvOYL1mvd9NxDf4EifSTOS2rzJIZsgk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=X1nZqVr/4wKv08b9jiq4UoRlnZTes864AeNDFvDY8jk=; b=IFdNqX03FxNLlhnCmKRgX/8S6PXdWNrsrnl5MjJok//DHGPjEY5HyN+sD9zVeeUYW6 WZeMKn1yQTvUfjbT+muyN9RtyqIM06QgwFDeiGVMsjB4yo68l5y//L9cqLSBiQrCo21m M14W3ZMOkUtB7a9rfW73tyPfrsGV39JEc9XcXkhY+aNRPB9CDQFtL52UIe5xvB+pDLGS wwwlTvn2jjOLtYpZgxaLJlkZvCH+fydw1pnCtwAo6jH+8Z4NDcneBHNm/IlyU7bgHx9Y wY7ZXE9Pxh7ZPKCupp6sZhH7BT0u+8HIQxW+SUPgVq8aESKs5PZXqIZw6HRrJyQuUPFo lgmw== X-Gm-Message-State: AFeK/H3DKPYgxNcloiWIDsZClLVi5Y3uj1PGAOKOJdsPJQ8xhYVP2dDfYGkcOjVQL9xzlWtB X-Received: by 10.84.146.140 with SMTP id g12mr9666394pla.70.1489642205942; Wed, 15 Mar 2017 22:30:05 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id x10sm7414237pfi.21.2017.03.15.22.30.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:05 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 03/17] thermal: cpu_cooling: Replace cpufreq_device with cpufreq_dev Date: Thu, 16 Mar 2017 10:59:38 +0530 Message-Id: <1ebaf8113e79154e9b8e7696c4e1c70791d26e14.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Objects of "struct cpufreq_cooling_device" are named a bit inconsistently. Lets use cpufreq_dev everywhere. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 133 +++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 67 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 7ce73eee866f..7a19033d7f79 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -218,11 +218,11 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, /** * build_dyn_power_table() - create a dynamic power to frequency table - * @cpufreq_device: the cpufreq cooling device in which to store the table + * @cpufreq_dev: the cpufreq cooling device in which to store the table * @capacitance: dynamic power coefficient for these cpus * * Build a dynamic power to frequency table for this cpu and store it - * in @cpufreq_device. This table will be used in cpu_power_to_freq() and + * in @cpufreq_dev. This table will be used in cpu_power_to_freq() and * cpu_freq_to_power() to convert between power and frequency * efficiently. Power is stored in mW, frequency in KHz. The * resulting table is in ascending order. @@ -231,7 +231,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, * -ENOMEM if we run out of memory or -EAGAIN if an OPP was * added/enabled while the function was executing. */ -static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, +static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_dev, u32 capacitance) { struct power_table *power_table; @@ -240,10 +240,10 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, int num_opps = 0, cpu, i, ret = 0; unsigned long freq; - for_each_cpu(cpu, &cpufreq_device->allowed_cpus) { + for_each_cpu(cpu, &cpufreq_dev->allowed_cpus) { dev = get_cpu_device(cpu); if (!dev) { - dev_warn(&cpufreq_device->cool_dev->device, + dev_warn(&cpufreq_dev->cool_dev->device, "No cpu device for cpu %d\n", cpu); continue; } @@ -296,9 +296,9 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, goto free_power_table; } - cpufreq_device->cpu_dev = dev; - cpufreq_device->dyn_power_table = power_table; - cpufreq_device->dyn_power_table_entries = i; + cpufreq_dev->cpu_dev = dev; + cpufreq_dev->dyn_power_table = power_table; + cpufreq_dev->dyn_power_table_entries = i; return 0; @@ -308,26 +308,26 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device, return ret; } -static u32 cpu_freq_to_power(struct cpufreq_cooling_device *cpufreq_device, +static u32 cpu_freq_to_power(struct cpufreq_cooling_device *cpufreq_dev, u32 freq) { int i; - struct power_table *pt = cpufreq_device->dyn_power_table; + struct power_table *pt = cpufreq_dev->dyn_power_table; - for (i = 1; i < cpufreq_device->dyn_power_table_entries; i++) + for (i = 1; i < cpufreq_dev->dyn_power_table_entries; i++) if (freq < pt[i].frequency) break; return pt[i - 1].power; } -static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_device, +static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_dev, u32 power) { int i; - struct power_table *pt = cpufreq_device->dyn_power_table; + struct power_table *pt = cpufreq_dev->dyn_power_table; - for (i = 1; i < cpufreq_device->dyn_power_table_entries; i++) + for (i = 1; i < cpufreq_dev->dyn_power_table_entries; i++) if (power < pt[i].power) break; @@ -336,37 +336,37 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_device, /** * get_load() - get load for a cpu since last updated - * @cpufreq_device: &struct cpufreq_cooling_device for this cpu + * @cpufreq_dev: &struct cpufreq_cooling_device for this cpu * @cpu: cpu number - * @cpu_idx: index of the cpu in cpufreq_device->allowed_cpus + * @cpu_idx: index of the cpu in cpufreq_dev->allowed_cpus * * Return: The average load of cpu @cpu in percentage since this * function was last called. */ -static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu, +static u32 get_load(struct cpufreq_cooling_device *cpufreq_dev, int cpu, int cpu_idx) { u32 load; u64 now, now_idle, delta_time, delta_idle; now_idle = get_cpu_idle_time(cpu, &now, 0); - delta_idle = now_idle - cpufreq_device->time_in_idle[cpu_idx]; - delta_time = now - cpufreq_device->time_in_idle_timestamp[cpu_idx]; + delta_idle = now_idle - cpufreq_dev->time_in_idle[cpu_idx]; + delta_time = now - cpufreq_dev->time_in_idle_timestamp[cpu_idx]; if (delta_time <= delta_idle) load = 0; else load = div64_u64(100 * (delta_time - delta_idle), delta_time); - cpufreq_device->time_in_idle[cpu_idx] = now_idle; - cpufreq_device->time_in_idle_timestamp[cpu_idx] = now; + cpufreq_dev->time_in_idle[cpu_idx] = now_idle; + cpufreq_dev->time_in_idle_timestamp[cpu_idx] = now; return load; } /** * get_static_power() - calculate the static power consumed by the cpus - * @cpufreq_device: struct &cpufreq_cooling_device for this cpu cdev + * @cpufreq_dev: struct &cpufreq_cooling_device for this cpu cdev * @tz: thermal zone device in which we're operating * @freq: frequency in KHz * @power: pointer in which to store the calculated static power @@ -379,25 +379,24 @@ static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu, * * Return: 0 on success, -E* on failure. */ -static int get_static_power(struct cpufreq_cooling_device *cpufreq_device, +static int get_static_power(struct cpufreq_cooling_device *cpufreq_dev, struct thermal_zone_device *tz, unsigned long freq, u32 *power) { struct dev_pm_opp *opp; unsigned long voltage; - struct cpumask *cpumask = &cpufreq_device->allowed_cpus; + struct cpumask *cpumask = &cpufreq_dev->allowed_cpus; unsigned long freq_hz = freq * 1000; - if (!cpufreq_device->plat_get_static_power || - !cpufreq_device->cpu_dev) { + if (!cpufreq_dev->plat_get_static_power || !cpufreq_dev->cpu_dev) { *power = 0; return 0; } - opp = dev_pm_opp_find_freq_exact(cpufreq_device->cpu_dev, freq_hz, + opp = dev_pm_opp_find_freq_exact(cpufreq_dev->cpu_dev, freq_hz, true); if (IS_ERR(opp)) { - dev_warn_ratelimited(cpufreq_device->cpu_dev, + dev_warn_ratelimited(cpufreq_dev->cpu_dev, "Failed to find OPP for frequency %lu: %ld\n", freq_hz, PTR_ERR(opp)); return -EINVAL; @@ -407,31 +406,31 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_device, dev_pm_opp_put(opp); if (voltage == 0) { - dev_err_ratelimited(cpufreq_device->cpu_dev, + dev_err_ratelimited(cpufreq_dev->cpu_dev, "Failed to get voltage for frequency %lu\n", freq_hz); return -EINVAL; } - return cpufreq_device->plat_get_static_power(cpumask, tz->passive_delay, - voltage, power); + return cpufreq_dev->plat_get_static_power(cpumask, tz->passive_delay, + voltage, power); } /** * get_dynamic_power() - calculate the dynamic power - * @cpufreq_device: &cpufreq_cooling_device for this cdev + * @cpufreq_dev: &cpufreq_cooling_device for this cdev * @freq: current frequency * * Return: the dynamic power consumed by the cpus described by - * @cpufreq_device. + * @cpufreq_dev. */ -static u32 get_dynamic_power(struct cpufreq_cooling_device *cpufreq_device, +static u32 get_dynamic_power(struct cpufreq_cooling_device *cpufreq_dev, unsigned long freq) { u32 raw_cpu_power; - raw_cpu_power = cpu_freq_to_power(cpufreq_device, freq); - return (raw_cpu_power * cpufreq_device->last_load) / 100; + raw_cpu_power = cpu_freq_to_power(cpufreq_dev, freq); + return (raw_cpu_power * cpufreq_dev->last_load) / 100; } /* cpufreq cooling device callback functions are defined below */ @@ -449,9 +448,9 @@ static u32 get_dynamic_power(struct cpufreq_cooling_device *cpufreq_device, static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state) { - struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; + struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; - *state = cpufreq_device->max_level; + *state = cpufreq_dev->max_level; return 0; } @@ -468,9 +467,9 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *state) { - struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; + struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; - *state = cpufreq_device->cpufreq_state; + *state = cpufreq_dev->cpufreq_state; return 0; } @@ -488,21 +487,21 @@ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { - struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; - unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus); + struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; + unsigned int cpu = cpumask_any(&cpufreq_dev->allowed_cpus); unsigned int clip_freq; /* Request state should be less than max_level */ - if (WARN_ON(state > cpufreq_device->max_level)) + if (WARN_ON(state > cpufreq_dev->max_level)) return -EINVAL; /* Check if the old cooling action is same as new cooling action */ - if (cpufreq_device->cpufreq_state == state) + if (cpufreq_dev->cpufreq_state == state) return 0; - clip_freq = cpufreq_device->freq_table[state]; - cpufreq_device->cpufreq_state = state; - cpufreq_device->clipped_freq = clip_freq; + clip_freq = cpufreq_dev->freq_table[state]; + cpufreq_dev->cpufreq_state = state; + cpufreq_dev->clipped_freq = clip_freq; cpufreq_update_policy(cpu); @@ -539,10 +538,10 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, unsigned long freq; int i = 0, cpu, ret; u32 static_power, dynamic_power, total_load = 0; - struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; + struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; u32 *load_cpu = NULL; - cpu = cpumask_any_and(&cpufreq_device->allowed_cpus, cpu_online_mask); + cpu = cpumask_any_and(&cpufreq_dev->allowed_cpus, cpu_online_mask); /* * All the CPUs are offline, thus the requested power by @@ -556,16 +555,16 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, freq = cpufreq_quick_get(cpu); if (trace_thermal_power_cpu_get_power_enabled()) { - u32 ncpus = cpumask_weight(&cpufreq_device->allowed_cpus); + u32 ncpus = cpumask_weight(&cpufreq_dev->allowed_cpus); load_cpu = kcalloc(ncpus, sizeof(*load_cpu), GFP_KERNEL); } - for_each_cpu(cpu, &cpufreq_device->allowed_cpus) { + for_each_cpu(cpu, &cpufreq_dev->allowed_cpus) { u32 load; if (cpu_online(cpu)) - load = get_load(cpufreq_device, cpu, i); + load = get_load(cpufreq_dev, cpu, i); else load = 0; @@ -576,10 +575,10 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, i++; } - cpufreq_device->last_load = total_load; + cpufreq_dev->last_load = total_load; - dynamic_power = get_dynamic_power(cpufreq_device, freq); - ret = get_static_power(cpufreq_device, tz, freq, &static_power); + dynamic_power = get_dynamic_power(cpufreq_dev, freq); + ret = get_static_power(cpufreq_dev, tz, freq, &static_power); if (ret) { kfree(load_cpu); return ret; @@ -587,7 +586,7 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, if (load_cpu) { trace_thermal_power_cpu_get_power( - &cpufreq_device->allowed_cpus, + &cpufreq_dev->allowed_cpus, freq, load_cpu, i, dynamic_power, static_power); kfree(load_cpu); @@ -620,12 +619,12 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, cpumask_var_t cpumask; u32 static_power, dynamic_power; int ret; - struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; + struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; if (!alloc_cpumask_var(&cpumask, GFP_KERNEL)) return -ENOMEM; - cpumask_and(cpumask, &cpufreq_device->allowed_cpus, cpu_online_mask); + cpumask_and(cpumask, &cpufreq_dev->allowed_cpus, cpu_online_mask); num_cpus = cpumask_weight(cpumask); /* None of our cpus are online, so no power */ @@ -635,14 +634,14 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, goto out; } - freq = cpufreq_device->freq_table[state]; + freq = cpufreq_dev->freq_table[state]; if (!freq) { ret = -EINVAL; goto out; } - dynamic_power = cpu_freq_to_power(cpufreq_device, freq) * num_cpus; - ret = get_static_power(cpufreq_device, tz, freq, &static_power); + dynamic_power = cpu_freq_to_power(cpufreq_dev, freq) * num_cpus; + ret = get_static_power(cpufreq_dev, tz, freq, &static_power); if (ret) goto out; @@ -680,24 +679,24 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, int ret; s32 dyn_power; u32 last_load, normalised_power, static_power; - struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; + struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; - cpu = cpumask_any_and(&cpufreq_device->allowed_cpus, cpu_online_mask); + cpu = cpumask_any_and(&cpufreq_dev->allowed_cpus, cpu_online_mask); /* None of our cpus are online */ if (cpu >= nr_cpu_ids) return -ENODEV; cur_freq = cpufreq_quick_get(cpu); - ret = get_static_power(cpufreq_device, tz, cur_freq, &static_power); + ret = get_static_power(cpufreq_dev, tz, cur_freq, &static_power); if (ret) return ret; dyn_power = power - static_power; dyn_power = dyn_power > 0 ? dyn_power : 0; - last_load = cpufreq_device->last_load ?: 1; + last_load = cpufreq_dev->last_load ?: 1; normalised_power = (dyn_power * 100) / last_load; - target_freq = cpu_power_to_freq(cpufreq_device, normalised_power); + target_freq = cpu_power_to_freq(cpufreq_dev, normalised_power); *state = cpufreq_cooling_get_level(cpu, target_freq); if (*state == THERMAL_CSTATE_INVALID) { @@ -707,7 +706,7 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, return -EINVAL; } - trace_thermal_power_cpu_limit(&cpufreq_device->allowed_cpus, + trace_thermal_power_cpu_limit(&cpufreq_dev->allowed_cpus, target_freq, *state, power); return 0; } From patchwork Thu Mar 16 05:29:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95374 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660659qgd; Wed, 15 Mar 2017 22:30:30 -0700 (PDT) X-Received: by 10.99.178.81 with SMTP id t17mr6494995pgo.136.1489642230341; Wed, 15 Mar 2017 22:30:30 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d82si2946670pfe.328.2017.03.15.22.30.29; Wed, 15 Mar 2017 22:30:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751442AbdCPFaN (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:13 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:33951 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751362AbdCPFaK (ORCPT ); Thu, 16 Mar 2017 01:30:10 -0400 Received: by mail-pg0-f41.google.com with SMTP id 141so19595436pgd.1 for ; Wed, 15 Mar 2017 22:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=LvCc0ZR39XhT/i1TmmMtxUBdJ8hJGO2yXslb9A6Rjm4=; b=YHmoUjrn/1LguGq3i/DGSSeg+aIqoG9kvoV/nBjbkDUsXob2n1lEQKv1KDP50reYSe kZ0dTlrWmeTSYiyNHrP0ha1IcL6EiwcAgY9P0UiYsMpKNDF7Jp/DJ9eOc0Z5Ni/Tqc0b wc0ji9+cEr4RnDmLyLPeguJb36Gk9PkYQQf1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=LvCc0ZR39XhT/i1TmmMtxUBdJ8hJGO2yXslb9A6Rjm4=; b=AXFM8TxrwA8pDSjo/3Z75Nmw4CyX6Fc+8fRwNspFvYyWaSu91RsTjciboz/ciFGgkq NLMNeQdlL9Sx+3JG+VcYHVfOhJaOhvyvoacp9+BS+zUSq5qSM0mtp1fdhIdMGfjcgRhB fup8PnTJZ/DR8pw5jOg+Ku4063z1sQpvJYaxFpEDazT+jS7mDc82z82W+gzkiy+MkytF gVZKXL/1zy88XViUs+0eqodKt25MXM8GdsjeCHdwXMld5srHg5iuSTRFSojYZ2lOazb7 RvoePwB003r3HTtkxvceeUHccbpH91prB7BQ0ibFI+dwqzsX3ytkaHIFlOwafWLM/hRt UscA== X-Gm-Message-State: AFeK/H0YFAbiN/8vCcCTHlLc9sb0YtsWtsXbge70+y/1o5h2z6izq24rgD7jpONH54SDQKxU X-Received: by 10.98.194.157 with SMTP id w29mr8043715pfk.192.1489642209065; Wed, 15 Mar 2017 22:30:09 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id u129sm7389656pfb.130.2017.03.15.22.30.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:08 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 04/17] thermal: cpu_cooling: replace cool_dev with cdev Date: Thu, 16 Mar 2017 10:59:39 +0530 Message-Id: <7fd9ac075f06fb673c2e18b3c5aab9e41910ed12.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Objects of "struct thermal_cooling_device" are named a bit inconsistently. Lets use cdev everywhere. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 7a19033d7f79..e2931c20c309 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -65,7 +65,7 @@ struct power_table { * struct cpufreq_cooling_device - data for cooling device with cpufreq * @id: unique integer value corresponding to each cpufreq_cooling_device * registered. - * @cool_dev: thermal_cooling_device pointer to keep track of the + * @cdev: thermal_cooling_device pointer to keep track of the * registered cooling device. * @cpufreq_state: integer value representing the current state of cpufreq * cooling devices. @@ -90,7 +90,7 @@ struct power_table { */ struct cpufreq_cooling_device { int id; - struct thermal_cooling_device *cool_dev; + struct thermal_cooling_device *cdev; unsigned int cpufreq_state; unsigned int clipped_freq; unsigned int max_level; @@ -243,7 +243,7 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_dev, for_each_cpu(cpu, &cpufreq_dev->allowed_cpus) { dev = get_cpu_device(cpu); if (!dev) { - dev_warn(&cpufreq_dev->cool_dev->device, + dev_warn(&cpufreq_dev->cdev->device, "No cpu device for cpu %d\n", cpu); continue; } @@ -770,7 +770,7 @@ __cpufreq_cooling_register(struct device_node *np, get_static_t plat_static_func) { struct cpufreq_policy *policy; - struct thermal_cooling_device *cool_dev; + struct thermal_cooling_device *cdev; struct cpufreq_cooling_device *cpufreq_dev; char dev_name[THERMAL_NAME_LENGTH]; struct cpufreq_frequency_table *pos, *table; @@ -786,20 +786,20 @@ __cpufreq_cooling_register(struct device_node *np, policy = cpufreq_cpu_get(cpumask_first(temp_mask)); if (!policy) { pr_debug("%s: CPUFreq policy not found\n", __func__); - cool_dev = ERR_PTR(-EPROBE_DEFER); + cdev = ERR_PTR(-EPROBE_DEFER); goto free_cpumask; } table = policy->freq_table; if (!table) { pr_debug("%s: CPUFreq table not found\n", __func__); - cool_dev = ERR_PTR(-ENODEV); + cdev = ERR_PTR(-ENODEV); goto put_policy; } cpufreq_dev = kzalloc(sizeof(*cpufreq_dev), GFP_KERNEL); if (!cpufreq_dev) { - cool_dev = ERR_PTR(-ENOMEM); + cdev = ERR_PTR(-ENOMEM); goto put_policy; } @@ -808,7 +808,7 @@ __cpufreq_cooling_register(struct device_node *np, sizeof(*cpufreq_dev->time_in_idle), GFP_KERNEL); if (!cpufreq_dev->time_in_idle) { - cool_dev = ERR_PTR(-ENOMEM); + cdev = ERR_PTR(-ENOMEM); goto free_cdev; } @@ -816,7 +816,7 @@ __cpufreq_cooling_register(struct device_node *np, kcalloc(num_cpus, sizeof(*cpufreq_dev->time_in_idle_timestamp), GFP_KERNEL); if (!cpufreq_dev->time_in_idle_timestamp) { - cool_dev = ERR_PTR(-ENOMEM); + cdev = ERR_PTR(-ENOMEM); goto free_time_in_idle; } @@ -827,7 +827,7 @@ __cpufreq_cooling_register(struct device_node *np, cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) * cpufreq_dev->max_level, GFP_KERNEL); if (!cpufreq_dev->freq_table) { - cool_dev = ERR_PTR(-ENOMEM); + cdev = ERR_PTR(-ENOMEM); goto free_time_in_idle_timestamp; } @@ -841,7 +841,7 @@ __cpufreq_cooling_register(struct device_node *np, ret = build_dyn_power_table(cpufreq_dev, capacitance); if (ret) { - cool_dev = ERR_PTR(ret); + cdev = ERR_PTR(ret); goto free_table; } @@ -852,7 +852,7 @@ __cpufreq_cooling_register(struct device_node *np, ret = ida_simple_get(&cpufreq_ida, 0, 0, GFP_KERNEL); if (ret < 0) { - cool_dev = ERR_PTR(ret); + cdev = ERR_PTR(ret); goto free_power_table; } cpufreq_dev->id = ret; @@ -872,13 +872,13 @@ __cpufreq_cooling_register(struct device_node *np, snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", cpufreq_dev->id); - cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, - cooling_ops); - if (IS_ERR(cool_dev)) + cdev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, + cooling_ops); + if (IS_ERR(cdev)) goto remove_ida; cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0]; - cpufreq_dev->cool_dev = cool_dev; + cpufreq_dev->cdev = cdev; mutex_lock(&cooling_list_lock); list_add(&cpufreq_dev->node, &cpufreq_dev_list); @@ -907,7 +907,7 @@ __cpufreq_cooling_register(struct device_node *np, cpufreq_cpu_put(policy); free_cpumask: free_cpumask_var(temp_mask); - return cool_dev; + return cdev; } /** @@ -1043,7 +1043,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) list_del(&cpufreq_dev->node); mutex_unlock(&cooling_list_lock); - thermal_cooling_device_unregister(cpufreq_dev->cool_dev); + thermal_cooling_device_unregister(cpufreq_dev->cdev); ida_simple_remove(&cpufreq_ida, cpufreq_dev->id); kfree(cpufreq_dev->dyn_power_table); kfree(cpufreq_dev->time_in_idle_timestamp); From patchwork Thu Mar 16 05:29:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95375 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660661qgd; Wed, 15 Mar 2017 22:30:30 -0700 (PDT) X-Received: by 10.99.184.18 with SMTP id p18mr8129164pge.20.1489642230697; Wed, 15 Mar 2017 22:30:30 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d82si2946670pfe.328.2017.03.15.22.30.30; Wed, 15 Mar 2017 22:30:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482AbdCPFaP (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:15 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:35268 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751362AbdCPFaN (ORCPT ); Thu, 16 Mar 2017 01:30:13 -0400 Received: by mail-pg0-f41.google.com with SMTP id b129so19567172pgc.2 for ; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=7PowYXdYn9FSuefGPmR8P3kiSxJh9M5R/Cw8/89t+UQ=; b=j7pMufmWKAW+j6MOo2d4uaZqKLWfkwP7DLChceUQpf5xtK6pwKrRNtahK6MwliaEG8 6qKsnaEuxCYl9C3gNQVHQfRSGKK9ClNvWui/abVyL72QQmaQgRN4Js43TTCDr4hJgVPP a1wJnAIwW7rU916SdRD2xN5Cs5HpWbkog03Hg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=7PowYXdYn9FSuefGPmR8P3kiSxJh9M5R/Cw8/89t+UQ=; b=YY0QKJUJpzA48E1Io/m5iDNo+BruoHpCeIf9L5aV9MdE+YEk1tVGMSxvMjdkKqoMxw NbKRJbAuKyGIRokIU4yry5Yk1g7ssCNctpbBtFwk9CC6xjDrBT9LqMw3pCVfdTPHGy7a Yx76nCxdk9W/6g55WjvmzNVbTllD6oods42NzWakPPzGzZm+EcxB1AieDmFBt4DyAsJG ObZQ2sAVW0Pva3M4xL/+UWZTZ1cV/7Lj45t4rw2m178856Um0S3CvNSyvkYKvfw+2GPX +bmCRTccwOts6AqHiPCCdwLD3xd1nsMiNcuM/BexamXlXg+1CGJK+Mb1eOOPKG94sXzC bhYg== X-Gm-Message-State: AFeK/H1y65otIA0eT8VImdDqBLQ5YzJofAiBauthYWhm+4tYmHpmkgeI7wU0LVXS2RvTP0yi X-Received: by 10.99.174.71 with SMTP id e7mr8019463pgp.3.1489642212271; Wed, 15 Mar 2017 22:30:12 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id d189sm7475246pga.17.2017.03.15.22.30.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:11 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 05/17] thermal: cpu_cooling: remove cpufreq_cooling_get_level() Date: Thu, 16 Mar 2017 10:59:40 +0530 Message-Id: <707918c88ce650ea11d160e31965482cdebc9a39.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is only one user of cpufreq_cooling_get_level() and that already has pointer to the cpufreq_dev structure. It can directly call get_level() instead and we can get rid of cpufreq_cooling_get_level(). Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 33 +-------------------------------- include/linux/cpu_cooling.h | 6 ------ 2 files changed, 1 insertion(+), 38 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index e2931c20c309..99dc6833de75 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -137,37 +137,6 @@ static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_dev, } /** - * cpufreq_cooling_get_level - for a given cpu, return the cooling level. - * @cpu: cpu for which the level is required - * @freq: the frequency of interest - * - * This function will match the cooling level corresponding to the - * requested @freq and return it. - * - * Return: The matched cooling level on success or THERMAL_CSTATE_INVALID - * otherwise. - */ -unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) -{ - struct cpufreq_cooling_device *cpufreq_dev; - - mutex_lock(&cooling_list_lock); - list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { - if (cpumask_test_cpu(cpu, &cpufreq_dev->allowed_cpus)) { - unsigned long level = get_level(cpufreq_dev, freq); - - mutex_unlock(&cooling_list_lock); - return level; - } - } - mutex_unlock(&cooling_list_lock); - - pr_err("%s: cpu:%d not part of any cooling device\n", __func__, cpu); - return THERMAL_CSTATE_INVALID; -} -EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); - -/** * cpufreq_thermal_notifier - notifier callback for cpufreq policy change. * @nb: struct notifier_block * with callback info. * @event: value showing cpufreq event for which this function invoked. @@ -698,7 +667,7 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, normalised_power = (dyn_power * 100) / last_load; target_freq = cpu_power_to_freq(cpufreq_dev, normalised_power); - *state = cpufreq_cooling_get_level(cpu, target_freq); + *state = get_level(cpufreq_dev, target_freq); if (*state == THERMAL_CSTATE_INVALID) { dev_err_ratelimited(&cdev->device, "Failed to convert %dKHz for cpu %d into a cdev state\n", diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index c156f5082758..96c5e4c2f9c8 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -82,7 +82,6 @@ of_cpufreq_power_cooling_register(struct device_node *np, */ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); -unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq); #else /* !CONFIG_CPU_THERMAL */ static inline struct thermal_cooling_device * cpufreq_cooling_register(const struct cpumask *clip_cpus) @@ -117,11 +116,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) { return; } -static inline -unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) -{ - return THERMAL_CSTATE_INVALID; -} #endif /* CONFIG_CPU_THERMAL */ #endif /* __CPU_COOLING_H__ */ From patchwork Thu Mar 16 05:29:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95376 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660663qgd; Wed, 15 Mar 2017 22:30:31 -0700 (PDT) X-Received: by 10.84.129.195 with SMTP id b61mr9695901plb.83.1489642231052; Wed, 15 Mar 2017 22:30:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d82si2946670pfe.328.2017.03.15.22.30.30; Wed, 15 Mar 2017 22:30:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751523AbdCPFaT (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:19 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:34381 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751362AbdCPFaQ (ORCPT ); Thu, 16 Mar 2017 01:30:16 -0400 Received: by mail-pf0-f180.google.com with SMTP id v190so18981119pfb.1 for ; Wed, 15 Mar 2017 22:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=GcyFRt72FtxqWhYtG34pd10p6ebfWEvR+F40cVEOrQs=; b=bEY/ZYsHA0uWtVpUT/Gpwm3OOhwuU/ymfd4RHKhkTgHjTgBSxyI1CK3miL0Cy0DRCQ hiqA99UBIJINoIyUQMCLe4pgV/X0GTRZJi8qUXRm5zoCIMd+Jso3CJs6t4oLCSJkNbFd lasZ9wwNx5CvIE6DV/XSoBpxHIL7z6BdRrEBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=GcyFRt72FtxqWhYtG34pd10p6ebfWEvR+F40cVEOrQs=; b=S5/nGQi+mq+bmlBhzag98ZqQcedhGeAZXe+ijBsLfNBw8mUC2krFOW6rQi6M0uIGeZ 6aTWSeMdcDSkkMMexXCNjuiEb8STsTDP+IJbfp5b1GKkcxCQPajYOwyVFmHnf0CQ5mq8 WkO9geb84cjDaffHkBKBtIYTKbWhIQoxXO3zP3tN3C7hjq3d2IP2CqRFe7sfJWQwj0oP PPF52l8BUqBVsdH1BANjp/wvsurTvKwvBDOTVBZKSczWDLG2phWSM/pq5aIUCn0al7Lf iHhgdECR6++b8Rj7dC+zQ3xZ9vXaUimtJy8W14qNS1h9lLWG1kRvotMixSWo02K3EGKr gElw== X-Gm-Message-State: AFeK/H2X8TIgUDM0ujLp8XO8j+NiZ0M3odtgxeBIxMpr1srD/DLgZQHnl6CWy2md1jrGViw6 X-Received: by 10.99.213.81 with SMTP id v17mr7782246pgi.130.1489642215425; Wed, 15 Mar 2017 22:30:15 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id s21sm7398024pfs.87.2017.03.15.22.30.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:14 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 06/17] thermal: cpu_cooling: get rid of a variable in cpufreq_set_cur_state() Date: Thu, 16 Mar 2017 10:59:41 +0530 Message-Id: <587728c8bc2173c5d742a24ec14ade8bdc5d6e92.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'cpu' is used at only one place and there is no need to keep a separate variable for it. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 99dc6833de75..46e90122b746 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -457,7 +457,6 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; - unsigned int cpu = cpumask_any(&cpufreq_dev->allowed_cpus); unsigned int clip_freq; /* Request state should be less than max_level */ @@ -472,7 +471,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, cpufreq_dev->cpufreq_state = state; cpufreq_dev->clipped_freq = clip_freq; - cpufreq_update_policy(cpu); + cpufreq_update_policy(cpumask_any(&cpufreq_dev->allowed_cpus)); return 0; } From patchwork Thu Mar 16 05:29:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95378 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660747qgd; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) X-Received: by 10.98.134.142 with SMTP id x136mr8268962pfd.64.1489642247446; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b189si4145766pga.296.2017.03.15.22.30.47; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647AbdCPFaf (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:35 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:33441 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751563AbdCPFa1 (ORCPT ); Thu, 16 Mar 2017 01:30:27 -0400 Received: by mail-pg0-f48.google.com with SMTP id n190so19664776pga.0 for ; Wed, 15 Mar 2017 22:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Y5jC4GCSRcDXFla0kPizwgNK9f6rto5AXsrUp8yvvqw=; b=jlESVRsZYg1TN/GB7Ec4UJYkSMyM3UI8LxIrT+02NSuLbgzRkszseArky9R2beTlGh cwlEtGPxA2N1mmMuxR7W5gC1UABDeo1+hD/xaGL5Jji3u703TGZFsEJ2DOiWwLBY4QfE 9cybgW//WFgsE2mUhkzDVolwzyeHAgOij1274= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Y5jC4GCSRcDXFla0kPizwgNK9f6rto5AXsrUp8yvvqw=; b=Toiv2iwyqz+mvCFjCjpAd/6LBSM4UKA3euibJhrMqKKSMDvtxWYHQmfefNyT2yg2kd 7pSvKxF5nyrQFgFkFO6XL2Tmi+AB30mug0+TPqg0n4iTclcEckwiGe4M7I1hWUMzll/6 XTaDX46r/82prksRrFbLOg5WTV6yWLrxNKi9XTPzrI/6dt4iAeeZtqOTi8gXi+2rqz2C cwdP+r9RQVpVvwuLceTV11FgF1qMdQjFEPAza/chIm5bcmZQ4irB4k/LL7kv2794pqGA pQCcG7rdTVKMFC8wC8bEaGYmmOF+TVb8rrbFOB5PeZFl/i4i3DcQGF3Y4Znhtv8Xxkfz Lftw== X-Gm-Message-State: AFeK/H0BqZnc070how7vKLD/nX4WBqpMBZDmfcoCJTMadLNJKBd+g0SxgdBhf2K3/JoTVLmR X-Received: by 10.98.89.139 with SMTP id k11mr7898320pfj.196.1489642226015; Wed, 15 Mar 2017 22:30:26 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id d63sm7394484pfg.132.2017.03.15.22.30.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:25 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 09/17] thermal: cpu_cooling: store cpufreq policy Date: Thu, 16 Mar 2017 10:59:44 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpufreq policy can be used by the cpu_cooling driver, lets store it in the cpufreq_cooling_device structure. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 2c169fee693e..7590279bf1de 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -67,6 +67,7 @@ struct power_table { * registered. * @cdev: thermal_cooling_device pointer to keep track of the * registered cooling device. + * @policy: cpufreq policy. * @cpufreq_state: integer value representing the current state of cpufreq * cooling devices. * @clipped_freq: integer value representing the absolute value of the clipped @@ -91,6 +92,7 @@ struct power_table { struct cpufreq_cooling_device { int id; struct thermal_cooling_device *cdev; + struct cpufreq_policy *policy; unsigned int cpufreq_state; unsigned int clipped_freq; unsigned int max_level; @@ -827,6 +829,7 @@ __cpufreq_cooling_register(struct device_node *np, cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0]; cpufreq_dev->cdev = cdev; + cpufreq_dev->policy = policy; mutex_lock(&cooling_list_lock); list_add(&cpufreq_dev->node, &cpufreq_dev_list); From patchwork Thu Mar 16 05:29:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95379 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660751qgd; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) X-Received: by 10.99.115.12 with SMTP id o12mr7934951pgc.165.1489642247829; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b189si4145766pga.296.2017.03.15.22.30.47; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751698AbdCPFam (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:42 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:34047 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751659AbdCPFai (ORCPT ); Thu, 16 Mar 2017 01:30:38 -0400 Received: by mail-pg0-f49.google.com with SMTP id 141so19600619pgd.1 for ; Wed, 15 Mar 2017 22:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=u/n/G9DaXdEmSEJ2Dc+glzJTFTzTdQV/7ULdVTJO224=; b=IySGXHNtTep0R44tWjtMr5pzojBvt1g1f2wR+LcekInFP60prR9tustUZnTME8igEM SHY3N3BTIeLcrgXwpmSlMs9/fzB0u7eh0FNJ5FpF15qv70FFCVnRzZcJyR6pfcCEEhYi EglPneX5HTbE18O7Q7zIUlXzC5Ol7C1p70qsw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=u/n/G9DaXdEmSEJ2Dc+glzJTFTzTdQV/7ULdVTJO224=; b=lONvhEXkzzZPAwMwes6L6MeoapmOS4dGWiupnUQnqkn/6kuhxUWFgdbLkhkh0iGpbi lhU9QB2r6SXWaL2Q6htg6bVypLBgmcCqvX3gasybpy+6IO4TStVXvP8UaWwINwqnLn7+ bn9OjXeQ7AX6ZCpA4veafs469fj0UOF/hkUQtHlTyDb8Pn5XJklFrV2px54DtLl1Plgj maWOBWFw1HmNAOid8DpHQEBLElVhda291ZqKH1GrabFZ9uWtVCc2TaFN9vvzp/1VrkSX pLa+ymQsAH+wexPZc1pOV+X0C79+8lMibD9EwbthQig2Z6NrFe/m0AdwKLYEJeL7D3FT 9Zdg== X-Gm-Message-State: AFeK/H2THQx1RU8MD4S57YZnWq7jtfph1zvYbsXhZDU6sxfjmtaAYRDeoiBrouP4cfVOmyqy X-Received: by 10.98.105.134 with SMTP id e128mr7865952pfc.19.1489642232348; Wed, 15 Mar 2017 22:30:32 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id b76sm1902204pfd.90.2017.03.15.22.30.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:31 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 11/17] thermal: cpu_cooling: get rid of 'allowed_cpus' Date: Thu, 16 Mar 2017 10:59:46 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'allowed_cpus' is a copy of policy->related_cpus and can be replaced by it directly. At some places we are only concerned about online CPUs and policy->cpus can be used there. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 77 ++++++++++++------------------------------- 1 file changed, 21 insertions(+), 56 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 1df6c9039e45..b7b193cb0e7a 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -74,7 +74,6 @@ struct power_table { * frequency. * @max_level: maximum cooling level. One less than total number of valid * cpufreq frequencies. - * @allowed_cpus: all the cpus involved for this cpufreq_cooling_device. * @node: list_head to link all cpufreq_cooling_device together. * @last_load: load measured by the latest call to cpufreq_get_requested_power() * @time_in_idle: previous reading of the absolute time that this cpu was idle @@ -97,7 +96,6 @@ struct cpufreq_cooling_device { unsigned int clipped_freq; unsigned int max_level; unsigned int *freq_table; /* In descending order */ - struct cpumask allowed_cpus; struct list_head node; u32 last_load; u64 *time_in_idle; @@ -162,7 +160,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, mutex_lock(&cooling_list_lock); list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { - if (!cpumask_test_cpu(policy->cpu, &cpufreq_dev->allowed_cpus)) + if (policy != cpufreq_dev->policy) continue; /* @@ -305,7 +303,7 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_dev, * get_load() - get load for a cpu since last updated * @cpufreq_dev: &struct cpufreq_cooling_device for this cpu * @cpu: cpu number - * @cpu_idx: index of the cpu in cpufreq_dev->allowed_cpus + * @cpu_idx: index of the cpu in time_in_idle* * * Return: The average load of cpu @cpu in percentage since this * function was last called. @@ -352,7 +350,7 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_dev, { struct dev_pm_opp *opp; unsigned long voltage; - struct cpumask *cpumask = &cpufreq_dev->allowed_cpus; + struct cpumask *cpumask = cpufreq_dev->policy->related_cpus; unsigned long freq_hz = freq * 1000; if (!cpufreq_dev->plat_get_static_power || !cpufreq_dev->cpu_dev) { @@ -469,7 +467,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, cpufreq_dev->cpufreq_state = state; cpufreq_dev->clipped_freq = clip_freq; - cpufreq_update_policy(cpumask_any(&cpufreq_dev->allowed_cpus)); + cpufreq_update_policy(cpufreq_dev->policy->cpu); return 0; } @@ -505,28 +503,18 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, int i = 0, cpu, ret; u32 static_power, dynamic_power, total_load = 0; struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; + struct cpufreq_policy *policy = cpufreq_dev->policy; u32 *load_cpu = NULL; - cpu = cpumask_any_and(&cpufreq_dev->allowed_cpus, cpu_online_mask); - - /* - * All the CPUs are offline, thus the requested power by - * the cdev is 0 - */ - if (cpu >= nr_cpu_ids) { - *power = 0; - return 0; - } - - freq = cpufreq_quick_get(cpu); + freq = cpufreq_quick_get(policy->cpu); if (trace_thermal_power_cpu_get_power_enabled()) { - u32 ncpus = cpumask_weight(&cpufreq_dev->allowed_cpus); + u32 ncpus = cpumask_weight(policy->related_cpus); load_cpu = kcalloc(ncpus, sizeof(*load_cpu), GFP_KERNEL); } - for_each_cpu(cpu, &cpufreq_dev->allowed_cpus) { + for_each_cpu(cpu, policy->related_cpus) { u32 load; if (cpu_online(cpu)) @@ -551,9 +539,9 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, } if (load_cpu) { - trace_thermal_power_cpu_get_power( - &cpufreq_dev->allowed_cpus, - freq, load_cpu, i, dynamic_power, static_power); + trace_thermal_power_cpu_get_power(policy->related_cpus, freq, + load_cpu, i, dynamic_power, + static_power); kfree(load_cpu); } @@ -582,38 +570,22 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, unsigned long state, u32 *power) { unsigned int freq, num_cpus; - cpumask_var_t cpumask; u32 static_power, dynamic_power; int ret; struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; - if (!alloc_cpumask_var(&cpumask, GFP_KERNEL)) - return -ENOMEM; - - cpumask_and(cpumask, &cpufreq_dev->allowed_cpus, cpu_online_mask); - num_cpus = cpumask_weight(cpumask); - - /* None of our cpus are online, so no power */ - if (num_cpus == 0) { - *power = 0; - ret = 0; - goto out; - } + num_cpus = cpumask_weight(cpufreq_dev->policy->cpus); freq = cpufreq_dev->freq_table[state]; - if (!freq) { - ret = -EINVAL; - goto out; - } + if (!freq) + return -EINVAL; dynamic_power = cpu_freq_to_power(cpufreq_dev, freq) * num_cpus; ret = get_static_power(cpufreq_dev, tz, freq, &static_power); if (ret) - goto out; + return ret; *power = static_power + dynamic_power; -out: - free_cpumask_var(cpumask); return ret; } @@ -641,19 +613,14 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, struct thermal_zone_device *tz, u32 power, unsigned long *state) { - unsigned int cpu, cur_freq, target_freq; + unsigned int cur_freq, target_freq; int ret; s32 dyn_power; u32 last_load, normalised_power, static_power; struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; + struct cpufreq_policy *policy = cpufreq_dev->policy; - cpu = cpumask_any_and(&cpufreq_dev->allowed_cpus, cpu_online_mask); - - /* None of our cpus are online */ - if (cpu >= nr_cpu_ids) - return -ENODEV; - - cur_freq = cpufreq_quick_get(cpu); + cur_freq = cpufreq_quick_get(policy->cpu); ret = get_static_power(cpufreq_dev, tz, cur_freq, &static_power); if (ret) return ret; @@ -668,12 +635,12 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, if (*state == THERMAL_CSTATE_INVALID) { dev_err_ratelimited(&cdev->device, "Failed to convert %dKHz for cpu %d into a cdev state\n", - target_freq, cpu); + target_freq, policy->cpu); return -EINVAL; } - trace_thermal_power_cpu_limit(&cpufreq_dev->allowed_cpus, - target_freq, *state, power); + trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state, + power); return 0; } @@ -780,8 +747,6 @@ __cpufreq_cooling_register(struct device_node *np, goto free_time_in_idle_timestamp; } - cpumask_copy(&cpufreq_dev->allowed_cpus, policy->related_cpus); - if (capacitance) { cpufreq_dev->plat_get_static_power = plat_static_func; From patchwork Thu Mar 16 05:29:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95380 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660754qgd; Wed, 15 Mar 2017 22:30:48 -0700 (PDT) X-Received: by 10.98.41.5 with SMTP id p5mr7847311pfp.183.1489642248193; Wed, 15 Mar 2017 22:30:48 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b189si4145766pga.296.2017.03.15.22.30.47; Wed, 15 Mar 2017 22:30:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751734AbdCPFap (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:45 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:35361 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbdCPFam (ORCPT ); Thu, 16 Mar 2017 01:30:42 -0400 Received: by mail-pg0-f46.google.com with SMTP id b129so19572270pgc.2 for ; Wed, 15 Mar 2017 22:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=lCfVOM7v8pS+eUEE+4HTpcJuran3YMJflDnN4b3F4uU=; b=JW+fFxGqzBPwy1isVo1V9Qka1X+BfV8ICB52fkCkn83wD9eO6gqDd8oRmZpIsm5zn4 timsaa+7a4+cib8+Q+k2ZfnL8kujHH5b3mYHgTmed0GNf9freFiNhWCQpadejXTGu9MG PSyD+b1WvaJsmpnDNLG1n8ElTYcpAzLYvDX9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=lCfVOM7v8pS+eUEE+4HTpcJuran3YMJflDnN4b3F4uU=; b=YfmexNATZ8Cj38LvOQ2wF9H3xCTfKXcou6e6hlwlgsYyCbrpS7vYbtTa3wBZjhgUr0 4gh5fVzq6mFYmdDRfbZP3w8edIl0XO6M0rFfOUJKZ3QDmeqkVnhW2FkR5W9r4r2D/TiK mZDxLHC/ljfvjtiUK5vljRCmOszRpDNvDttOBlo6H8peIAuqWz87HxFUzngeWhT95E22 ka6aDeAC9ejU8b5wusUfmcVNKlmREoAIFijwQ9JbJmUBvzXaE/1SF1oWowFXAzIKH1FO 4bVT+bEXwJfCKj1NMfHSm7rxjxlUb1iIFUbVmRCwcVETpYieI8siv7lWeDyuSdKvmP0Q xveA== X-Gm-Message-State: AFeK/H0zhaPgG0aOean6P66n5LWHYO0wnPSktmpQz31HhhvHpr4RyulCeGxSqFlTzoSQGTEd X-Received: by 10.84.254.68 with SMTP id a4mr29850pln.57.1489642235729; Wed, 15 Mar 2017 22:30:35 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id l19sm7482855pgo.13.2017.03.15.22.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:35 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 12/17] thermal: cpu_cooling: merge frequency and power tables Date: Thu, 16 Mar 2017 10:59:47 +0530 Message-Id: <22479b0dd7726d0d9fd7e9284bfa6b776ff08b39.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpu_cooling driver keeps two tables: - freq_table: table of frequencies in descending order, built from policy->freq_table. - power_table: table of frequencies and power in ascending order, built from OPP table. If the OPPs are used for the CPU device then both these tables are actually built using the OPP core and should have the same frequency entries. And there is no need to keep separate tables for this. Lets merge them both. Note that the new table is in descending order of frequencies and so the 'for' loops were required to be fixed at few places to make it work. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 123 ++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 71 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index b7b193cb0e7a..960135d85a71 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -49,14 +49,14 @@ */ /** - * struct power_table - frequency to power conversion + * struct freq_table - frequency table along with power entries * @frequency: frequency in KHz * @power: power in mW * * This structure is built when the cooling device registers and helps - * in translating frequency to power and viceversa. + * in translating frequency to power and vice versa. */ -struct power_table { +struct freq_table { u32 frequency; u32 power; }; @@ -79,9 +79,6 @@ struct power_table { * @time_in_idle: previous reading of the absolute time that this cpu was idle * @time_in_idle_timestamp: wall time of the last invocation of * get_cpu_idle_time_us() - * @dyn_power_table: array of struct power_table for frequency to power - * conversion, sorted in ascending order. - * @dyn_power_table_entries: number of entries in the @dyn_power_table array * @cpu_dev: the cpu_device of policy->cpu. * @plat_get_static_power: callback to calculate the static power * @@ -95,13 +92,11 @@ struct cpufreq_cooling_device { unsigned int cpufreq_state; unsigned int clipped_freq; unsigned int max_level; - unsigned int *freq_table; /* In descending order */ + struct freq_table *freq_table; /* In descending order */ struct list_head node; u32 last_load; u64 *time_in_idle; u64 *time_in_idle_timestamp; - struct power_table *dyn_power_table; - int dyn_power_table_entries; struct device *cpu_dev; get_static_t plat_get_static_power; }; @@ -126,10 +121,10 @@ static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_dev, unsigned long level; for (level = 0; level <= cpufreq_dev->max_level; level++) { - if (freq == cpufreq_dev->freq_table[level]) + if (freq == cpufreq_dev->freq_table[level].frequency) return level; - if (freq > cpufreq_dev->freq_table[level]) + if (freq > cpufreq_dev->freq_table[level].frequency) break; } @@ -186,28 +181,25 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, } /** - * build_dyn_power_table() - create a dynamic power to frequency table - * @cpufreq_dev: the cpufreq cooling device in which to store the table + * update_freq_table() - Update the freq table with power numbers + * @cpufreq_dev: the cpufreq cooling device in which to update the table * @capacitance: dynamic power coefficient for these cpus * - * Build a dynamic power to frequency table for this cpu and store it - * in @cpufreq_dev. This table will be used in cpu_power_to_freq() and - * cpu_freq_to_power() to convert between power and frequency - * efficiently. Power is stored in mW, frequency in KHz. The - * resulting table is in ascending order. + * Update the freq table with power numbers. This table will be used in + * cpu_power_to_freq() and cpu_freq_to_power() to convert between power and + * frequency efficiently. Power is stored in mW, frequency in KHz. The + * resulting table is in descending order. * * Return: 0 on success, -EINVAL if there are no OPPs for any CPUs, - * -ENOMEM if we run out of memory or -EAGAIN if an OPP was - * added/enabled while the function was executing. + * or -ENOMEM if we run out of memory. */ -static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_dev, - u32 capacitance) +static int update_freq_table(struct cpufreq_cooling_device *cpufreq_dev, + u32 capacitance) { - struct power_table *power_table; + struct freq_table *freq_table = cpufreq_dev->freq_table; struct dev_pm_opp *opp; struct device *dev = NULL; - int num_opps = 0, cpu = cpufreq_dev->policy->cpu, i, ret = 0; - unsigned long freq; + int num_opps = 0, cpu = cpufreq_dev->policy->cpu, i; dev = get_cpu_device(cpu); if (unlikely(!dev)) { @@ -220,25 +212,32 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_dev, if (num_opps < 0) return num_opps; - if (num_opps == 0) + /* + * The cpufreq table is also built from the OPP table and so the count + * should match. + */ + if (num_opps != cpufreq_dev->max_level + 1) { + dev_warn(dev, "Number of OPPs not matching with max_levels\n"); return -EINVAL; + } - power_table = kcalloc(num_opps, sizeof(*power_table), GFP_KERNEL); - if (!power_table) - return -ENOMEM; - - for (freq = 0, i = 0; - opp = dev_pm_opp_find_freq_ceil(dev, &freq), !IS_ERR(opp); - freq++, i++) { - u32 freq_mhz, voltage_mv; + for (i = 0; i < cpufreq_dev->max_level; i++) { + unsigned long freq = freq_table[i].frequency * 1000; + u32 freq_mhz = freq_table[i].frequency / 1000; u64 power; + u32 voltage_mv; - if (i >= num_opps) { - ret = -EAGAIN; - goto free_power_table; + /* + * Find ceil frequency as 'freq' may be slightly lower than OPP + * freq due to truncation while converting to kHz. + */ + opp = dev_pm_opp_find_freq_ceil(dev, &freq); + if (IS_ERR(opp)) { + dev_err(dev, "failed to get opp for %lu frequency\n", + freq); + return -EINVAL; } - freq_mhz = freq / 1000000; voltage_mv = dev_pm_opp_get_voltage(opp) / 1000; dev_pm_opp_put(opp); @@ -249,54 +248,39 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_dev, power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv; do_div(power, 1000000000); - /* frequency is stored in power_table in KHz */ - power_table[i].frequency = freq / 1000; - /* power is stored in mW */ - power_table[i].power = power; - } - - if (i != num_opps) { - ret = PTR_ERR(opp); - goto free_power_table; + freq_table[i].power = power; } cpufreq_dev->cpu_dev = dev; - cpufreq_dev->dyn_power_table = power_table; - cpufreq_dev->dyn_power_table_entries = i; return 0; - -free_power_table: - kfree(power_table); - - return ret; } static u32 cpu_freq_to_power(struct cpufreq_cooling_device *cpufreq_dev, u32 freq) { int i; - struct power_table *pt = cpufreq_dev->dyn_power_table; + struct freq_table *freq_table = cpufreq_dev->freq_table; - for (i = 1; i < cpufreq_dev->dyn_power_table_entries; i++) - if (freq < pt[i].frequency) + for (i = 1; i < cpufreq_dev->max_level; i++) + if (freq > freq_table[i].frequency) break; - return pt[i - 1].power; + return freq_table[i - 1].power; } static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_dev, u32 power) { int i; - struct power_table *pt = cpufreq_dev->dyn_power_table; + struct freq_table *freq_table = cpufreq_dev->freq_table; - for (i = 1; i < cpufreq_dev->dyn_power_table_entries; i++) - if (power < pt[i].power) + for (i = 1; i < cpufreq_dev->max_level; i++) + if (power > freq_table[i].power) break; - return pt[i - 1].frequency; + return freq_table[i - 1].frequency; } /** @@ -463,7 +447,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, if (cpufreq_dev->cpufreq_state == state) return 0; - clip_freq = cpufreq_dev->freq_table[state]; + clip_freq = cpufreq_dev->freq_table[state].frequency; cpufreq_dev->cpufreq_state = state; cpufreq_dev->clipped_freq = clip_freq; @@ -576,7 +560,7 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, num_cpus = cpumask_weight(cpufreq_dev->policy->cpus); - freq = cpufreq_dev->freq_table[state]; + freq = cpufreq_dev->freq_table[state].frequency; if (!freq) return -EINVAL; @@ -750,7 +734,7 @@ __cpufreq_cooling_register(struct device_node *np, if (capacitance) { cpufreq_dev->plat_get_static_power = plat_static_func; - ret = build_dyn_power_table(cpufreq_dev, capacitance); + ret = update_freq_table(cpufreq_dev, capacitance); if (ret) { cdev = ERR_PTR(ret); goto free_table; @@ -764,14 +748,14 @@ __cpufreq_cooling_register(struct device_node *np, ret = ida_simple_get(&cpufreq_ida, 0, 0, GFP_KERNEL); if (ret < 0) { cdev = ERR_PTR(ret); - goto free_power_table; + goto free_table; } cpufreq_dev->id = ret; /* Fill freq-table in descending order of frequencies */ for (i = 0, freq = -1; i <= cpufreq_dev->max_level; i++) { freq = find_next_max(policy->freq_table, freq); - cpufreq_dev->freq_table[i] = freq; + cpufreq_dev->freq_table[i].frequency = freq; /* Warn for duplicate entries */ if (!freq) @@ -788,7 +772,7 @@ __cpufreq_cooling_register(struct device_node *np, if (IS_ERR(cdev)) goto remove_ida; - cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0]; + cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0].frequency; cpufreq_dev->cdev = cdev; cpufreq_dev->policy = policy; @@ -805,8 +789,6 @@ __cpufreq_cooling_register(struct device_node *np, remove_ida: ida_simple_remove(&cpufreq_ida, cpufreq_dev->id); -free_power_table: - kfree(cpufreq_dev->dyn_power_table); free_table: kfree(cpufreq_dev->freq_table); free_time_in_idle_timestamp: @@ -953,7 +935,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) thermal_cooling_device_unregister(cpufreq_dev->cdev); ida_simple_remove(&cpufreq_ida, cpufreq_dev->id); - kfree(cpufreq_dev->dyn_power_table); kfree(cpufreq_dev->time_in_idle_timestamp); kfree(cpufreq_dev->time_in_idle); kfree(cpufreq_dev->freq_table); From patchwork Thu Mar 16 05:29:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95381 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660838qgd; Wed, 15 Mar 2017 22:31:08 -0700 (PDT) X-Received: by 10.99.49.13 with SMTP id x13mr5296230pgx.128.1489642268735; Wed, 15 Mar 2017 22:31:08 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si2965884pfk.113.2017.03.15.22.31.08; Wed, 15 Mar 2017 22:31:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751763AbdCPFat (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:49 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36176 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbdCPFap (ORCPT ); Thu, 16 Mar 2017 01:30:45 -0400 Received: by mail-pg0-f42.google.com with SMTP id g2so19546817pge.3 for ; Wed, 15 Mar 2017 22:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=GlzTatM5BBtgtVwJKIg5ErxQuKs6ZMm2CvfCbgjetiM=; b=RUE1W6jtxHMXdSnbNc8oiB2qkKiax5VVPQRpjZMvpZg8/kSvTEQRLE8ZOBR2488ZVm jOsYyNMieoImTtMkq/1fbkJoVM70DDjFiiznzObMkertwFSz3m4RAegGh5Jk56YJrOjd AmZrup1CgMjlY7gq9Q2Gv/TWXMhDm2LA4tTz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=GlzTatM5BBtgtVwJKIg5ErxQuKs6ZMm2CvfCbgjetiM=; b=mFpDDFEg4VNgvmKG3t1qnQyc3qfC4OwHQMlfpLpSLVXrUQPcKKe31aVbL8Q93kRJll mVkmQu0Of2V/OCRJ+eL901VqE1tf8eUY13cZE3yb6vbjHJ0bO11v3vlwBCcbmQ/8MXv9 V+kwYu7pKY0MbcJCNo0HTwNudonfGD9BfpEWchyoZi6IRSjkGmMJa5V37uK5pKjc7jl4 r7j/3pERy0EHeBDOANiICkARMmXSISJsb36eZ7fewCKUlbLDItv5jH/VizUvXoFrrfnw 6jaY4jt8ncc8to4m7XljLwvU0iaPZUiyqvnvgL928UJixSwCd6p6pUGHYvBG8tUkNE7S QpYQ== X-Gm-Message-State: AFeK/H3GRBIdJlxAHeUAXa7YAznEtOFNy1IT+ulOt/f0XklI7LC3Xsnm+yeDyLNgiVu8UyX/ X-Received: by 10.99.173.69 with SMTP id y5mr7919976pgo.35.1489642239054; Wed, 15 Mar 2017 22:30:39 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id v186sm7441517pgv.44.2017.03.15.22.30.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:38 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 13/17] thermal: cpu_cooling: create structure for idle time stats Date: Thu, 16 Mar 2017 10:59:48 +0530 Message-Id: <35e6886bbf741ed214416ab1d76dd46632888a66.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We keep two arrays for idle time stats and allocate memory for them separately. It would be much easier to follow if we create an array of idle stats structure instead and allocate it once. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 53 ++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 28 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 960135d85a71..69388a903706 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -62,6 +62,16 @@ struct freq_table { }; /** + * struct time_in_idle - Idle time stats + * @time: previous reading of the absolute time that this cpu was idle + * @timestamp: wall time of the last invocation of get_cpu_idle_time_us() + */ +struct time_in_idle { + u64 time; + u64 timestamp; +}; + +/** * struct cpufreq_cooling_device - data for cooling device with cpufreq * @id: unique integer value corresponding to each cpufreq_cooling_device * registered. @@ -76,9 +86,7 @@ struct freq_table { * cpufreq frequencies. * @node: list_head to link all cpufreq_cooling_device together. * @last_load: load measured by the latest call to cpufreq_get_requested_power() - * @time_in_idle: previous reading of the absolute time that this cpu was idle - * @time_in_idle_timestamp: wall time of the last invocation of - * get_cpu_idle_time_us() + * @idle_time: idle time stats * @cpu_dev: the cpu_device of policy->cpu. * @plat_get_static_power: callback to calculate the static power * @@ -95,8 +103,7 @@ struct cpufreq_cooling_device { struct freq_table *freq_table; /* In descending order */ struct list_head node; u32 last_load; - u64 *time_in_idle; - u64 *time_in_idle_timestamp; + struct time_in_idle *idle_time; struct device *cpu_dev; get_static_t plat_get_static_power; }; @@ -297,18 +304,19 @@ static u32 get_load(struct cpufreq_cooling_device *cpufreq_dev, int cpu, { u32 load; u64 now, now_idle, delta_time, delta_idle; + struct time_in_idle *idle_time = &cpufreq_dev->idle_time[cpu_idx]; now_idle = get_cpu_idle_time(cpu, &now, 0); - delta_idle = now_idle - cpufreq_dev->time_in_idle[cpu_idx]; - delta_time = now - cpufreq_dev->time_in_idle_timestamp[cpu_idx]; + delta_idle = now_idle - idle_time->time; + delta_time = now - idle_time->timestamp; if (delta_time <= delta_idle) load = 0; else load = div64_u64(100 * (delta_time - delta_idle), delta_time); - cpufreq_dev->time_in_idle[cpu_idx] = now_idle; - cpufreq_dev->time_in_idle_timestamp[cpu_idx] = now; + idle_time->time = now_idle; + idle_time->timestamp = now; return load; } @@ -705,22 +713,14 @@ __cpufreq_cooling_register(struct device_node *np, return ERR_PTR(-ENOMEM); num_cpus = cpumask_weight(policy->related_cpus); - cpufreq_dev->time_in_idle = kcalloc(num_cpus, - sizeof(*cpufreq_dev->time_in_idle), - GFP_KERNEL); - if (!cpufreq_dev->time_in_idle) { + cpufreq_dev->idle_time = kcalloc(num_cpus, + sizeof(*cpufreq_dev->idle_time), + GFP_KERNEL); + if (!cpufreq_dev->idle_time) { cdev = ERR_PTR(-ENOMEM); goto free_cdev; } - cpufreq_dev->time_in_idle_timestamp = - kcalloc(num_cpus, sizeof(*cpufreq_dev->time_in_idle_timestamp), - GFP_KERNEL); - if (!cpufreq_dev->time_in_idle_timestamp) { - cdev = ERR_PTR(-ENOMEM); - goto free_time_in_idle; - } - /* max_level is an index, not a counter */ cpufreq_dev->max_level = i - 1; @@ -728,7 +728,7 @@ __cpufreq_cooling_register(struct device_node *np, GFP_KERNEL); if (!cpufreq_dev->freq_table) { cdev = ERR_PTR(-ENOMEM); - goto free_time_in_idle_timestamp; + goto free_idle_time; } if (capacitance) { @@ -791,10 +791,8 @@ __cpufreq_cooling_register(struct device_node *np, ida_simple_remove(&cpufreq_ida, cpufreq_dev->id); free_table: kfree(cpufreq_dev->freq_table); -free_time_in_idle_timestamp: - kfree(cpufreq_dev->time_in_idle_timestamp); -free_time_in_idle: - kfree(cpufreq_dev->time_in_idle); +free_idle_time: + kfree(cpufreq_dev->idle_time); free_cdev: kfree(cpufreq_dev); return cdev; @@ -935,8 +933,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) thermal_cooling_device_unregister(cpufreq_dev->cdev); ida_simple_remove(&cpufreq_ida, cpufreq_dev->id); - kfree(cpufreq_dev->time_in_idle_timestamp); - kfree(cpufreq_dev->time_in_idle); + kfree(cpufreq_dev->idle_time); kfree(cpufreq_dev->freq_table); kfree(cpufreq_dev); } From patchwork Thu Mar 16 05:29:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95385 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp661018qgd; Wed, 15 Mar 2017 22:31:39 -0700 (PDT) X-Received: by 10.99.7.206 with SMTP id 197mr7869993pgh.95.1489642298951; Wed, 15 Mar 2017 22:31:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z62si4145225pgb.391.2017.03.15.22.31.38; Wed, 15 Mar 2017 22:31:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbdCPFbi (ORCPT + 25 others); Thu, 16 Mar 2017 01:31:38 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:36189 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751749AbdCPFas (ORCPT ); Thu, 16 Mar 2017 01:30:48 -0400 Received: by mail-pg0-f53.google.com with SMTP id g2so19547539pge.3 for ; Wed, 15 Mar 2017 22:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=nTw5v5AeuXN2aR49ft8AryYj59Cyy1Z3/RPE5hydpxo=; b=MPn3Cqj2qa70RmUb987wJUF8yvkqyeDSWmDd3YBljY6ikpbcc72fqyR6sB53gMiXzn XuU7U9m1oUW7Fvp4lqPUs2XJlSDq1uOuAPiyxE6+MQapiUl9gQ+D33A6VFKA4Jm5Ak9D V/N+56MNn6OHuk7K8nWQqDYWVoCAbTIWr5RiY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=nTw5v5AeuXN2aR49ft8AryYj59Cyy1Z3/RPE5hydpxo=; b=th9X7F8hyBoSbeKJpKSqGUj1D0iaJOrPnj7JHA1Q/96GmQqKyGAJmTpNfhHYCitz2J CHmpxPw/1lnAuoeVdYDhUSDP7qyI5TdJX+0FgjKB3OzP3QX+2O3WUpfwwb6mZuxFLTAG 5QpHQ3l4jLVFt47G+YgCBl1IyTr0OvtQRdiY3w2qGkCHSg6LIKySWDYISlpsCbwCr3Co sefiYkwLrvQvz2pEkjXdRRkKaSYNpzARzgwWX6puJqZdI2oJvUOEg7aJn08VA9k0gbkQ 8nyQu5kLVylSKGA105FugKQ5GLUfGZPoTRJVfpu74sfYRskut6Nxuq1vbgWQuqcokU1B hz7g== X-Gm-Message-State: AFeK/H0wgzpsi3cKMqoUhNW4WoyGWD16oeEmrQv0EkK1vEtKHwPi31nvnQhoPW/kkKNPwfvI X-Received: by 10.99.129.200 with SMTP id t191mr8206413pgd.41.1489642242297; Wed, 15 Mar 2017 22:30:42 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id m6sm7406776pfm.22.2017.03.15.22.30.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:41 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 14/17] thermal: cpu_cooling: get_level() can't fail Date: Thu, 16 Mar 2017 10:59:49 +0530 Message-Id: <670bd7723463c1a8e45bb9fb1c40b7a6e3ee73e0.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The frequency passed to get_level() is returned by cpu_power_to_freq() and it is guaranteed that get_level() can't fail. Get rid of error code. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 69388a903706..fd84802d2e8e 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -120,22 +120,19 @@ static LIST_HEAD(cpufreq_dev_list); * @cpufreq_dev: cpufreq_dev for which the property is required * @freq: Frequency * - * Return: level on success, THERMAL_CSTATE_INVALID on error. + * Return: level corresponding to the frequency. */ static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_dev, unsigned int freq) { + struct freq_table *freq_table = cpufreq_dev->freq_table; unsigned long level; - for (level = 0; level <= cpufreq_dev->max_level; level++) { - if (freq == cpufreq_dev->freq_table[level].frequency) - return level; - - if (freq > cpufreq_dev->freq_table[level].frequency) + for (level = 1; level < cpufreq_dev->max_level; level++) + if (freq > freq_table[level].frequency) break; - } - return THERMAL_CSTATE_INVALID; + return level - 1; } /** @@ -624,13 +621,6 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, target_freq = cpu_power_to_freq(cpufreq_dev, normalised_power); *state = get_level(cpufreq_dev, target_freq); - if (*state == THERMAL_CSTATE_INVALID) { - dev_err_ratelimited(&cdev->device, - "Failed to convert %dKHz for cpu %d into a cdev state\n", - target_freq, policy->cpu); - return -EINVAL; - } - trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state, power); return 0; From patchwork Thu Mar 16 05:29:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95382 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660840qgd; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) X-Received: by 10.98.134.142 with SMTP id x136mr8270503pfd.64.1489642269083; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si2965884pfk.113.2017.03.15.22.31.08; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786AbdCPFay (ORCPT + 25 others); Thu, 16 Mar 2017 01:30:54 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:35412 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbdCPFat (ORCPT ); Thu, 16 Mar 2017 01:30:49 -0400 Received: by mail-pg0-f45.google.com with SMTP id b129so19575030pgc.2 for ; Wed, 15 Mar 2017 22:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=YwDvGhN/ikBRJyYCn64jJuTGyRwV4jcwda4lIl/UIuA=; b=SKx78DIEH2Eq5qyiD+1gcEV2W5I8ceMfZfKwFvF9Vh0kQGlpbxHVYfjlDrYM4hTAVI zdf9R5oBkPFbw09H10HvWeway7aWCKKFodaJxiKDDY53o2VHYzX+/wO870r0ZaYR1cde iDUo0LrCU57BQyEPz/WoYY3qLDyI7f7phSlzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=YwDvGhN/ikBRJyYCn64jJuTGyRwV4jcwda4lIl/UIuA=; b=jFFVJwqPTmAxe/Q/8tsMB3N0j/eS1u5rvlmPJ51XY3csdJHx/Ub1F/0YKt3Zhl6Qig ZV7oVBWknm1ndU7gS8y2vtoLc7uolMQn1Gf7hXm39yJDJVIy7j5f1x6CX38HvL4H7B5x USvCjWYxqncmfQ8GOf2XOwurzoCUw+Af3xDrx6rJPvPIliTaZZ+6QhlaCs+OKxRfqT1k KO3tNxJ54daCjfYevEB6JaI707606ZzkP5HiUrt2FwqT7xw1Ok0hJzUeswY6cVC8rRwG GB+xRRxkIEsf8JgDCru8NXhZABTu+0rhdr8KJVKF8vmnBhr8oFh3TqIqDqq30YLUoUYp CQWQ== X-Gm-Message-State: AFeK/H2ZIQDANsp4QlvJsurM9T4h6CUzvI6h0H6xZtATPynRQ2Uc/h/d+XQO1t+A7qJGiHMV X-Received: by 10.84.241.203 with SMTP id t11mr9768058plm.48.1489642248661; Wed, 15 Mar 2017 22:30:48 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id x10sm7419401pfi.21.2017.03.15.22.30.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:48 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 16/17] thermal: cpu_cooling: 'freq' can't be zero in cpufreq_state2power() Date: Thu, 16 Mar 2017 10:59:51 +0530 Message-Id: <252aef1977bab800768c5144e907f8d0696323a9.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The frequency table shouldn't have any zero frequency entries and so such a check isn't required. Though it would be better to make sure 'state' is within limits. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index fb535fd5aa12..768a95bcc392 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -561,12 +561,13 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, int ret; struct cpufreq_cooling_device *cpufreq_dev = cdev->devdata; + /* Request state should be less than max_level */ + if (WARN_ON(state > cpufreq_dev->max_level)) + return -EINVAL; + num_cpus = cpumask_weight(cpufreq_dev->policy->cpus); freq = cpufreq_dev->freq_table[state].frequency; - if (!freq) - return -EINVAL; - dynamic_power = cpu_freq_to_power(cpufreq_dev, freq) * num_cpus; ret = get_static_power(cpufreq_dev, tz, freq, &static_power); if (ret) From patchwork Thu Mar 16 05:29:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95384 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660849qgd; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) X-Received: by 10.98.46.130 with SMTP id u124mr8132553pfu.204.1489642269757; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si2965884pfk.113.2017.03.15.22.31.09; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751809AbdCPFbB (ORCPT + 25 others); Thu, 16 Mar 2017 01:31:01 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:33066 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbdCPFa6 (ORCPT ); Thu, 16 Mar 2017 01:30:58 -0400 Received: by mail-pf0-f178.google.com with SMTP id w189so19008344pfb.0 for ; Wed, 15 Mar 2017 22:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=dkL0TZqzCW2AOQ4TGC9HfU7Su82X/avgNwGi9Z+OtAw=; b=gBk7tQ2l3/emWYqDwnAmKGHALDGvl6aeXl4MMD3XIM3Q5e98r0rjsX+5o7B6uhWCZT YS9ukoyGqrRJr/aO7y8fuLjVt7EUMpSqJPXwhihGVb6Ac8Nvq9W8j11DQIn3MrstJVI5 AbbFwEiXMPeJZAm9s1frF0HzXyl55j3A5ajaM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=dkL0TZqzCW2AOQ4TGC9HfU7Su82X/avgNwGi9Z+OtAw=; b=TUbbv9OnDggxYXPPsuwiFMueD/DSfnQL4/jOgPgpVEcH0kGlnHj/oyNzIsGx88r7ZU XxxPbz1F+HFZuoFUPS28Cy5Byt8gUxdhgqjuuDBQ7TDJQ8/n9Fi2G+PmcNwRPA2zIIBs b4tYiFzkUbqk0vKekosrTIQObnLu8duGxLUO5zySLPGIYK+7cruNIQ6kPnWaDAnFzJrp Da2PsLO93hdbI55l3/3YD1fkDx3zN4rdHolktf7SK2dV3HwgURGMW2U4oETeF4rNJP2A dRcgIW9vGwVg6l9+G3h8+ThmCfjrHWVMZk/H2cwWZLTqnvTQpdbY9iKoyAEdDCfw0eCD Qqwg== X-Gm-Message-State: AFeK/H04YY1WcFsPxgCM0/jW7HK+4/WyPTNT9cOVsxlFto0+SI/mfDTEUyxHaufs+f1h51hf X-Received: by 10.98.223.133 with SMTP id d5mr8209520pfl.222.1489642251725; Wed, 15 Mar 2017 22:30:51 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id z189sm7491547pgb.3.2017.03.15.22.30.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:51 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 17/17] thermal: cpu_cooling: Rearrange struct cpufreq_cooling_device Date: Thu, 16 Mar 2017 10:59:52 +0530 Message-Id: <57676b8e5f4e21ae1645b8cc2a2ddb5f059262bc.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This shrinks the size of the structure on arm64 by 8 bytes by avoiding padding of 4 bytes at two places. Also add missing doc comment for freq_table Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 768a95bcc392..f31c753ac08f 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -75,17 +75,18 @@ struct time_in_idle { * struct cpufreq_cooling_device - data for cooling device with cpufreq * @id: unique integer value corresponding to each cpufreq_cooling_device * registered. - * @cdev: thermal_cooling_device pointer to keep track of the - * registered cooling device. - * @policy: cpufreq policy. + * @last_load: load measured by the latest call to cpufreq_get_requested_power() * @cpufreq_state: integer value representing the current state of cpufreq * cooling devices. * @clipped_freq: integer value representing the absolute value of the clipped * frequency. * @max_level: maximum cooling level. One less than total number of valid * cpufreq frequencies. + * @freq_table: Freq table in descending order of frequencies + * @cdev: thermal_cooling_device pointer to keep track of the + * registered cooling device. + * @policy: cpufreq policy. * @node: list_head to link all cpufreq_cooling_device together. - * @last_load: load measured by the latest call to cpufreq_get_requested_power() * @idle_time: idle time stats * @plat_get_static_power: callback to calculate the static power * @@ -94,14 +95,14 @@ struct time_in_idle { */ struct cpufreq_cooling_device { int id; - struct thermal_cooling_device *cdev; - struct cpufreq_policy *policy; + u32 last_load; unsigned int cpufreq_state; unsigned int clipped_freq; unsigned int max_level; struct freq_table *freq_table; /* In descending order */ + struct thermal_cooling_device *cdev; + struct cpufreq_policy *policy; struct list_head node; - u32 last_load; struct time_in_idle *idle_time; get_static_t plat_get_static_power; };