Skip to content

Commit 5f55836

Browse files
Clive Linrafaeljw
authored andcommitted
PM: QoS: Add check to make sure CPU latency is non-negative
CPU latency should never be negative, which will be incorrectly high when converted to unsigned data type. Commit 8d36694 ("PM: QoS: Add check to make sure CPU freq is non-negative") makes sure CPU frequency is non-negative to fix incorrect behavior in freqency QoS. Add an analogous check to make sure CPU latency is non-negative so as to prevent this problem from happening in CPU latency QoS. Signed-off-by: Clive Lin <clive.lin@mediatek.com> [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 706a741 commit 5f55836

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
@@ -220,6 +220,11 @@ static struct pm_qos_constraints cpu_latency_constraints = {
220220
.type = PM_QOS_MIN,
221221
};
222222

223+
static inline bool cpu_latency_qos_value_invalid(s32 value)
224+
{
225+
return value < 0 && value != PM_QOS_DEFAULT_VALUE;
226+
}
227+
223228
/**
224229
* cpu_latency_qos_limit - Return current system-wide CPU latency QoS limit.
225230
*/
@@ -263,7 +268,7 @@ static void cpu_latency_qos_apply(struct pm_qos_request *req,
263268
*/
264269
void cpu_latency_qos_add_request(struct pm_qos_request *req, s32 value)
265270
{
266-
if (!req)
271+
if (!req || cpu_latency_qos_value_invalid(value))
267272
return;
268273

269274
if (cpu_latency_qos_request_active(req)) {
@@ -289,7 +294,7 @@ EXPORT_SYMBOL_GPL(cpu_latency_qos_add_request);
289294
*/
290295
void cpu_latency_qos_update_request(struct pm_qos_request *req, s32 new_value)
291296
{
292-
if (!req)
297+
if (!req || cpu_latency_qos_value_invalid(new_value))
293298
return;
294299

295300
if (!cpu_latency_qos_request_active(req)) {

0 commit comments

Comments
 (0)