diff mbox series

thermal/core: Clear all mitigation when thermal zone is disabled

Message ID 1640083318-19277-1-git-send-email-quic_manafm@quicinc.com (mailing list archive)
State Superseded, archived
Headers show
Series thermal/core: Clear all mitigation when thermal zone is disabled | expand

Commit Message

Manaf Meethalavalappu Pallikunhi Dec. 21, 2021, 10:41 a.m. UTC
Whenever a thermal zone is in trip violated state, there is a chance
that the same thermal zone mode can be disabled either via thermal
core API or via thermal zone sysfs. Once it is disabled, the framework
bails out any re-evaluation of thermal zone. It leads to a case where
if it is already in mitigation state, it will stay the same state
until it is re-enabled.

To avoid above mentioned issue, on thermal zone disable request
reset thermal zone and clear mitigation for each trip explicitly.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
---
 drivers/thermal/thermal_core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Matthias Kaehlcke Dec. 23, 2021, 2:52 p.m. UTC | #1
On Tue, Dec 21, 2021 at 04:11:58PM +0530, Manaf Meethalavalappu Pallikunhi wrote:
> Whenever a thermal zone is in trip violated state, there is a chance
> that the same thermal zone mode can be disabled either via thermal
> core API or via thermal zone sysfs. Once it is disabled, the framework
> bails out any re-evaluation of thermal zone. It leads to a case where
> if it is already in mitigation state, it will stay the same state
> until it is re-enabled.
> 
> To avoid above mentioned issue, on thermal zone disable request
> reset thermal zone and clear mitigation for each trip explicitly.
> 
> Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
> ---
>  drivers/thermal/thermal_core.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 51374f4..a8ae340 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -427,6 +427,7 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
>  					enum thermal_device_mode mode)
>  {
>  	int ret = 0;
> +	int count;
>  
>  	mutex_lock(&tz->lock);
>  
> @@ -449,8 +450,14 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
>  
>  	if (mode == THERMAL_DEVICE_ENABLED)
>  		thermal_notify_tz_enable(tz->id);
> -	else
> +	else {
> +		/* make sure all previous throttlings are cleared */
> +		thermal_zone_device_init(tz);
> +		for (count = 0; count < tz->trips; count++)
> +			handle_thermal_trip(tz, count);

nit: s/count/trip/
Manaf Meethalavalappu Pallikunhi Dec. 29, 2021, 6:52 a.m. UTC | #2
On 12/23/2021 8:22 PM, Matthias Kaehlcke wrote:
> On Tue, Dec 21, 2021 at 04:11:58PM +0530, Manaf Meethalavalappu Pallikunhi wrote:
>> Whenever a thermal zone is in trip violated state, there is a chance
>> that the same thermal zone mode can be disabled either via thermal
>> core API or via thermal zone sysfs. Once it is disabled, the framework
>> bails out any re-evaluation of thermal zone. It leads to a case where
>> if it is already in mitigation state, it will stay the same state
>> until it is re-enabled.
>>
>> To avoid above mentioned issue, on thermal zone disable request
>> reset thermal zone and clear mitigation for each trip explicitly.
>>
>> Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
>> ---
>>   drivers/thermal/thermal_core.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>> index 51374f4..a8ae340 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -427,6 +427,7 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
>>   					enum thermal_device_mode mode)
>>   {
>>   	int ret = 0;
>> +	int count;
>>   
>>   	mutex_lock(&tz->lock);
>>   
>> @@ -449,8 +450,14 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
>>   
>>   	if (mode == THERMAL_DEVICE_ENABLED)
>>   		thermal_notify_tz_enable(tz->id);
>> -	else
>> +	else {
>> +		/* make sure all previous throttlings are cleared */
>> +		thermal_zone_device_init(tz);
>> +		for (count = 0; count < tz->trips; count++)
>> +			handle_thermal_trip(tz, count);
> nit: s/count/trip/
Updated in V2
diff mbox series

Patch

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 51374f4..a8ae340 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -427,6 +427,7 @@  static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
 					enum thermal_device_mode mode)
 {
 	int ret = 0;
+	int count;
 
 	mutex_lock(&tz->lock);
 
@@ -449,8 +450,14 @@  static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
 
 	if (mode == THERMAL_DEVICE_ENABLED)
 		thermal_notify_tz_enable(tz->id);
-	else
+	else {
+		/* make sure all previous throttlings are cleared */
+		thermal_zone_device_init(tz);
+		for (count = 0; count < tz->trips; count++)
+			handle_thermal_trip(tz, count);
+
 		thermal_notify_tz_disable(tz->id);
+	}
 
 	return ret;
 }