Subject: port-i386/2631: pcvt & pccons too fast for some keyboards
To: None <gnats-bugs@NetBSD.ORG>
From: Mike Long <mike.long@analog.com>
List: netbsd-bugs
Date: 07/16/1996 00:19:27
>Number:         2631
>Category:       port-i386
>Synopsis:       pcvt & pccons too fast for some keyboards
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 16 00:50:02 1996
>Last-Modified:
>Originator:     Mike Long <mike.long@analog.com>
>Organization:
	Beta-Testers Anonymous
>Release:        1.2_BETA
>Environment:

System: NetBSD azathoth 1.2_BETA NetBSD 1.2_BETA (AZATHOTH) #90: Mon Jul 15 23:10:33 EDT 1996 root@azathoth:/usr/src/sys/arch/i386/compile/AZATHOTH i386


>Description:
	I helped Dave Burgess (<burgess@cynjut.neonramp.com>) solve a
problem he was having with a vanishing keyboard on an IBM
PS/Valuepoint.  He was able to solve the problem by increasing the
delays required before accessing the keyboard controller.

	Hellmuth Michaelis was in the loop, so this change should also
be in the next version of pcvt.

>How-To-Repeat:
	Boot a 1.2_BETA kernel configured to use pcvt on an IBM
PS/Valuepoint.  May also happen with a kernel containing pccons.

>Fix:
	Apply the patches below to increase the delays in both pcvt
and pccons.  The amount of delay added is probably overkill, but those
are the values Dave used.  I haven't noticed any impact on keyboard
performance; I use pccons.

*** /sys/arch/i386/isa/pcvt/pcvt_hdr.h~	Mon May 13 07:32:33 1996
--- /sys/arch/i386/isa/pcvt/pcvt_hdr.h	Mon Jul 15 23:49:12 1996
***************
*** 1400,1403 ****
--- 1400,1408 ----
  	{ volatile u_char x = inb(0x84); (void) &x;} \
  	{ volatile u_char x = inb(0x84); (void) &x;} \
+ 	{ volatile u_char x = inb(0x84); (void) &x;} \
+ 	{ volatile u_char x = inb(0x84); (void) &x;} \
+ 	{ volatile u_char x = inb(0x84); (void) &x;} \
+ 	{ volatile u_char x = inb(0x84); (void) &x;} \
+ 	{ volatile u_char x = inb(0x84); (void) &x;} \
  	{ volatile u_char x = inb(0x84); (void) &x;}
  
***************
*** 1407,1413 ****
  				/* keyboard controller                    */
  #if PCVT_NETBSD > 9
! #define PCVT_KBD_DELAY()	delay(7)
  #elif PCVT_FREEBSD || (PCVT_NETBSD <= 9)
! #define PCVT_KBD_DELAY()	DELAY(7)
  #endif
  #endif /* PCVT_PORTIO_DELAY */
--- 1412,1418 ----
  				/* keyboard controller                    */
  #if PCVT_NETBSD > 9
! #define PCVT_KBD_DELAY()	delay(11)
  #elif PCVT_FREEBSD || (PCVT_NETBSD <= 9)
! #define PCVT_KBD_DELAY()	DELAY(11)
  #endif
  #endif /* PCVT_PORTIO_DELAY */

*** /sys/arch/i386/isa/pccons.c.orig	Wed Jun  5 07:36:07 1996
--- /sys/arch/i386/isa/pccons.c	Mon Jul 15 23:09:25 1996
***************
*** 177,184 ****
--- 183,195 ----
  void pccnpollc __P((dev_t, int));
  
+ /* wait 7+ us for keyboard controller; ~1.25us per inb() */
  #define	KBD_DELAY \
  	{ u_char x = inb(0x84); (void) x; } \
  	{ u_char x = inb(0x84); (void) x; } \
  	{ u_char x = inb(0x84); (void) x; } \
+ 	{ u_char x = inb(0x84); (void) x; } \
+ 	{ u_char x = inb(0x84); (void) x; } \
+ 	{ u_char x = inb(0x84); (void) x; } \
+ 	{ u_char x = inb(0x84); (void) x; } \
  	{ u_char x = inb(0x84); (void) x; }
  



>Audit-Trail:
>Unformatted: