From owner-svn-src-all@FreeBSD.ORG Fri Mar 20 22:01:45 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EAD1106564A; Fri, 20 Mar 2009 22:01:45 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4CBEB8FC16; Fri, 20 Mar 2009 22:01:45 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2KM1jYe015027; Fri, 20 Mar 2009 22:01:45 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2KM1jPY015026; Fri, 20 Mar 2009 22:01:45 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200903202201.n2KM1jPY015026@svn.freebsd.org> From: Andrew Thompson Date: Fri, 20 Mar 2009 22:01:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190184 - head/sys/dev/usb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2009 22:01:46 -0000 Author: thompsa Date: Fri Mar 20 22:01:45 2009 New Revision: 190184 URL: http://svn.freebsd.org/changeset/base/190184 Log: MFp4 //depot/projects/usb @159479,159502,159516,159522,159529 Workaround for buggy USB hardware not handling new SETUP packet before STATUS stage is complete, this allows xfers to endpoint0 to return a short frame. Submitted by: Hans Petter Selasky Reported by: me Modified: head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Fri Mar 20 21:57:54 2009 (r190183) +++ head/sys/dev/usb/usb_transfer.c Fri Mar 20 22:01:45 2009 (r190184) @@ -113,7 +113,6 @@ static const struct usb2_config usb2_con .endpoint = 0x00, /* Control pipe */ .direction = UE_DIR_ANY, .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, .mh.callback = &usb2_do_clear_stall_callback, .mh.timeout = 1000, /* 1 second */ .mh.interval = 50, /* 50ms */ @@ -1251,6 +1250,20 @@ usb2_start_hardware_sub(struct usb2_xfer /* no longer active */ xfer->flags_int.control_act = 0; } + + /* Check for invalid number of frames */ + if (xfer->nframes > 2) { + /* + * If you need to split a control transfer, you + * have to do one part at a time. Only with + * non-control transfers you can do multiple + * parts a time. + */ + DPRINTFN(0, "Too many frames: %u\n", + (unsigned int)xfer->nframes); + goto error; + } + /* * Check if there is a control * transfer in progress: @@ -1495,23 +1508,28 @@ usb2_start_hardware(struct usb2_xfer *xf */ if (USB_GET_DATA_ISREAD(xfer)) { - if (xfer->flags_int.control_xfr) { - - /* - * Control transfers do not support reception - * of multiple short USB frames ! - */ + if (xfer->flags.short_frames_ok) { + xfer->flags_int.short_xfer_ok = 1; + xfer->flags_int.short_frames_ok = 1; + } else if (xfer->flags.short_xfer_ok) { + xfer->flags_int.short_xfer_ok = 1; - if (xfer->flags.short_xfer_ok) { - xfer->flags_int.short_xfer_ok = 1; - } - } else { - - if (xfer->flags.short_frames_ok) { - xfer->flags_int.short_xfer_ok = 1; + /* check for control transfer */ + if (xfer->flags_int.control_xfr) { + /* + * 1) Control transfers do not support + * reception of multiple short USB + * frames in host mode and device side + * mode, with exception of: + * + * 2) Due to sometimes buggy device + * side firmware we need to do a + * STATUS stage in case of short + * control transfers in USB host mode. + * The STATUS stage then becomes the + * "alt_next" to the DATA stage. + */ xfer->flags_int.short_frames_ok = 1; - } else if (xfer->flags.short_xfer_ok) { - xfer->flags_int.short_xfer_ok = 1; } } } @@ -2652,7 +2670,6 @@ usb2_clear_data_toggle(struct usb2_devic * .interval = 50, //50 milliseconds * .bufsize = sizeof(struct usb2_device_request), * .mh.timeout = 1000, //1.000 seconds - * .mh.flags = { }, * .mh.callback = &my_clear_stall_callback, // ** * }; *