Skip to contentSkip to conversation

i8042: activate panic blink only in X

RFC/PATCH-mm Dmitry Torokhov 5 participants 7 messages Sep 3, 2006 – Sep 21, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

Here is an attempt to make panicblink only active in X so there is a chance of keyboard still working after panic in text console. Any reason why is should not be done this way?

Signature · 45 lines
Dmitry

Input: i8042 - blink keyboard LEDs during panic only when in X

This gives keyboard a chance to work in text console so user
can attempt to exctract more useful data form crashed box
(for example some backtraces from SysRq)

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/serio/i8042.c |   10 ++++++++++
 1 files changed, 10 insertions(+)

Index: work/drivers/input/serio/i8042.c
===================================================================
--- work.orig/drivers/input/serio/i8042.c
+++ work/drivers/input/serio/i8042.c
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/rcupdate.h>
 #include <linux/platform_device.h>
+#include <linux/vt_kern.h>
 
 #include <asm/io.h>
 
@@ -831,6 +832,15 @@ static long i8042_panic_blink(long count
 	static char led;
 
 	/*
+	 * Only blink while in X because it messes up scrollback in console
+	 * preventing users to see the entire oops.
+	 */
+#ifdef CONFIG_HW_CONSOLE
+	if (vc_cons[fg_console].d->vc_mode != KD_GRAPHICS)
+		return 0;
+#endif
+
+	/*
 	 * We expect frequency to be about 1/2s. KDB uses about 1s.
 	 * Make sure they are different.
 	 */

-- 
VGER BF report: H 0.00257812
#1 lore raw
Quoted 6 lines · Dmitry Torokhov

To: LKML <[email protected]>
Subject: [RFC/PATCH-mm] i8042: activate panic blink only in X
From: Dmitry Torokhov <[email protected]>
Date: Sat, 2 Sep 2006 23:20:36 -0400
Cc: Andrew Morton <[email protected]>, Grant Coady <[email protected]>

Quoted 6 lines

Hi,

Here is an attempt to make panicblink only active in X so there is a chance of keyboard still working after panic in text console. Any reason why is should not be done this way?

Works as expected here on console, I cannot test the X function.

Grant.

Signature · 1 line
VGER BF report: U 0.480126
#2 lore raw
In reply to Dmitry Torokhov
Quoted 6 lines · Dmitry Torokhov

Hi,

Here is an attempt to make panicblink only active in X so there is a chance of keyboard still working after panic in text console. Any reason why is should not be done this way?

Looks good to me.

Of course it would be even better to fix the panic stuff to not disrupt scrollback, but short of that it's a good idea.

-Andi (original panic blink author)

#3 lore raw
Quoted 9 lines · Andi Kleen
Quoted 6 lines · Dmitry Torokhov

Hi,

Here is an attempt to make panicblink only active in X so there is a chance of keyboard still working after panic in text console. Any reason why is should not be done this way?

Quoted 6 lines

Looks good to me.

Of course it would be even better to fix the panic stuff to not disrupt scrollback, but short of that it's a good idea.

-Andi (original panic blink author)

I'd like to have panic blink and also be able to Shft-Up to previous console screens.

If possible, kill the console blank timer too? (dunno if you have).

Example: Oops screen on 2.4 recently I paged up to where the fault started, the screen blanker kicked in while I was hand copying info and wiped previous screens :( Caused significant delay in working out what the issue was (slackware-10.2 2.4.33.1 glibc nptl boo-boo).

Is it safe / easy to do on oops/panic?

Grant.

#4 lore raw

Hi,

Quoted 8 lines · Grant Coady

If possible, kill the console blank timer too? (dunno if you have).

Example: Oops screen on 2.4 recently I paged up to where the fault started, the screen blanker kicked in while I was hand copying info and wiped previous screens :( Caused significant delay in working out what the issue was (slackware-10.2 2.4.33.1 glibc nptl boo-boo).

Is it safe / easy to do on oops/panic?

It should be as easy as e.g. doing a

int system_oopsed __read_mostly = 0;

if (!system_oopsed)

    blank();

in the timer handler as opposed to painfully deregistering the whole handler in the critical system state after an OOPS.
A funny side effect is that this way even improves system stability after OOPS, since the blanking (which doesn't happen then)
might bomb, too ;)

Andreas Mohr

#5 lore raw
Quoted 10 lines · Andreas Mohr

Hi,

Quoted 7 lines · Grant Coady

If possible, kill the console blank timer too? (dunno if you have).

Example: Oops screen on 2.4 recently I paged up to where the fault started, the screen blanker kicked in while I was hand copying info and wiped previous screens :( Caused significant delay in working out what the issue was (slackware-10.2 2.4.33.1 glibc nptl boo-boo).

Quoted 5 lines
Quoted 1 line

Is it safe / easy to do on oops/panic?

It should be as easy as e.g. doing a

int system_oopsed __read_mostly = 0;

Can't see where to set this one, from the kernel/panic.c notifier chain?

Quoted 2 lines

if (!system_oopsed)
blank();

drivers/char/vt.c:
...
static void blank_screen_t(unsigned long dummy)

{
        if (unlikely(!keventd_up())) {
                mod_timer(&console_timer, jiffies + blankinterval);
                return;
        }
        blank_timer_expired = 1;
        schedule_work(&console_work);
}

Looks like the place to stop the screen blanker, that's as far as I'm game to travel.

Hooking the panic notifier chain looks too scary for this little black duck ;)

Grant.

Quoted 8 lines

in the timer handler as opposed to painfully deregistering the whole handler in the critical system state after an OOPS.
A funny side effect is that this way even improves system stability after OOPS, since the blanking (which doesn't happen then)
might bomb, too ;)

Andreas Mohr

#6 lore raw
In reply to Grant Coady
Quoted 13 lines · Grant Coady
Quoted 11 lines · Andi Kleen
Quoted 6 lines · Dmitry Torokhov

Hi,

Here is an attempt to make panicblink only active in X so there is a chance of keyboard still working after panic in text console. Any reason why is should not be done this way?

Looks good to me.

Quoted 7 lines
Quoted 4 lines

Of course it would be even better to fix the panic stuff to not disrupt scrollback, but short of that it's a good idea.

-Andi (original panic blink author)

I'd like to have panic blink and also be able to Shft-Up to previous console screens.

Ok, so here is my attempt at keeping panic blink in console whithout atkbd bitching at us about ACKs/NAKs. Console scrollback still does not work for me, most likely because it needs scheduler to run, but SysRq seems to be working well.

Please try it and tell meif it works for you. Thanks!

Signature · 67 lines
Dmitry

Subject: i8042 - supress ACK/NAKs when blinking during panic

Input: i8042 - supress ACK/NAKs when blinking during panic

This allows using SysRq and not fill logs with complaints from atkbd.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/serio/i8042.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

Index: work/drivers/input/serio/i8042.c
===================================================================
--- work.orig/drivers/input/serio/i8042.c
+++ work/drivers/input/serio/i8042.c
@@ -106,6 +106,7 @@ static unsigned char i8042_ctr;
 static unsigned char i8042_mux_present;
 static unsigned char i8042_kbd_irq_registered;
 static unsigned char i8042_aux_irq_registered;
+static unsigned char i8042_suppress_kbd_ack;
 static struct platform_device *i8042_platform_device;
 
 static irqreturn_t i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs);
@@ -316,7 +317,7 @@ static irqreturn_t i8042_interrupt(int i
 	unsigned char str, data;
 	unsigned int dfl;
 	unsigned int port_no;
-	int ret;
+	int ret = 1;
 
 	spin_lock_irqsave(&i8042_lock, flags);
 	str = i8042_read_status();
@@ -378,10 +379,16 @@ static irqreturn_t i8042_interrupt(int i
 	    dfl & SERIO_PARITY ? ", bad parity" : "",
 	    dfl & SERIO_TIMEOUT ? ", timeout" : "");
 
+	if (unlikely(i8042_suppress_kbd_ack))
+		if (port_no == I8042_KBD_PORT_NO &&
+		    (data == 0xfa || data == 0xfe)) {
+			i8042_suppress_kbd_ack = 0;
+			goto out;
+		}
+
 	if (likely(port->exists))
 		serio_interrupt(port->serio, data, dfl, regs);
 
-	ret = 1;
  out:
 	return IRQ_RETVAL(ret);
 }
@@ -842,11 +849,13 @@ static long i8042_panic_blink(long count
 	led ^= 0x01 | 0x04;
 	while (i8042_read_status() & I8042_STR_IBF)
 		DELAY;
+	i8042_suppress_kbd_ack = 1;
 	i8042_write_data(0xed); /* set leds */
 	DELAY;
 	while (i8042_read_status() & I8042_STR_IBF)
 		DELAY;
 	DELAY;
+	i8042_suppress_kbd_ack = 1;
 	i8042_write_data(led);
 	DELAY;
 	last_blink = count;