From owner-p4-projects@FreeBSD.ORG Thu Nov 6 23:04:45 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7D3A3106567E; Thu, 6 Nov 2008 23:04:45 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40F46106567A for ; Thu, 6 Nov 2008 23:04:45 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F0CF78FC14 for ; Thu, 6 Nov 2008 23:04:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mA6N4iSB037523 for ; Thu, 6 Nov 2008 23:04:44 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mA6N4ipd037521 for perforce@freebsd.org; Thu, 6 Nov 2008 23:04:44 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 6 Nov 2008 23:04:44 GMT Message-Id: <200811062304.mA6N4ipd037521@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 152598 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2008 23:04:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=152598 Change 152598 by hselasky@hselasky_laptop001 on 2008/11/06 23:03:50 Fix a problem setting the alternate setting of an interface while there are FIFOs attached to that interface. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#29 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#29 (text+ko) ==== @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -66,7 +67,7 @@ static void usb2_check_strings(struct usb2_device *udev); static usb2_error_t usb2_fill_iface_data(struct usb2_device *udev, uint8_t iface_index, uint8_t alt_index); static void usb2_notify_addq(const char *type, struct usb2_device *udev); -static void usb2_fifo_free_wrap(struct usb2_device *udev, uint8_t iface_index, uint8_t free_all); +static void usb2_fifo_free_wrap(struct usb2_device *udev, uint8_t iface_index, uint8_t flag); /* static structures */ @@ -672,8 +673,11 @@ if (udev->flags.usb2_mode == USB_MODE_DEVICE) { usb2_detach_device(udev, iface_index, 1); } - /* free all FIFOs for this interface */ - usb2_fifo_free_wrap(udev, iface_index, 0); + /* + * Free all generic FIFOs for this interface, except control + * endpoint FIFOs: + */ + usb2_fifo_free_wrap(udev, iface_index, 2); err = usb2_fill_iface_data(udev, iface_index, alt_index); if (err) { @@ -2078,13 +2082,18 @@ * usb2_fifo_free_wrap * * The function will free the FIFOs. + * + * Flag values: + * 0: Free all FIFOs except control endpoints matching "iface_index". + * 1: Free all FIFOs matching "iface_index". + * 2: Free all generic FIFOs except control endpoints matching + * "iface_index". *------------------------------------------------------------------------*/ static void usb2_fifo_free_wrap(struct usb2_device *udev, - uint8_t iface_index, uint8_t free_all) + uint8_t iface_index, uint8_t flag) { struct usb2_fifo *f; - struct usb2_pipe *pipe; uint16_t i; /* @@ -2095,11 +2104,20 @@ if (f == NULL) { continue; } - pipe = f->priv_sc0; - if ((pipe == &udev->default_pipe) && (free_all == 0)) { - /* don't free UGEN control endpoint yet */ - continue; + /* Check if the FIFO is of generic type */ + if (f->methods == &usb2_ugen_methods) { + if ((f->dev_ep_index == 0) && + ((flag == 0) || (flag == 2))) { + /* don't free UGEN control endpoint yet */ + continue; + } + } else { + if (flag == 2) { + /* don't free non-generic FIFO */ + continue; + } } + /* Check if the interface index matches */ if ((iface_index == f->iface_index) || (iface_index == USB_IFACE_INDEX_ANY)) {