import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / base / power / wakeup.c
index 79715e7fa43e34c9cbf9a4521a657d7bb952f9c6..3a9d608385c1229d2cbc75d92f73eb986719e914 100644 (file)
 #include <trace/events/power.h>
 
 #include "power.h"
+//#ifndef CONFIG_ARM64
+#if 1
+int wakeup_debug = 0;
+#define _TAG_WAKEUP "WAKEUP"
+#define wakeup_log(fmt, ...)    do { if (wakeup_debug) pr_info("[%s][%s]" fmt, _TAG_WAKEUP, __func__, ##__VA_ARGS__); } while (0)
+#define wakeup_warn(fmt, ...)   do { if (wakeup_debug) pr_warn("[%s][%s]" fmt, _TAG_WAKEUP, __func__, ##__VA_ARGS__); } while (0)
 
 /*
  * If set, the suspend/hibernate code will abort transitions to a sleep state
  * if wakeup events are registered during or immediately before the transition.
  */
 bool events_check_enabled __read_mostly;
+EXPORT_SYMBOL_GPL(events_check_enabled);
 
 /*
  * Combined counters of registered wakeup events and wakeup events in progress.
@@ -392,7 +399,11 @@ static void wakeup_source_activate(struct wakeup_source *ws)
        ws->active_count++;
        ws->last_time = ktime_get();
        if (ws->autosleep_enabled)
+       {
+               //<20130327> <marc.huang> add wakeup source dubug log
+               wakeup_warn("ws->name: %s\n", ws->name);
                ws->start_prevent_time = ws->last_time;
+       }
 
        /* Increment the counter of events in progress. */
        cec = atomic_inc_return(&combined_event_count);
@@ -428,6 +439,9 @@ void __pm_stay_awake(struct wakeup_source *ws)
        if (!ws)
                return;
 
+       //<20130327> <marc.huang> add wakeup source dubug log
+       wakeup_log("ws->name: %s\n", ws->name);
+
        spin_lock_irqsave(&ws->lock, flags);
 
        wakeup_source_report_event(ws);
@@ -515,12 +529,18 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
        ws->timer_expires = 0;
 
        if (ws->autosleep_enabled)
+       {
+               //<20130327> <marc.huang> add wakeup source dubug log
+               wakeup_warn("ws->name: %s\n", ws->name);
                update_prevent_sleep_time(ws, now);
+       }
 
        /*
         * Increment the counter of registered wakeup events and decrement the
         * couter of wakeup events in progress simultaneously.
         */
+    // FIXME: CHECK BUG here ??? if combined_event_count = 0x????0000, then atomic_add_return(...) --> 0x????ffff
+    //        , which is not the expected result !!!
        cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
        trace_wakeup_source_deactivate(ws->name, cec);
 
@@ -545,6 +565,9 @@ void __pm_relax(struct wakeup_source *ws)
        if (!ws)
                return;
 
+       //<20130327> <marc.huang> add wakeup source dubug log
+       wakeup_log("ws->name: %s\n", ws->name);
+
        spin_lock_irqsave(&ws->lock, flags);
        if (ws->active)
                wakeup_source_deactivate(ws);
@@ -615,6 +638,9 @@ void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec)
        if (!ws)
                return;
 
+       //<20130327> <marc.huang> add wakeup source dubug log
+       wakeup_log("ws->name: %s\n", ws->name);
+
        spin_lock_irqsave(&ws->lock, flags);
 
        wakeup_source_report_event(ws);
@@ -704,6 +730,10 @@ bool pm_wakeup_pending(void)
                split_counters(&cnt, &inpr);
                ret = (cnt != saved_count || inpr > 0);
                events_check_enabled = !ret;
+
+               //<20130327> <marc.huang> add wakeup source dubug log
+               if (ret)
+                       wakeup_warn("cnt: %d, saved_count: %d, inpr: %d\n", cnt, saved_count, inpr);
        }
        spin_unlock_irqrestore(&events_lock, flags);
 
@@ -712,6 +742,7 @@ bool pm_wakeup_pending(void)
 
        return ret;
 }
+EXPORT_SYMBOL_GPL(pm_wakeup_pending);
 
 /**
  * pm_get_wakeup_count - Read the number of registered wakeup events.
@@ -739,6 +770,8 @@ bool pm_get_wakeup_count(unsigned int *count, bool block)
                        if (inpr == 0 || signal_pending(current))
                                break;
 
+                       //<20130327> <marc.huang> add wakeup source dubug log
+                       print_active_wakeup_sources();
                        schedule();
                }
                finish_wait(&wakeup_count_wait_queue, &wait);
@@ -854,7 +887,11 @@ static int print_wakeup_source_stats(struct seq_file *m,
 
        return ret;
 }
-
+#endif
+//#ifdef CONFIG_ARM64
+#if 1
+static struct dentry *wakeup_sources_stats_dentry;
+#endif
 /**
  * wakeup_sources_stats_show - Print wakeup sources statistics information.
  * @m: seq_file to print the statistics into.
@@ -868,8 +905,11 @@ static int wakeup_sources_stats_show(struct seq_file *m, void *unused)
                "last_change\tprevent_suspend_time\n");
 
        rcu_read_lock();
+//#ifndef CONFIG_ARM64 
+#if 1
        list_for_each_entry_rcu(ws, &wakeup_sources, entry)
                print_wakeup_source_stats(m, ws);
+#endif
        rcu_read_unlock();
 
        return 0;