From 839ade8d690354deabad3a0c54e6793900979c05 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Thu, 16 May 2019 23:03:33 -0700 Subject: [PATCH] qos: Execute notifier callbacks atomically Allowing the pm_qos notifier callbacks to execute without holding pm_qos_lock can cause the callbacks to misbehave, e.g. the cpuidle callback could erroneously send more IPIs than necessary. Fix this by executing the pm_qos callbacks while pm_qos_lock is held. Signed-off-by: Sultan Alsawaf --- kernel/power/qos.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 64264014a909..3c8699e44566 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -353,9 +353,6 @@ int pm_qos_update_target(struct pm_qos_constraints *c, pm_qos_set_value(c, curr_value); pm_qos_set_value_for_cpus(c, &cpus); - spin_unlock(&pm_qos_lock); - - trace_pm_qos_update_target(action, prev_value, curr_value); /* * if cpu mask bits are set, call the notifier call chain * to update the new qos restriction for the cores @@ -369,6 +366,10 @@ int pm_qos_update_target(struct pm_qos_constraints *c, } else { ret = 0; } + spin_unlock(&pm_qos_lock); + + trace_pm_qos_update_target(action, prev_value, curr_value); + return ret; } -- 2.11.0