From e1a9e7daead151be148b762b6916c34ffbda8119 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Thu, 23 Feb 2017 16:02:45 -0800 Subject: [PATCH] ANDROID: idle_notifier: Add generic idle notifiers AOSP Change-ID: Idf29cda15be151f494ff245933c12462643388d5 moved x86_64 idle notifiers as generic so that they can be used in interactive governor. Upstream change 8e7a7ee9ddd5 ("x86/idle: Remove idle_notifier") removed x86_64 idle notifiers altogether. This patch add generic idle notifiers again. Change-Id: Iffb48a1ea0348d9ddad93df697e4743a5531fe73 Fixes: android-4.9 commit bfd2a547fc17 ("ANDROID: ARM: Call idle notifiers") Signed-off-by: Amit Pundir Git-Commit: d82a8035d09bcfcac238b80ad97335167665a7c3 Git-Repo: https://android-git.linaro.org/git/kernel/linaro-android.git Signed-off-by: Rishabh Bhatnagar --- include/linux/cpu.h | 7 +++++++ kernel/cpu.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index bc6c879bd110..ce49a25c013d 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -221,4 +221,11 @@ static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; extern bool cpu_mitigations_off(void); extern bool cpu_mitigations_auto_nosmt(void); +#define IDLE_START 1 +#define IDLE_END 2 + +void idle_notifier_register(struct notifier_block *n); +void idle_notifier_unregister(struct notifier_block *n); +void idle_notifier_call_chain(unsigned long val); + #endif /* _LINUX_CPU_H_ */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 5a3a429ea9cd..25febb1ad207 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2498,3 +2498,23 @@ bool cpu_mitigations_auto_nosmt(void) return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT; } EXPORT_SYMBOL_GPL(cpu_mitigations_auto_nosmt); + +static ATOMIC_NOTIFIER_HEAD(idle_notifier); + +void idle_notifier_register(struct notifier_block *n) +{ + atomic_notifier_chain_register(&idle_notifier, n); +} +EXPORT_SYMBOL_GPL(idle_notifier_register); + +void idle_notifier_unregister(struct notifier_block *n) +{ + atomic_notifier_chain_unregister(&idle_notifier, n); +} +EXPORT_SYMBOL_GPL(idle_notifier_unregister); + +void idle_notifier_call_chain(unsigned long val) +{ + atomic_notifier_call_chain(&idle_notifier, val, NULL); +} +EXPORT_SYMBOL_GPL(idle_notifier_call_chain);