Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753314AbbK3J0g (ORCPT ); Mon, 30 Nov 2015 04:26:36 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:39716 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752548AbbK3J0c (ORCPT ); Mon, 30 Nov 2015 04:26:32 -0500 X-Listener-Flag: 11101 Message-ID: <1448875581.29031.14.camel@mtksdaap41> Subject: Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model. From: dawei chien To: Viresh Kumar CC: "Rafael J. Wysocki" , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , "Kumar Gala" , Matthias Brugger , Daniel Kurtz , Sascha Hauer , Daniel Lezcano , , , , , , , Sascha Hauer , "Punit Agrawal" Date: Mon, 30 Nov 2015 17:26:21 +0800 In-Reply-To: <20151130053845.GM3373@ubuntu> References: <1448616727-29367-1-git-send-email-dawei.chien@mediatek.com> <1448616727-29367-4-git-send-email-dawei.chien@mediatek.com> <20151130053845.GM3373@ubuntu> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3328 Lines: 101 On Mon, 2015-11-30 at 11:08 +0530, Viresh Kumar wrote: > On 27-11-15, 17:32, Dawei Chien wrote: > > MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering > > cooling devices with dynamic power coefficient. > > > > Signed-off-by: Dawei Chien > > --- > > This patch is base on patchset: > > https://lkml.org/lkml/2015/11/17/251 > > --- > > drivers/cpufreq/mt8173-cpufreq.c | 28 ++++++++++++++++++++-------- > > 1 file changed, 20 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c > > index 83001dc..4d39468 100644 > > --- a/drivers/cpufreq/mt8173-cpufreq.c > > +++ b/drivers/cpufreq/mt8173-cpufreq.c > > @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy, > > return 0; > > } > > > > +#define DYNAMIC_POWER "dynamic-power-coefficient" > > + > > 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; > > > > if (WARN_ON(!np)) > > return; > > > > if (of_find_property(np, "#cooling-cells", NULL)) { > > - info->cdev = of_cpufreq_cooling_register(np, > > - policy->related_cpus); > > + if (!info->cdev) { > > Why will info->cdev be non-NULL here ? This is a error-checking to avoid user or any script by command line hotplug CPU more than two times, we don't need to register cooling device on this case. I will remove it if you don't agree it. > > + of_property_read_u32(np, DYNAMIC_POWER, &capacitance); > > This can fail, in which case capacitance will be used uninitialized. > Fix that by initializing it with 0 at the beginning of this routine. Thank you, I will follow your comment to fix it on next version. > > + info->cdev = of_cpufreq_power_cooling_register(np, > > + policy->related_cpus, > > + capacitance, > > + NULL); > > > > - if (IS_ERR(info->cdev)) { > > - dev_err(info->cpu_dev, > > - "running cpufreq without cooling device: %ld\n", > > - PTR_ERR(info->cdev)); > > + if (IS_ERR(info->cdev)) { > > + dev_err(info->cpu_dev, > > + "running cpufreq without cooling device: %ld\n", > > + PTR_ERR(info->cdev)); > > > > - info->cdev = NULL; > > + info->cdev = NULL; > > + } > > } > > } > > > > @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy) > > { > > struct mtk_cpu_dvfs_info *info = policy->driver_data; > > > > - cpufreq_cooling_unregister(info->cdev); > > + if (info->cdev) > > + cpufreq_cooling_unregister(info->cdev); > > + > > Why do you need to update this? This is a error-checking to avoid user or any script by command line unplug CPU more than two times, we don't need to unregister cooling device on this case. I will remove it if you don't agree it. > > dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table); > > mtk_cpu_dvfs_info_release(info); > > kfree(info); > > -- > > 1.7.9.5 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/