From patchwork Wed Nov 15 09:19:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 118926 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp3271206edl; Wed, 15 Nov 2017 01:22:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMZsqBwhEMqLExKqwdSnI54jNz7+Ngq3YHoDQr6JkCcPjfnmdcWc2IZvDalyNvxqsysJqomL X-Received: by 10.99.108.67 with SMTP id h64mr8686611pgc.119.1510737721255; Wed, 15 Nov 2017 01:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510737721; cv=none; d=google.com; s=arc-20160816; b=R9eaoBlYmtcaTeMJzvaXYaIDsl3SPr24G8GALHeIGf81iMOugqchnGHiQ411Ubr2pJ RRkGqUrMJAjfeZbIjRmn42KrcOx0FrVbsNUCeqSNksLAh+EmKzrvHDOILG8jH5+4OhGG MU2huQQc7Xv4Y++S79KN7ShaHGBbMJIW/EPw1IsS+gZ9tfTPlCNQYzqXGW6r7JH5vsPk L3OutO/yWuuJSAs1TS2DgANMCYUMN7xeifgdZ8zCLRCCQRxhmt28tJiTkU4NtFIMI8av 5GduZHjAlfPwRt4BJNoJ4BrsCyMW07ZnlXtzth/cj8ClVL4Ed9R69DSFsTM37VxBh4zi Ajxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TROy9LBHK4ObN6nqkjG3noq2HFOOaEmOoO/RcXFAyJw=; b=zCoeSDkqP+2PQJlIKiT/JZwKIb+fRxUytmiaV4dGqME+UefPmEkNyL91x7H9/qs6CQ GNHA/ScX7reGclxMgtJ5gnferS0u3WJKGGl+6H6OeHMQg5skEhQoInRvCa4fbmpPYw5I GbRW1vzyyQRAYx8PMjEDz+MoJdKE7VA2iFWobhhjZJ/BzYNRao1xOu+QSl0qEptuEDqx +PyCAFQ6rhufXkVhz84GXd5ecemrFSCE5kZ6HR5w5mF+cx13Zevy30/d3H0GwWbx8K5N Tcei86IQYgPs5HWP1/f8A6UqYsQmk8wpd9dryQK8nALCAcbZa8030iBOGBDJ6iD99fmL 1v/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXjdCeQz; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si17624195plz.611.2017.11.15.01.22.01; Wed, 15 Nov 2017 01:22:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXjdCeQz; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1757109AbdKOJV7 (ORCPT + 11 others); Wed, 15 Nov 2017 04:21:59 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:48686 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756430AbdKOJU5 (ORCPT ); Wed, 15 Nov 2017 04:20:57 -0500 Received: by mail-pg0-f68.google.com with SMTP id s11so12126662pgc.5 for ; Wed, 15 Nov 2017 01:20:57 -0800 (PST) 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=TROy9LBHK4ObN6nqkjG3noq2HFOOaEmOoO/RcXFAyJw=; b=PXjdCeQzNhIEScTyKm/HuagznXkZNz+dpJgjLVHPrqDwZlQZhPNeFOwSNXsp3AWrV5 nTfHaEVORamrr3z0yxIfAkjQ+QhSpXzGYSYy5bqDiVvuRM4iOrBoqw3QrRAjan0MtWXj f0AoJmrjkCFvcxqIifZrXE3an/xrasJxdWzXM= 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=TROy9LBHK4ObN6nqkjG3noq2HFOOaEmOoO/RcXFAyJw=; b=Yj4ulo+nmZ7KHEBbADkRpozkgKYoZcvYCdc0n6JLIOIJP/F7pkK4aVJBoTbzcRD+FK /tQpe2TKF2pR6pyxXzSR1KDvBbxIg2YkJZmXvbHGGfWUZfcSMm4r/icOBlCyeX8zcWCS c9pAD4zpDHhxbhjki2ks30cqTEkp5IvaxtkoaEzFzyQUd9xha41effhQ0ofmIMJwUTxQ pQRL2IhNwegPklwPCMYXmVr/RuBtJIN2vX8O5jqf1TzazKsGljbn7uZmcEZmP7UxeVtF NNj2p5W7LqCeTtCOAPe+HBLPAG5KnF1UGzcTAQqxnpT/kPUoBg5pil/xD/3BEbJYy4uy aaHw== X-Gm-Message-State: AJaThX6zcaXfO+RcYsbn3KbXeLZD9A/sN1+FRC0RMEV7+64IhHFohvg9 F6DMZeSnguGPCJm8JMSFYdOLyQ== X-Received: by 10.84.128.68 with SMTP id 62mr15216713pla.442.1510737657095; Wed, 15 Nov 2017 01:20:57 -0800 (PST) Received: from localhost ([122.171.67.221]) by smtp.gmail.com with ESMTPSA id m25sm8892062pfk.37.2017.11.15.01.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 01:20:56 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , edubezval@gmail.com, Amit Daniel Kachhap , Javi Merino , Jonathan Corbet , Sudeep Holla , Zhang Rui , Matthias Brugger Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 1/4] cpu_cooling: Make of_cpufreq_power_cooling_register() parse DT Date: Wed, 15 Nov 2017 14:49:45 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org All the callers of of_cpufreq_power_cooling_register() have almost identical code and it makes more sense to move that code into the helper as its all about reading DT properties. This got rid of lot of redundant code. Signed-off-by: Viresh Kumar --- Documentation/thermal/cpu-cooling-api.txt | 7 ++--- drivers/cpufreq/arm_big_little.c | 23 +-------------- drivers/cpufreq/cpufreq-dt.c | 27 +---------------- drivers/cpufreq/mediatek-cpufreq.c | 22 +------------- drivers/cpufreq/qoriq-cpufreq.c | 14 +-------- drivers/thermal/cpu_cooling.c | 49 +++++++++++++++++++------------ include/linux/cpu_cooling.h | 15 ++-------- 7 files changed, 41 insertions(+), 116 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/Documentation/thermal/cpu-cooling-api.txt b/Documentation/thermal/cpu-cooling-api.txt index 71653584cd03..4f6f5e9bb4d6 100644 --- a/Documentation/thermal/cpu-cooling-api.txt +++ b/Documentation/thermal/cpu-cooling-api.txt @@ -51,8 +51,7 @@ Dynamic power). "plat_static_func" is a function to calculate the static power consumed by these cpus (See 2.2 Static power). 1.1.4 struct thermal_cooling_device *of_cpufreq_power_cooling_register( - struct device_node *np, const struct cpumask *clip_cpus, u32 capacitance, - get_static_t plat_static_func) + struct cpufreq_policy *policy) Similar to cpufreq_power_cooling_register, this function register a cpufreq cooling device with power extensions using the device tree @@ -76,8 +75,8 @@ cpu. If you are using CONFIG_CPUFREQ_DT then the device. The `plat_static_func` parameter of `cpufreq_power_cooling_register()` -and `of_cpufreq_power_cooling_register()` is optional. If you don't -provide it, only dynamic power will be considered. +is optional. If you don't provide it, only dynamic power will be +considered. 2.1 Dynamic power diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index 65ec5f01aa8d..3d5ed4ef3927 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -526,34 +526,13 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy) static void bL_cpufreq_ready(struct cpufreq_policy *policy) { - struct device *cpu_dev = get_cpu_device(policy->cpu); int cur_cluster = cpu_to_cluster(policy->cpu); - struct device_node *np; /* Do not register a cpu_cooling device if we are in IKS mode */ if (cur_cluster >= MAX_CLUSTERS) return; - np = of_node_get(cpu_dev->of_node); - if (WARN_ON(!np)) - return; - - if (of_find_property(np, "#cooling-cells", NULL)) { - u32 power_coefficient = 0; - - of_property_read_u32(np, "dynamic-power-coefficient", - &power_coefficient); - - cdev[cur_cluster] = of_cpufreq_power_cooling_register(np, - policy, power_coefficient, NULL); - if (IS_ERR(cdev[cur_cluster])) { - dev_err(cpu_dev, - "running cpufreq without cooling device: %ld\n", - PTR_ERR(cdev[cur_cluster])); - cdev[cur_cluster] = NULL; - } - } - of_node_put(np); + cdev[cur_cluster] = of_cpufreq_power_cooling_register(policy); } static struct cpufreq_driver bL_cpufreq_driver = { diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 545946ad0752..1e7bec7694ab 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -319,33 +319,8 @@ static int cpufreq_exit(struct cpufreq_policy *policy) static void cpufreq_ready(struct cpufreq_policy *policy) { struct private_data *priv = policy->driver_data; - struct device_node *np = of_node_get(priv->cpu_dev->of_node); - if (WARN_ON(!np)) - return; - - /* - * For now, just loading the cooling device; - * thermal DT code takes care of matching them. - */ - if (of_find_property(np, "#cooling-cells", NULL)) { - u32 power_coefficient = 0; - - of_property_read_u32(np, "dynamic-power-coefficient", - &power_coefficient); - - priv->cdev = of_cpufreq_power_cooling_register(np, - policy, power_coefficient, NULL); - if (IS_ERR(priv->cdev)) { - dev_err(priv->cpu_dev, - "running cpufreq without cooling device: %ld\n", - PTR_ERR(priv->cdev)); - - priv->cdev = NULL; - } - } - - of_node_put(np); + priv->cdev = of_cpufreq_power_cooling_register(policy); } static struct cpufreq_driver dt_cpufreq_driver = { diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c index 18c4bd9a5c65..dd0bc783cb8b 100644 --- a/drivers/cpufreq/mediatek-cpufreq.c +++ b/drivers/cpufreq/mediatek-cpufreq.c @@ -310,28 +310,8 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy, static void mtk_cpufreq_ready(struct cpufreq_policy *policy) { struct mtk_cpu_dvfs_info *info = policy->driver_data; - struct device_node *np = of_node_get(info->cpu_dev->of_node); - u32 capacitance = 0; - if (WARN_ON(!np)) - return; - - if (of_find_property(np, "#cooling-cells", NULL)) { - of_property_read_u32(np, DYNAMIC_POWER, &capacitance); - - info->cdev = of_cpufreq_power_cooling_register(np, - policy, capacitance, NULL); - - if (IS_ERR(info->cdev)) { - dev_err(info->cpu_dev, - "running cpufreq without cooling device: %ld\n", - PTR_ERR(info->cdev)); - - info->cdev = NULL; - } - } - - of_node_put(np); + info->cdev = of_cpufreq_power_cooling_register(policy); } static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu) diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index 4ada55b8856e..3a665c18e14e 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c @@ -275,20 +275,8 @@ static int qoriq_cpufreq_target(struct cpufreq_policy *policy, static void qoriq_cpufreq_ready(struct cpufreq_policy *policy) { struct cpu_data *cpud = policy->driver_data; - struct device_node *np = of_get_cpu_node(policy->cpu, NULL); - if (of_find_property(np, "#cooling-cells", NULL)) { - cpud->cdev = of_cpufreq_cooling_register(np, policy); - - if (IS_ERR(cpud->cdev) && PTR_ERR(cpud->cdev) != -ENOSYS) { - pr_err("cpu%d is not running as cooling device: %ld\n", - policy->cpu, PTR_ERR(cpud->cdev)); - - cpud->cdev = NULL; - } - } - - of_node_put(np); + cpud->cdev = of_cpufreq_power_cooling_register(policy); } static struct cpufreq_driver qoriq_cpufreq_driver = { diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 908a8014cf76..5740b49fee68 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -873,38 +873,51 @@ EXPORT_SYMBOL(cpufreq_power_cooling_register); /** * of_cpufreq_power_cooling_register() - create cpufreq cooling device with power extensions - * @np: a valid struct device_node to the cooling device device tree node - * @policy: cpufreq policy - * @capacitance: dynamic power coefficient for these cpus - * @plat_static_func: function to calculate the static power consumed by these - * cpus (optional) + * @policy: CPUFreq policy. * * This interface function registers the cpufreq cooling device with * the name "thermal-cpufreq-%x". This api can support multiple * instances of cpufreq cooling devices. Using this API, the cpufreq - * cooling device will be linked to the device tree node provided. + * cooling device will be linked to the device tree node of the provided + * policy's CPU. * Using this function, the cooling device will implement the power * extensions by using a simple cpu power model. The cpus must have * registered their OPPs using the OPP library. * - * An optional @plat_static_func may be provided to calculate the - * static power consumed by these cpus. If the platform's static - * power consumption is unknown or negligible, make it NULL. + * It also takes into account, if property present in policy CPU node, the + * static power consumed by the cpu. * * Return: a valid struct thermal_cooling_device pointer on success, - * on failure, it returns a corresponding ERR_PTR(). + * and NULL on failure. */ struct thermal_cooling_device * -of_cpufreq_power_cooling_register(struct device_node *np, - struct cpufreq_policy *policy, - u32 capacitance, - get_static_t plat_static_func) +of_cpufreq_power_cooling_register(struct cpufreq_policy *policy) { - if (!np) - return ERR_PTR(-EINVAL); + struct device_node *np = of_get_cpu_node(policy->cpu, NULL); + struct thermal_cooling_device *cdev = NULL; + u32 capacitance = 0; + + if (!np) { + pr_err("cpu_cooling: OF node not available for cpu%d\n", + policy->cpu); + return NULL; + } - return __cpufreq_cooling_register(np, policy, capacitance, - plat_static_func); + if (of_find_property(np, "#cooling-cells", NULL)) { + of_property_read_u32(np, "dynamic-power-coefficient", + &capacitance); + + cdev = __cpufreq_cooling_register(np, policy, capacitance, + NULL); + if (IS_ERR(cdev)) { + pr_err("cpu_cooling: cpu%d is not running as cooling device: %ld\n", + policy->cpu, PTR_ERR(cdev)); + cdev = NULL; + } + } + + of_node_put(np); + return cdev; } EXPORT_SYMBOL(of_cpufreq_power_cooling_register); diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index d4292ebc5c8b..f09d4feb34f4 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -56,10 +56,7 @@ of_cpufreq_cooling_register(struct device_node *np, struct cpufreq_policy *policy); struct thermal_cooling_device * -of_cpufreq_power_cooling_register(struct device_node *np, - struct cpufreq_policy *policy, - u32 capacitance, - get_static_t plat_static_func); +of_cpufreq_power_cooling_register(struct cpufreq_policy *policy); #else static inline struct thermal_cooling_device * of_cpufreq_cooling_register(struct device_node *np, @@ -69,10 +66,7 @@ of_cpufreq_cooling_register(struct device_node *np, } static inline struct thermal_cooling_device * -of_cpufreq_power_cooling_register(struct device_node *np, - struct cpufreq_policy *policy, - u32 capacitance, - get_static_t plat_static_func) +of_cpufreq_power_cooling_register(struct cpufreq_policy *policy) { return NULL; } @@ -105,10 +99,7 @@ of_cpufreq_cooling_register(struct device_node *np, } static inline struct thermal_cooling_device * -of_cpufreq_power_cooling_register(struct device_node *np, - struct cpufreq_policy *policy, - u32 capacitance, - get_static_t plat_static_func) +of_cpufreq_power_cooling_register(struct cpufreq_policy *policy) { return NULL; } From patchwork Wed Nov 15 09:19: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: 118925 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp3270963edl; Wed, 15 Nov 2017 01:21:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMYWGwh+RZWab3KrCUQX3idBNIjALlavgRMfKgxI5gjQLZn0hhr1peMZmhvhJ2x1Rbd6ijQx X-Received: by 10.101.72.1 with SMTP id h1mr15185348pgs.249.1510737701637; Wed, 15 Nov 2017 01:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510737701; cv=none; d=google.com; s=arc-20160816; b=kPTb8ihIGvIaX/NWdFpCWSIjU2hc0LGoQ3dxni2kn1gOu1/JGxyouBksftxq1ssGTH YUOpbCuUX+upGaJlhbdX5XJCCuJnrF9sugT6vwNnEbtNt+jC9qRRH5oMnqAWesyEMtTE p7BWi3TQhoRV5C/kWzc0dV8ztHdq5/7dJfJD97EUECtScvjHP4zSJUDT5MB8v7GXWM4a e6aKd/zwdxOEUr6IwxNu0z2wisL+L6pvT+2IzAa9vL6t3cMTaVVPCmTwMT5lRRpIFVdQ p7Vqw4pNgL+JFpyIcl/VWQHrs0hhJ3YyOZiSuLE6IHGypQA/WA0nArfI9rbczZvhN1Fv kOoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KpZPQhY1OfkFlJdsmhdJGExGo+/K9Kad1tn2vOg/hEM=; b=rmNztA4lvrvA7h0CtfDyFcWozVQqvj7dRlnRjlg5toFLWOzUX2hsT/vV+HKYFk4gbr jw/1MtYnrd8nffjsObD+ePzy9K7jNfXFvnOrPQQWZHeJU/vuMXCPfpD5SINwZzftbV9D 0znxdcd1fUkdNNsxoN+Ob5R+LE+vzpSGHS2bkpxr9gPYOfqgOvU/3Uo+XMOiDNBSqaSb AvuATADBTrxC70gBFCl20jpzkwN1sn2SExE7ZTzFC6xDLv6vG+mz5A6JTVwbQ/L5VgQm vTU7SpcPa+3nZFqie2S9S0V1wqE/P2uI2rErj49gmpMU5T8Vlaszc3QWSyJP6mBbpE6T 8MCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i9jhOiML; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si17624195plz.611.2017.11.15.01.21.41; Wed, 15 Nov 2017 01:21:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i9jhOiML; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1756985AbdKOJVg (ORCPT + 11 others); Wed, 15 Nov 2017 04:21:36 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:47335 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756920AbdKOJVH (ORCPT ); Wed, 15 Nov 2017 04:21:07 -0500 Received: by mail-pf0-f193.google.com with SMTP id t69so7614773pfg.4 for ; Wed, 15 Nov 2017 01:21:06 -0800 (PST) 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=KpZPQhY1OfkFlJdsmhdJGExGo+/K9Kad1tn2vOg/hEM=; b=i9jhOiMLIcX0zhR5WbpXEPCvNmIQIzZshxrBlW2Yf9m3W4Jti1AZ/OA2k22G5GrSHx EQ4b05hPwZ7JN0GVRCm+YjQMf9+dMtjfCJZ278stRW/ifpftMbPUq/TgANNpvm7LQ3o6 cwGcCw2iah68TM8rsZ/WblfUCTT7ak//avSR8= 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=KpZPQhY1OfkFlJdsmhdJGExGo+/K9Kad1tn2vOg/hEM=; b=YUBe5IIO56hWQEDOONcrsFFnLs7gOJ5nebgw7OO67flUkigotGYSSE/vg2SPuAZk1J 901doa4UYims4YjBCpma94S09t4Bi/x2cJrdeTP8BjHuCH80SMPIJlE3uYbPUfoSe1gj IzV6KfQC5CFcnGkmVTvLh2mxJWFhXW0cANfAs/smghCGyb0I/YGxFjcegE2qNfY3HHcw JEKGn8u0WXuA9Ct1LJ1aknzKarXssJWVOqmDnXl7vVnCfvZYJyLDoJEtpSZn5QnLSeMX JKv2PAxJC2OGhS70oXxzuLejgmQgXFRzIjCtflVVNakUo+B6dyXbKKCno8ODjpU1t3o0 q1Lw== X-Gm-Message-State: AJaThX5N2+OklmJKDm2iGDeRfCm3R+myRo+V23p992uvhJhR+RjmMjoN bKABG3V1gWobAaaLzgA2bGLyVw== X-Received: by 10.99.110.6 with SMTP id j6mr15329804pgc.246.1510737666160; Wed, 15 Nov 2017 01:21:06 -0800 (PST) Received: from localhost ([122.171.67.221]) by smtp.gmail.com with ESMTPSA id v15sm39122606pfa.50.2017.11.15.01.21.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 01:21:05 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , edubezval@gmail.com, Amit Daniel Kachhap , Javi Merino , Zhang Rui , Steven Rostedt , Ingo Molnar Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , lukasz.luba@arm.com, linux-kernel@vger.kernel.org, Javi Merino , Punit Agrawal Subject: [PATCH 4/4] cpu_cooling: Drop static-power related stuff Date: Wed, 15 Nov 2017 14:49:48 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org No one has used it for the last two and half years (since it was introduced by commit c36cf0717631 ("thermal: cpu_cooling: implement the power cooling device API")), get rid of it. Cc: Javi Merino Cc: Punit Agrawal Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 106 +++++------------------------------------ include/linux/cpu_cooling.h | 3 -- include/trace/events/thermal.h | 10 ++-- 3 files changed, 16 insertions(+), 103 deletions(-) -- 2.15.0.194.g9af6a3dea062 Acked-by: Eduardo Valentin diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 55d6b9fb909d..f102ad6127a4 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -88,7 +88,6 @@ struct time_in_idle { * @policy: cpufreq policy. * @node: list_head to link all cpufreq_cooling_device together. * @idle_time: idle time stats - * @plat_get_static_power: callback to calculate the static power * * This structure is required for keeping information of each registered * cpufreq_cooling_device. @@ -104,7 +103,6 @@ struct cpufreq_cooling_device { struct cpufreq_policy *policy; struct list_head node; struct time_in_idle *idle_time; - get_static_t plat_get_static_power; }; static DEFINE_IDA(cpufreq_ida); @@ -318,60 +316,6 @@ static u32 get_load(struct cpufreq_cooling_device *cpufreq_cdev, int cpu, return load; } -/** - * get_static_power() - calculate the static power consumed by the cpus - * @cpufreq_cdev: 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 - * - * Calculate the static power consumed by the cpus described by - * @cpu_actor running at frequency @freq. This function relies on a - * platform specific function that should have been provided when the - * actor was registered. If it wasn't, the static power is assumed to - * be negligible. The calculated static power is stored in @power. - * - * Return: 0 on success, -E* on failure. - */ -static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, - struct thermal_zone_device *tz, unsigned long freq, - u32 *power) -{ - struct dev_pm_opp *opp; - unsigned long voltage; - struct cpufreq_policy *policy = cpufreq_cdev->policy; - struct cpumask *cpumask = policy->related_cpus; - unsigned long freq_hz = freq * 1000; - struct device *dev; - - if (!cpufreq_cdev->plat_get_static_power) { - *power = 0; - return 0; - } - - dev = get_cpu_device(policy->cpu); - WARN_ON(!dev); - - opp = dev_pm_opp_find_freq_exact(dev, freq_hz, true); - if (IS_ERR(opp)) { - dev_warn_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n", - freq_hz, PTR_ERR(opp)); - return -EINVAL; - } - - voltage = dev_pm_opp_get_voltage(opp); - dev_pm_opp_put(opp); - - if (voltage == 0) { - dev_err_ratelimited(dev, "Failed to get voltage for frequency %lu\n", - freq_hz); - return -EINVAL; - } - - return cpufreq_cdev->plat_get_static_power(cpumask, tz->passive_delay, - voltage, power); -} - /** * get_dynamic_power() - calculate the dynamic power * @cpufreq_cdev: &cpufreq_cooling_device for this cdev @@ -491,8 +435,8 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, u32 *power) { unsigned long freq; - int i = 0, cpu, ret; - u32 static_power, dynamic_power, total_load = 0; + int i = 0, cpu; + u32 total_load = 0; struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; struct cpufreq_policy *policy = cpufreq_cdev->policy; u32 *load_cpu = NULL; @@ -522,22 +466,15 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, cpufreq_cdev->last_load = total_load; - dynamic_power = get_dynamic_power(cpufreq_cdev, freq); - ret = get_static_power(cpufreq_cdev, tz, freq, &static_power); - if (ret) { - kfree(load_cpu); - return ret; - } + *power = get_dynamic_power(cpufreq_cdev, freq); if (load_cpu) { trace_thermal_power_cpu_get_power(policy->related_cpus, freq, - load_cpu, i, dynamic_power, - static_power); + load_cpu, i, *power); kfree(load_cpu); } - *power = static_power + dynamic_power; return 0; } @@ -561,8 +498,6 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, unsigned long state, u32 *power) { unsigned int freq, num_cpus; - u32 static_power, dynamic_power; - int ret; struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; /* Request state should be less than max_level */ @@ -572,13 +507,9 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus); freq = cpufreq_cdev->freq_table[state].frequency; - dynamic_power = cpu_freq_to_power(cpufreq_cdev, freq) * num_cpus; - ret = get_static_power(cpufreq_cdev, tz, freq, &static_power); - if (ret) - return ret; + *power = cpu_freq_to_power(cpufreq_cdev, freq) * num_cpus; - *power = static_power + dynamic_power; - return ret; + return 0; } /** @@ -606,21 +537,14 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, unsigned long *state) { unsigned int cur_freq, target_freq; - int ret; - s32 dyn_power; - u32 last_load, normalised_power, static_power; + u32 last_load, normalised_power; struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; struct cpufreq_policy *policy = cpufreq_cdev->policy; cur_freq = cpufreq_quick_get(policy->cpu); - ret = get_static_power(cpufreq_cdev, tz, cur_freq, &static_power); - if (ret) - return ret; - - dyn_power = power - static_power; - dyn_power = dyn_power > 0 ? dyn_power : 0; + power = power > 0 ? power : 0; last_load = cpufreq_cdev->last_load ?: 1; - normalised_power = (dyn_power * 100) / last_load; + normalised_power = (power * 100) / last_load; target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); *state = get_level(cpufreq_cdev, target_freq); @@ -671,8 +595,6 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table, * @policy: cpufreq policy * Normally this should be same as cpufreq policy->related_cpus. * @capacitance: dynamic power coefficient for these cpus - * @plat_static_func: function to calculate the static power consumed by these - * cpus (optional) * * This interface function registers the cpufreq cooling device with the name * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq @@ -684,8 +606,7 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table, */ static struct thermal_cooling_device * __cpufreq_cooling_register(struct device_node *np, - struct cpufreq_policy *policy, u32 capacitance, - get_static_t plat_static_func) + struct cpufreq_policy *policy, u32 capacitance) { struct thermal_cooling_device *cdev; struct cpufreq_cooling_device *cpufreq_cdev; @@ -755,8 +676,6 @@ __cpufreq_cooling_register(struct device_node *np, } if (capacitance) { - cpufreq_cdev->plat_get_static_power = plat_static_func; - ret = update_freq_table(cpufreq_cdev, capacitance); if (ret) { cdev = ERR_PTR(ret); @@ -813,7 +732,7 @@ __cpufreq_cooling_register(struct device_node *np, struct thermal_cooling_device * cpufreq_cooling_register(struct cpufreq_policy *policy) { - return __cpufreq_cooling_register(NULL, policy, 0, NULL); + return __cpufreq_cooling_register(NULL, policy, 0); } EXPORT_SYMBOL_GPL(cpufreq_cooling_register); @@ -853,8 +772,7 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) of_property_read_u32(np, "dynamic-power-coefficient", &capacitance); - cdev = __cpufreq_cooling_register(np, policy, capacitance, - NULL); + cdev = __cpufreq_cooling_register(np, policy, capacitance); if (IS_ERR(cdev)) { pr_err("cpu_cooling: cpu%d is not running as cooling device: %ld\n", policy->cpu, PTR_ERR(cdev)); diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index a0204c58d269..22d7364cbc16 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -30,9 +30,6 @@ struct cpufreq_policy; -typedef int (*get_static_t)(cpumask_t *cpumask, int interval, - unsigned long voltage, u32 *power); - #ifdef CONFIG_CPU_THERMAL /** * cpufreq_cooling_register - function to create cpufreq cooling device. diff --git a/include/trace/events/thermal.h b/include/trace/events/thermal.h index 466c09d882ad..52424cf13408 100644 --- a/include/trace/events/thermal.h +++ b/include/trace/events/thermal.h @@ -93,9 +93,9 @@ TRACE_EVENT(thermal_zone_trip, TRACE_EVENT(thermal_power_cpu_get_power, TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load, - size_t load_len, u32 dynamic_power, u32 static_power), + size_t load_len, u32 dynamic_power), - TP_ARGS(cpus, freq, load, load_len, dynamic_power, static_power), + TP_ARGS(cpus, freq, load, load_len, dynamic_power), TP_STRUCT__entry( __bitmask(cpumask, num_possible_cpus()) @@ -103,7 +103,6 @@ TRACE_EVENT(thermal_power_cpu_get_power, __dynamic_array(u32, load, load_len) __field(size_t, load_len ) __field(u32, dynamic_power ) - __field(u32, static_power ) ), TP_fast_assign( @@ -114,13 +113,12 @@ TRACE_EVENT(thermal_power_cpu_get_power, load_len * sizeof(*load)); __entry->load_len = load_len; __entry->dynamic_power = dynamic_power; - __entry->static_power = static_power; ), - TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d static_power=%d", + TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d", __get_bitmask(cpumask), __entry->freq, __print_array(__get_dynamic_array(load), __entry->load_len, 4), - __entry->dynamic_power, __entry->static_power) + __entry->dynamic_power) ); TRACE_EVENT(thermal_power_cpu_limit,