From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D7A5C433E4 for ; Mon, 20 Jul 2020 12:18:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E021722B4D for ; Mon, 20 Jul 2020 12:18:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kroah.com header.i=@kroah.com header.b="npmmPscE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fHRc77/V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728700AbgGTMSd (ORCPT ); Mon, 20 Jul 2020 08:18:33 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:58923 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbgGTMSd (ORCPT ); Mon, 20 Jul 2020 08:18:33 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id DA422580458; Mon, 20 Jul 2020 08:18:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 20 Jul 2020 08:18:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=Zou6qAflmxW7TQM12J8BVt0wUlM oX2IiWZ/QdAdyc6w=; b=npmmPscEfVl5ZO2ikn3bQb/N4pTyVSJ2vHu2kyeuf0n w14Sch7ufOxs6SGCWUjJFR1WVBKYIM1wws8FpeOW2Ve3xzl415Mkwr8ytvV2O4ys A6kHcOIPSNXCgMojs2HSxveUte3rJb/gs/NQYV6E5D2N9BEg9oV9lDN6LLISMFs3 ElVAyxnvA5S+vzpx8iuRjWX4cuye0QPQT0H3BZZuOu41TNhdRP6PUsLtfhiSgZvG NSQgitjikhvkv6TmV+dQmHwpgsv/PBeiHOiMbQDp2B61gM+BT47nXp5w5AKDMfQs QeFNIO+yVdh6DHNlXkGcFgs9B/m7op7lWiEGaW5KWuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Zou6qA flmxW7TQM12J8BVt0wUlMoX2IiWZ/QdAdyc6w=; b=fHRc77/VHodwY8LztJRtyc irPG7DCEVBhT7wiGzL6S09HFpEIFQvjJmSHxUQ8inp0zNwnwQhSt2ZdttkkoEY6J U4kUmSxra9dtv0BIHJK6ZSe0aCFn2E/sRc0MKbyXBDExbyjDNJt5hD8jN5/kmsWu R36xXYuzJhhHKzqgNNCSDuB8SMZbxJgJFPxZDoxPkVGjRJXBNVfcKWOuqpIcgrwa PP0arTKIilV3Sv7MvqZSK7ZuBWG1fAkqKDFiJcvaFMH4XL28TsGHgOuGn43RnISN oKt4hlIBV8X0B8ofhUAEtEphjoY490FVOrPLKt9960rJHGYgiHV/Uh5WI63Z+ogw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrgeeggddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepifhrvghgucfm jfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepueelledthe ekleethfeludduvdfhffeuvdffudevgeehkeegieffveehgeeftefgnecuffhomhgrihhn pehkvghrnhgvlhdrohhrghenucfkphepkeefrdekiedrkeelrddutdejnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghh rdgtohhm X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 424FF3280059; Mon, 20 Jul 2020 08:18:30 -0400 (EDT) Date: Mon, 20 Jul 2020 14:18:40 +0200 From: Greg KH To: Viresh Kumar Cc: stable@vger.kernel.org, Amit Daniel Kachhap , Javi Merino , Zhang Rui , Eduardo Valentin , Vincent Guittot , Finley Xiao , Amit Kucheria , Daniel Lezcano , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [For-STABLE] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power Message-ID: <20200720121840.GB2984743@kroah.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 01:23:43PM +0530, Viresh Kumar wrote: > From: Finley Xiao > > commit 371a3bc79c11b707d7a1b7a2c938dc3cc042fffb upstream. > > The function cpu_power_to_freq is used to find a frequency and set the > cooling device to consume at most the power to be converted. For example, > if the power to be converted is 80mW, and the em table is as follow. > struct em_cap_state table[] = { > /* KHz mW */ > { 1008000, 36, 0 }, > { 1200000, 49, 0 }, > { 1296000, 59, 0 }, > { 1416000, 72, 0 }, > { 1512000, 86, 0 }, > }; > The target frequency should be 1416000KHz, not 1512000KHz. > > Fixes: 349d39dc5739 ("thermal: cpu_cooling: merge frequency and power tables") > Cc: # v4.13+ > Signed-off-by: Finley Xiao > Acked-by: Viresh Kumar > Reviewed-by: Amit Kucheria > Signed-off-by: Daniel Lezcano > Link: https://lore.kernel.org/r/20200619090825.32747-1-finley.xiao@rock-chips.com > Signed-off-by: Viresh Kumar > --- > Hi Greg, > > I am resending this as I got your emails of this failing on 4.14, 4.19 > and 5.4. This should be applied to all three of them. > > @Finley: I hope I have done it correctly, please do check it as this > required me to rewrite the code to adapt to previous kernels. > > drivers/thermal/cpu_cooling.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 908a8014cf76..1f4387a5ceae 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -280,11 +280,11 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev, > int i; > struct freq_table *freq_table = cpufreq_cdev->freq_table; > > - for (i = 1; i <= cpufreq_cdev->max_level; i++) > - if (power > freq_table[i].power) > + for (i = 0; i < cpufreq_cdev->max_level; i++) > + if (power >= freq_table[i].power) > break; > > - return freq_table[i - 1].frequency; > + return freq_table[i].frequency; > } > > /** > -- > 2.25.0.rc1.19.g042ed3e048af > Now queued up, thanks. greg k-h