Skip to content

Commit 3acec69

Browse files
lukaszluba-armrafaeljw
authored andcommitted
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>
1 parent 07abb19 commit 3acec69

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

kernel/power/energy_model.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
612612
else if (cb->get_cost)
613613
flags |= EM_PERF_DOMAIN_ARTIFICIAL;
614614

615+
/*
616+
* EM only supports uW (exception is artificial EM).
617+
* Therefore, check and force the drivers to provide
618+
* power in uW.
619+
*/
620+
if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
621+
dev_err(dev, "EM: only supports uW power values\n");
622+
ret = -EINVAL;
623+
goto unlock;
624+
}
625+
615626
ret = em_create_pd(dev, nr_states, cb, cpus, flags);
616627
if (ret)
617628
goto unlock;

0 commit comments

Comments
 (0)