Message ID | 20240110115526.30776-1-di.shen@unisoc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-22142-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp743817dyi; Wed, 10 Jan 2024 04:05:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpF158eXHl9WSJ6JJNS9NUIYgckPGTyjCTfqWN01jzj2s0ysNCbpjQseWJgZt6uzO+/IHB X-Received: by 2002:a17:90b:2503:b0:28c:d0ab:adf0 with SMTP id ns3-20020a17090b250300b0028cd0abadf0mr613262pjb.96.1704888344259; Wed, 10 Jan 2024 04:05:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704888344; cv=none; d=google.com; s=arc-20160816; b=apgK91V5Z6sElpRb79ydOuR0eyPKMKLeie76aHsWg8j/sEl2UWX/b8jhbAk9edbuLY vMCiQael7m8xJAsHRD5y9nI04TUqoHMolUoX4q+l+GO3FJPymz2ng8Sa3MJpl8oCmTnH EcH8vFKvWLMFUd2zpEgOwqKzTl+sQWrrRAL9Gi/fYjFCceHZE1bBc+CUYlau097cFiil ia3Ec3gq1wUzLc52vfLKTF2XNcLnEs31U7OfwVab0z52PEAhn05GMQrPPrRvcKkkovPf AXGoEYNhGqSWmHPZw6rhGj5YxM8KM1qnwXgaZkA734VFWA8CbA7cB0/P9up26IUvT3tY kBMw== ARC-Message-Signature: i=1; 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=Xil8R2MiKh3cpNryT4KO7eOiGjLPp2EkEcjPYuRCBMc=; fh=V8JsB5Nz8lP9WCU7XY58dCiMDIEgQ31tjBN28lzHpAg=; b=HctI9R5gc21Y/x79P7cCE8FS8zdItLh0nUa2yiJabN2oAINC+DwUDInC2zsD4iiu/h N5y/MQN2wxw+YA9rv/Fv4/BA7KZG5xv5WIVocwSY6YFINsstdjf+lykX+pyRHzlXl6wx FY30MVQ5upU7D2ZvtogErUO05MHptMlJ/v9EJ9CPnngBMJa29+Sb+AbJvXux2FN88FLz qA/OH6aS7ZLdVlOvmxBeWV0GOhnHpinEZY0ohEpA6rRpgB+TIO+K44GTbi17qVGi4GvV D8bZfuyqJPE6mGAb0zCmnH6Dia3Fc1sJfhExi0ehSLv4G07GoyDdZ3GmFyBn4UHTOR7z oBUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22142-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22142-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 jx10-20020a17090b46ca00b0028d77346f6fsi1277123pjb.29.2024.01.10.04.05.43 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 04:05:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22142-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; spf=pass (google.com: domain of linux-kernel+bounces-22142-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22142-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 9097DB251B5 for <ouuuleilei@gmail.com>; Wed, 10 Jan 2024 11:56:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B0DA482D8; Wed, 10 Jan 2024 11:55:58 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [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 806B0481A2 for <linux-kernel@vger.kernel.org>; Wed, 10 Jan 2024 11:55:50 +0000 (UTC) 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 40ABtV4Y048116; Wed, 10 Jan 2024 19:55:31 +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 4T95fV60jCz2NZjch; Wed, 10 Jan 2024 19:48:34 +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, 10 Jan 2024 19:55:28 +0800 From: Di Shen <di.shen@unisoc.com> To: <lukasz.luba@arm.com>, <rafael@kernel.org>, <daniel.lezcano@linaro.org>, <rui.zhang@intel.com> CC: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <wvw@google.com>, <tkjos@google.com>, <xuewen.yan@unisoc.com>, <zhanglyra@gmail.com>, <orsonzhai@gmail.com>, <cindygm567@gmail.com> Subject: [PATCH V7] thermal/core/power_allocator: avoid thermal cdev can not be reset Date: Wed, 10 Jan 2024 19:55:26 +0800 Message-ID: <20240110115526.30776-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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 40ABtV4Y048116 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787705000287888499 X-GMAIL-MSGID: 1787705000287888499 |
Series |
[V7] thermal/core/power_allocator: avoid thermal cdev can not be reset
|
|
Commit Message
Di Shen
Jan. 10, 2024, 11:55 a.m. UTC
Commit 0952177f2a1f ("thermal/core/power_allocator: Update once
cooling devices when temp is low") adds an update flag to avoid
the thermal event is triggered when there is no need, and
thermal cdev would be updated once when temperature is low.
But when the trips are writable, and switch_on_temp is set
to be a higher value, the cooling device state may not be
reset to 0, because last_temperature is smaller than the
switch_on_temp.
For example:
First:
switch_on_temp=70 control_temp=85;
Then userspace change the trip_temp:
switch_on_temp=45 control_temp=55 cur_temp=54
Then userspace reset the trip_temp:
switch_on_temp=70 control_temp=85 cur_temp=57 last_temp=54
At this time, the cooling device state should be reset to 0.
However, because cur_temp(57) < switch_on_temp(70)
last_temp(54) < switch_on_temp(70) ----> update = false,
update is false, the cooling device state can not be reset.
Considering tz->passive can also be represented the temperature
status, this patch modifies the update flag with tz->passive.
When the first time the temperature drops below switch_on, the
states of cooling devices can be reset once, and the tz->passive
is updated to 0. In the next round, because tz->passive is 0,
the cdev->state would not be updated.
By using the tz->passive as the "update" flag, the issue above
can be solved, and the cooling devices can be update only once
when the temperature is low.
Fixes: 0952177f2a1f ("thermal/core/power_allocator: Update once cooling devices when temp is low")
Cc: <stable@vger.kernel.org> # v5.13+
Suggested-by: Wei Wang <wvw@google.com>
Signed-off-by: Di Shen <di.shen@unisoc.com>
---
V7:
- Some formatting changes.
- Add Suggested-by tag.
V6: [6]
Compared to the previous version:
- Not change the thermal core.
- Not add new variables and function.
- Use tz->passive as "update" flag to indicate whether the cooling
devices should be reset.
V5: [5]
- Simplify the reset ops, make it no return value and no specific
trip ID as argument.
- Extend the commit message.
V4: [4]
- Compared to V3, handle it in thermal core instead of in governor.
- Add an ops to the governor structure, and call it when a trip
point is changed.
- Define reset ops for power allocator.
V3: [3]
- Add fix tag.
V2: [2]
- Compared to v1, do not revert.
- Add a variable(last_switch_on_temp) in power_allocator_params
to record the last switch_on_temp value.
- Adds a function to renew the update flag and update the
last_switch_on_temp when thermal trips are writable.
V1: [1]
- Revert commit 0952177f2a1f.
[1] https://lore.kernel.org/all/20230309135515.1232-1-di.shen@unisoc.com/
[2] https://lore.kernel.org/all/20230315093008.17489-1-di.shen@unisoc.com/
[3] https://lore.kernel.org/all/20230320095620.7480-1-di.shen@unisoc.com/
[4] https://lore.kernel.org/all/20230619063534.12831-1-di.shen@unisoc.com/
[5] https://lore.kernel.org/all/20230710033234.28641-1-di.shen@unisoc.com/
[6] https://lore.kernel.org/all/20240109112736.32566-1-di.shen@unisoc.com/
---
---
drivers/thermal/gov_power_allocator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 1/10/24 11:55, Di Shen wrote: > Commit 0952177f2a1f ("thermal/core/power_allocator: Update once > cooling devices when temp is low") adds an update flag to avoid > the thermal event is triggered when there is no need, and > thermal cdev would be updated once when temperature is low. > > But when the trips are writable, and switch_on_temp is set > to be a higher value, the cooling device state may not be > reset to 0, because last_temperature is smaller than the > switch_on_temp. > > For example: > First: > switch_on_temp=70 control_temp=85; > Then userspace change the trip_temp: > switch_on_temp=45 control_temp=55 cur_temp=54 > > Then userspace reset the trip_temp: > switch_on_temp=70 control_temp=85 cur_temp=57 last_temp=54 > > At this time, the cooling device state should be reset to 0. > However, because cur_temp(57) < switch_on_temp(70) > last_temp(54) < switch_on_temp(70) ----> update = false, > update is false, the cooling device state can not be reset. > > Considering tz->passive can also be represented the temperature > status, this patch modifies the update flag with tz->passive. > > When the first time the temperature drops below switch_on, the > states of cooling devices can be reset once, and the tz->passive > is updated to 0. In the next round, because tz->passive is 0, > the cdev->state would not be updated. > > By using the tz->passive as the "update" flag, the issue above > can be solved, and the cooling devices can be update only once > when the temperature is low. > > Fixes: 0952177f2a1f ("thermal/core/power_allocator: Update once cooling devices when temp is low") > Cc: <stable@vger.kernel.org> # v5.13+ > Suggested-by: Wei Wang <wvw@google.com> > Signed-off-by: Di Shen <di.shen@unisoc.com> > > --- > V7: > - Some formatting changes. > - Add Suggested-by tag. > > V6: [6] > Compared to the previous version: > - Not change the thermal core. > - Not add new variables and function. > - Use tz->passive as "update" flag to indicate whether the cooling > devices should be reset. > > V5: [5] > - Simplify the reset ops, make it no return value and no specific > trip ID as argument. > - Extend the commit message. > > V4: [4] > - Compared to V3, handle it in thermal core instead of in governor. > - Add an ops to the governor structure, and call it when a trip > point is changed. > - Define reset ops for power allocator. > > V3: [3] > - Add fix tag. > > V2: [2] > - Compared to v1, do not revert. > - Add a variable(last_switch_on_temp) in power_allocator_params > to record the last switch_on_temp value. > - Adds a function to renew the update flag and update the > last_switch_on_temp when thermal trips are writable. > > V1: [1] > - Revert commit 0952177f2a1f. > > [1] https://lore.kernel.org/all/20230309135515.1232-1-di.shen@unisoc.com/ > [2] https://lore.kernel.org/all/20230315093008.17489-1-di.shen@unisoc.com/ > [3] https://lore.kernel.org/all/20230320095620.7480-1-di.shen@unisoc.com/ > [4] https://lore.kernel.org/all/20230619063534.12831-1-di.shen@unisoc.com/ > [5] https://lore.kernel.org/all/20230710033234.28641-1-di.shen@unisoc.com/ > [6] https://lore.kernel.org/all/20240109112736.32566-1-di.shen@unisoc.com/ > --- > --- > drivers/thermal/gov_power_allocator.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c > index 7b6aa265ff6a..81e061f183ad 100644 > --- a/drivers/thermal/gov_power_allocator.c > +++ b/drivers/thermal/gov_power_allocator.c > @@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, > > trip = params->trip_switch_on; > if (trip && tz->temperature < trip->temperature) { > - update = tz->last_temperature >= trip->temperature; > + update = tz->passive; > tz->passive = 0; > reset_pid_controller(params); > allow_maximum_power(tz, update); Thanks for the patch, LGTM. Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
On Wed, Jan 10, 2024 at 2:03 PM Lukasz Luba <lukasz.luba@arm.com> wrote: > > > > On 1/10/24 11:55, Di Shen wrote: > > Commit 0952177f2a1f ("thermal/core/power_allocator: Update once > > cooling devices when temp is low") adds an update flag to avoid > > the thermal event is triggered when there is no need, and > > thermal cdev would be updated once when temperature is low. > > > > But when the trips are writable, and switch_on_temp is set > > to be a higher value, the cooling device state may not be > > reset to 0, because last_temperature is smaller than the > > switch_on_temp. > > > > For example: > > First: > > switch_on_temp=70 control_temp=85; > > Then userspace change the trip_temp: > > switch_on_temp=45 control_temp=55 cur_temp=54 > > > > Then userspace reset the trip_temp: > > switch_on_temp=70 control_temp=85 cur_temp=57 last_temp=54 > > > > At this time, the cooling device state should be reset to 0. > > However, because cur_temp(57) < switch_on_temp(70) > > last_temp(54) < switch_on_temp(70) ----> update = false, > > update is false, the cooling device state can not be reset. > > > > Considering tz->passive can also be represented the temperature > > status, this patch modifies the update flag with tz->passive. > > > > When the first time the temperature drops below switch_on, the > > states of cooling devices can be reset once, and the tz->passive > > is updated to 0. In the next round, because tz->passive is 0, > > the cdev->state would not be updated. > > > > By using the tz->passive as the "update" flag, the issue above > > can be solved, and the cooling devices can be update only once > > when the temperature is low. > > > > Fixes: 0952177f2a1f ("thermal/core/power_allocator: Update once cooling devices when temp is low") > > Cc: <stable@vger.kernel.org> # v5.13+ > > Suggested-by: Wei Wang <wvw@google.com> > > Signed-off-by: Di Shen <di.shen@unisoc.com> > > > > --- > > V7: > > - Some formatting changes. > > - Add Suggested-by tag. > > > > V6: [6] > > Compared to the previous version: > > - Not change the thermal core. > > - Not add new variables and function. > > - Use tz->passive as "update" flag to indicate whether the cooling > > devices should be reset. > > > > V5: [5] > > - Simplify the reset ops, make it no return value and no specific > > trip ID as argument. > > - Extend the commit message. > > > > V4: [4] > > - Compared to V3, handle it in thermal core instead of in governor. > > - Add an ops to the governor structure, and call it when a trip > > point is changed. > > - Define reset ops for power allocator. > > > > V3: [3] > > - Add fix tag. > > > > V2: [2] > > - Compared to v1, do not revert. > > - Add a variable(last_switch_on_temp) in power_allocator_params > > to record the last switch_on_temp value. > > - Adds a function to renew the update flag and update the > > last_switch_on_temp when thermal trips are writable. > > > > V1: [1] > > - Revert commit 0952177f2a1f. > > > > [1] https://lore.kernel.org/all/20230309135515.1232-1-di.shen@unisoc.com/ > > [2] https://lore.kernel.org/all/20230315093008.17489-1-di.shen@unisoc.com/ > > [3] https://lore.kernel.org/all/20230320095620.7480-1-di.shen@unisoc.com/ > > [4] https://lore.kernel.org/all/20230619063534.12831-1-di.shen@unisoc.com/ > > [5] https://lore.kernel.org/all/20230710033234.28641-1-di.shen@unisoc.com/ > > [6] https://lore.kernel.org/all/20240109112736.32566-1-di.shen@unisoc.com/ > > --- > > --- > > drivers/thermal/gov_power_allocator.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c > > index 7b6aa265ff6a..81e061f183ad 100644 > > --- a/drivers/thermal/gov_power_allocator.c > > +++ b/drivers/thermal/gov_power_allocator.c > > @@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, > > > > trip = params->trip_switch_on; > > if (trip && tz->temperature < trip->temperature) { > > - update = tz->last_temperature >= trip->temperature; > > + update = tz->passive; > > tz->passive = 0; > > reset_pid_controller(params); > > allow_maximum_power(tz, update); > > Thanks for the patch, LGTM. > > Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Applied as 6.8-rc1 material with modified subject and edited changelog. Thanks!
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 7b6aa265ff6a..81e061f183ad 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, trip = params->trip_switch_on; if (trip && tz->temperature < trip->temperature) { - update = tz->last_temperature >= trip->temperature; + update = tz->passive; tz->passive = 0; reset_pid_controller(params); allow_maximum_power(tz, update);