usb-uhci: implement bandwidth management
commit3200d1085df5f368885428e33d9439f55c7f1a47
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 26 Jan 2012 12:57:40 +0000 (26 13:57 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 10 Feb 2012 10:11:01 +0000 (10 11:11 +0100)
treea3ad2c11ab1fdcd1f9307e62b4e7657f87c0bb6a
parent57c83dacfe179bf061b8fa79d9553ebabe4d2ff4
usb-uhci: implement bandwidth management

The OS is allowed to make the UHCI Controller run in circles.  That is
usually done to serve multiple connected USB devices in a robin-round
fashion, so the available USB bandwidth is evenly distributed between
devices.

The uhci emulation handles this in a very poor way though.  When it
figures it runs in circles it stops processing unconditionally, so
it usually processes at most a single transfer desriptor per queue,
even if there are multiple transfer descriptors are queued up.

This patch makes uhci act in a more sophisticated way.  It keeps track
of successful processed transfer descriptors and transfered bytes.  Then
it will stop processing when there is nothing to do (no transfer
descriptor was completed the last round) or when the transfered data
reaches the usb bandwidth limit.

Result is that the usb-storage devices connected to uhci are ten times
faster, mkfs.vfat time for a 64M stick goes down from five seconds to
a half second.  Reason for this is that we are now processing up to 20
transfer descriptors (with 64 bytes each) per frame instead of a single
one.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-uhci.c