From: Andi Kleen I have a weird KVM that refuses to switch consoles when the keyboard controller doesn't process key presses. Actually it switches, but only after a long delay which usually drives me crazy. This patch changes the panic loop to eat keys from the keyboard controller on i386 boxes. With that I can switch consoles after a panic. The ioport should be available on all PC like boxes, the reset code also depends on it being at a fixed place. ioport.c is not the best place in the world to place the function, but I didn't find a better one. It cannot be inlined to avoid include hell. arch/i386/kernel/ioport.c | 13 +++++++++++++ include/asm-i386/system.h | 3 +++ kernel/panic.c | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff -puN arch/i386/kernel/ioport.c~eat-keys-on-panic arch/i386/kernel/ioport.c --- 25/arch/i386/kernel/ioport.c~eat-keys-on-panic 2003-05-31 10:29:44.000000000 -0700 +++ 25-akpm/arch/i386/kernel/ioport.c 2003-05-31 10:30:03.000000000 -0700 @@ -15,6 +15,9 @@ #include #include #include +#include + +#include /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */ static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value) @@ -129,3 +132,13 @@ asmlinkage int sys_iopl(unsigned long un set_thread_flag(TIF_IRET); return 0; } + +/* Some KVMs don't switch consoles unless the keyboard is served. */ +void eat_key(void) +{ + if (inb(0x60) & 1) { + mdelay(1); + inb(0x64); + } + mdelay(1); +} diff -puN include/asm-i386/system.h~eat-keys-on-panic include/asm-i386/system.h --- 25/include/asm-i386/system.h~eat-keys-on-panic 2003-05-31 10:29:44.000000000 -0700 +++ 25-akpm/include/asm-i386/system.h 2003-05-31 10:29:44.000000000 -0700 @@ -476,4 +476,7 @@ extern int is_sony_vaio_laptop; #define BROKEN_PNP_BIOS 0x0004 #define BROKEN_CPUFREQ 0x0008 +#define HAVE_EAT_KEY +void eat_key(void); + #endif diff -puN kernel/panic.c~eat-keys-on-panic kernel/panic.c --- 25/kernel/panic.c~eat-keys-on-panic 2003-05-31 10:29:44.000000000 -0700 +++ 25-akpm/kernel/panic.c 2003-05-31 10:29:44.000000000 -0700 @@ -96,8 +96,11 @@ NORET_TYPE void panic(const char * fmt, disabled_wait(caller); #endif local_irq_enable(); - for (;;) - ; + for (;;) { +#ifdef HAVE_EAT_KEY + eat_key(); +#endif + } } /** _