PM: EM: Force device drivers to provide power in uW
Subsystems (3)
Lukasz Luba
maintainerPATCH 1/1 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).
---
Hi all,
The was an issue reported recently that the EM could be used with not aligned drivers which provide milli-Watts. This patch prevents such drivers to register EM (although there are no such in upstream).
Regards,
Lukasz
kernel/power/energy_model.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/power/energy_model.c +11 -0
@@ -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;
Signature · 1 line
2.25.1
Quoted 35 lines · Lukasz Luba
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 <[email protected]>Signed-off-by Lukasz Luba <[email protected]>---
Hi all,
The was an issue reported recently that the EM could be used with not aligned drivers which provide milli-Watts. This patch prevents such drivers to register EM (although there are no such in upstream).
Regards,
Lukaszkernel/power/energy_model.c | 11 +++++++++++ 1 file changed, 11 insertions(+)kernel/power/energy_model.c +5
-0@@ -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. +*/
kernel/power/energy_model.c int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
Quoted 10 lines
kernel/power/energy_model.c +6
-1+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; --
Applied as 6.9-rc material, thanks!
Lukasz Luba
maintainerQuoted 40 lines · Rafael J. Wysocki
Quoted 39 lines · Lukasz Luba
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 <[email protected]>Signed-off-by Lukasz Luba <[email protected]>---
Hi all,
The was an issue reported recently that the EM could be used with not aligned drivers which provide milli-Watts. This patch prevents such drivers to register EM (although there are no such in upstream).
Regards,
Lukaszkernel/power/energy_model.c | 11 +++++++++++ 1 file changed, 11 insertions(+)kernel/power/energy_model.c +9
-0@@ -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;
Quoted 8 lines
kernel/power/energy_model.c int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
Quoted 6 lines
kernel/power/energy_model.c +2
-1+ } + ret =em_create_pd (dev, nr_states, cb, cpus, flags);if (ret) goto unlock; --Applied as 6.9-rc material, thanks!
Thank you Rafael!