[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/17] uhci: Retry to fill the queue while waiting f
From: |
Hans de Goede |
Subject: |
[Qemu-devel] [PATCH 16/17] uhci: Retry to fill the queue while waiting for td completion |
Date: |
Wed, 24 Oct 2012 18:31:19 +0200 |
If the guest is using multiple transfers to try and keep the usb bus busy /
used at maximum efficiency, currently we would see / do the following:
1) submit transfer 1 to the device
2) submit transfer 2 to the device
3) report transfer 1 completion to guest
4) report transfer 2 completion to guest
5) submit transfer 1 to the device
6) report transfer 1 completion to guest
7) submit transfer 2 to the device
8) report transfer 2 completion to guest
etc.
So after the initial submission we would effectively only have 1 transfer
in flight, rather then 2. This is caused by us not checking the queue for
addition of new transfers by the guest (ie the resubmission of a recently
finished transfer), while waiting for a pending transfer to complete.
This patch does add a check for this, changing the sequence to:
1) submit transfer 1 to the device
2) submit transfer 2 to the device
3) report transfer 1 completion to guest
4) submit transfer 1 to the device
5) report transfer 2 completion to guest
6) submit transfer 2 to the device
etc.
Thus keeping 2 transfers in flight (most of the time, and always 1),
as intended by the guest.
Signed-off-by: Hans de Goede <address@hidden>
---
hw/usb/hcd-uhci.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index beeb3fd..a9e06ef 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -110,7 +110,7 @@ struct UHCIQueue {
UHCIState *uhci;
USBEndpoint *ep;
QTAILQ_ENTRY(UHCIQueue) next;
- QTAILQ_HEAD(, UHCIAsync) asyncs;
+ QTAILQ_HEAD(asyncs_head, UHCIAsync) asyncs;
int8_t valid;
};
@@ -843,15 +843,25 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q,
uint32_t qh_addr,
}
if (async) {
- if (!async->done)
- return TD_RESULT_ASYNC_CONT;
if (queuing) {
/* we are busy filling the queue, we are not prepared
to consume completed packages then, just leave them
in async state */
return TD_RESULT_ASYNC_CONT;
}
+ if (!async->done) {
+ UHCI_TD last_td;
+ UHCIAsync *last = QTAILQ_LAST(&async->queue->asyncs, asyncs_head);
+ /*
+ * While we are waiting for the current td to complete, the guest
+ * may have added more tds to the queue. Note we re-read the td
+ * rather then caching it, as we want to see guest made changes!
+ */
+ uhci_read_td(s, &last_td, last->td_addr);
+ uhci_queue_fill(async->queue, &last_td);
+ return TD_RESULT_ASYNC_CONT;
+ }
uhci_async_unlink(async);
goto done;
}
--
1.7.12.1
- [Qemu-devel] [PATCH 09/17] uhci: Make uhci_fill_queue() actually operate on an UHCIQueue, (continued)
- [Qemu-devel] [PATCH 09/17] uhci: Make uhci_fill_queue() actually operate on an UHCIQueue, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 05/17] uhci: Drop unnecessary forward declaration of some static functions, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 08/17] uhci: Add uhci_read_td() helper function, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 03/17] uhci: cleanup: Add an unlink call to uhci_async_cancel(), Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 11/17] uhci: Immediately free queues on device disconnect, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 13/17] uhci: Detect guest td re-use, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 12/17] uhci: Verify queue has not been changed by guest, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 10/17] uhci: Store ep in UHCIQueue, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 14/17] uhci: When the guest marks a pending td non-active, cancel the queue, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 17/17] uhci: Use only one queue for ctrl endpoints, Hans de Goede, 2012/10/24
- [Qemu-devel] [PATCH 16/17] uhci: Retry to fill the queue while waiting for td completion,
Hans de Goede <=
- [Qemu-devel] [PATCH 15/17] uhci: Always mark a queue valid when we encounter it, Hans de Goede, 2012/10/24
- Re: [Qemu-devel] uhci: Cleanups, fixes and improvements, Gerd Hoffmann, 2012/10/25