From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Lezcano Subject: Re: [PATCH V2 6/7] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver Date: Tue, 27 Mar 2018 13:10:07 +0200 Message-ID: References: <1519226968-19821-1-git-send-email-daniel.lezcano@linaro.org> <1519226968-19821-7-git-send-email-daniel.lezcano@linaro.org> <20180223073432.GF26947@vireshk-i7> <20180327034344.GC21693@leoy-ThinkPad-X240s> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20180327034344.GC21693@leoy-ThinkPad-X240s> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Leo Yan Cc: Viresh Kumar , edubezval@gmail.com, kevin.wangtao@linaro.org, vincent.guittot@linaro.org, amit.kachhap@gmail.com, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org List-Id: linux-pm@vger.kernel.org On 27/03/2018 05:43, Leo Yan wrote: > On Fri, Feb 23, 2018 at 12:28:51PM +0100, Daniel Lezcano wrote: >> On 23/02/2018 08:34, Viresh Kumar wrote: >>> On 21-02-18, 16:29, Daniel Lezcano wrote: > >> [ ... ] >> >>>> +static s64 cpuidle_cooling_runtime(struct cpuidle_cooling_device *idle_cdev) >>>> +{ >>>> + s64 next_wakeup; >>>> + int state = idle_cdev->state; >>>> + >>>> + /* >>>> + * The function must never be called when there is no >>>> + * mitigation because: >>>> + * - that does not make sense >>>> + * - we end up with a division by zero >>>> + */ >>>> + BUG_ON(!state); >>> >>> As there is no locking in place, we can surely hit this case. What if >>> the state changed to 0 right before this routine was called ? >>> >>> I would suggest we should just return 0 in that case and get away with >>> the BUG_ON(). > > Here if 'state' equals to 0 and we return 0, then the return value will > be same with when 'state' = 100; this lets the return value confused. > > I think for 'state' = 0, should we return -1 so indicate the hrtimer > will not be set for this case? Yeah, I will look at how to make this smoother. Thanks -- Daniel -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog