]> git.baikalelectronics.ru Git - uboot.git/commit
console: usb: kbd: Limit poll frequency to improve performance
authorThomas Watson <twatson52@icloud.com>
Thu, 10 Feb 2022 21:13:14 +0000 (15:13 -0600)
committerMarek Vasut <marex@denx.de>
Thu, 10 Feb 2022 23:03:48 +0000 (00:03 +0100)
commitf2f3c39bae75fe48665ed699e2fa6b65d7ebdda6
tree27c4e7f1a858af09f8d85d3669fca72175a9e632
parent3a7a9d5f06b0456a4c5db31fe8830aa65b049752
console: usb: kbd: Limit poll frequency to improve performance

Using the XHCI driver, the function `usb_kbd_poll_for_event` takes
30-40ms to run. The exact time is dependent on the polling interval the
keyboard requests in its descriptor, and likely cannot be significantly
reduced without major rework to the XHCI driver.

The U-Boot EFI console service sets a timer to poll the keyboard every 5
microseconds, and this timer is checked every time a block is read off
disk. The net effect is that, on my system, loading a ~40MiB kernel and
initrd takes about 62 seconds with a slower keyboard and 53 seconds
with a faster one, with the vast majority of the time spent polling the
keyboard.

To solve this problem, this patch adds a 20ms delay between consecutive
calls to `usb_kbd_poll_for_event`. This is sufficient to reduce the
total loading time to under half a second for both keyboards, and does
not impact the perceived keystroke latency.

Signed-off-by: Thomas Watson <twatson52@icloud.com>
common/usb_kbd.c