Commit 8d366942 authored by Shivnandan Kumar's avatar Shivnandan Kumar Committed by Rafael J. Wysocki

PM: QoS: Add check to make sure CPU freq is non-negative

CPU frequency should never be negative.

If some client driver calls freq_qos_update_request with a
negative value which will be very high in absolute terms,
then frequency QoS sets max CPU freq at fmax as it considers
it's absolute value but it will add plist node with negative
priority.

plist node has priority from INT_MIN (highest) to INT_MAX(lowest).
Once priority is set as negative, another client will not be able
to reduce CPU frequency.

Adding check to make sure CPU freq is non-negative will fix
this problem.
Signed-off-by: default avatarShivnandan Kumar <quic_kshivnan@quicinc.com>
[ rjw: Changelog edits ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent e0dccc3b
...@@ -531,7 +531,7 @@ int freq_qos_add_request(struct freq_constraints *qos, ...@@ -531,7 +531,7 @@ int freq_qos_add_request(struct freq_constraints *qos,
{ {
int ret; int ret;
if (IS_ERR_OR_NULL(qos) || !req) if (IS_ERR_OR_NULL(qos) || !req || value < 0)
return -EINVAL; return -EINVAL;
if (WARN(freq_qos_request_active(req), if (WARN(freq_qos_request_active(req),
...@@ -563,7 +563,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request); ...@@ -563,7 +563,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request);
*/ */
int freq_qos_update_request(struct freq_qos_request *req, s32 new_value) int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
{ {
if (!req) if (!req || new_value < 0)
return -EINVAL; return -EINVAL;
if (WARN(!freq_qos_request_active(req), if (WARN(!freq_qos_request_active(req),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment