diff mbox series

[RFC,3/3] thermal: power_allocator: get proper max power limited by user

Message ID 20210126104001.20361-4-lukasz.luba@arm.com
State New
Headers show
Series New thermal interface allowing IPA to get max power | expand

Commit Message

Lukasz Luba Jan. 26, 2021, 10:40 a.m. UTC
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 mbox series

Patch

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];