kernel: Add PRE/POST noti for cpu pm
authorYoungtae Lee <yt0729.lee@samsung.com>
Thu, 2 Nov 2017 11:36:17 +0000 (20:36 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:30:24 +0000 (17:30 +0900)
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 <yt0729.lee@samsung.com>
include/linux/cpu_pm.h
kernel/cpu_pm.c
kernel/sched/idle.c

index 455b233dd3b1be5a9e5b500ddeb0c6c7e8938be5..9a3bc18a493bfcef7e7a92f63297230ff6cf7af4 100644 (file)
@@ -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
index 67b02e138a472da5f908a6eb2156887e058d0704..ea4135831b331a26affa7f708d64fd33546cdfb1 100644 (file)
@@ -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
  *
index c1dbb2cc1f29c8a936f5a0fe4b1a467c10e2b9b5..7f2d0145f71efb6221942e0c8e0ec63f732b7b30 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/stackprotector.h>
 #include <linux/suspend.h>
 #include <linux/livepatch.h>
+#include <linux/cpu_pm.h>
 
 #include <asm/tlb.h>
 
@@ -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();