summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2015-04-23 14:53:38 -0700
committerMichael Bestas <mkbestas@lineageos.org>2019-12-23 23:43:35 +0200
commit8ad00b7be2aa63a208b8e72ecabce16ad1610ccb (patch)
tree9331efd054f4c05b9b855507f1db4c288001c436 /include/linux
parent6edd3f1417d82add8c98d292ba39912b830c3d80 (diff)
PM: wakeup_reasons: fix race condition
log_possible_wakeup_reason() and stop_logging_wakeup_reasons() can race, as the latter can be called from process context, and both can run on separate cores. Change-Id: I306441d0be46dd4fe58c55cdc162f9d61a28c27d Signed-off-by: Iliyan Malchev <malchev@google.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/wakeup_reason.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/wakeup_reason.h b/include/linux/wakeup_reason.h
index a26b1c998139..ca6226cc1c55 100644
--- a/include/linux/wakeup_reason.h
+++ b/include/linux/wakeup_reason.h
@@ -61,16 +61,22 @@ static inline void start_logging_wakeup_reasons(void)
{
extern bool log_wakeups;
extern struct completion wakeups_completion;
- log_wakeups = true;
+ ACCESS_ONCE(log_wakeups) = true;
init_completion(&wakeups_completion);
}
-static inline bool logging_wakeup_reasons(void)
+static inline bool logging_wakeup_reasons_nosync(void)
{
extern bool log_wakeups;
return ACCESS_ONCE(log_wakeups);
}
+static inline bool logging_wakeup_reasons(void)
+{
+ smp_rmb();
+ return logging_wakeup_reasons_nosync();
+}
+
void log_base_wakeup_reason(int irq);
void log_suspend_abort_reason(const char *fmt, ...);