When using seabios with Xen and qemu, I frequently get the following message:
WARNING - Timeout at i8042_flush:69!
I do have a slightly unusual configuration compared to the typical Xen configuration. We are running with no hvmloader. However I don't think that's related to this issue....
The flush routine attempts to read the queue depth's worth of data from the port and then checks to see if the queue is empty. There are two issues with this. First is that qemu and seabios disagree about the queue depth. Qemu's ps2 buffer has 256 entries, and I8042_BUFFER_SIZE is 16 for seabios. The second is that a command may arrive between the start of the flush loop and the completion.
I believe a more robust way to do this would be to first issue a RESET command, and then flush. That resolves the issue that I am seeing.
Signed-off By: John Baboval john.baboval@virtualcomputer.com --- diff --git a/src/ps2port.c b/src/ps2port.c index 58335af..4ed25bf 100644 --- a/src/ps2port.c +++ b/src/ps2port.c @@ -20,7 +20,7 @@ // Timeout value. #define I8042_CTL_TIMEOUT 10000
-#define I8042_BUFFER_SIZE 16 +#define I8042_BUFFER_SIZE 256
static int i8042_wait_read(void) @@ -391,7 +391,7 @@ handle_09(void) } v = inb(PORT_PS2_DATA);
- if (!(GET_EBDA(ps2ctr) & I8042_CTR_KBDINT)) + if (!(GET_EBDA(ps2ctr) & I8042_CTR_KBDINT)) // Interrupts not enabled. goto done;
@@ -409,13 +409,17 @@ done: static void keyboard_init(void *data) { + int ret; + u8 param[2]; /* flush incoming keys */ - int ret = i8042_flush(); + ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); + if (ret) + return; + ret = i8042_flush(); if (ret) return;
// Controller self-test. - u8 param[2]; ret = i8042_command(I8042_CMD_CTL_TEST, param); if (ret) return;