From patchwork Mon May 16 19:56:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 95814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9A2A8B6EDD for ; Tue, 17 May 2011 05:57:16 +1000 (EST) Received: from localhost ([::1]:37990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM3uk-0005PI-7Q for incoming@patchwork.ozlabs.org; Mon, 16 May 2011 15:57:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]:57731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM3uD-0005J6-3i for qemu-devel@nongnu.org; Mon, 16 May 2011 15:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QM3uB-0004M1-Vg for qemu-devel@nongnu.org; Mon, 16 May 2011 15:56:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM3uB-0004Lg-MC for qemu-devel@nongnu.org; Mon, 16 May 2011 15:56:39 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4GJuc1v015325 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 May 2011 15:56:39 -0400 Received: from rincewind.home.kraxel.org (vpn1-4-42.ams2.redhat.com [10.36.4.42]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4GJuXwl018078; Mon, 16 May 2011 15:56:34 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 603C2429E1; Mon, 16 May 2011 21:56:23 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 16 May 2011 21:56:15 +0200 Message-Id: <1305575782-31766-12-git-send-email-kraxel@redhat.com> In-Reply-To: <1305575782-31766-1-git-send-email-kraxel@redhat.com> References: <1305575782-31766-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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 11/18] usb-linux: walk async urb list in cancel 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 Lookup async urbs which are to be canceled using the linked list instead of the direct opaque pointer. There are two reasons we are doing that: First, to avoid the opaque poiner to the callback, which is needed for upcoming cleanups. Second, because we might need multiple urbs per request for highspeed support, so a single opaque pointer doesn't cut it any more anyway. Signed-off-by: Gerd Hoffmann --- usb-linux.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 3c5a248..b8f7705 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -315,19 +315,25 @@ static void async_complete(void *opaque) } } -static void async_cancel(USBPacket *unused, void *opaque) +static void async_cancel(USBPacket *p, void *opaque) { - AsyncURB *aurb = opaque; - USBHostDevice *s = aurb->hdev; + USBHostDevice *s = opaque; + AsyncURB *aurb; - DPRINTF("husb: async cancel. aurb %p\n", aurb); + QLIST_FOREACH(aurb, &s->aurbs, next) { + if (p != aurb->packet) { + continue; + } - /* Mark it as dead (see async_complete above) */ - aurb->packet = NULL; + DPRINTF("husb: async cancel: packet %p, aurb %p\n", p, aurb); - int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb); - if (r < 0) { - DPRINTF("husb: async. discard urb failed errno %d\n", errno); + /* Mark it as dead (see async_complete above) */ + aurb->packet = NULL; + + int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb); + if (r < 0) { + DPRINTF("husb: async. discard urb failed errno %d\n", errno); + } } } @@ -696,7 +702,7 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) } } - usb_defer_packet(p, async_cancel, aurb); + usb_defer_packet(p, async_cancel, s); return USB_RET_ASYNC; } @@ -828,7 +834,7 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p, } } - usb_defer_packet(p, async_cancel, aurb); + usb_defer_packet(p, async_cancel, s); return USB_RET_ASYNC; }