From d20fcccf325633cdc06e1ae1941487e68d5a0fa7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 21 Sep 2012 18:57:34 -0300 Subject: [RHEL6 qemu-kvm PATCH 13/23] ehci: Properly report completed but not yet processed packets to the guest RH-Author: Hans de Goede Message-id: <1348253864-3050-13-git-send-email-hdegoede@redhat.com> Patchwork-id: 42189 O-Subject: [RHEL-6.4 qemu-kvm PATCH 12/22] ehci: Properly report completed but not yet processed packets to the guest Bugzilla: 805172 RH-Acked-by: Uri Lublin RH-Acked-by: Arnon Gilboa RH-Acked-by: Gerd Hoffmann Reported packets which have completed before being cancelled as such to the host. Note that the new code path this patch adds is untested since it I've been unable to actually trigger the race which needs this code path. Signed-off-by: Hans de Goede Upstream commit: 4b63a0df3bda8a2c278e45d9d94d9ba6d5791d8d Conflicts: hw/usb-ehci.c --- hw/usb-ehci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Signed-off-by: Eduardo Habkost --- hw/usb-ehci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index 22abc55..a9cbd68 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -473,6 +473,9 @@ static const char *ehci_mmio_names[] = { [ CONFIGFLAG ] = "CONFIGFLAG", }; +static int ehci_state_executing(EHCIQueue *q, int async); +static int ehci_state_writeback(EHCIQueue *q, int async); + static const char *nr2str(const char **n, size_t len, uint32_t nr) { if (nr < len && n[nr] != NULL) { @@ -675,6 +678,14 @@ static void ehci_free_queue(EHCIQueue *q, int async) if (q->async == EHCI_ASYNC_INFLIGHT) { usb_cancel_packet(&q->packet); } + if (q->async == EHCI_ASYNC_FINISHED) { + int state = ehci_get_state(q->ehci, async); + /* This is a normal, but rare condition (cancel racing completion) */ + fprintf(stderr, "EHCI: Warning packet completed but not processed\n"); + ehci_state_executing(q, async); + ehci_state_writeback(q, async); + ehci_set_state(q->ehci, async, state); + } QTAILQ_REMOVE(head, q, next); qemu_free(q); } -- 1.7.11.4