Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp935415lqp; Thu, 21 Mar 2024 23:35:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4RLWVQXoTP0W+fTuqgciV1H6JeYaBenR/4+5iVGQh5jcbs+4moDaWHCoAQFDp8vWGpuMxo21zWK9vSyltOOW6M9NlDpF/TOVwvUUrtQ== X-Google-Smtp-Source: AGHT+IFbWFYh0MLdc6Yz0LEUYS6/rDKoSK30PzGuFwaFV2YktK4rkvGSsNY/x3RD+g7x1bLCaYBM X-Received: by 2002:a05:6214:104f:b0:696:7026:51bd with SMTP id l15-20020a056214104f00b00696702651bdmr220935qvr.49.1711089306316; Thu, 21 Mar 2024 23:35:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711089306; cv=pass; d=google.com; s=arc-20160816; b=RmgaFgIdroon5xDdYsU7ikbw5mqBR1W1Ks0xu+f54tsSA2ix7zKj8TqWwh/o1TglJH oVsRx1OkFwEgkiFirN1L+upIND5XbHCL9Vp8N1MhF/zafPQFKyXBhJvEXTkwM7m6OQNo wiz1ejf4dkelqpq8Q2DtBLgIcpzsqxPPn8fzayZQVKVO8jzQ7IEFZZrFN4X6Uf0ASD5W 3C1rQ3pOp8K3t4ZIwAZQr7rJaQBrwq9eCXbYCo4gcpzvQ4e6H/BL455IiPG6sV/TGx+O XcwijtQyEliekjPwVw1UBJC9wY6hmigia2QNz0CHd5BV/uvGyVb0IB58asb3CtwDWwUB AUtg== 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:to:from :dkim-signature; bh=ktnsnF64wj/H5bwoeAclYjmtYjAzqxy2pnWppwBZrP8=; fh=V9AeBafJgTW96HdC48wsxGAfd7Fe9P2uAL8tLCjpUN4=; b=Oj8ERTSfaFu5MX0zI/yo7mVm9tHz5Rv0LNH0DkNLvLaZ8CCAbFITFGu52nxxs8R8+M x++LpsyeHjtSJoVu6xFASOYaLjpjITwOocu5Vdt1MMfOiewEDTZFc0498FNWyMV4vg7b JV+gkudaSpSPICuYUKu4IA4zOdCLgTCoWmafzW9KMavsZ0PHOL6MAIaK61h2unWWCbWw fxe/WxjZsvh+3Y+3Bq4LdvQs+Kg05sTvyR50+smI8DZbvfcP7uS5knpBED0DrO+8DAH0 oDp4v2mSGdynEQ+QoBCWcr2CfxyPsB/9qV5xXCV3TAmlmkSUI+Y/qvpTMFMVUyzx6RtA ShiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rock-chips.com header.s=default header.b=FOZvCIFx; 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-110996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110996-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 ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iw7-20020a0562140f2700b00691837e4f57si1457730qvb.565.2024.03.21.23.35.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 23:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rock-chips.com header.s=default header.b=FOZvCIFx; 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-110996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110996-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 10FFB1C22C6C for ; Fri, 22 Mar 2024 06:35:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CF58D26D; Fri, 22 Mar 2024 06:35:02 +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="FOZvCIFx" Received: from mail-m11885.qiye.163.com (mail-m11885.qiye.163.com [115.236.118.85]) (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 0497179D0 for ; Fri, 22 Mar 2024 06:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.236.118.85 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711089300; cv=none; b=MUIN9qiEzlsbeP2dQHJEfCbCPXpV5BOeo1uswQKDouRLkD8C5BVPX8POjjH3j+J9LKZK5wMGRUhUws99CGpI4Rt+6D+fdnxMsHOC2ub57y9JfREUPa5RpPq9yHvovmENUy0+3mFPHcmjuELbEMPCms0hCJZbRucxYYzSazr5GSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711089300; c=relaxed/simple; bh=i0+PV72/2dFaK31wvWPoX0d6bxJSY6XBCsINwakqKcM=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=UxLl80Ne2J0u+S39fYY8q1vPVmlqVvVK5otouM9sSV+mB+3RaUKObrGnoETLCG45T4n2HysfmAHY9nl+XxyCWsqfOoesxrY4Gjax5MC5g/d+2ataTQna2XNRhzPbtNrt6n4ws1GQ/if0SUoddhP8nTs5IJjMfrD4mExKF5cWGu0= 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=FOZvCIFx; arc=none smtp.client-ip=115.236.118.85 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=FOZvCIFx+okQon3GjQmyCaG7uOsxXgdd1r8gVHPktpOMMg+n0Q9s7RrYOCXm9eJCcUyw8fWEBF/CEBADcgFPbntFYkLIhY8MHPxUZVTfwEUW3CdAPxKMdXsKZn1dj4CLz9oME+p2PADGgEAOTDO0AeIMwBKjHnMn8r6rUTuNL5k=; 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 916477E067C for ; Fri, 22 Mar 2024 09:45:31 +0800 (CST) From: Ye Zhang To: linux-kernel@vger.kernel.org Subject: [PATCH v2] thermal: devfreq_cooling: Fix perf state when calculate dfc res_util Date: Fri, 22 Mar 2024 09:45:31 +0800 Message-Id: <20240322014531.1840999-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 tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZGR4fSVZNHUtOGk0fSUpKGRlVEwETFh oSFyQUDg9ZV1kYEgtZQVlOQ1VJSVVMVUpKT1lXWRYaDxIVHRRZQVlPS0hVSkhNTkJMVUpLS1VKQk tLWQY+ X-HM-Tid: 0a8e63d5acfc09cfkunm916477e067c X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NFE6Mxw*SzMOTxRRNjoSNwgQ NRMwCRFVSlVKTEpKS0xKQkhJSkhMVTMWGhIXVQIeVQETGhUcOwkUGBBWGBMSCwhVGBQWRVlXWRIL WUFZTkNVSUlVTFVKSk9ZV1kIAVlBSkNDSzcG 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