[PATCH 2/2] powercap: DTPM: Check Energy Model type for power values scale
From: Lukasz Luba
Date: Mon Feb 07 2022 - 02:44:32 EST
The Energy Model power values might be in an abstract scale. In such case
it's safe to bail out during the registration, since the PowerCap
framework supports only micro-Watts.
Signed-off-by: Lukasz Luba <lukasz.luba@xxxxxxx>
---
drivers/powercap/dtpm_cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
index b740866b228d..e6bcde081de4 100644
--- a/drivers/powercap/dtpm_cpu.c
+++ b/drivers/powercap/dtpm_cpu.c
@@ -188,7 +188,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu)
return 0;
pd = em_cpu_get(cpu);
- if (!pd)
+ if (!pd || !(pd->flags & EM_PERF_DOMAIN_MILLIWATTS))
return -EINVAL;
dtpm_cpu = per_cpu(dtpm_per_cpu, cpu);
--
2.17.1