lkml.org 
[lkml]   [2021]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 3/3] thermal: power_allocator: get proper max power limited by user
Date
Use new API interface to get the maximum power of the cooling device. This
is needed to properly allocate and split the total power budget. The
allowed limit is taken from supported cooling device and then checked with
limits set in DT. The final state value is used for asking for the related
power value the cooling device.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
drivers/thermal/gov_power_allocator.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 92acae53df49..ec33fba5a358 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -308,6 +308,20 @@ power_actor_set_power(struct thermal_cooling_device *cdev,
return 0;
}

+static int
+power_actor_get_max_power(struct thermal_cooling_device *cdev,
+ struct thermal_instance *instance, u32 *max_power)
+{
+ unsigned long min_state = 0;
+
+ if (cdev->ops->get_user_min_state)
+ cdev->ops->get_user_min_state(cdev, &min_state);
+
+ min_state = max(instance->lower, min_state);
+
+ return cdev->ops->state2power(cdev, min_state, max_power);
+}
+
/**
* divvy_up_power() - divvy the allocated power between the actors
* @req_power: each actor's requested power
@@ -455,8 +469,7 @@ static int allocate_power(struct thermal_zone_device *tz,

weighted_req_power[i] = frac_to_int(weight * req_power[i]);

- if (cdev->ops->state2power(cdev, instance->lower,
- &max_power[i]))
+ if (power_actor_get_max_power(cdev, instance, &max_power[i]))
continue;

total_req_power += req_power[i];
--
2.17.1
\
 
 \ /
  Last update: 2021-01-26 12:41    [W:0.778 / U:0.768 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site