Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp168721lqe; Thu, 4 Apr 2024 03:14:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgp94/9AFj0B8h+rei+9WYyYEh9PTxntPEjordsh0f3T+vr1v5qFYCRamZfsf7cor/9fcU2xEMrn8Q17ZfxD3BBUuxO3oM6OxuYEvI5w== X-Google-Smtp-Source: AGHT+IFP9MNgeLdwfCoWgKAvA05dSrf+trDVe5vyHWq3PFcMPq8O8/ZiMxCOwiOw+hDdtV948l4J X-Received: by 2002:ac2:4344:0:b0:516:7de8:335a with SMTP id o4-20020ac24344000000b005167de8335amr1677104lfl.59.1712225640270; Thu, 04 Apr 2024 03:14:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712225640; cv=pass; d=google.com; s=arc-20160816; b=N+7peRpKeqyhsMhMvZt39SUM2fa7qVn2f7aN6Q705FltkCQbfsW8e8+eeqkgK6noHd A9pMYFrgE/IlZCsXsC0ZoL6iRdreMAe85mYKfPVr3O5Xh9u5QIcGq7tMdQpFmmObuXNQ MMotwch5qN2/fg1IY5uccFAfsW3Kwp5LevJcktJxscGvqmU3ocDECVMoG4lLOqdesc8p X5584Jp8qSBvEQoL6Rnm2Thk27VOvK6Jgce7kDU39tR4Nw8HeikNSfH8sY+/j4OHf+yj OcO8dX+GEb9+mrsoqfs7mmg22PAdLdZ1WdaKb3wD8u7QbPEKr8RuRMsPyMN2L8ZjVSW9 T5KQ== 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; bh=YiRbTPHNlf2OSrpxKPzXnNYbMM36rRcFD+cTS5xPkAA=; fh=28CBtIv2fS13Lxo0a0lKKkoqoZXj2Qn11052CQrDkR8=; b=XWNP6TWzom96A1Qiyd0a2X5/rglppguZ6A94ZitKZO1UTSxPYckgX8oUoIZKgLkgIT ZOvHDvT3Mj6FbNTm6FqAaVXt5Z/OaeG/rxSpHc3+ZFOY32E5VdrqZIZ7GP/oc+f7Guf2 b7KH2y4dswmnJD/eUno6fNob30+nVLswIHh6MgRiZFS9iLwIJEDowm54Gmp5zb9lVaki hWqhdKLhmMoK/7WG8WzpstuqVXCukMF99C4xGkQlG2dHVXx6WZ9hqfE7eWyyhc3iPqKI hXJg2uvG12Zcmp4r62f+ZntPrlKS+fm9oofgDryWv00x0DUqboI2tFE0cqcAumaOYh2f rUWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-131228-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x9-20020a170906710900b00a4e26173876si7436628ejj.554.2024.04.04.03.14.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 03:14:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131228-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-131228-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 F3E4B1F25563 for ; Thu, 4 Apr 2024 10:13:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17FD776035; Thu, 4 Apr 2024 10:13:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17D783D96B; Thu, 4 Apr 2024 10:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712225631; cv=none; b=RbaljSFUI1ExRKX3Y1sPsdnJLFVEJi4is/xCA5w7fkxNjzc6loGYy1l3OwQiVV+pPbQeAbuB1ewMI3Ev/woLVszalYk0eZ8Us/8fWQ7/usLlyrgIM3TJelM3xEh1JXRKQialRJJWRAUYqhDANeHH2Lws/HvPRBf9pYNI7XNmzOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712225631; c=relaxed/simple; bh=1g2lgazccbIgiKqk/5FBTyjfoksupEjMYOaoWUKxbCo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=jd+3Exg2uOERi7+CJJCv6gC6EqxhXY718Ub0FhjvWbvgE6O0qFiuMAHK7MrsqB8BU++3A6UJtg9ARY7rxQeYogebnFoPDmc+yE6y/Q8St5dfgA+FZp06Vs67ZPa8C/M0tNZDSqSPz4jEdqz0MdZ6M6OMHNd/4LVlId5EVP1HkJc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 110B8FEC; Thu, 4 Apr 2024 03:14:18 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.73.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C3D693F7B4; Thu, 4 Apr 2024 03:13:45 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Cc: lukasz.luba@arm.com, stable@vger.kernel.org, ye.zhang@rock-chips.com, d-gole@ti.com, rafael@kernel.org, "Rafael J . Wysocki" Subject: [STABLE 5.15][PATCH] thermal: devfreq_cooling: Fix perf state when calculate dfc res_util Date: Thu, 4 Apr 2024 11:13:29 +0100 Message-Id: <20240404101329.1956664-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.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 From: Ye Zhang 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 Reviewed-by: Dhruva Gole Reviewed-by: Lukasz Luba Signed-off-by: Rafael J. Wysocki Signed-off-by: Lukasz Luba --- Hi Greg, I have solved small backporting conflict to that v5.15. The patch is based on tag v5.15.99 and it's for this failing backport: https://lore.kernel.org/stable/2024033050-imitation-unmixed-ef53@gregkh/ Regards, Lukasz Luba 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 d38a80adec733..5be79b5d788e5 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -199,7 +199,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; dfc->res_util = dfc->em_pd->table[state].power; dfc->res_util *= SCALE_ERROR_MITIGATION; -- 2.25.1