Hello,

Issue #1: KDB patch for keyboard freeze issue. 
----------------------------------------------

In case of using KDB on my Compaq Deskpro PCs, there is a keyboard freeze
after exiting from KDB. I am using "kdb-v1.9-2.4.13" on SCO/Caldera OpenLinux
3.1.1 ( with Linux-2.4.13 ).

After doing some investigation i could see that KDB is using a polled
mechanism
to get keyboard input, and in doing so, it is not disabling the signalling 
of OBF interrupts on the keyboard controller. This leads to spurious keyboard
interrupts after exiting from KDB, and also in my case ( with Compaq
Deskpro's )
it causes some issues with the keyboard controller's state machine, and 
keyboard no longer responds. 

I am including a patch for kdb-v1.9-2.4.13, which disables OBF interrupts on
local processor at kdb entry point, and re-enables OBF interrupts at exit
point,
which seems to solve this keyboard freeze issue. In my opinion this is a 
generic solution which should work on all keyboard controllers with this kind
of behaviour.

Issue #2: 
--------

I have also noticed that using "ssb" command on KDB, causes a complete system
freeze. I will be grateful if you can let us know if this is a known issue and
if any patch is available for it.

Looking fwd. to your early feedback.

Thanks & Best Regards,

Ashish Kalra.
Senior Custom Kernel Engineer,
SCO Group.
diff -Naur -X patches/dontdiff linux-2.4.13/arch/i386/kdb/kdba_io.c 
linux-2.4.13-kdb/arch/i386/kdb/kdba_io.c
--- linux-2.4.13/arch/i386/kdb/kdba_io.c        Thu Dec 13 17:15:40 2001
+++ linux-2.4.13-kdb/arch/i386/kdb/kdba_io.c    Fri Dec 13 16:13:37 2002
@@ -51,6 +51,9 @@
 #include <linux/kdb.h>
 #include <linux/kdbprivate.h>
 
+/* [EMAIL PROTECTED] */
+#include  <asm/keyboard.h>
+
 #define KDB_BLINK_LED 1
 
 int kdb_port;
@@ -373,3 +376,59 @@
                }
        }
 }
+
+/* 
+ * On some Compaq Deskpro's, there is a keyboard freeze many times after
+ * exiting from the kdb. As kdb's keyboard handler is not interrupt-driven and 
+ * uses a polled interface, it makes more sense to disable motherboard keyboard
+ * controller's OBF interrupts during kdb's polling.In case, of interrupts 
+ * remaining enabled during kdb's polling, it may cause un-necessary 
+ * interrupts being signalled during keypresses, which are also sometimes seen
+ * as spurious interrupts after exiting from kdb. This hack to disable OBF
+ * interrupts before entry to kdb and re-enabling them at kdb exit point also 
+ * solves the keyboard freeze issue. These functions are called from
+ * kdb_local(), hence these are arch. specific setup and cleanup functions
+ * executing only on the local processor - [EMAIL PROTECTED] 
+ */
+
+void kdba_local_arch_setup(void)
+{
+       unsigned char c;
+
+       while (kbd_read_status() & KBD_STAT_IBF);
+       kbd_write_command(KBD_CCMD_READ_MODE);
+       mdelay(1);
+       while (kbd_read_status() & KBD_STAT_IBF);
+       while ( !(kbd_read_status() & KBD_STAT_OBF) );
+       c = kbd_read_input();
+       c &= ~KBD_MODE_KBD_INT;
+       while (kbd_read_status() & KBD_STAT_IBF);
+       kbd_write_command(KBD_CCMD_WRITE_MODE);
+       mdelay(1);
+       while (kbd_read_status() & KBD_STAT_IBF);
+       kbd_write_output(c);
+       mdelay(1);
+       while (kbd_read_status() & KBD_STAT_IBF);
+       mdelay(1);
+}
+
+void kdba_local_arch_cleanup(void)
+{
+       unsigned char c;
+
+       while (kbd_read_status() & KBD_STAT_IBF);
+       kbd_write_command(KBD_CCMD_READ_MODE);
+       mdelay(1);
+       while (kbd_read_status() & KBD_STAT_IBF);
+       while ( !(kbd_read_status() & KBD_STAT_OBF) );
+       c = kbd_read_input();
+       c |= KBD_MODE_KBD_INT;
+       while (kbd_read_status() & KBD_STAT_IBF);
+       kbd_write_command(KBD_CCMD_WRITE_MODE);
+       mdelay(1);
+       while (kbd_read_status() & KBD_STAT_IBF);
+       kbd_write_output(c);
+       mdelay(1);
+       while (kbd_read_status() & KBD_STAT_IBF);
+       mdelay(1);
+}
diff -Naur -X patches/dontdiff linux-2.4.13/include/linux/kdbprivate.h 
linux-2.4.13-kdb/include/linux/kdbprivate.h
--- linux-2.4.13/include/linux/kdbprivate.h     Wed Oct 16 16:07:09 2002
+++ linux-2.4.13-kdb/include/linux/kdbprivate.h Fri Dec 13 16:14:30 2002
@@ -304,6 +304,12 @@
 extern char *kdb_cmds[];
 
        /*
+        * Architecture Dependant Local Processor setup & cleanup interfaces
+        */
+extern void kdba_local_arch_setup(void);
+extern void kdba_local_arch_cleanup(void);
+
+       /*
         * Defines for kdb_symbol_print.
         */
 #define KDB_SP_SPACEB  0x0001          /* Space before string */
diff -Naur -X patches/dontdiff linux-2.4.13/kdb/kdbmain.c 
linux-2.4.13-kdb/kdb/kdbmain.c
--- linux-2.4.13/kdb/kdbmain.c  Thu Dec 13 17:15:40 2001
+++ linux-2.4.13-kdb/kdb/kdbmain.c      Fri Dec 13 16:14:04 2002
@@ -858,6 +858,8 @@
                return 0;       /* Not for us, dismiss it */
        }
 
+       kdba_local_arch_setup();
+       
        while (1) {
                /*
                 * Initialize pager context.
@@ -924,6 +926,8 @@
                        kdb_cmderror(diag);
        }
 
+       kdba_local_arch_cleanup();
+       
        return(diag);
 }
 
@@ -1013,6 +1017,7 @@
              kdb_dbtrap_t db_result, kdb_eframe_t ef)
 {
        int result = 1;
+
        /* Stay in kdb() until 'go', 'ss[b]' or an error */
        while (1) {
                int i;
@@ -1067,6 +1072,7 @@
                KDB_DEBUG_STATE("kdb_main_loop 4", reason);
                break;
        }
+
        return(result != 0);
 }
 

Reply via email to