From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAj-0006aG-Vi for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2KAh-00040J-8s for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAh-0003zz-0t for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:39 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1SAKbMU026972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 05:20:37 -0500 From: Gerd Hoffmann Date: Tue, 28 Feb 2012 11:20:15 +0100 Message-Id: <1330424430-23015-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1330424430-23015-1-git-send-email-kraxel@redhat.com> References: <1330424430-23015-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 06/21] usb-uhci: implement packet queuing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann When a usb device is busy processing a packet (and returns USB_RET_ASYNC), continue walking the transfer descriptor list and process them to fill the request queue. Signed-off-by: Gerd Hoffmann --- hw/usb-uhci.c | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 13298aa..70e3881 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -942,6 +942,34 @@ static int qhdb_insert(QhDb *db, uint32_t addr) return 0; } +static void uhci_fill_queue(UHCIState *s, UHCI_TD *td) +{ + uint32_t int_mask = 0; + uint32_t plink = td->link; + uint32_t token = uhci_queue_token(td); + UHCI_TD ptd; + int ret; + + fprintf(stderr, "%s: -- %x\n", __func__, token); + while (is_valid(plink)) { + pci_dma_read(&s->dev, plink & ~0xf, &ptd, sizeof(ptd)); + le32_to_cpus(&ptd.link); + le32_to_cpus(&ptd.ctrl); + le32_to_cpus(&ptd.token); + le32_to_cpus(&ptd.buffer); + if (!(ptd.ctrl & TD_CTRL_ACTIVE)) { + break; + } + if (uhci_queue_token(&ptd) != token) { + break; + } + ret = uhci_handle_td(s, plink, &ptd, &int_mask); + assert(ret == 2); /* got USB_RET_ASYNC */ + assert(int_mask == 0); + plink = ptd.link; + } +} + static void uhci_process_frame(UHCIState *s) { uint32_t frame_addr, link, old_td_ctrl, val, int_mask; @@ -1044,8 +1072,9 @@ static void uhci_process_frame(UHCIState *s) DPRINTF("uhci: TD 0x%x async. " "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, td.link, td.ctrl, td.token, curr_qh); - fprintf(stderr, "async td: link %x%s\n", - td.link, is_valid(td.link) ? " valid" : ""); + if (is_valid(td.link)) { + uhci_fill_queue(s, &td); + } link = curr_qh ? qh.link : td.link; continue; -- 1.7.1