Add upper and lower limits in IPA power budget calculation
Subsystems (2)
Lukasz Luba
maintainerv2 cover Add upper and lower limits in IPA power budget calculation
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.
This v2 contains for completeness a patch posted by Michael. The patches are re-based on top of current thermal/linux-next branch.
Changes:
v2:
- added check for cdev_is_power_actor(), before using cdev->ops->state2power() pointed out by Daniel
- added Michael's patch for consistency
- re-based on top of current thermal/linux-next
v1:
can be found here [2]
Regards,
Lukasz
[1] https://lore.kernel.org/linux-pm/[email protected]/
[2] https://lore.kernel.org/linux-pm/[email protected]/
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
Michael Kao (1):
thermal: core: add upper and lower limits to power_actor_set_power
drivers/thermal/gov_power_allocator.c | 40 +++++++++++- drivers/thermal/thermal_core.c | 88 --------------------------- drivers/thermal/thermal_core.h | 6 -- 3 files changed, 38 insertions(+), 96 deletions(-)
Signature · 1 line
2.17.1
Lukasz Luba
maintainerPATCH v2 1/4 thermal: core: add upper and lower limits to power_actor_set_power
From: Michael Kao <[email protected]>
The upper and lower limits of thermal throttle state in the DT do not apply to the Intelligent Power Allocation (IPA) governor. Add the clamping for cooling device upper and lower limits in the power_actor_set_power() used by IPA.
--- drivers/thermal/thermal_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/thermal_core.c +1 -1
@@ -672,7 +672,7 @@ int power_actor_set_power(struct thermal_cooling_device *cdev,if (ret)return ret; - instance->target = state; + instance->target =clamp_val (state, instance->lower, instance->upper);mutex_lock (&cdev->lock); cdev->updated = false;mutex_unlock (&cdev->lock);
Signature · 1 line
2.17.1
Lukasz Luba
maintainerPATCH v2 2/4 thermal: power_allocator: respect upper and lower bounds for cooling device
In reply to Lukasz LubaThe 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.
--- drivers/thermal/gov_power_allocator.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thermal/gov_power_allocator.c +6 -2
@@ -96,7 +96,10 @@ 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, &min_power)) +if (!cdev_is_power_actor (cdev)) +continue ; + +if (cdev->ops->state2power (cdev, instance->upper, &min_power))continue ; sustainable_power += min_power;
@@ -398,7 +401,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, &max_power[i])) +if (cdev->ops->state2power (cdev, instance->lower, + &max_power[i]))continue ; total_req_power += req_power[i];
Signature · 1 line
2.17.1
[thermal: thermal/next] thermal: power_allocator: Respect upper and lower bounds for cooling device
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 8132df3a06a41823aa370dbb4ff08f48fa07f6df Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//8132df3a06a41823aa370dbb4ff08f48fa07f6df Author: Lukasz Luba <[email protected]> AuthorDate: Thu, 15 Oct 2020 12:24:39 +01:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Tue, 27 Oct 2020 09:44:32 +01:00
thermal: power_allocator: Respect upper and lower bounds for cooling device
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.
--- drivers/thermal/gov_power_allocator.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thermal/gov_power_allocator.c +6 -2
@@ -96,7 +96,10 @@ 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, &min_power)) +if (!cdev_is_power_actor (cdev)) +continue ; + +if (cdev->ops->state2power (cdev, instance->upper, &min_power))continue ; sustainable_power += min_power;
@@ -398,7 +401,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, &max_power[i])) +if (cdev->ops->state2power (cdev, instance->lower, + &max_power[i]))continue ; total_req_power += req_power[i];
Lukasz Luba
maintainerPATCH v2 3/4 thermal: core: remove unused functions in power actor section
In reply to Lukasz LubaSince the Intelligent Power Allocation (IPA) uses different way to get minimum and maximum power for a given cooling device, the helper functions are not needed. There is no other code which uses them, so remove the helper functions.
--- drivers/thermal/thermal_core.c | 47 ---------------------------------- drivers/thermal/thermal_core.h | 4 --- 2 files changed, 51 deletions(-)
drivers/thermal/thermal_core.c +0 -47
@@ -600,53 +600,6 @@ static void thermal_zone_device_check(struct work_struct *work)* how to estimate their devices power consumption. */ -/** -* power_actor_get_max_power() - get the maximum power that a cdev can consume -* @cdev: pointer to &thermal_cooling_device -* @max_power: pointer in which to store the maximum power -* -* Calculate the maximum power consumption in milliwats that the -* cooling device can currently consume and store it in @max_power. -* -* Return: 0 on success, -EINVAL if @cdev doesn't support the -* power_actor API or -E* on other error. -*/ -int power_actor_get_max_power (struct thermal_cooling_device *cdev, -u32 *max_power) -{ -if (!cdev_is_power_actor (cdev)) -return -EINVAL ; - -return cdev->ops->state2power (cdev,0 , max_power); -} - -/** -* power_actor_get_min_power() - get the mainimum power that a cdev can consume -* @cdev: pointer to &thermal_cooling_device -* @min_power: pointer in which to store the minimum power -* -* Calculate the minimum power consumption in milliwatts that the -* cooling device can currently consume and store it in @min_power. -* -* Return: 0 on success, -EINVAL if @cdev doesn't support the -* power_actor API or -E* on other error. -*/ -int power_actor_get_min_power (struct thermal_cooling_device *cdev, -u32 *min_power) -{ -unsigned long max_state; -int ret; - -if (!cdev_is_power_actor (cdev)) -return -EINVAL ; - - ret = cdev->ops->get_max_state (cdev, &max_state); -if (ret) -return ret; - -return cdev->ops->state2power (cdev, max_state, min_power); -} -/** * power_actor_set_power() - limit the maximum power a cooling device consumes * @cdev: pointer to &thermal_cooling_device
drivers/thermal/thermal_core.h +0 -4
@@ -65,10 +65,6 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) cdev->ops->power2state; } -int power_actor_get_max_power (struct thermal_cooling_device *cdev, -u32 *max_power); -int power_actor_get_min_power (struct thermal_cooling_device *cdev, -u32 *min_power);int power_actor_set_power (struct thermal_cooling_device *cdev,struct thermal_instance *ti,u32 power);/**
Signature · 1 line
2.17.1
[thermal: thermal/next] thermal: core: Remove unused functions in power actor section
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 87d2380260524e55e090e14012c1b07c1f6d4096 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//87d2380260524e55e090e14012c1b07c1f6d4096 Author: Lukasz Luba <[email protected]> AuthorDate: Thu, 15 Oct 2020 12:24:40 +01:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Tue, 27 Oct 2020 09:44:32 +01:00
thermal: core: Remove unused functions in power actor section
Since the Intelligent Power Allocation (IPA) uses different way to get minimum and maximum power for a given cooling device, the helper functions are not needed. There is no other code which uses them, so remove the helper functions.
--- drivers/thermal/thermal_core.c | 47 +--------------------------------- drivers/thermal/thermal_core.h | 4 +--- 2 files changed, 51 deletions(-)
drivers/thermal/thermal_core.c +0 -47
@@ -601,53 +601,6 @@ static void thermal_zone_device_check(struct work_struct *work)*/ /** -* power_actor_get_max_power() - get the maximum power that a cdev can consume -* @cdev: pointer to &thermal_cooling_device -* @max_power: pointer in which to store the maximum power -* -* Calculate the maximum power consumption in milliwats that the -* cooling device can currently consume and store it in @max_power. -* -* Return: 0 on success, -EINVAL if @cdev doesn't support the -* power_actor API or -E* on other error. -*/ -int power_actor_get_max_power (struct thermal_cooling_device *cdev, -u32 *max_power) -{ -if (!cdev_is_power_actor (cdev)) -return -EINVAL ; - -return cdev->ops->state2power (cdev,0 , max_power); -} - -/** -* power_actor_get_min_power() - get the mainimum power that a cdev can consume -* @cdev: pointer to &thermal_cooling_device -* @min_power: pointer in which to store the minimum power -* -* Calculate the minimum power consumption in milliwatts that the -* cooling device can currently consume and store it in @min_power. -* -* Return: 0 on success, -EINVAL if @cdev doesn't support the -* power_actor API or -E* on other error. -*/ -int power_actor_get_min_power (struct thermal_cooling_device *cdev, -u32 *min_power) -{ -unsigned long max_state; -int ret; - -if (!cdev_is_power_actor (cdev)) -return -EINVAL ; - - ret = cdev->ops->get_max_state (cdev, &max_state); -if (ret) -return ret; - -return cdev->ops->state2power (cdev, max_state, min_power); -} - -/** * power_actor_set_power() - limit the maximum power a cooling device consumes * @cdev: pointer to &thermal_cooling_device * @instance: thermal instance to update
drivers/thermal/thermal_core.h +0 -4
@@ -65,10 +65,6 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) cdev->ops->power2state; } -int power_actor_get_max_power (struct thermal_cooling_device *cdev, -u32 *max_power); -int power_actor_get_min_power (struct thermal_cooling_device *cdev, -u32 *min_power);int power_actor_set_power (struct thermal_cooling_device *cdev,struct thermal_instance *ti,u32 power);/**
Lukasz Luba
maintainerPATCH v2 4/4 thermal: move power_actor_set_power into IPA
In reply to Lukasz LubaSince the power actor section has one function power_actor_set_power() move it into Intelligent Power Allocation (IPA). There is no other user of that helper function. It would also allow to remove the check of cdev_is_power_actor() because the code which calls it in IPA already does the needed check. Make the function static since only IPA use it.
--- drivers/thermal/gov_power_allocator.c | 32 +++++++++++++++++++++ drivers/thermal/thermal_core.c | 41 --------------------------- drivers/thermal/thermal_core.h | 2 -- 3 files changed, 32 insertions(+), 43 deletions(-)
drivers/thermal/gov_power_allocator.c +32 -0
@@ -254,6 +254,38 @@ static u32 pid_controller(struct thermal_zone_device *tz,return power_range; } +/** +* power_actor_set_power() - limit the maximum power a cooling device consumes +* @cdev: pointer to &thermal_cooling_device +* @instance: thermal instance to update +* @power: the power in milliwatts +* +* Set the cooling device to consume at most @power milliwatts. The limit is +* expected to be a cap at the maximum power consumption. +* +* Return: 0 on success, -EINVAL if the cooling device does not +* implement the power actor API or -E* for other failures. +*/ +static int +power_actor_set_power (struct thermal_cooling_device *cdev, +struct thermal_instance *instance,u32 power) +{ +unsigned long state; +int ret; + + ret = cdev->ops->power2state (cdev, power, &state); +if (ret) +return ret; + + instance->target =clamp_val (state, instance->lower, instance->upper); +mutex_lock (&cdev->lock); + cdev->updated = false; +mutex_unlock (&cdev->lock); +thermal_cdev_update (cdev); + +return 0 ; +} +/** * divvy_up_power() - divvy the allocated power between the actors * @req_power: each actor's requested power
drivers/thermal/thermal_core.c +0 -41
47 lines not on this page · raw message
drivers/thermal/thermal_core.h +0 -2
@@ -65,8 +65,6 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) cdev->ops->power2state; } -int power_actor_set_power (struct thermal_cooling_device *cdev, -struct thermal_instance *ti,u32 power);/** * struct thermal_trip - representation of a point in temperature domain * @np: pointer to struct device_node that this trip point was created from
Signature · 1 line
2.17.1
[thermal: thermal/next] thermal: core: Move power_actor_set_power into IPA
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 345a8af7ea63ac75a9000159d6298769d3d50f91 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//345a8af7ea63ac75a9000159d6298769d3d50f91 Author: Lukasz Luba <[email protected]> AuthorDate: Thu, 15 Oct 2020 12:24:41 +01:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Tue, 27 Oct 2020 09:44:32 +01:00
thermal: core: Move power_actor_set_power into IPA
Since the power actor section has one function power_actor_set_power() move it into Intelligent Power Allocation (IPA). There is no other user of that helper function. It would also allow to remove the check of cdev_is_power_actor() because the code which calls it in IPA already does the needed check. Make the function static since only IPA use it.
--- drivers/thermal/gov_power_allocator.c | 32 ++++++++++++++++++++- drivers/thermal/thermal_core.c | 41 +-------------------------- drivers/thermal/thermal_core.h | 2 +- 3 files changed, 32 insertions(+), 43 deletions(-)
drivers/thermal/gov_power_allocator.c +32 -0
@@ -255,6 +255,38 @@ static u32 pid_controller(struct thermal_zone_device *tz, }/** +* power_actor_set_power() - limit the maximum power a cooling device consumes +* @cdev: pointer to &thermal_cooling_device +* @instance: thermal instance to update +* @power: the power in milliwatts +* +* Set the cooling device to consume at most @power milliwatts. The limit is +* expected to be a cap at the maximum power consumption. +* +* Return: 0 on success, -EINVAL if the cooling device does not +* implement the power actor API or -E* for other failures. +*/ +static int +power_actor_set_power (struct thermal_cooling_device *cdev, +struct thermal_instance *instance,u32 power) +{ +unsigned long state; +int ret; + + ret = cdev->ops->power2state (cdev, power, &state); +if (ret) +return ret; + + instance->target =clamp_val (state, instance->lower, instance->upper); +mutex_lock (&cdev->lock); + cdev->updated = false; +mutex_unlock (&cdev->lock); +thermal_cdev_update (cdev); + +return 0 ; +} + +/** * divvy_up_power() - divvy the allocated power between the actors * @req_power: each actor's requested power * @max_power: each actor's maximum available power
drivers/thermal/thermal_core.c +0 -41
47 lines not on this page · raw message
drivers/thermal/thermal_core.h +0 -2
@@ -65,8 +65,6 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) cdev->ops->power2state; } -int power_actor_set_power (struct thermal_cooling_device *cdev, -struct thermal_instance *ti,u32 power);/** * struct thermal_trip - representation of a point in temperature domain * @np: pointer to struct device_node that this trip point was created from
Daniel Lezcano
AppliedApplied, thanks
Quoted 38 lines · Lukasz Luba
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.
This v2 contains for completeness a patch posted by Michael. The patches are re-based on top of current thermal/linux-next branch.
Changes:
v2:
- added check forcdev_is_power_actor(), before usingcdev->ops->state2power()pointed out by Daniel
- added Michael's patch for consistency
- re-based on top of current thermal/linux-next
v1:
can be found here [2]Regards,
Lukasz[1] https://lore.kernel.org/linux-pm/[email protected]/
[2] https://lore.kernel.org/linux-pm/[email protected]/Lukasz Luba (3):
thermal:power_allocator: respect upper and lower bounds for cooling
device
thermal: core: remove unused functions in power actor section
thermal: movepower_actor_set_powerinto IPAMichael Kao (1):
thermal: core: add upper and lower limits topower_actor_set_powerdrivers/thermal/gov_power_allocator.c | 40 +++++++++++- drivers/thermal/thermal_core.c | 88 --------------------------- drivers/thermal/thermal_core.h | 6 -- 3 files changed, 38 insertions(+), 96 deletions(-)
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Lukasz Luba
maintainerQuoted 3 lines · Daniel Lezcano
Applied, thanks
Thank you Daniel!