From patchwork Wed Feb 7 02:09:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Di Shen X-Patchwork-Id: 197701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1948759dyb; Tue, 6 Feb 2024 18:10:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtC/cQ70gfjpQafUImyJp/fkrPLxbL8AfBUOpIMFGh//nP7/JrDJUJUI5PP7ywr99w2jJ5 X-Received: by 2002:a5d:6da2:0:b0:33b:48ef:e746 with SMTP id u2-20020a5d6da2000000b0033b48efe746mr2929782wrs.68.1707271807241; Tue, 06 Feb 2024 18:10:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707271807; cv=pass; d=google.com; s=arc-20160816; b=U0e3mD1q1HdO42/yxy4MAY+xyrN5K54gjcACvM3U/TZ7j9oTOOC+DFwKZNdqHJCkb+ GnQsZef3AKl6zFS14aau8tMl3apIWDIQUmX3pHOYsyESLB2TsbX2rbGBGk+T0pD0Khn1 /ZObz7OUEG37bqFs7BKoWM3hSTq0IcwhXPOcW4XX1f6h083J+Abcib13Mie0n9SElHFB JOlV7VkGlgRnWn4r3BSSikpJKP+fc5trxpH+r2yIJsTM5AkNVCKb4Z4qLGkzbgLBEUyF lT12apeHalZF+l80e5x1pA2OaX6YKzKSnDHyNzMMd7yJ8Cx6RyfozaFVylK6le6te9aV eUyw== 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 :message-id:date:subject:cc:to:from; bh=pXZ92d7RFJYHLQ55tnncyCtNSXYsICTnjx3so8hBSD4=; fh=5mGxToy96H3XFpdJ/+deD65vJdn9wZmQnNV1rzujk/g=; b=Opj7AvZLgB1NSZ9hBqnjWPvLVxwJe1ZrChkdcWQGD49M/6VnETyroZKubiVVme2es6 OmnVI7geuC+sWxklLqgkpiCeYZcnDH1Xq+oKzuS1Z+vBHJKLLLnti9+eJaPCGwE5T/qJ YJaLQtcgxizq6bYwJAEEAeav0zq6m9QqemdyvKta5jcD2ISRQ/+9RfxnFwxJQYki8kIp C3HRG34IqW7Y9Alt/nBjc6pp1s9Oh88jeouJBLF5iyiTSp/AAjLYiOaOEOtBZ3nAiY4h JhRAdpAjC16xOHjzXCeuaMK7vwYlyRGxzPBD73NKfh2AzGA1MHfvqLsz3mMjVQgSkpFZ KnwQ==; dara=google.com 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-55837-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55837-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWpYlP2umF6ZHypjmUgNlTx+iSBqexhN820UV7asFHNGKzbYYiDimMya1fo/7/+D/BOLBh2u413MYqIbS4IZkmbtQXoXw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h8-20020a50ed88000000b0055ef9a173fdsi193980edr.546.2024.02.06.18.10.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 18:10:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55837-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-55837-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55837-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D0F071F285AF for ; Wed, 7 Feb 2024 02:10:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1397EED9; Wed, 7 Feb 2024 02:09:52 +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 4C4F4FBE5; Wed, 7 Feb 2024 02:09:48 +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=1707271790; cv=none; b=MHz/wKw9PErxmM8helxaBEypJ8YiTEBzSQZBrZOyyv7KdX7RaQkm5bK8HH049Sy49MUTLhbdJ3gBCK0ca7BGHpYRATk0XD7wRXCUIAjKazMRYgXINd1+3keLUjSrzOxdFKr0tTzqXLaN2WEkVpD7Bz3t2bCw8WrBECUo+iCSeo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707271790; c=relaxed/simple; bh=nTXU8U898NWajyMP5BJwpco2rbN3R6w4FOQtYKp+DMc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MhuayEMu2NNMBz0/AfTTPd21iVAy1awjojxtbESHyPDYI+Oq2Ecr1Arl2wXnzAQ1gaJ6htA6WQEtnTrVwA9BUg+LosIJWPiI1UdIUnyKey7XDs1x7/jqasItKHo/IER6SkiB76FDDeYgaz6f7U3YfLi6RkNDwcrPcq+eGFQF4oc= 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 41729UAA090594; Wed, 7 Feb 2024 10:09:30 +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 4TV3TH0pWyz2K25NR; Wed, 7 Feb 2024 10:09:23 +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; Wed, 7 Feb 2024 10:09:28 +0800 From: Di Shen To: , , , CC: , , , , , Subject: [RESEND][PATCH V2] thermal: power_allocator: Avoid overwriting PID coefficients from setup time Date: Wed, 7 Feb 2024 10:09:23 +0800 Message-ID: <20240207020923.4720-1-di.shen@unisoc.com> X-Mailer: git-send-email 2.17.1 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 41729UAA090594 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790204242559019079 X-GMAIL-MSGID: 1790204242559019079 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,