]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Add try_acquire_console_sem
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 11 Feb 2005 00:03:00 +0000 (16:03 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 11 Feb 2005 00:03:00 +0000 (16:03 -0800)
The new PowerMac sleep code provides an arch hook that can be used by video
drivers on laptops to bring back the screen very early, pretty much before
anything else.  This basically turns reports of the style "my laptop doesn't
wakeup" to "I get this or this oops/error/panic on wakeup", making fixing the
PM related bugs possible on a whole range of them.

However, the fbdev wakeup code triggers WARN_ON's in the VT subsystem if
called without the console semaphore when redrawing the screen (I added those
warnings a couple of kernel versions ago), and we can't call
acquire_console_sem() since we are so early in the wakeup process that we are
considered as in_atomic() (we hold irqs off too).

This patch addds a try_acquire_console_sem() function that can be used by
those video drivers that implement this early wakeup hook.  If the acquire
fails (which should never happen in practice), wakeup is delayed to the normal
PCI callback which does a blocking acquire_console_sem().

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/console.h
kernel/printk.c

index d5077755f78c81d335a8e30a712b0ab487cad453..99fd8e4be694adcdb52a8d4eb877058e61d8c3b4 100644 (file)
@@ -105,6 +105,7 @@ extern void register_console(struct console *);
 extern int unregister_console(struct console *);
 extern struct console *console_drivers;
 extern void acquire_console_sem(void);
+extern int try_acquire_console_sem(void);
 extern void release_console_sem(void);
 extern void console_conditional_schedule(void);
 extern void console_unblank(void);
index d914a90d6206dd764f42d4eaa003f1b0706c41f6..d981e7e4153a81d72bec0492a83f8b4d96133ba8 100644 (file)
@@ -611,6 +611,16 @@ void acquire_console_sem(void)
 }
 EXPORT_SYMBOL(acquire_console_sem);
 
+int try_acquire_console_sem(void)
+{
+       if (down_trylock(&console_sem))
+               return -1;
+       console_locked = 1;
+       console_may_schedule = 0;
+       return 0;
+}
+EXPORT_SYMBOL(try_acquire_console_sem);
+
 int is_console_locked(void)
 {
        return console_locked;