From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756564AbbCCK7v (ORCPT ); Tue, 3 Mar 2015 05:59:51 -0500 Received: from service87.mimecast.com ([91.220.42.44]:39412 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756551AbbCCK7s convert rfc822-to-8bit (ORCPT ); Tue, 3 Mar 2015 05:59:48 -0500 Message-ID: <54F5941F.6030402@arm.com> Date: Tue, 03 Mar 2015 10:59:43 +0000 From: Kapileshwar Singh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Viresh Kumar , Javi Merino CC: Eduardo Valentin , Zhang Rui , Linux PM list , "linux-kernel@vger.kernel.org" , Punit Agrawal , Lina Iyer , Mark Brown , Jon Medhurst Subject: Re: [PATCH v3 5/5] thermal: cpu_cooling: update the cpu device when cpufreq updates the policy cpu References: <1425316643-31991-1-git-send-email-javi.merino@arm.com> <1425316643-31991-6-git-send-email-javi.merino@arm.com> In-Reply-To: X-OriginalArrivalTime: 03 Mar 2015 10:59:44.0868 (UTC) FILETIME=[2857C240:01D055A1] X-MC-Unique: 115030310594604201 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Viresh! On 03/03/15 04:03, Viresh Kumar wrote: > On Mon, Mar 2, 2015 at 10:47 PM, Javi Merino wrote: >> From: Kapileshwar Singh >> >> When cpufreq changes the policy cpu, we need to update our cached cpu >> device accordingly. >> >> Cc: Zhang Rui >> Cc: Eduardo Valentin >> Signed-off-by: Kapileshwar Singh >> --- >> drivers/thermal/cpu_cooling.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c >> index c4974144c787..e306d6bc3cf1 100644 >> --- a/drivers/thermal/cpu_cooling.c >> +++ b/drivers/thermal/cpu_cooling.c >> @@ -269,6 +269,9 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, >> mutex_unlock(&cooling_cpufreq_lock); >> break; >> >> + case CPUFREQ_UPDATE_POLICY_CPU: >> + update_cpu_device(policy->cpu); >> + break; >> case CPUFREQ_CREATE_POLICY: >> update_cpu_device(policy->cpu); >> break; > > First of all, I wasn't able to find 3/5 on LKML and I looked at 3/7 > from an earlier > version to look at how update_cpu_device() looks like. > > What I couldn't understand is why do you need to update things if policy->cpu > is changing ? > We store the device pointer of the lead CPU (policy CPU) in a cpufreq domain as a part of the cpufreq_cooling_device data structure. There is one cpufreq_cooling_device per cpufreq domain. We need the device to find out the current OPP for the cpufreq_cooling_device for our static power calculation. opp = opp_find_freq_exact(cpu_dev, freq_hz, true); voltage = dev_pm_opp_get_voltage(opp); The problem we are trying to solve here is: When this lead CPU gets hotplugged out, the device pointer becomes stale and the policy cpu for the cpufreq domain changes. We then store the new policy CPU's device pointer for the in cpufreq_cooling_device on the reception of a notification from cpufreq. Being open to your suggestions for any other possible ways to solve the problem.. Regards, KP > I am expecting a detailed answer here according to your design, and we may > be able to work out without such updates. Lets see.. >