[COMMON] thermal: core: Bounded polling workqueue on CPU1
authorHyeonseong Gil <hs.gil@samsung.com>
Mon, 8 Aug 2016 03:45:43 +0000 (12:45 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:13:23 +0000 (17:13 +0900)
Resolved migration conflicts from kernel 4.9 to 4.14.

Change-Id: I1d470d7269703588b7afa1f35fcb24ceaaf9e413
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/thermal_core.c
include/linux/thermal.h

index 5bad0fc13ff8b2e3843a3bf2cf290e9d94ada77b..6a6144d9cbadede918f7dd31d398c32c56281ce2 100644 (file)
@@ -50,6 +50,15 @@ static DEFINE_MUTEX(poweroff_lock);
 static atomic_t in_suspend;
 static bool power_off_triggered;
 
+#ifdef CONFIG_SCHED_HMP
+#define BOUNDED_CPU            1
+static void start_poll_queue(struct thermal_zone_device *tz, int delay)
+{
+       mod_delayed_work_on(tz->poll_queue_cpu, system_freezable_wq, &tz->poll_queue,
+                       msecs_to_jiffies(delay));
+}
+#endif
+
 static struct thermal_governor *def_governor;
 
 /*
@@ -293,11 +302,19 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
                                            int delay)
 {
        if (delay > 1000)
+#ifdef CONFIG_SCHED_HMP
+               start_poll_queue(tz, delay);
+#else
                mod_delayed_work(system_freezable_wq, &tz->poll_queue,
                                 round_jiffies(msecs_to_jiffies(delay)));
+#endif
        else if (delay)
+#ifdef CONFIG_SCHED_HMP
+               start_poll_queue(tz, delay);
+#else
                mod_delayed_work(system_freezable_wq, &tz->poll_queue,
                                 msecs_to_jiffies(delay));
+#endif
        else
                cancel_delayed_work(&tz->poll_queue);
 }
@@ -1229,6 +1246,9 @@ thermal_zone_device_register(const char *type, int trips, int mask,
        tz->trips = trips;
        tz->passive_delay = passive_delay;
        tz->polling_delay = polling_delay;
+#ifdef CONFIG_SCHED_HMP
+       tz->poll_queue_cpu = BOUNDED_CPU;
+#endif
 
        /* sys I/F */
        /* Add nodes that are always present via .groups */
@@ -1495,6 +1515,43 @@ static inline int genetlink_init(void) { return 0; }
 static inline void genetlink_exit(void) {}
 #endif /* !CONFIG_NET */
 
+#ifdef CONFIG_SCHED_HMP
+static int thermal_cpu_callback(struct notifier_block *nfb,
+                                       unsigned long action, void *hcpu)
+{
+       unsigned int cpu = (unsigned long)hcpu;
+       struct thermal_zone_device *pos;
+
+       switch (action) {
+       case CPU_ONLINE:
+               if (cpu == BOUNDED_CPU) {
+                       list_for_each_entry(pos, &thermal_tz_list, node) {
+                               pos->poll_queue_cpu = BOUNDED_CPU;
+                               if (pos->polling_delay) {
+                                       start_poll_queue(pos, pos->polling_delay);
+                               }
+                       }
+               }
+               break;
+       case CPU_DOWN_PREPARE:
+               list_for_each_entry(pos, &thermal_tz_list, node) {
+                       if (pos->poll_queue_cpu == cpu) {
+                               pos->poll_queue_cpu = 0;
+                               if (pos->polling_delay)
+                                       start_poll_queue(pos, pos->polling_delay);
+                       }
+               }
+               break;
+       }
+       return NOTIFY_OK;
+}
+
+static struct notifier_block thermal_cpu_notifier =
+{
+       .notifier_call = thermal_cpu_callback,
+};
+#endif
+
 static int thermal_pm_notify(struct notifier_block *nb,
                             unsigned long mode, void *_unused)
 {
@@ -1547,6 +1604,9 @@ static int __init thermal_init(void)
        if (result)
                goto exit_netlink;
 
+#ifdef CONFIG_SCHED_HMP
+       register_hotcpu_notifier(&thermal_cpu_notifier);
+#endif
        result = register_pm_notifier(&thermal_pm_nb);
        if (result)
                pr_warn("Thermal: Can not register suspend notifier, return %d\n",
@@ -1572,6 +1632,9 @@ error:
 static void __exit thermal_exit(void)
 {
        unregister_pm_notifier(&thermal_pm_nb);
+#ifdef CONFIG_SCHED_HMP
+       unregister_hotcpu_notifier(&thermal_cpu_notifier);
+#endif
        of_thermal_destroy_zones();
        genetlink_exit();
        class_unregister(&thermal_class);
index f969b5e790e1f360668bc0d068d3fd49b7e4575e..d2df798831e8707ab921e2f8b3e1811844707854 100644 (file)
@@ -235,6 +235,7 @@ struct thermal_zone_device {
        struct list_head node;
        struct delayed_work poll_queue;
        enum thermal_notify_event notify_event;
+       int poll_queue_cpu;
 };
 
 /**