aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/gov_power_allocator.c
diff options
context:
space:
mode:
authorLukasz Luba <lukasz.luba@arm.com>2020-10-15 12:24:41 +0100
committerDaniel Lezcano <daniel.lezcano@linaro.org>2020-10-27 09:44:32 +0100
commit345a8af7ea63ac75a9000159d6298769d3d50f91 (patch)
treedd1df271c1c1a05a698ba048384ae0109c3b6865 /drivers/thermal/gov_power_allocator.c
parentthermal: core: Remove unused functions in power actor section (diff)
downloadlinux-dev-345a8af7ea63ac75a9000159d6298769d3d50f91.tar.xz
linux-dev-345a8af7ea63ac75a9000159d6298769d3d50f91.zip
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. Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201015112441.4056-5-lukasz.luba@arm.com
Diffstat (limited to 'drivers/thermal/gov_power_allocator.c')
-rw-r--r--drivers/thermal/gov_power_allocator.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index eb8c9afadf19..b29e21c56a4f 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -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