Skip to content

Commit 3a8395b

Browse files
Chungkai Yangrafaeljw
authored andcommitted
PM: QoS: Restore support for default value on frequency QoS
Commit 8d36694 ("PM: QoS: Add check to make sure CPU freq is non-negative") makes sure CPU freq is non-negative to avoid negative value converting to unsigned data type. However, when the value is PM_QOS_DEFAULT_VALUE, pm_qos_update_target specifically uses c->default_value which is set to FREQ_QOS_MIN/MAX_DEFAULT_VALUE when cpufreq_policy_alloc is executed, for this case handling. Adding check for PM_QOS_DEFAULT_VALUE to let default setting work will fix this problem. Fixes: 8d36694 ("PM: QoS: Add check to make sure CPU freq is non-negative") Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/lkml/CAJZ5v0gxNOWhC58PHeUhW_tgf6d1fGJVZ1x91zkDdht11yUv-A@mail.gmail.com/ Signed-off-by: Chungkai Yang <[email protected]> Cc: 6.0+ <[email protected]> # 6.0+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 06c2afb commit 3a8395b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/power/qos.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@ late_initcall(cpu_latency_qos_init);
426426

427427
/* Definitions related to the frequency QoS below. */
428428

429+
static inline bool freq_qos_value_invalid(s32 value)
430+
{
431+
return value < 0 && value != PM_QOS_DEFAULT_VALUE;
432+
}
433+
429434
/**
430435
* freq_constraints_init - Initialize frequency QoS constraints.
431436
* @qos: Frequency QoS constraints to initialize.
@@ -531,7 +536,7 @@ int freq_qos_add_request(struct freq_constraints *qos,
531536
{
532537
int ret;
533538

534-
if (IS_ERR_OR_NULL(qos) || !req || value < 0)
539+
if (IS_ERR_OR_NULL(qos) || !req || freq_qos_value_invalid(value))
535540
return -EINVAL;
536541

537542
if (WARN(freq_qos_request_active(req),
@@ -563,7 +568,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request);
563568
*/
564569
int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
565570
{
566-
if (!req || new_value < 0)
571+
if (!req || freq_qos_value_invalid(new_value))
567572
return -EINVAL;
568573

569574
if (WARN(!freq_qos_request_active(req),

0 commit comments

Comments
 (0)