Merge remote-tracking branch 'common/android-3.0' into msm-3.0
* common/android-3.0: (570 commits)
misc: remove kernel debugger core
ARM: common: fiq_debugger: dump sysrq directly to console if enabled
ARM: common: fiq_debugger: add irq context debug functions
net: wireless: bcmdhd: Call init_ioctl() only if was started properly for WEXT
net: wireless: bcmdhd: Call init_ioctl() only if was started properly
net: wireless: bcmdhd: Fix possible memory leak in escan/iscan
cpufreq: interactive governor: default 20ms timer
cpufreq: interactive governor: go to intermediate hi speed before max
cpufreq: interactive governor: scale to max only if at min speed
cpufreq: interactive governor: apply intermediate load on current speed
ARM: idle: update idle ticks before call idle end notifier
input: gpio_input: don't print debounce message unless flag is set
net: wireless: bcm4329: Skip dhd_bus_stop() if bus is already down
net: wireless: bcmdhd: Skip dhd_bus_stop() if bus is already down
net: wireless: bcmdhd: Improve suspend/resume processing
net: wireless: bcmdhd: Check if FW is Ok for internal FW call
tcp: Don't nuke connections for the wrong protocol
ARM: common: fiq_debugger: make uart irq be no_suspend
net: wireless: Skip connect warning for CONFIG_CFG80211_ALLOW_RECONNECT
mm: avoid livelock on !__GFP_FS allocations
...
Conflicts:
arch/arm/mm/cache-l2x0.c
arch/arm/vfp/vfpmodule.c
drivers/mmc/core/host.c
kernel/power/wakelock.c
net/bluetooth/hci_event.c
Signed-off-by: Bryan Huntsman <bryanh@codeaurora.org>
diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 892e3ec..23dfc40 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -52,6 +52,14 @@
struct wake_lock main_wake_lock;
suspend_state_t requested_suspend_state = PM_SUSPEND_MEM;
static struct wake_lock unknown_wakeup;
+/* flag to warn/bug if wakelocks are taken after suspend_noirq */
+static int msm_suspend_check_done;
+static struct wake_lock suspend_backoff_lock;
+
+#define SUSPEND_BACKOFF_THRESHOLD 10
+#define SUSPEND_BACKOFF_INTERVAL 10000
+
+static unsigned suspend_short_count;
#ifdef CONFIG_WAKELOCK_STAT
static struct wake_lock deleted_wake_locks;
@@ -323,10 +331,18 @@
return 0;
}
+static void suspend_backoff(void)
+{
+ pr_info("suspend: too many immediate wakeups, back off\n");
+ wake_lock_timeout(&suspend_backoff_lock,
+ msecs_to_jiffies(SUSPEND_BACKOFF_INTERVAL));
+}
+
static void suspend(struct work_struct *work)
{
int ret;
int entry_event_num;
+ struct timespec ts_entry, ts_exit;
if (has_wake_lock(WAKE_LOCK_SUSPEND)) {
if (debug_mask & DEBUG_SUSPEND)
@@ -335,20 +351,33 @@
}
entry_event_num = current_event_num;
- sys_sync();
+ suspend_sys_sync_queue();
if (debug_mask & DEBUG_SUSPEND)
pr_info("suspend: enter suspend\n");
+ getnstimeofday(&ts_entry);
ret = pm_suspend(requested_suspend_state);
+ getnstimeofday(&ts_exit);
+
if (debug_mask & DEBUG_EXIT_SUSPEND) {
- struct timespec ts;
struct rtc_time tm;
- getnstimeofday(&ts);
- rtc_time_to_tm(ts.tv_sec, &tm);
+ rtc_time_to_tm(ts_exit.tv_sec, &tm);
pr_info("suspend: exit suspend, ret = %d "
"(%d-%02d-%02d %02d:%02d:%02d.%09lu UTC)\n", ret,
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
+ tm.tm_hour, tm.tm_min, tm.tm_sec, ts_exit.tv_nsec);
}
+
+ if (ts_exit.tv_sec - ts_entry.tv_sec <= 1) {
+ ++suspend_short_count;
+
+ if (suspend_short_count == SUSPEND_BACKOFF_THRESHOLD) {
+ suspend_backoff();
+ suspend_short_count = 0;
+ }
+ } else {
+ suspend_short_count = 0;
+ }
+
if (current_event_num == entry_event_num) {
if (debug_mask & DEBUG_SUSPEND)
pr_info("suspend: pm_suspend returned with no event\n");
@@ -383,11 +412,21 @@
#endif
if (debug_mask & DEBUG_SUSPEND)
pr_info("power_suspend_late return %d\n", ret);
+
+ if (ret == 0)
+ msm_suspend_check_done = 1;
return ret;
}
+static int power_resume_early(struct device *dev)
+{
+ msm_suspend_check_done = 0;
+ return 0;
+}
+
static struct dev_pm_ops power_driver_pm_ops = {
.suspend_noirq = power_suspend_late,
+ .resume_noirq = power_resume_early,
};
static struct platform_driver power_driver = {
@@ -530,12 +569,24 @@
void wake_lock(struct wake_lock *lock)
{
+ /*
+ * if wake lock is being called too late in the suspend sequence,
+ * call bug so we get to analyze the callstack
+ */
+ BUG_ON(msm_suspend_check_done);
+
wake_lock_internal(lock, 0, 0);
}
EXPORT_SYMBOL(wake_lock);
void wake_lock_timeout(struct wake_lock *lock, long timeout)
{
+ /*
+ * if wake lock is being called too late in the suspend sequence,
+ * call bug so we get to analyze the callstack
+ */
+ BUG_ON(msm_suspend_check_done);
+
wake_lock_internal(lock, timeout, 1);
}
EXPORT_SYMBOL(wake_lock_timeout);
@@ -615,6 +666,8 @@
wake_lock_init(&main_wake_lock, WAKE_LOCK_SUSPEND, "main");
wake_lock(&main_wake_lock);
wake_lock_init(&unknown_wakeup, WAKE_LOCK_SUSPEND, "unknown_wakeups");
+ wake_lock_init(&suspend_backoff_lock, WAKE_LOCK_SUSPEND,
+ "suspend_backoff");
ret = platform_device_register(&power_device);
if (ret) {
@@ -627,6 +680,14 @@
goto err_platform_driver_register;
}
+ INIT_COMPLETION(suspend_sys_sync_comp);
+ suspend_sys_sync_work_queue =
+ create_singlethread_workqueue("suspend_sys_sync");
+ if (suspend_sys_sync_work_queue == NULL) {
+ ret = -ENOMEM;
+ goto err_suspend_sys_sync_work_queue;
+ }
+
suspend_work_queue = create_singlethread_workqueue("suspend");
if (suspend_work_queue == NULL) {
ret = -ENOMEM;
@@ -640,10 +701,12 @@
return 0;
err_suspend_work_queue:
+err_suspend_sys_sync_work_queue:
platform_driver_unregister(&power_driver);
err_platform_driver_register:
platform_device_unregister(&power_device);
err_platform_device_register:
+ wake_lock_destroy(&suspend_backoff_lock);
wake_lock_destroy(&unknown_wakeup);
wake_lock_destroy(&main_wake_lock);
#ifdef CONFIG_WAKELOCK_STAT
@@ -658,8 +721,10 @@
remove_proc_entry("wakelocks", NULL);
#endif
destroy_workqueue(suspend_work_queue);
+ destroy_workqueue(suspend_sys_sync_work_queue);
platform_driver_unregister(&power_driver);
platform_device_unregister(&power_device);
+ wake_lock_destroy(&suspend_backoff_lock);
wake_lock_destroy(&unknown_wakeup);
wake_lock_destroy(&main_wake_lock);
#ifdef CONFIG_WAKELOCK_STAT