Initial Contribution
msm-2.6.38: tag AU_LINUX_ANDROID_GINGERBREAD.02.03.04.00.142
Signed-off-by: Bryan Huntsman <bryanh@codeaurora.org>
diff --git a/kernel/printk.c b/kernel/printk.c
index 4835df7..ff1a52c 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1184,6 +1184,14 @@
console_unlock();
}
+static void __cpuinit console_flush(struct work_struct *work)
+{
+ console_lock();
+ console_unlock();
+}
+
+static __cpuinitdata DECLARE_WORK(console_cpu_notify_work, console_flush);
+
/**
* console_cpu_notify - print deferred console messages after CPU hotplug
* @self: notifier struct
@@ -1194,6 +1202,9 @@
* will be spooled but will not show up on the console. This function is
* called when a new CPU comes online (or fails to come up), and ensures
* that any such output gets printed.
+ *
+ * Special handling must be done for cases invoked from an atomic context,
+ * as we can't be taking the console semaphore here.
*/
static int __cpuinit console_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
@@ -1205,6 +1216,12 @@
case CPU_UP_CANCELED:
console_lock();
console_unlock();
+ /* invoked with preemption disabled, so defer */
+ case CPU_DYING:
+ if (!console_trylock())
+ schedule_work(&console_cpu_notify_work);
+ else
+ console_unlock();
}
return NOTIFY_OK;
}