ehci: Use uframe precision for interrupt threshold checking (v2)
authorHans de Goede <hdegoede@redhat.com>
Tue, 18 Dec 2012 13:17:02 +0000 (14:17 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 7 Jan 2013 11:57:23 +0000 (12:57 +0100)
commit9359a58b122187964d7465d48165680eadbf69d3
treeb11f1c707a4c2877786c51d5d7cc6d28f57d7420
parentbbbc39ccacf66ef58261c155f9eed503947c3023
ehci: Use uframe precision for interrupt threshold checking (v2)

Before this patch, the following could happen:
1) Transfer completes, raises interrupt
2) .5 ms later we check if the guest has queued up any new transfers
3) We find and execute a new transfer
4) .2 ms later the new transfer completes
5) We re-run our frame_timer to write back the completion, but less then
   1 ms has passed since our last run, so frindex is not changed, so the
   interrupt threshold code delays the interrupt
6) 1 ms from the re-run our frame-timer runs again and finally delivers
   the interrupt

This leads to unnecessary large delays of interrupts, this code fixes this
by changing frindex to uframe precision and using that for interrupt threshold
control, making the interrupt fire at step 5 for guest which have low interrupt
threshold settings (like Linux).

Note that the guest still sees the frindex move in steps of 8 for migration
compatibility.

This boosts Linux read speed of a simple cheap USB thumb drive by 6 %.

Changes in v2:
-Make the guest see frindex move in steps of 8 by modifying ehci_opreg_read,
 rather then using a shadow variable

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/hcd-ehci.c