Skip to contentSkip to conversation

powercap: dtpm_cpu: Fix error check against freq_qos_add_request()

PATCH Applied Daniel Lezcano 2 participants 2 messages Feb 13, 2024 – Feb 16, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powercap: dtpm_cpu: Fix error check against freq_qos_add_request()

The caller of the function freq_qos_add_request() checks again a non zero value but freq_qos_add_request() can return '1' if the request already exists. Therefore, the setup function fails while the QoS request actually did not failed.

Fix that by changing the check against a negative value like all the other callers of the function.

Fixes 0e8f68d7f0485 ("Add CPU energy model based support")
---
 drivers/powercap/dtpm_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/powercap/dtpm_cpu.c +1 -1
index 9193c3b8edeb..ae7ee611978b 100644
@@ -219,7 +219,7 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
 	ret = freq_qos_add_request(&policy->constraints,
 				   &dtpm_cpu->qos_req, FREQ_QOS_MAX,
 				   pd->table[pd->nr_perf_states - 1].frequency);
-	if (ret)
+	if (ret < 0)
 		goto out_dtpm_unregister;
 
 	cpufreq_cpu_put(policy);
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 20 lines · Daniel Lezcano

The caller of the function freq_qos_add_request() checks again a non zero value but freq_qos_add_request() can return '1' if the request already exists. Therefore, the setup function fails while the QoS request actually did not failed.

Fix that by changing the check against a negative value like all the other callers of the function.

Fixes 0e8f68d7f0485 ("Add CPU energy model based support")
---
 drivers/powercap/dtpm_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/powercap/dtpm_cpu.c +0 -0
index 9193c3b8edeb..ae7ee611978b 100644

drivers/powercap/dtpm_cpu.c static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)

Quoted 9 lines
drivers/powercap/dtpm_cpu.c +1 -2
@@ -219,7 +219,7 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
        ret = freq_qos_add_request(&policy->constraints,
                                   &dtpm_cpu->qos_req, FREQ_QOS_MAX,
                                   pd->table[pd->nr_perf_states - 1].frequency);
-       if (ret)
+       if (ret < 0)
                goto out_dtpm_unregister;
 
        cpufreq_cpu_put(policy);
--

Applied as 6.9 material, thanks!