summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorLukasz Luba <lukasz.luba@arm.com>2024-03-08 12:32:03 +0000
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-03-13 20:48:38 +0100
commit3acec69a94eaaf3d7ebb043e1db45cc26f58a847 (patch)
tree5c52ef1b33a3fbef3a94d9e6307ae0cd18091d36 /kernel
parent07abb19a9b201c11e4367e8a428be7235b6dbd0d (diff)
PM: EM: Force device drivers to provide power in uW
The EM only supports power in uW. Make sure that it is not possible to register some downstream driver which doesn't provide power in uW. The only exception is artificial EM, but that EM is ignored by the rest of kernel frameworks (thermal, powercap, etc). Reported-by: PoShao Chen <poshao.chen@mediatek.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/power/energy_model.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index b686ac0345bd..9e1c9aa399ea 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
else if (cb->get_cost)
flags |= EM_PERF_DOMAIN_ARTIFICIAL;
+ /*
+ * EM only supports uW (exception is artificial EM).
+ * Therefore, check and force the drivers to provide
+ * power in uW.
+ */
+ if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
+ dev_err(dev, "EM: only supports uW power values\n");
+ ret = -EINVAL;
+ goto unlock;
+ }
+
ret = em_create_pd(dev, nr_states, cb, cpus, flags);
if (ret)
goto unlock;