Subject: kern/20433: PC Kbd works in BIOS/Console but fails during boot
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dbarnes@ieee.org>
List: netbsd-bugs
Date: 02/19/2003 14:08:47
>Number:         20433
>Category:       kern
>Synopsis:       PC Kbd works in BIOS/Console but fails during boot
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 19 14:09:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Dave Barnes
>Release:        1.5, 1.6, 1.6-current Alpha and I386
>Organization:
>Environment:
>Description:
PC style keyboard works fine in BIOS (or on Alpha in the SRM console) but fails during boot with a variety of keyboard error codes.  Seems to be worse on some systems than others.  The failure can occur suddenly on systems that had been working just fine.  The keyboard error codes appear to be random.
>How-To-Repeat:
This is a hard problem to repeat since it seems to depend on exact timing between the host processor and the keyboard interface controller. On a system with just the right conditions it will fail just about every time.  A change in temp is enough to change the timing relationship just enough to make the problem go away on some systems and to show up on others.
>Fix:
The following diff appears to catch and clear up the keyboard error enough to make the keyboard work.  I've been using the diff on the Alpha Multia system for several months and only recently had the problem show up with an i386 system.  This diff seems to work in both cases.

*** dev/pckbc/pckbd.c.orig	Sun Mar 17 13:41:00 2002
--- dev/pckbc/pckbd.c	Wed Nov 27 17:47:25 2002
***************
*** 284,289 ****
--- 284,301 ----
  	/* Reset the keyboard. */
  	cmd[0] = KBC_RESET;
  	res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 1, resp, 1);
+ 
+ 	/* Hack by djb.....
+ 	 * If we get bad stuff from the keyboard, reset it again just
+ 	 * in case.
+ 	*/ 
+ 	if (res || (resp[0] != KBR_RSTDONE)) {
+ 		printf("pckbdprobe: DJB Hack!, res=%d; resp=0x%x\n", res, resp[0]);
+ 		/* Let's try again:) */	
+ 		pckbc_flush(pa->pa_tag, pa->pa_slot);
+ 		cmd[0] = KBC_RESET;
+ 		res = pckbc_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 1, resp, 1);
+ 	}
  	if (res) {
  #ifdef DEBUG
  		printf("pckbdprobe: reset error %d\n", res);

>Release-Note:
>Audit-Trail:
>Unformatted: