From patchwork Mon Jul 9 10:20:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 169738 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 12B952C0220 for ; Mon, 9 Jul 2012 20:20:59 +1000 (EST) Received: from localhost ([::1]:34957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoB5M-00027X-FZ for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2012 06:20:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoB56-00026R-P1 for qemu-devel@nongnu.org; Mon, 09 Jul 2012 06:20:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoB54-0002wl-Ji for qemu-devel@nongnu.org; Mon, 09 Jul 2012 06:20:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoB54-0002vn-49 for qemu-devel@nongnu.org; Mon, 09 Jul 2012 06:20:38 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q69AKaXw007410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Jul 2012 06:20:36 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q69AKYxF002776; Mon, 9 Jul 2012 06:20:35 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 2144D431D7; Mon, 9 Jul 2012 12:20:33 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 9 Jul 2012 12:20:25 +0200 Message-Id: <1341829233-24381-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1341829233-24381-1-git-send-email-kraxel@redhat.com> References: <1341829233-24381-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH] usb: split endpoint init and reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create a new usb_ep_reset() function to reset endpoint state, without re-initialiting the queues, so we don't unlink in-flight packets just because usb-host has to re-parse the descriptor tables. Signed-off-by: Gerd Hoffmann --- hw/usb.h | 1 + hw/usb/core.c | 13 +++++++++++-- hw/usb/host-linux.c | 5 +++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/usb.h b/hw/usb.h index a5623d3..9cd2f89 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -363,6 +363,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p); void usb_cancel_packet(USBPacket * p); void usb_ep_init(USBDevice *dev); +void usb_ep_reset(USBDevice *dev); void usb_ep_dump(USBDevice *dev); struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep); uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep); diff --git a/hw/usb/core.c b/hw/usb/core.c index 0e02da7..fe15be0 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -550,7 +550,7 @@ void usb_packet_cleanup(USBPacket *p) qemu_iovec_destroy(&p->iov); } -void usb_ep_init(USBDevice *dev) +void usb_ep_reset(USBDevice *dev) { int ep; @@ -559,7 +559,6 @@ void usb_ep_init(USBDevice *dev) dev->ep_ctl.ifnum = 0; dev->ep_ctl.dev = dev; dev->ep_ctl.pipeline = false; - QTAILQ_INIT(&dev->ep_ctl.queue); for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) { dev->ep_in[ep].nr = ep + 1; dev->ep_out[ep].nr = ep + 1; @@ -573,6 +572,16 @@ void usb_ep_init(USBDevice *dev) dev->ep_out[ep].dev = dev; dev->ep_in[ep].pipeline = false; dev->ep_out[ep].pipeline = false; + } +} + +void usb_ep_init(USBDevice *dev) +{ + int ep; + + usb_ep_reset(dev); + QTAILQ_INIT(&dev->ep_ctl.queue); + for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) { QTAILQ_INIT(&dev->ep_in[ep].queue); QTAILQ_INIT(&dev->ep_out[ep].queue); } diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index 5479fb5..9ba8925 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -1136,7 +1136,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s) USBDescriptor *d; bool active = false; - usb_ep_init(&s->dev); + usb_ep_reset(&s->dev); for (i = 0;; i += d->bLength) { if (i+2 >= s->descr_len) { @@ -1239,7 +1239,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s) return 0; error: - usb_ep_init(&s->dev); + usb_ep_reset(&s->dev); return 1; } @@ -1326,6 +1326,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num, goto fail; } + usb_ep_init(&dev->dev); ret = usb_linux_update_endp_table(dev); if (ret) { goto fail;