linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add panic blinking to 2.6
@ 2004-10-31  1:36 Andi Kleen
  2004-10-31  2:25 ` Chris Wedgwood
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2004-10-31  1:36 UTC (permalink / raw)
  To: akpm, linux-kernel


This patch readds the panic blinking that was in 2.4
to 2.6. This is useful to see when you're in X that the 
machine has paniced 

It addresses previously criticism.
It should work now when the keyboard interrupt is off. 
It doesn't fully emulate the handler, but has a timeout 
for this case.

Signed-off-by: Andi Kleen <ak@suse.de>

diff -u linux-2.6.9-work/drivers/input/serio/i8042.c-PANIC linux-2.6.9-work/drivers/input/serio/i8042.c
--- linux-2.6.9-work/drivers/input/serio/i8042.c-PANIC	2004-10-19 01:55:13.000000000 +0200
+++ linux-2.6.9-work/drivers/input/serio/i8042.c	2004-10-20 05:20:24.000000000 +0200
@@ -887,6 +887,41 @@
         0
 };
 
+static int blink_frequency = 500;
+module_param_named(panicblink, blink_frequency, int, 0600);
+
+/* Catch the case when the kbd interrupt is off */
+#define DELAY do { mdelay(1); if (++delay > 10) return delay; } while(0) 
+
+/* Tell the user who may be running in X and not see the console that we have 
+   panic'ed. This is to distingush panics from "real" lockups.  */
+static long i8042_panic_blink(long count)
+{ 
+	long delay = 0;
+	static long last_blink;
+	static char led;
+	/* Roughly 1/2s frequency. KDB uses about 1s. Make sure it is 
+	   different. */
+	if (!blink_frequency) 
+		return 0;
+	if (count - last_blink < blink_frequency)
+		return 0;
+	led ^= 0x01 | 0x04;
+	while (i8042_read_status() & I8042_STR_IBF)
+		DELAY;
+	i8042_write_data(0xed); /* set leds */
+	DELAY;
+	while (i8042_read_status() & I8042_STR_IBF)
+		DELAY;
+	DELAY;
+	i8042_write_data(led);
+	DELAY;
+	last_blink = count;
+	return delay;
+}  
+
+#undef DELAY
+
 /*
  * Suspend/resume handlers for the new PM scheme (driver model)
  */
@@ -1047,6 +1082,8 @@
 
 	register_reboot_notifier(&i8042_notifier);
 
+	panic_blink = i8042_panic_blink;
+
 	return 0;
 }
 
@@ -1077,6 +1114,8 @@
 	driver_unregister(&i8042_driver);
 
 	i8042_platform_exit();
+
+	panic_blink = NULL;
 }
 
 module_init(i8042_init);
diff -u linux-2.6.9-work/include/linux/kernel.h-PANIC linux-2.6.9-work/include/linux/kernel.h
--- linux-2.6.9-work/include/linux/kernel.h-PANIC	2004-10-19 01:55:35.000000000 +0200
+++ linux-2.6.9-work/include/linux/kernel.h	2004-10-20 05:17:55.000000000 +0200
@@ -66,6 +66,7 @@
 	})
 
 extern struct notifier_block *panic_notifier_list;
+extern long (*panic_blink)(long time);
 NORET_TYPE void panic(const char * fmt, ...)
 	__attribute__ ((NORET_AND format (printf, 1, 2)));
 asmlinkage NORET_TYPE void do_exit(long error_code)
diff -u linux-2.6.9-work/kernel/panic.c-PANIC linux-2.6.9-work/kernel/panic.c
--- linux-2.6.9-work/kernel/panic.c-PANIC	2004-10-19 01:55:36.000000000 +0200
+++ linux-2.6.9-work/kernel/panic.c	2004-10-20 05:17:55.000000000 +0200
@@ -37,6 +37,15 @@
 }
 __setup("panic=", panic_setup);
 
+static long no_blink(long time)
+{
+	return 0;
+}
+
+/* Returns how long it waited in ms */
+long (*panic_blink)(long time) = no_blink;
+EXPORT_SYMBOL(panic_blink);
+
 /**
  *	panic - halt the system
  *	@fmt: The text string to print
@@ -49,6 +58,7 @@
  
 NORET_TYPE void panic(const char * fmt, ...)
 {
+	long i;
 	static char buf[1024];
 	va_list args;
 #if defined(CONFIG_ARCH_S390)
@@ -70,15 +80,16 @@
 
 	if (panic_timeout > 0)
 	{
-		int i;
 		/*
 	 	 * Delay timeout seconds before rebooting the machine. 
 		 * We can't use the "normal" timers since we just panicked..
 	 	 */
 		printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
-		for (i = 0; i < panic_timeout; i++) {
+		for (i = 0; i < panic_timeout*1000; ) {
 			touch_nmi_watchdog();
-			mdelay(1000);
+			i += panic_blink(i);
+			mdelay(1);
+			i++;
 		}
 		/*
 		 *	Should we run the reboot notifier. For the moment Im
@@ -99,8 +110,11 @@
         disabled_wait(caller);
 #endif
 	local_irq_enable();
-	for (;;)
-		;
+	for (i = 0;;) { 
+		i += panic_blink(i);
+		mdelay(1); 
+		i++; 
+	}
 }
 
 EXPORT_SYMBOL(panic);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add panic blinking to 2.6
  2004-10-31  1:36 [PATCH] Add panic blinking to 2.6 Andi Kleen
@ 2004-10-31  2:25 ` Chris Wedgwood
  2004-10-31  2:54   ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wedgwood @ 2004-10-31  2:25 UTC (permalink / raw)
  To: Andi Kleen; +Cc: akpm, linux-kernel

On Sun, Oct 31, 2004 at 02:36:49AM +0100, Andi Kleen wrote:

> This patch readds the panic blinking that was in 2.4
> to 2.6.

cool

> +static int blink_frequency = 500;
> +module_param_named(panicblink, blink_frequency, int, 0600);

does it reall need to be a module? 

> +/* Returns how long it waited in ms */
> +long (*panic_blink)(long time) = no_blink;
> +EXPORT_SYMBOL(panic_blink);

i dont know we can't have this unconditionally with the 500ms period
(always present and on)

would that really harm anything?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add panic blinking to 2.6
  2004-10-31  2:25 ` Chris Wedgwood
@ 2004-10-31  2:54   ` Andi Kleen
  0 siblings, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2004-10-31  2:54 UTC (permalink / raw)
  To: Chris Wedgwood; +Cc: Andi Kleen, akpm, linux-kernel

On Sat, Oct 30, 2004 at 07:25:37PM -0700, Chris Wedgwood wrote:
> > +static int blink_frequency = 500;
> > +module_param_named(panicblink, blink_frequency, int, 0600);
> 
> does it reall need to be a module? 

It isn't a module.
> 
> > +/* Returns how long it waited in ms */
> > +long (*panic_blink)(long time) = no_blink;
> > +EXPORT_SYMBOL(panic_blink);
> 
> i dont know we can't have this unconditionally with the 500ms period
> (always present and on)
> 
> would that really harm anything?

Yes, one broken KVM seems to block switching with it in some cases

-Andi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-31  2:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-31  1:36 [PATCH] Add panic blinking to 2.6 Andi Kleen
2004-10-31  2:25 ` Chris Wedgwood
2004-10-31  2:54   ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).