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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 A2EA2C433E0 for ; Tue, 7 Jul 2020 15:27:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A26F20663 for ; Tue, 7 Jul 2020 15:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135655; bh=Hzd4mdpfs9i93+btfq6vbDL4GqORE4KZfetCqu8IKOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aH+v9d0YzDW3kfwEoiOIGFw+lPU30Wz0Gx9xWbdDj66t3aOSxK9nsdgYFBSzZwy8e OMwNgN3hSfDQviJHSWJyZQ5YJdb8aElT102WFDZJLa9PRjVMvPUtWKHCmL18psmEdy x+u0rGkFDqCtG1z9pAXnkaA0hFpPNVgbG9VWf9d4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730359AbgGGP1W (ORCPT ); Tue, 7 Jul 2020 11:27:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:41728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730355AbgGGP1Q (ORCPT ); Tue, 7 Jul 2020 11:27:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0730B20663; Tue, 7 Jul 2020 15:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135635; bh=Hzd4mdpfs9i93+btfq6vbDL4GqORE4KZfetCqu8IKOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMrnIz0svDOYVdD9rYfxGStVcaI8jxhh72xv8ZqG3qjfLLPY6JDUnXjV5zz/emPX+ lNL42sZxx4ZPQTwzeezLgMl0Jm+HLZ7fGlL5pmLNq8JOF/WRuygXjr+ElRpZR3Fo0M dueVXFe3AtOCJwBGW9yYIYd4qw5r3s5evKeJyYo8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Finley Xiao , Viresh Kumar , Amit Kucheria , Daniel Lezcano Subject: [PATCH 5.7 096/112] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power Date: Tue, 7 Jul 2020 17:17:41 +0200 Message-Id: <20200707145805.543763207@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145800.925304888@linuxfoundation.org> References: <20200707145800.925304888@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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: Greg Kroah-Hartman --- drivers/thermal/cpufreq_cooling.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -123,12 +123,12 @@ static u32 cpu_power_to_freq(struct cpuf { int i; - for (i = cpufreq_cdev->max_level - 1; i >= 0; i--) { - if (power > cpufreq_cdev->em->table[i].power) + for (i = cpufreq_cdev->max_level; i >= 0; i--) { + if (power >= cpufreq_cdev->em->table[i].power) break; } - return cpufreq_cdev->em->table[i + 1].frequency; + return cpufreq_cdev->em->table[i].frequency; } /**