From: Youngtae Lee Date: Thu, 2 Nov 2017 11:36:17 +0000 (+0900) Subject: kernel: Add PRE/POST noti for cpu pm X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=15ee69803e88063f51f8b41e992a9676bc88e2e2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git kernel: Add PRE/POST noti for cpu pm CPU_PM_ENTER_PREPARE is called before adding a timer event. CPU_PM_EXIT is called after CPU_PM_EXIT. Change-Id: I339cdcc1d20bbbbeb85de9f3b8bbf79150c7dfe5 Signed-off-by: Youngtae Lee --- diff --git a/include/linux/cpu_pm.h b/include/linux/cpu_pm.h index 455b233dd3b1..9a3bc18a493b 100644 --- a/include/linux/cpu_pm.h +++ b/include/linux/cpu_pm.h @@ -47,6 +47,9 @@ * Event codes passed as unsigned long val to notifier calls */ enum cpu_pm_event { + /* A single cpu is preparing lopower state */ + CPU_PM_ENTER_PREPARE, + /* A single cpu is entering a low power state */ CPU_PM_ENTER, @@ -56,6 +59,9 @@ enum cpu_pm_event { /* A single cpu is exiting a low power state */ CPU_PM_EXIT, + /* A single cpu is post existing a low power state */ + CPU_PM_EXIT_POST, + /* A cpu power domain is entering a low power state */ CPU_CLUSTER_PM_ENTER, @@ -73,6 +79,8 @@ int cpu_pm_enter(void); int cpu_pm_exit(void); int cpu_cluster_pm_enter(void); int cpu_cluster_pm_exit(void); +int cpu_pm_enter_pre(void); +int cpu_pm_exit_post(void); #else @@ -105,5 +113,16 @@ static inline int cpu_cluster_pm_exit(void) { return 0; } + +static inline int cpu_pm_enter_pre(void) +{ + return 0; +} + +static inline int cpu_pm_exit_post(void) +{ + return 0; +} + #endif #endif diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 67b02e138a47..ea4135831b33 100644 --- a/kernel/cpu_pm.c +++ b/kernel/cpu_pm.c @@ -104,6 +104,12 @@ int cpu_pm_enter(void) } EXPORT_SYMBOL_GPL(cpu_pm_enter); +int cpu_pm_enter_pre(void) +{ + return cpu_pm_notify(CPU_PM_ENTER_PREPARE, -1, NULL); +} +EXPORT_SYMBOL_GPL(cpu_pm_enter_pre); + /** * cpu_pm_exit - CPU low power exit notifier * @@ -122,6 +128,12 @@ int cpu_pm_exit(void) } EXPORT_SYMBOL_GPL(cpu_pm_exit); +int cpu_pm_exit_post(void) +{ + return cpu_pm_notify(CPU_PM_EXIT_POST, -1, NULL); +} +EXPORT_SYMBOL_GPL(cpu_pm_exit_post); + /** * cpu_cluster_pm_enter - CPU cluster low power entry notifier * diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index c1dbb2cc1f29..7f2d0145f71e 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -220,6 +221,7 @@ static void do_idle(void) */ __current_set_polling(); + cpu_pm_enter_pre(); quiet_vmstat(); tick_nohz_idle_enter(); @@ -255,6 +257,7 @@ static void do_idle(void) * This is required because for polling idle loops we will not have had * an IPI to fold the state for us. */ + cpu_pm_exit_post(); preempt_set_need_resched(); tick_nohz_idle_exit(); __current_clr_polling();