@@ -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];
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(-)