Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp350924lqp; Thu, 21 Mar 2024 03:22:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW56tvn6ZnUyPYrxLBNGcWE5AdARF7JKDlW76/kS2VkpEkuAaN4T214bq5Yrz6ZVj3RYVMgIAmHsjwuSyaDCgDiflc0qvpq/EuRqJF7ww== X-Google-Smtp-Source: AGHT+IGPralrxLcYSl3kEr5VWrcmH+7HhBHJjY6A1rKEaeCaY1RSLtE+qaMqPMVnlUefvovwxYXy X-Received: by 2002:a17:906:470f:b0:a45:231:9b4b with SMTP id y15-20020a170906470f00b00a4502319b4bmr5320296ejq.20.1711016525606; Thu, 21 Mar 2024 03:22:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711016525; cv=pass; d=google.com; s=arc-20160816; b=yE4LPhd4h1I/T4PvWKa5vpA4HxnCQrn2efh8Sfsb6F77H4+72uWj4A43HUce9LFHGG CZHewN+1bYXZyFsuj112Q8FNrDRk2kUEM72AbbPUbfrtoMj4V+zSzbX3NCsHPnX7WMAE 6bzrH5wOmHClzJQqKFv1Ia4j0rsOQ2w+bH4z1DHKgWfJLSn9vIddgfGkMcFaIdK1roPw /w0RhOsOsXl2vTdWoXsqMiQJYRPDDOvmK/e7SxMldYtLtcgO/8SEmLfBMCQFUot71Gi9 Bzv7rU8UL+WKyB7bnftMuR2f4EieNW+bCXV1EQ1dV6WtuYjtkpGKCaA356ENb1Qj1/ej NTKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ktnsnF64wj/H5bwoeAclYjmtYjAzqxy2pnWppwBZrP8=; fh=KNAZwROhZwwcKvzw2YRKLYyUXGTWn5seo6RkapJ8QwU=; b=NX+XPwYD+xyukxByFMaMJV5whG6c1yMesYGTmVRUrZDZ2fc3AsGxWjBi6UdcsxqEzd FQ6oAwd4ZSIWOPpGE429LoI4iEsSupTSV/EPMLwRh1aXIrg2iQ6qp2Iwqv9RDUko+tuQ N4zHPlzPpyEoUYVwIO3tf0rnYr2jyTTgCaNXzRz7Kh3lXKrI5b1xbp9ZHeKegnRnWX1J EDd7lHsDflX4eIlsLFNLygmoVuePQaOxRhiMFfwTOf3LT04pxVSRMx/q0k/1ufgMDXEg vuIGzoB7ciVqjyc8JQECOZ+6UojaN8xnDRJwlkO7RPaWDc+jXog5Bq5GmHRjZNLT4mIh Qbog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rock-chips.com header.s=default header.b=FLvH+Y2h; arc=pass (i=1 spf=pass spfdomain=rock-chips.com dkim=pass dkdomain=rock-chips.com dmarc=pass fromdomain=rock-chips.com); spf=pass (google.com: domain of linux-kernel+bounces-109887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a24-20020a17090640d800b00a46618ec5fasi7537571ejk.452.2024.03.21.03.22.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 03:22:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rock-chips.com header.s=default header.b=FLvH+Y2h; arc=pass (i=1 spf=pass spfdomain=rock-chips.com dkim=pass dkdomain=rock-chips.com dmarc=pass fromdomain=rock-chips.com); spf=pass (google.com: domain of linux-kernel+bounces-109887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1B5531F224EC for ; Thu, 21 Mar 2024 10:22:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0C2356766; Thu, 21 Mar 2024 10:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="FLvH+Y2h" Received: from mail-m4921.qiye.163.com (mail-m4921.qiye.163.com [45.254.49.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 221C056448; Thu, 21 Mar 2024 10:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711016516; cv=none; b=KZXKV/spNQghW+qs13sZrOZlJjZu3RGSctsmEjZBpcxnl3/ZRb5M7HQn2ibiUQDG41INjEPdXcPzV72ANsNkZaFoBS9841swWEUV/j3CbMnIa/5s+KnYPMLyLcjfkZAauOPHN8j75gYy/Ja6F8TdDTkXF50RtbBy5NKJf7IETQk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711016516; c=relaxed/simple; bh=i0+PV72/2dFaK31wvWPoX0d6bxJSY6XBCsINwakqKcM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=f0ry7c/86e4Lemt7VPRtMNdPte6bEg4liB80GjieBiBmx9dXCUh7AN9PDkvI7iwFpuxoW/olcEjC48N03RA0Xl3FG8ObVp4SQebXIJ9EUlGFIh80qZFnjrMrHdwfojlPv+niQI3rP+4XpB+ktXQfbWj8+iqKkB2ogFxCfA7wqfE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=FLvH+Y2h; arc=none smtp.client-ip=45.254.49.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com DKIM-Signature: a=rsa-sha256; b=FLvH+Y2h76AlDPjOD9msC4pT2xE4BWTFOguXgNsDgjOA9zfDgm9rtxIFllbE3G/ylIra5kBR+bVFpYUpYYimNX1hSCOjOYl4mF6F3mq7ysdonnY3l2mlGClPUuwb0PGatTcRH269fp6X1Bk6vXcYYht/S7zwiEvgbrxRFTn6APY=; s=default; c=relaxed/relaxed; d=rock-chips.com; v=1; bh=ktnsnF64wj/H5bwoeAclYjmtYjAzqxy2pnWppwBZrP8=; h=date:mime-version:subject:message-id:from; Received: from rockchip.. (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTPA id C897B7E033F; Thu, 21 Mar 2024 18:21:02 +0800 (CST) From: Ye Zhang To: ye.zhang@rock-chips.com, finley.xiao@rock-chips.com, heiko@sntech.de, daniel.lezcano@linaro.org, rui.zhang@intel.com, lukasz.luba@arm.com, rafael@kernel.org Cc: tao.huang@rock-chips.com, linux-rockchip@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] thermal: devfreq_cooling: Fix perf state when calculate dfc res_util Date: Thu, 21 Mar 2024 18:21:00 +0800 Message-Id: <20240321102100.2401340-1-ye.zhang@rock-chips.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQh4fGlYZQkoeSkwZQ00aTUJVEwETFh oSFyQUDg9ZV1kYEgtZQVlOQ1VJSVVMVUpKT1lXWRYaDxIVHRRZQVlPS0hVSk5DTUtIVUpLS1VKQl kG X-HM-Tid: 0a8e60874c5309cfkunmc897b7e033f X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PC46Fxw*ITMKEhVNMgIJITYd NiJPCR9VSlVKTEpKS0pNT01IQ0xMVTMWGhIXVQIeVQETGhUcOwkUGBBWGBMSCwhVGBQWRVlXWRIL WUFZTkNVSUlVTFVKSk9ZV1kIAVlBSU9PSTcG The issue occurs when the devfreq cooling device uses the EM power model and the get_real_power() callback is provided by the driver. The EM power table is sorted ascending,can't index the table by cooling device state,so convert cooling state to performance state by dfc->max_state - dfc->capped_state. Fixes: 615510fe13bd ("thermal: devfreq_cooling: remove old power model and use EM") Cc: 5.11+ # 5.11+ Signed-off-by: Ye Zhang --- v1 -> v2: - Update the commit message. drivers/thermal/devfreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index 50dec24e967a..8fd7cf1932cd 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -214,7 +214,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd res = dfc->power_ops->get_real_power(df, power, freq, voltage); if (!res) { - state = dfc->capped_state; + state = dfc->max_state - dfc->capped_state; /* Convert EM power into milli-Watts first */ rcu_read_lock(); -- 2.34.1