[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 29/36] uhci: Always mark a queue valid when we encou
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 29/36] uhci: Always mark a queue valid when we encounter it |
Date: |
Thu, 25 Oct 2012 14:52:02 +0200 |
From: Hans de Goede <address@hidden>
Before this patch we would not mark a queue valid when its head was a
non-active td. This causes us to misbehave in the following scenario:
1) queue with multiple input transfers queued
2) We hit some latency issue, causing qemu to get behind processing frames
3) When qemu gets to run again, it notices the first transfer ends short,
marking the head td non-active
4) It now processes 32+ frames in a row without giving the guest a chance
to run since it is behind
5) valid is decreased to 0, causing the queue to get cancelled also cancelling
already queued up further input transfers
6) guest gets to run, notices the inactive td, cleanups up further tds
from the short transfer, and lets the queue continue at the first td of
the next input transfer
7) we re-start the queue, issuing the second input transfer for the *second*
time, and any data read by the first time we issued it has been lost
Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/hcd-uhci.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 592ad8d..beeb3fd 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -183,6 +183,9 @@ static UHCIQueue *uhci_queue_new(UHCIState *s, uint32_t
qh_addr, UHCI_TD *td,
queue->ep = ep;
QTAILQ_INIT(&queue->asyncs);
QTAILQ_INSERT_HEAD(&s->queues, queue, next);
+ /* valid needs to be large enough to handle 10 frame delay
+ * for initial isochronous requests */
+ queue->valid = 32;
trace_usb_uhci_queue_add(queue->token);
return queue;
}
@@ -819,6 +822,10 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q,
uint32_t qh_addr,
}
}
+ if (q) {
+ q->valid = 32;
+ }
+
/* Is active ? */
if (!(td->ctrl & TD_CTRL_ACTIVE)) {
if (async) {
@@ -836,9 +843,6 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q,
uint32_t qh_addr,
}
if (async) {
- /* Already submitted */
- async->queue->valid = 32;
-
if (!async->done)
return TD_RESULT_ASYNC_CONT;
if (queuing) {
@@ -860,11 +864,6 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q,
uint32_t qh_addr,
}
async = uhci_async_alloc(q, td_addr);
- /* valid needs to be large enough to handle 10 frame delay
- * for initial isochronous requests
- */
- async->queue->valid = 32;
-
max_len = ((td->token >> 21) + 1) & 0x7ff;
spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0);
usb_packet_setup(&async->packet, pid, q->ep, td_addr, spd,
--
1.7.1
- [Qemu-devel] [PULL 00/36] usb patch queue, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 02/36] uhci: Move checks to continue queuing to uhci_fill_queue(), Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 20/36] uhci: Move emptying of the queue's asyncs' queue to uhci_queue_free, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 33/36] xhci: flush endpoint context unconditinally, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 10/36] usb: Rename __usb_packet_complete to usb_packet_complete_one, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 03/36] ehci: Get rid of packet tbytes field, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 29/36] uhci: Always mark a queue valid when we encounter it,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 18/36] uhci: Don't retry on error, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 11/36] usb: Add USB_RET_ADD_TO_QUEUE packet result code, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 08/36] ehci: Retry to fill the queue while waiting for td completion, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 15/36] usb: Enforce iso endpoints never returing USB_RET_ASYNC, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 01/36] uhci: Properly unmap packets on cancel / invalid pid, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 06/36] ehci: Speed up the timer of raising int from the async schedule, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 32/36] xhci: fix function name in error message, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 12/36] usb: Move clearing of queue on halt to the core, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 16/36] uhci: No need to handle async completion of isoc packets, Gerd Hoffmann, 2012/10/25
- [Qemu-devel] [PATCH 34/36] xhci: allow disabling interrupters, Gerd Hoffmann, 2012/10/25