OSDN Git Service

ehci_free_packet: Discard finished packets when the queue is halted
authorHans de Goede <hdegoede@redhat.com>
Tue, 9 Apr 2013 08:24:22 +0000 (10:24 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 23 Apr 2013 06:43:10 +0000 (08:43 +0200)
commite449f26bed42b1d8c6efefcd8dc768f23f19458f
tree475c949907211e54c0c0bc5d04b9b1a3dd1d7563
parent7d04c2b75562664a28612d7481f328ee4ec51dda
ehci_free_packet: Discard finished packets when the queue is halted

With pipelining it is possible to encounter a finished packet when cleaning
the queue due to a halt. This happens when a non stall error happens while
talking to a real device. In this case the queue on the usb-host side will
continue processing packets, and we can have completed packets waiting in
the queue after an error condition packet causing a halt.

There are 2 reasons to discard the completed packets at this point, rather
then trying to writing them back to the guest:

1) The guest expect to be able to cancel and/or change packets after the
packet with the error without doing an unlink, so writing them back may
confuse the guest.

2) Since the queue does not advance when halted, the writing back of these
packets will fail anyways since p->qtdaddr != q->qtdaddr, so the
ehci_verify_qtd call in ehci_writeback_async_complete_packet will fail.

Note that 2) means that then only functional change this patch introduces
is the printing of a warning when this scenario happens.

Note that discarding these packets means that the guest driver and the device
will get out of sync! This is unfortunate, but should not be a problem since
with a non stall error (iow an io-error) the 2 are out of sync already anyways.
Still this patch adds a warning to signal this happening.

Note that sofar this has only been seen with a DVB-T receiver, which gives
of a MPEG-2 stream, which allows for recovering from lost packets, see:
https://bugzilla.redhat.com/show_bug.cgi?id=890320

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