From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6lsE-0000S9-1B for qemu-devel@nongnu.org; Wed, 20 May 2009 09:30:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6ls9-0000RX-WF for qemu-devel@nongnu.org; Wed, 20 May 2009 09:30:19 -0400 Received: from [199.232.76.173] (port=41306 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6ls7-0000RL-Dm for qemu-devel@nongnu.org; Wed, 20 May 2009 09:30:15 -0400 Received: from mx03.syneticon.net ([78.111.66.105]:35877) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M6ls6-0001ot-RB for qemu-devel@nongnu.org; Wed, 20 May 2009 09:30:15 -0400 Received: from localhost (filter1.syneticon.net [192.168.113.83]) by mx03.syneticon.net (Postfix) with ESMTP id CC2A236525 for ; Wed, 20 May 2009 15:30:12 +0200 (CEST) Received: from mx03.syneticon.net ([192.168.113.84]) by localhost (mx03.syneticon.net [192.168.113.83]) (amavisd-new, port 10025) with ESMTP id m2pbNWgiB0RV for ; Wed, 20 May 2009 15:30:10 +0200 (CEST) Received: from [192.168.10.145] (koln-4db4e6cc.pool.einsundeins.de [77.180.230.204]) by mx03.syneticon.net (Postfix) with ESMTPSA for ; Wed, 20 May 2009 15:30:10 +0200 (CEST) Message-ID: <4A1405E1.70405@wpkg.org> Date: Wed, 20 May 2009 15:30:09 +0200 From: Tomasz Chmielewski MIME-Version: 1.0 References: <4A0C232D.1020201@wpkg.org> <4A13CDC4.3000704@wpkg.org> In-Reply-To: <4A13CDC4.3000704@wpkg.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [SOLUTION] "i8042.c: No controller found" -> OS sees no keyboard if I type "in BIOS" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Tomasz Chmielewski schrieb: >> When I boot the guest and type (just hit any keys) in the VNC window >> before the operating system boots, sometimes, the system loads with no >> keyboard present - as signified in dmesg on guest: >> >> i8042.c: No controller found >> >> As a result, I can't use the keyboard in the VNC window. > drivers/input/serio/i8042.c in the Linux kerne has this: > > static int i8042_controller_check(void) > { > if (i8042_flush() == I8042_BUFFER_SIZE) { > printk(KERN_ERR "i8042.c: No controller found.\n"); > return -ENODEV; > } > > return 0; > } > > > So, can it be that if we type anything on keyboard (or move mouse) while > Qemu's BIOS is still booting or later in the bootloader (GRUB, lilo), > some buffer is not flushed and Linux gets confused? And as a result, > decides there is no keyboard? Yes, this is what seems to happen - Qemu's keyboard buffer seems to be infinite or at least very big; normal 8042 devices have buffer of 16 bytes only. If we add "i8042.debug" parameter to kernel command line, we will see how many characters were flushed during boot, i.e.: drivers/input/serio/i8042.c: ff <- i8042 (flush, aux) [0] drivers/input/serio/i8042.c: 18 <- i8042 (flush, aux) [0] drivers/input/serio/i8042.c: 92 <- i8042 (flush, aux) [0] drivers/input/serio/i8042.c: 00 <- i8042 (flush, aux) [0] (...) With this 16 byte buffer in drivers/input/serio/i8042.h (before 2.6.11 it was 32 bytes I think): #define I8042_BUFFER_SIZE 16 and this piece of code in drivers/input/serio/i8042.c: /* * i8042_flush() flushes all data that may be in the keyboard and mouse buffers * of the i8042 down the toilet. */ static int i8042_flush(void) { unsigned long flags; unsigned char data, str; int i = 0; spin_lock_irqsave(&i8042_lock, flags); while (((str = i8042_read_status()) & I8042_STR_OBF) && (i < I8042_BUFFER_SIZE)) { udelay(50); data = i8042_read_data(); i++; dbg("%02x <- i8042 (flush, %s)", data, str & I8042_STR_AUXDATA ? "aux" : "kbd"); } spin_unlock_irqrestore(&i8042_lock, flags); return i; } Linux kernel thinks there is no controller: (...) drivers/input/serio/i8042.c: 28 <- i8042 (flush, aux) [0] drivers/input/serio/i8042.c: 00 <- i8042 (flush, aux) [0] i8042.c: No controller found. If we increase "I8042_BUFFER_SIZE" to 256 or more, we have a much better chance that a booted Linux will have a keyboard present. So, who's to be blamed? Linux kernel for having its i8042 buffer to small (16 bytes), fixable with: --- i8042.h.orig 2009-05-20 15:26:32.000000000 +0200 +++ i8042.h 2009-05-20 15:26:32.000000000 +0200 @@ -73,7 +73,7 @@ * the i8042 buffers. */ -#define I8042_BUFFER_SIZE 16 +#define I8042_BUFFER_SIZE 256 /* * Number of AUX ports on controllers supporting active multiplexing Or Qemu, for having its keyboard buffer too large (I'm not sure, but probably 256 bytes)? -- Tomasz Chmielewski http://wpkg.org