From patchwork Thu Jan 25 06:23:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Di Shen X-Patchwork-Id: 191847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1451892dyi; Wed, 24 Jan 2024 22:27:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjLe8psiQXntITC7jS0otYpVeaI5ukm6icwXwg9nXSbQtJebVe4ZMxNJIBYrX80n/vp6R4 X-Received: by 2002:a05:6a21:33a7:b0:199:fe49:6bb3 with SMTP id yy39-20020a056a2133a700b00199fe496bb3mr626815pzb.5.1706164028342; Wed, 24 Jan 2024 22:27:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706164028; cv=pass; d=google.com; s=arc-20160816; b=EWZIyduclbigX8h1uVdeYoZDOp491AQjlLeEkYsttPTBPkGGfYIjZ1xfIyPQSSJgc/ 8n5wa6d8UTgop7hSRYoZvxfkLnlSbP3jiS9leB72T0sVs75NRZnFnSwj0zhARWLNbHC6 X85DPzqMz6ObCYG0v8ChP8LAlll8qbUvNSu8GH27uQCLxj5B86tcIwyu1HmGCgpdIr3R IIakNpN7Cu150KEPOQdYPA2/W6bbISNXSJtQJsrKBo8MAyVA7+gYMmeyPEyPu/xo42GL Wg8DQ8JH3GvyPedZxZHpt1sosseXZC3e447oLw6lW8K+0c+DUm/Ec3uZ0lsCctqq7kfd mwdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from; bh=d4UGS1YD99z0Yfty5DZmN5o/KAtqOsg+qOkzVYFPHfc=; fh=V34BVVpU8VmKs8PEHIlT/yincNXP2mvih5acAjYfdrQ=; b=Ux4TLqv3mvNLFaqH/fyYpzkQcCT0CU5WzdFXU8mHoj4ASf1BdN2ttTlEWxQ2h1jDCM ygMYNjws64AaX+4hyMcPeXveLKj+HKiNLodyz819ypKkMixFUu30HwxTA7RdiWv0Veli ebZ4SbSzsRM7VuVWu3kDql+i1nAN7PgDxTplCLFuLS0fcpcv170rf3Sbj3PphcNJcw/o 2iYTjgsMqL1MyqTSpfspUIhCG6RtylhRfJd2+i9v8OOO37VekWkT47n11szIBpLjIDNz jDTLpUu3kH7b453dpY/sT0u7IIv6xtqT47TYVlJStfhfGTgWJNJF/HDRPLc6peeAlYIY xqVw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-38002-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38002-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id r22-20020a638f56000000b005d4d50dd1acsi2450757pgn.605.2024.01.24.22.27.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 22:27:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38002-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-38002-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38002-ouuuleilei=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 828FCB2215E for ; Thu, 25 Jan 2024 06:24:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 075C8111A1; Thu, 25 Jan 2024 06:24:16 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (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 26A3410A12; Thu, 25 Jan 2024 06:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706163854; cv=none; b=WnafPK1LsZEzIkJKYc9ZfyxdIUWfCcJF8q9Vr19RI53J2UB7QoJjUvzH2mB3df3nMMY1Gg0W4mh5aqNuO7GU5DaX5+2z//3xNnjuNjg48BdGvkGWMDyY6q6uTwSIvOzBVkUA3l5XeHkpmRlF3LYtWeJdP7E5djr4ZDxEuU+T2fY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706163854; c=relaxed/simple; bh=IJnqiJ3su0ULAtCoiKNxfIa4lBJxYdBgJQZXApe+y2A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EqJV3bUAMVwF7sSDvN7nUgMv2CIUz+o59UxiSKmZCUDAeilO67IsVBH4Aoh2ZvE4NIVEdndPRDEn8hqTc4AcBbjbGXI2Sibm68YafszVWSv6+MObbXcHDJze1cPqrBGGKlpDOoagbSsXAp9Kh14+PngGHnUUi17h/THiR8Tptdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 40P6NZMG074726; Thu, 25 Jan 2024 14:23:35 +0800 (+08) (envelope-from Di.Shen@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4TL9Z2408Nz2SKBpW; Thu, 25 Jan 2024 14:16:10 +0800 (CST) Received: from bj10906pcu1.spreadtrum.com (10.0.73.72) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Jan 2024 14:23:33 +0800 From: Di Shen To: , , , CC: , , , , , Subject: [PATCH V2] thermal: power_allocator: Avoid overwriting PID coefficients from setup time Date: Thu, 25 Jan 2024 14:23:31 +0800 Message-ID: <20240125062331.28943-1-di.shen@unisoc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <1f8914cb-fc66-4068-8f7c-4d13b2454f7d@arm.com> References: <1f8914cb-fc66-4068-8f7c-4d13b2454f7d@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 40P6NZMG074726 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789042651942324879 X-GMAIL-MSGID: 1789042651942324879 When the PID coefficients k_* are set via sysfs before the IPA algorithm is triggered then the coefficients would be overwritten after IPA throttle() is called. The old configuration values might be different than the new values estimated by the IPA internal algorithm. There might be a time delay when this overwriting happens. It depends on the thermal zone temperature value. The temperature value needs to cross the first trip point value then IPA algorithms start operating. Although, the PID coefficients setup time should not be affected or linked to any later operating phase and values must not be overwritten. This patch initializes params->sustainable_power when the governor binds to thermal zone to avoid overwriting k_*. The basic function won't be affected, as the k_* still can be estimated if the sustainable_power is modified. Signed-off-by: Di Shen Reviewed-by: Lukasz Luba --- drivers/thermal/gov_power_allocator.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 81e061f183ad..1b17dc4c219c 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -711,6 +711,8 @@ static int power_allocator_bind(struct thermal_zone_device *tz) if (!tz->tzp->sustainable_power) dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n"); + else + params->sustainable_power = tz->tzp->sustainable_power; estimate_pid_constants(tz, tz->tzp->sustainable_power, params->trip_switch_on,