From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQUui-0003Yl-T0 for qemu-devel@nongnu.org; Mon, 13 Jul 2009 19:26:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQUud-0003YU-9x for qemu-devel@nongnu.org; Mon, 13 Jul 2009 19:26:27 -0400 Received: from [199.232.76.173] (port=33357 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQUud-0003YR-4S for qemu-devel@nongnu.org; Mon, 13 Jul 2009 19:26:23 -0400 Received: from wa-out-1112.google.com ([209.85.146.182]:62921) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQUuc-0003Aa-LC for qemu-devel@nongnu.org; Mon, 13 Jul 2009 19:26:22 -0400 Received: by wa-out-1112.google.com with SMTP id k17so352369waf.18 for ; Mon, 13 Jul 2009 16:26:20 -0700 (PDT) Message-ID: <04b201ca0411$514a9d40$732d2b09@DineshThinkpad> From: "Dinesh Subhraveti" Date: Mon, 13 Jul 2009 16:26:14 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_04AF_01CA03D6.A42D0920" Subject: [Qemu-devel] [PATCH] No keyboard / mouse after reboot List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. ------=_NextPart_000_04AF_01CA03D6.A42D0920 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable At system initialization, some guests conclude that i8042 controller is = missing when the PS2 buffer is full. As a result, the guest comes up = with no keyboard or mouse. The behavior is seen when the user types or = mouses over the VNC window during the BIOS phase of a reboot, causing = the PS2 buffer to fill up. It doesn't occur when the system boots the = first time, since the device is initially disabled and doesn't accept = events. This patch tunes Qemu parameters to reasonable values which make the = guest happy. Linux assumes the size of PS2 buffer to be 16 bytes, while = Qemu defines it as 256. Reducing PS2_QUEUE_SIZE to 15 ensures that the = guest never sees the buffer to be full. However, PS2 mouse event handler drops mouse events unless there is at = least 16 bytes of buffer space left in the queue (to account for mouse = movements that consume multiple events). With PS2_QUEUE_SIZE reduced to = 15, there will never be 16 bytes left in the queue and no mouse event = ever gets in. So the size of reserved buffer space is reduced to 8. With these changes, both keyboard and mouse remain responsive after = reboot, even when typed or moused over during reboot. Tested with SLES = 11 GM 64-bit guest. --- diff --git a/hw/ps2.c b/hw/ps2.c index fb77005..51a3ab8 100644 --- a/hw/ps2.c +++ b/hw/ps2.c @@ -70,7 +70,7 @@ #define MOUSE_STATUS_ENABLED 0x20 #define MOUSE_STATUS_SCALE21 0x10 -#define PS2_QUEUE_SIZE 256 +#define PS2_QUEUE_SIZE 15 typedef struct { uint8_t data[PS2_QUEUE_SIZE]; @@ -346,7 +346,7 @@ static void ps2_mouse_event(void *opaque, s->mouse_buttons =3D buttons_state; if (!(s->mouse_status & MOUSE_STATUS_REMOTE) && - (s->common.queue.count < (PS2_QUEUE_SIZE - 16))) { + (s->common.queue.count < (PS2_QUEUE_SIZE - 8))) { for(;;) { /* if not remote, send event. Multiple events are sent if too big deltas */ ------=_NextPart_000_04AF_01CA03D6.A42D0920 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
At system initialization, some guests conclude that i8042 = controller is=20 missing when the PS2 buffer is full.  As a result, the guest comes = up with=20 no keyboard or mouse.  The behavior is seen when the user = types or=20 mouses over the VNC window during the BIOS phase of a reboot, causing = the PS2=20 buffer to fill up.  It doesn't occur when the system boots the = first time,=20 since the device is initially disabled and doesn't accept events.
 
This patch tunes Qemu parameters to reasonable values which = make the=20 guest happy.  Linux assumes the size of PS2 buffer to be 16 bytes, = while=20 Qemu defines it as 256.  Reducing PS2_QUEUE_SIZE to 15 ensures that = the=20 guest never sees the buffer to be full.
 
However, PS2 mouse event handler drops mouse events unless there is = at=20 least 16 bytes of buffer space left in the queue (to account for mouse = movements=20 that consume multiple events).  With PS2_QUEUE_SIZE reduced to 15, = there=20 will never be 16 bytes left in the queue and no mouse event ever gets = in. =20 So the size of reserved buffer space is reduced to 8.
 
With these changes, both keyboard and mouse remain responsive after = reboot,=20 even when typed or moused over during reboot.  Tested with SLES 11 = GM=20 64-bit guest.
 
---
diff --git a/hw/ps2.c b/hw/ps2.c
index fb77005..51a3ab8 = 100644
---=20 a/hw/ps2.c
+++ b/hw/ps2.c
@@ -70,7 +70,7 @@
 #define=20 MOUSE_STATUS_ENABLED    0x20
 #define=20 MOUSE_STATUS_SCALE21    0x10

-#define = PS2_QUEUE_SIZE=20 256
+#define PS2_QUEUE_SIZE 15

 typedef struct=20 {
     uint8_t data[PS2_QUEUE_SIZE];
@@ -346,7 = +346,7=20 @@ static void ps2_mouse_event(void *opaque,
     = s->mouse_buttons =3D buttons_state;

     = if=20 (!(s->mouse_status & MOUSE_STATUS_REMOTE)=20 &&
-       =20 (s->common.queue.count < (PS2_QUEUE_SIZE - 16)))=20 {
+        = (s->common.queue.count <=20 (PS2_QUEUE_SIZE - 8))) = {
        =20 for(;;)=20 {
           &n= bsp; /*=20 if not remote, send event. Multiple events are sent=20 if
           &= nbsp;   =20 too big deltas */
------=_NextPart_000_04AF_01CA03D6.A42D0920--