Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1132306ybt; Tue, 7 Jul 2020 08:28:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6JDZb9DiE00pB1uLo6i7YHqDByIg2MkaIpZb4hNVBFLYDIVnd3r8tfb+XYOcu53gX1kwN X-Received: by 2002:a17:906:c096:: with SMTP id f22mr25542467ejz.159.1594135706682; Tue, 07 Jul 2020 08:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594135706; cv=none; d=google.com; s=arc-20160816; b=VU6gs87RDwdErXA4Ug4bvz58K9qAmbGeXMYenWH32AYMWMsVW3Avb4X8SWwuOfPMRr jDDISTJlQti2qa3bidh0ZxgH/5FkoXS1E1KFYoftFOTGR9uoSo+zbtjTCDXZ/4mLjhBF QitGUY4mXGSf6lvJGBLa3DXZBalZWZ6O/2ey2G2wC6Jl3F9CGErHFluDvGcZFVNnPK9w AF1ycv9Ksr1cR1MOCzPVce+SbDp6zC6c/kPo/axO5VwQWUHsxhw6a/S+3AJfGj0eUCl1 JJJWn5FTvErbNEK+PBDU7yhtWrjdZnTMxVcljJEUoEfs84TAIfISNLmRWoqk2Skq3K6x kdFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DFpO4PpuWbP0hJ/t702QMSkE+1QBCjIxpiwMrrw3LII=; b=ftUf9M8CQg3l40WDjtojuWZhBJSNafwRF+1XjVJRyZ0JCxtixPNIcVs6Yj1WSz9sGM eZP02GxRhBN2fTCHFN7NjMhb8pRzyJUUBb4W6I7OuhJXRD7Xxapo+m6lcBq7H6/TfT5B fl/aym1toM/XKeUg3vLd4xT7gBh4EmZDoCvzHd5dQ/Qy+MIv+/t3Ys3vFem0MvXVrjX4 c4beP0PJnq+cJsoE8T6mbnj2Zk196pWzNH8Nssk677GrDPLCc3YOs3V3oNkCX8Mpv5OH +anPkljd3hRNxyC+q6VtmZl/CHs6JWWZJZ0elTmTv7IZUUlVLrqetSAbhbYCP/952dsH ZHcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IMrnIz0s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox14si15521889ejb.688.2020.07.07.08.28.03; Tue, 07 Jul 2020 08:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IMrnIz0s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730369AbgGGP1Y (ORCPT + 99 others); Tue, 7 Jul 2020 11:27:24 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; } /**