mbox series

[0/3] Add upper and lower limits in IPA power budget calculation

Message ID 20201007122256.28080-1-lukasz.luba@arm.com
Headers show
Series Add upper and lower limits in IPA power budget calculation | expand

Message

Lukasz Luba Oct. 7, 2020, 12:22 p.m. UTC
Hi all,

This patch set makes thermal governor Intelligent Power Allocation (IPA)
aware of cooling device limits for upper and lower bounds and respects them
in the internal power budget calculation.
The patch set should be applied on top of some already posted IPA changes [1][2].

Regards,
Lukasz

[1] https://lore.kernel.org/linux-pm/20201002122416.13659-1-lukasz.luba@arm.com/
[2] https://lore.kernel.org/linux-pm/9ecedd8a-fbc3-895c-d79c-f05af5c90ae5@arm.com/T/#t

Lukasz Luba (3):
  thermal: power_allocator: respect upper and lower bounds for cooling
    device
  thermal: core: remove unused functions in power actor section
  thermal: move power_actor_set_power into IPA

 drivers/thermal/gov_power_allocator.c | 38 ++++++++++-
 drivers/thermal/thermal_core.c        | 90 ---------------------------
 drivers/thermal/thermal_core.h        |  6 --
 3 files changed, 36 insertions(+), 98 deletions(-)

Comments

Daniel Lezcano Oct. 14, 2020, 12:31 p.m. UTC | #1
On 07/10/2020 14:22, Lukasz Luba wrote:
> The thermal cooling device specified in DT might be instantiated for
> a thermal zone trip point with a limited set of OPPs to operate on. This
> configuration should be supported by Intelligent Power Allocation (IPA),
> since it is a standard for other governors. Change the code and allow IPA
> to get power value of lower and upper bound set for a given cooling
> device.
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>  drivers/thermal/gov_power_allocator.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
> index dd59085f38f5..f9ee7787b325 100644
> --- a/drivers/thermal/gov_power_allocator.c
> +++ b/drivers/thermal/gov_power_allocator.c
> @@ -96,7 +96,8 @@ static u32 estimate_sustainable_power(struct thermal_zone_device *tz)
>  		if (instance->trip != params->trip_max_desired_temperature)
>  			continue;
>  
> -		if (power_actor_get_min_power(cdev, tz, &min_power))
> +		if (cdev->ops->state2power(cdev, tz, instance->upper,
> +					   &min_power))

	if (cdev->ops->state2power && cdev->ops->state2power(cdev, tz,
							instance->upper,
							&min_power))

?

>  			continue;
>  
>  		sustainable_power += min_power;
> @@ -404,7 +405,8 @@ static int allocate_power(struct thermal_zone_device *tz,
>  
>  		weighted_req_power[i] = frac_to_int(weight * req_power[i]);
>  
> -		if (power_actor_get_max_power(cdev, tz, &max_power[i]))
> +		if (cdev->ops->state2power(cdev, tz, instance->lower,
> +					   &max_power[i]))
>  			continue;

Same here ?

>  		total_req_power += req_power[i];
>
Daniel Lezcano Oct. 14, 2020, 12:45 p.m. UTC | #2
On 07/10/2020 14:22, Lukasz Luba wrote:
> Hi all,
> 
> This patch set makes thermal governor Intelligent Power Allocation (IPA)
> aware of cooling device limits for upper and lower bounds and respects them
> in the internal power budget calculation.
> The patch set should be applied on top of some already posted IPA changes [1][2].
> 
> Regards,
> Lukasz
> 
> [1] https://lore.kernel.org/linux-pm/20201002122416.13659-1-lukasz.luba@arm.com/
> [2] https://lore.kernel.org/linux-pm/9ecedd8a-fbc3-895c-d79c-f05af5c90ae5@arm.com/T/#t
> 
> Lukasz Luba (3):
>   thermal: power_allocator: respect upper and lower bounds for cooling
>     device
>   thermal: core: remove unused functions in power actor section
>   thermal: move power_actor_set_power into IPA
> 
>  drivers/thermal/gov_power_allocator.c | 38 ++++++++++-
>  drivers/thermal/thermal_core.c        | 90 ---------------------------
>  drivers/thermal/thermal_core.h        |  6 --
>  3 files changed, 36 insertions(+), 98 deletions(-)

Thanks for this series. Except a comment in patch 1/3, it looks good to me.
Lukasz Luba Oct. 14, 2020, 4:05 p.m. UTC | #3
On 10/14/20 1:31 PM, Daniel Lezcano wrote:
> On 07/10/2020 14:22, Lukasz Luba wrote:
>> The thermal cooling device specified in DT might be instantiated for
>> a thermal zone trip point with a limited set of OPPs to operate on. This
>> configuration should be supported by Intelligent Power Allocation (IPA),
>> since it is a standard for other governors. Change the code and allow IPA
>> to get power value of lower and upper bound set for a given cooling
>> device.
>>
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>> ---
>>   drivers/thermal/gov_power_allocator.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
>> index dd59085f38f5..f9ee7787b325 100644
>> --- a/drivers/thermal/gov_power_allocator.c
>> +++ b/drivers/thermal/gov_power_allocator.c
>> @@ -96,7 +96,8 @@ static u32 estimate_sustainable_power(struct thermal_zone_device *tz)
>>   		if (instance->trip != params->trip_max_desired_temperature)
>>   			continue;
>>   
>> -		if (power_actor_get_min_power(cdev, tz, &min_power))
>> +		if (cdev->ops->state2power(cdev, tz, instance->upper,
>> +					   &min_power))
> 
> 	if (cdev->ops->state2power && cdev->ops->state2power(cdev, tz,
> 							instance->upper,
> 							&min_power))
> 
> ?


Yes, worth to check. I had this in [1] and missed it here while playing
with re-base of these patch series and other test branches.

I will send v2 with the needed cdev_is_power_actor() check.

> 
>>   			continue;
>>   
>>   		sustainable_power += min_power;
>> @@ -404,7 +405,8 @@ static int allocate_power(struct thermal_zone_device *tz,
>>   
>>   		weighted_req_power[i] = frac_to_int(weight * req_power[i]);
>>   
>> -		if (power_actor_get_max_power(cdev, tz, &max_power[i]))
>> +		if (cdev->ops->state2power(cdev, tz, instance->lower,
>> +					   &max_power[i]))
>>   			continue;
> 
> Same here ?

Inside that loop we check (just a few lines above):

		if (!cdev_is_power_actor(cdev))
			continue;

then we call this:

		if (cdev->ops->state2power(cdev, tz, instance->lower,
					&max_power[i]))

So it should be safe.

> 
>>   		total_req_power += req_power[i];
>>
> 
> 

Thank you Daniel for reviewing this.

Regards,
Lukasz

[1] 
https://lore.kernel.org/linux-pm/20201008170426.465-3-lukasz.luba@arm.com/