Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / kernel / printk.c
index ddebdcc..63eb290 100644 (file)
@@ -26,8 +26,8 @@
 #include <linux/jiffies.h>
 #include <linux/nmi.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/interrupt.h>                   /* For in_interrupt() */
+#include <linux/config.h>
 #include <linux/delay.h>
 #include <linux/smp.h>
 #include <linux/security.h>
@@ -56,7 +56,7 @@ int console_printk[4] = {
        DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
 };
 
-EXPORT_UNUSED_SYMBOL(console_printk);  /*  June 2006  */
+EXPORT_SYMBOL(console_printk);
 
 /*
  * Low lever drivers may need that to know if they can schedule in
@@ -81,7 +81,8 @@ struct console *console_drivers;
  * path in the console code where we end up in places I want
  * locked without the console sempahore held
  */
-static int console_locked, console_suspended;
+static int console_locked;
+int console_suspended;
 
 /*
  * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars
@@ -354,9 +355,7 @@ static void __call_console_drivers(unsigned long start, unsigned long end)
        struct console *con;
 
        for (con = console_drivers; con; con = con->next) {
-               if ((con->flags & CON_ENABLED) && con->write &&
-                               (cpu_online(smp_processor_id()) ||
-                               (con->flags & CON_ANYTIME)))
+               if ((con->flags & CON_ENABLED) && con->write)
                        con->write(con, &LOG_BUF(start), end - start);
        }
 }
@@ -466,7 +465,6 @@ static int printk_time = 1;
 #else
 static int printk_time = 0;
 #endif
-module_param(printk_time, int, S_IRUGO | S_IWUSR);
 
 static int __init printk_time_setup(char *str)
 {
@@ -483,18 +481,6 @@ __attribute__((weak)) unsigned long long printk_clock(void)
        return sched_clock();
 }
 
-/* Check if we have any console registered that can be called early in boot. */
-static int have_callable_console(void)
-{
-       struct console *con;
-
-       for (con = console_drivers; con; con = con->next)
-               if (con->flags & CON_ANYTIME)
-                       return 1;
-
-       return 0;
-}
-
 /**
  * printk - print a kernel message
  * @fmt: format string
@@ -550,9 +536,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
                zap_locks();
 
        /* This stops the holder of console_sem just where we want him */
-       local_irq_save(flags);
-       lockdep_off();
-       spin_lock(&logbuf_lock);
+       spin_lock_irqsave(&logbuf_lock, flags);
        printk_cpu = smp_processor_id();
 
        /* Emit the output into the temporary buffer */
@@ -615,31 +599,27 @@ asmlinkage int vprintk(const char *fmt, va_list args)
                        log_level_unknown = 1;
        }
 
-       if (!down_trylock(&console_sem)) {
+       if (!cpu_online(smp_processor_id())) {
                /*
-                * We own the drivers.  We can drop the spinlock and
-                * let release_console_sem() print the text, maybe ...
+                * Some console drivers may assume that per-cpu resources have
+                * been allocated.  So don't allow them to be called by this
+                * CPU until it is officially up.  We shouldn't be calling into
+                * random console drivers on a CPU which doesn't exist yet..
                 */
-               console_locked = 1;
                printk_cpu = UINT_MAX;
-               spin_unlock(&logbuf_lock);
-
+               spin_unlock_irqrestore(&logbuf_lock, flags);
+               goto out;
+       }
+       if (!down_trylock(&console_sem)) {
+               console_locked = 1;
                /*
-                * Console drivers may assume that per-cpu resources have
-                * been allocated. So unless they're explicitly marked as
-                * being able to cope (CON_ANYTIME) don't call them until
-                * this CPU is officially up.
+                * We own the drivers.  We can drop the spinlock and let
+                * release_console_sem() print the text
                 */
-               if (cpu_online(smp_processor_id()) || have_callable_console()) {
-                       console_may_schedule = 0;
-                       release_console_sem();
-               } else {
-                       /* Release by hand to avoid flushing the buffer. */
-                       console_locked = 0;
-                       up(&console_sem);
-               }
-               lockdep_on();
-               local_irq_restore(flags);
+               printk_cpu = UINT_MAX;
+               spin_unlock_irqrestore(&logbuf_lock, flags);
+               console_may_schedule = 0;
+               release_console_sem();
        } else {
                /*
                 * Someone else owns the drivers.  We drop the spinlock, which
@@ -647,11 +627,9 @@ asmlinkage int vprintk(const char *fmt, va_list args)
                 * console drivers with the output which we just produced.
                 */
                printk_cpu = UINT_MAX;
-               spin_unlock(&logbuf_lock);
-               lockdep_on();
-               local_irq_restore(flags);
+               spin_unlock_irqrestore(&logbuf_lock, flags);
        }
-
+out:
        preempt_enable();
        return printed_len;
 }
@@ -753,23 +731,6 @@ int __init add_preferred_console(char *name, int idx, char *options)
        return 0;
 }
 
-/**
- * suspend_console - suspend the console subsystem
- *
- * This disables printk() while we go into suspend states
- */
-void suspend_console(void)
-{
-       acquire_console_sem();
-       console_suspended = 1;
-}
-
-void resume_console(void)
-{
-       console_suspended = 0;
-       release_console_sem();
-}
-
 /**
  * acquire_console_sem - lock the console system for exclusive use.
  *
@@ -780,11 +741,12 @@ void resume_console(void)
  */
 void acquire_console_sem(void)
 {
-       BUG_ON(in_interrupt());
        if (console_suspended) {
                down(&secondary_console_sem);
                return;
        }
+
+       BUG_ON(in_interrupt());
        down(&console_sem);
        console_locked = 1;
        console_may_schedule = 1;
@@ -805,7 +767,7 @@ int is_console_locked(void)
 {
        return console_locked;
 }
-EXPORT_UNUSED_SYMBOL(is_console_locked);  /*  June 2006  */
+EXPORT_SYMBOL(is_console_locked);
 
 /**
  * release_console_sem - unlock the console system
@@ -832,8 +794,6 @@ void release_console_sem(void)
                return;
        }
 
-       console_may_schedule = 0;
-
        for ( ; ; ) {
                spin_lock_irqsave(&logbuf_lock, flags);
                wake_klogd |= log_start - log_end;
@@ -847,17 +807,11 @@ void release_console_sem(void)
                local_irq_restore(flags);
        }
        console_locked = 0;
+       console_may_schedule = 0;
        up(&console_sem);
        spin_unlock_irqrestore(&logbuf_lock, flags);
-       if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) {
-               /*
-                * If we printk from within the lock dependency code,
-                * from within the scheduler code, then do not lock
-                * up due to self-recursion:
-                */
-               if (!lockdep_internal())
-                       wake_up_interruptible(&log_wait);
-       }
+       if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait))
+               wake_up_interruptible(&log_wait);
 }
 EXPORT_SYMBOL(release_console_sem);