From nobody@FreeBSD.org  Wed Mar 22 06:41:25 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 50D3816A422
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Mar 2006 06:41:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5201F43D66
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Mar 2006 06:41:21 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k2M6fLbp021274
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Mar 2006 06:41:21 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k2M6fLaL021273;
	Wed, 22 Mar 2006 06:41:21 GMT
	(envelope-from nobody)
Message-Id: <200603220641.k2M6fLaL021273@www.freebsd.org>
Date: Wed, 22 Mar 2006 06:41:21 GMT
From: "Devon H. O'Dell" <dodell@iXsystems.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Fix keyboard hang for IBM / Intel blade servers
X-Send-Pr-Version: www-2.3

>Number:         94822
>Category:       kern
>Synopsis:       [kbd] [patch] Fix keyboard hang for IBM / Intel blade servers
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    dwhite
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 22 06:50:09 GMT 2006
>Closed-Date:    Fri Sep 22 01:22:20 GMT 2006
>Last-Modified:  Fri Sep 22 01:22:20 GMT 2006
>Originator:     Devon H. O'Dell
>Release:        6.0-RELEASE-p3
>Organization:
iXsystems
>Environment:
>Description:
On Intel / IBM blade machines, there is no atkbd(4) device. Previously, booting GENERIC on these blades would hang the machine. With this patch, this behavior is no more!

Yes! After many printf()'s, reboots of the blade (and the MM because the new firmware is horribly broken), I've found the hang and fixed it. Simply put, there's a keyboard / auxillary device drain procedure (empty_both_buffers) that expects to drain the buffers, but can't, because the buffers aren't what they think.

This patch fixes the issue by adding a timeout to the empty_both_buffers procedure. After two seconds of not being able to drain the buffer, it will give up and return to the caller.

Full use of the keyboard (via the VNC-based Java KVM on the MM or local USB) is afforded, and the system boots.
>How-To-Repeat:
Obtain relevant machine (SBX82, in this case), chassis, and boot the GENERIC kernel. Order pizza. Play poker. Notice it's still hung. Take shower. Sleep. Wake up. Notice it's still hung. Apply patch and live happily ever after.
>Fix:
This patch is alternatively available at http://www.sitetronics.com/~dodell/atkbdc_fix.patch in case the whitespace is goofed up by the paste into the web form.

-- begin patch --
Index: atkbdc.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/atkbdc/atkbdc.c,v
retrieving revision 1.22
diff -u -r1.22 atkbdc.c
--- atkbdc.c	4 Dec 2005 02:12:40 -0000	1.22
+++ atkbdc.c	22 Mar 2006 06:29:01 -0000
@@ -835,6 +835,7 @@
 {
     int t;
     int f;
+    int waited = 0;
 #if KBDIO_DEBUG >= 2
     int c1 = 0;
     int c2 = 0;
@@ -855,6 +856,16 @@
 	} else {
 	    t -= delta;
 	}
+
+	/*
+	 * Some systems (Intel/IBM blades) do not have keyboard devices and
+	 * will thus hang in this procedure. Time out after delta seconds to
+	 * avoid this hang -- the keyboard attach will fail later on.
+	 */
+        waited += (delta * 1000);
+        if (waited == (delta * 1000000))
+	    return;
+
 	DELAY(delta*1000);
     }
 #if KBDIO_DEBUG >= 2
-- end patch --
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dwhite 
Responsible-Changed-By: dwhite 
Responsible-Changed-When: Mon Sep 4 00:05:04 UTC 2006 
Responsible-Changed-Why:  
Taking 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94822 
State-Changed-From-To: open->feedback 
State-Changed-By: dwhite 
State-Changed-When: Mon Sep 4 00:19:37 UTC 2006 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94822 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/94822: commit references a PR
Date: Fri, 22 Sep 2006 01:06:01 +0000 (UTC)

 dwhite      2006-09-22 01:05:30 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/dev/atkbdc       atkbdc.c 
   Log:
   MFC rev 1.25:
      Avoid an infinite loop in empty_both_buffers() by adding a timeout.
      This helps systems that don't actually have atkbd controllers, such as
      the Intel SBX82 blade, boot without device.hints hacks.
   
   PR:             94822
   Submitted by:   Devon H. O'Dell <devon.odell@coyotepoint.com>
   Approved by:    re
   
   Revision  Changes    Path
   1.21.2.2  +11 -0     src/sys/dev/atkbdc/atkbdc.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: feedback->closed 
State-Changed-By: dwhite 
State-Changed-When: Fri Sep 22 01:21:46 UTC 2006 
State-Changed-Why:  
MFC completed. This change will be present in 6.2-R. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94822 
>Unformatted:
