Re: [linux-usb-devel] High speed, high bandwidth isoc
At 10:42 PM 7/16/2007, David Brownell wrote: On Monday 16 July 2007, Steve Calfee wrote: I am working on a project using a generic (non-FPGA) cypress fx2 to test host controllers. The good news is that Linux runs interrupt IN/OUTs at 3x1024 byte packets uframe, 24MBytes per second, over as long as I have tested, seconds. Verified by a bus analyzer. Good! :) The not so good news is that I have not been able to get high bandwidth isoc to work. I am using a stock Ubuntu Feisty - 2.6.20.15 kernel. I am going through usbdevfs. Not-so-Good ... :( I don't recall testing high bandwidth ISO. In general, ISO support is pretty weak with EHCI ... Update, I was able to get the high bandwidth ISO to work. I thought I would report how, for others in the future. When building the isoc array for submission, if it is a 2 or 3 packet per microframe IN or OUT, I thought that I just built more standard packets and ehci.c would know from the endpoint attributes the mult field. Wrong. What Linux wants is to get a packet 2 or 3 times as long as maxpacket in the length request. I have not tested all 3072 possible packet sizes, but certainly 1*3, 512*3 and 1024*3 and several sizes in between work for 20 second burst tests of transfers. All this from a userspace usbdevfs application! Linux (through usbdevfs at least) has a limitation, the max request it will accept is less than 48K per urb - 24K works. I have not tried everything in between. This means that to get iso running without dropouts (the whole point of iso) requires submitting lots of urbs in parallel. I have very successfully used 8 urbs transferring 24K per urb, but that means that the app has to reload at least every 8 ms. Probably a production app would need to use 32 or so urbs to be guaranteed the uninterrupted isoc flow. The high bandwidth stuff would really benefit from a zero copy usb kernel. Regards, Steve - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [patch 2.6.23-rc1-git 6/6] gadget zero cleanups
Clean up gadget zero, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the VERBOSE_DEBUG convention - Some whitespace fixes. - A few comment updates - Plus a few other small cleanups: don't pass gfp_t around when it's always going to be GFP_ATOMIC, and do static init of serial number. Also go to straight GPL; there's no real point in dual licensing this stuff any more. Signed-off-by: David Brownell [EMAIL PROTECTED] --- drivers/usb/gadget/zero.c | 239 ++ 1 file changed, 97 insertions(+), 142 deletions(-) --- g26.orig/drivers/usb/gadget/zero.c 2007-08-01 22:52:46.0 -0700 +++ g26/drivers/usb/gadget/zero.c 2007-08-01 23:13:23.0 -0700 @@ -1,38 +1,22 @@ /* * zero.c -- Gadget Zero, for USB development * - * Copyright (C) 2003-2004 David Brownell + * Copyright (C) 2003-2007 David Brownell * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - *notice, this list of conditions, and the following disclaimer, - *without modification. - * 2. Redistributions in binary form must reproduce the above copyright - *notice, this list of conditions and the following disclaimer in the - *documentation and/or other materials provided with the distribution. - * 3. The names of the above-listed copyright holders may not be used - *to endorse or promote products derived from this software without - *specific prior written permission. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License (GPL) as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS - * IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -57,30 +41,18 @@ * Many drivers will only have one configuration, letting them be much * simpler if they also don't support high speed operation (like this * driver does). + * + * Why is *this* driver using two configurations, rather than setting up + * two interfaces with different functions? To help verify that multiple + * configuration infrastucture is working correctly; also, so that it can + * work with low capability USB controllers without four bulk endpoints. */ -#define DEBUG 1 -// #define VERBOSE +/* #define VERBOSE_DEBUG */ -#include linux/module.h #include linux/kernel.h -#include linux/delay.h -#include linux/ioport.h -#include linux/slab.h -#include linux/errno.h -#include linux/init.h -#include linux/timer.h -#include linux/list.h -#include linux/interrupt.h #include linux/utsname.h #include linux/device.h -#include linux/moduleparam.h - -#include asm/byteorder.h -#include asm/io.h -#include asm/irq.h -#include asm/system.h -#include asm/unaligned.h #include linux/usb/ch9.h #include linux/usb_gadget.h @@ -90,7 +62,7 @@ /*-*/ -#define DRIVER_VERSION St Patrick's Day 2004 +#define DRIVER_VERSION Lughnsadh, 2007 static const char shortname [] = zero; static const char longname [] = Gadget Zero; @@ -131,30 +103,16 @@ struct zero_dev { struct timer_list resume; }; -#define xprintk(d,level,fmt,args...) \ -
[linux-usb-devel] [patch 2.6.23-rc1-git 5/6] file storage gadget cleanups
Clean up the file storage gadget, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the DEBUG (from Kconfig+Makefile) and VERBOSE_DEBUG conventions. - Remove some sparse warnings (it still dislikes the __user annotations) This gave only a minor object code shrinkage. Signed-off-by: David Brownell [EMAIL PROTECTED] Cc: Alan Stern [EMAIL PROTECTED] --- drivers/usb/gadget/file_storage.c | 118 ++ 1 file changed, 45 insertions(+), 73 deletions(-) --- g26.orig/drivers/usb/gadget/file_storage.c 2007-08-01 23:16:10.0 -0700 +++ g26/drivers/usb/gadget/file_storage.c 2007-08-01 23:29:00.0 -0700 @@ -217,17 +217,11 @@ */ -#undef DEBUG -#undef VERBOSE +/* #define VERBOSE_DEBUG */ #undef DUMP_MSGS -#include asm/system.h -#include asm/uaccess.h - -#include linux/bitops.h #include linux/blkdev.h -#include linux/compiler.h #include linux/completion.h #include linux/dcache.h #include linux/delay.h @@ -235,18 +229,10 @@ #include linux/fcntl.h #include linux/file.h #include linux/fs.h -#include linux/init.h -#include linux/kernel.h #include linux/kref.h #include linux/kthread.h #include linux/limits.h -#include linux/list.h -#include linux/module.h -#include linux/moduleparam.h -#include linux/pagemap.h #include linux/rwsem.h -#include linux/sched.h -#include linux/signal.h #include linux/slab.h #include linux/spinlock.h #include linux/string.h @@ -289,57 +275,51 @@ MODULE_LICENSE(Dual BSD/GPL); /*-*/ -#define xprintk(f,level,fmt,args...) \ - dev_printk(level , (f)-gadget-dev , fmt , ## args) #define yprintk(l,level,fmt,args...) \ dev_printk(level , (l)-dev , fmt , ## args) #ifdef DEBUG -#define DBG(fsg,fmt,args...) \ - xprintk(fsg , KERN_DEBUG , fmt , ## args) #define LDBG(lun,fmt,args...) \ yprintk(lun , KERN_DEBUG , fmt , ## args) #define MDBG(fmt,args...) \ printk(KERN_DEBUG DRIVER_NAME : fmt , ## args) #else -#define DBG(fsg,fmt,args...) \ - do { } while (0) #define LDBG(lun,fmt,args...) \ do { } while (0) #define MDBG(fmt,args...) \ do { } while (0) -#undef VERBOSE +#undef VERBOSE_DEBUG #undef DUMP_MSGS #endif /* DEBUG */ -#ifdef VERBOSE -#define VDBG DBG +#ifdef VERBOSE_DEBUG #define VLDBG LDBG #else -#define VDBG(fsg,fmt,args...) \ - do { } while (0) #define VLDBG(lun,fmt,args...) \ do { } while (0) -#endif /* VERBOSE */ +#endif /* VERBOSE_DEBUG */ -#define ERROR(fsg,fmt,args...) \ - xprintk(fsg , KERN_ERR , fmt , ## args) #define LERROR(lun,fmt,args...) \ yprintk(lun , KERN_ERR , fmt , ## args) - -#define WARN(fsg,fmt,args...) \ - xprintk(fsg , KERN_WARNING , fmt , ## args) #define LWARN(lun,fmt,args...) \ yprintk(lun , KERN_WARNING , fmt , ## args) - -#define INFO(fsg,fmt,args...) \ - xprintk(fsg , KERN_INFO , fmt , ## args) #define LINFO(lun,fmt,args...) \ yprintk(lun , KERN_INFO , fmt , ## args) #define MINFO(fmt,args...) \ printk(KERN_INFO DRIVER_NAME : fmt , ## args) +#define DBG(d, fmt, args...) \ + dev_dbg((d)-gadget-dev , fmt , ## args) +#define VDBG(d, fmt, args...) \ + dev_vdbg((d)-gadget-dev , fmt , ## args) +#define ERROR(d, fmt, args...) \ + dev_err((d)-gadget-dev , fmt , ## args) +#define WARN(d, fmt, args...) \ + dev_warn((d)-gadget-dev , fmt , ## args) +#define INFO(d, fmt, args...) \ + dev_info((d)-gadget-dev , fmt , ## args) + /*-*/ @@ -350,8 +330,8 @@ MODULE_LICENSE(Dual BSD/GPL); static struct { char*file[MAX_LUNS]; int ro[MAX_LUNS]; - int num_filenames; - int num_ros; + unsigned intnum_filenames; + unsigned intnum_ros; unsigned intnluns; int removable; @@ -951,8 +931,6 @@ static const struct usb_descriptor_heade #define FS_FUNCTION_PRE_EP_ENTRIES 2 -#ifdef CONFIG_USB_GADGET_DUALSPEED - /* * USB 2.0 devices need to expose both high speed and full speed * descriptors, unless they only run at full speed. @@ -1015,14 +993,14 @@ static const struct usb_descriptor_heade #define HS_FUNCTION_PRE_EP_ENTRIES 2 /* Maxpacket and other transfer characteristics vary by speed. */ -#define ep_desc(g,fs,hs) (((g)-speed==USB_SPEED_HIGH) ? (hs) : (fs)) - -#else - -/* If there's no high speed support, always use the full-speed descriptor. */ -#define ep_desc(g,fs,hs) fs - -#endif /* !CONFIG_USB_GADGET_DUALSPEED */ +static inline struct usb_endpoint_descriptor * +ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, + struct usb_endpoint_descriptor *hs) +{ + if (gadget_is_dualspeed(g) g-speed ==
[linux-usb-devel] [patch 2.6.23-rc1-git 1/6] gadget_is_{dualspeed, otg} predicates and cleanup
This adds two small inlines to the gadget stack, which will often evaluate to compile-time constants. That can help shrink object code and remove #ifdeffery. - gadget_is_dualspeed(), currently always a compile-time constant (depending on which controller is selected). - gadget_is_otg(), usually a compile time false, but this is a runtime test if the platform enables OTG (since it's reasonable to populate boards with different USB sockets). It also updates two peripheral controller drivers to use these: - fsl_usb2_udc, mostly OTG-related bugfixes: non-OTG devices must follow the rules about drawing VBUS power, and OTG ones need to reject invalid SET_FEATURE requests. - omap_udc, just scrubbing a bit of #ifdeffery. And also gadgetfs, which lost some #ifdefs and moved to a more standard handling of DEBUG and VERBOSE_DEBUG. The main benefits come from patches which will follow. Signed-off-by: David Brownell [EMAIL PROTECTED] --- drivers/usb/gadget/fsl_usb2_udc.c |9 ++- drivers/usb/gadget/inode.c| 44 +- drivers/usb/gadget/omap_udc.c | 10 ++-- include/linux/usb_gadget.h| 33 4 files changed, 59 insertions(+), 37 deletions(-) --- g26.orig/drivers/usb/gadget/fsl_usb2_udc.c 2007-08-01 22:27:55.0 -0700 +++ g26/drivers/usb/gadget/fsl_usb2_udc.c 2007-08-01 22:37:25.0 -0700 @@ -1090,14 +1090,11 @@ static int fsl_vbus_session(struct usb_g */ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA) { -#ifdef CONFIG_USB_OTG struct fsl_udc *udc; udc = container_of(gadget, struct fsl_udc, gadget); - if (udc-transceiver) return otg_set_power(udc-transceiver, mA); -#endif return -ENOTSUPP; } @@ -1319,7 +1316,7 @@ static void setup_received_irq(struct fs == USB_RECIP_DEVICE) { /* Note: The driver has not include OTG support yet. * This will be set when OTG support is added */ - if (!udc-gadget.is_otg) + if (!gadget_is_otg(udc-gadget)) break; else if (setup-bRequest == USB_DEVICE_B_HNP_ENABLE) udc-gadget.b_hnp_enable = 1; @@ -1328,6 +1325,8 @@ static void setup_received_irq(struct fs else if (setup-bRequest == USB_DEVICE_A_ALT_HNP_SUPPORT) udc-gadget.a_alt_hnp_support = 1; + else + break; rc = 0; } if (rc == 0) { @@ -1835,10 +1834,8 @@ int usb_gadget_unregister_driver(struct if (!driver || driver != udc_controller-driver || !driver-unbind) return -EINVAL; -#ifdef CONFIG_USB_OTG if (udc_controller-transceiver) (void)otg_set_peripheral(udc_controller-transceiver, 0); -#endif /* stop DR, disable intr */ dr_controller_stop(udc_controller); --- g26.orig/drivers/usb/gadget/inode.c 2007-08-01 22:27:55.0 -0700 +++ g26/drivers/usb/gadget/inode.c 2007-08-01 22:37:25.0 -0700 @@ -20,8 +20,7 @@ */ -// #define DEBUG /* data to help fault diagnosis */ -// #define VERBOSE /* extra debug messages (success too) */ +/* #define VERBOSE_DEBUG */ #include linux/init.h #include linux/module.h @@ -253,7 +252,7 @@ static const char *CHIP; do { } while (0) #endif /* DEBUG */ -#ifdef VERBOSE +#ifdef VERBOSE_DEBUG #define VDEBUG DBG #else #define VDEBUG(dev,fmt,args...) \ @@ -1010,11 +1009,12 @@ ep0_read (struct file *fd, char __user * /* assume that was SET_CONFIGURATION */ if (dev-current_config) { unsigned power; -#ifdef CONFIG_USB_GADGET_DUALSPEED - if (dev-gadget-speed == USB_SPEED_HIGH) + + if (gadget_is_dualspeed(dev-gadget) +(dev-gadget-speed + == USB_SPEED_HIGH)) power = dev-hs_config-bMaxPower; else -#endif power = dev-config-bMaxPower; usb_gadget_vbus_draw(dev-gadget, 2 * power); } @@ -1355,24 +1355,21 @@ static int config_buf (struct dev_data *dev, u8 type, unsigned index) { int len; -#ifdef CONFIG_USB_GADGET_DUALSPEED - int hs; -#endif + int hs = 0; /* only one configuration */ if (index 0) return -EINVAL; -#ifdef CONFIG_USB_GADGET_DUALSPEED - hs =
[linux-usb-devel] [patch 2.6.23-rc1-git 0/6] some gadget stack cleanups
Following this are several minor gadget stack updates: - Add gadget_is_dualspeed() and gadget_is_otg() predicates, which can help remove #ifdeffery and associated cleanups. Includes updates to fsl_usb2_udc, omap_udc, and gadgetfs. - Use those to cleanup the Ethernet gadget. Amazingly, this saved 2KBytes on one ARM. (Includes some other cleanups.) - Cleanups for gmidi ... doesn't actually use those predicates, this just adapts to CONFIG_USB_GADGET_DEBUG and shrinks the number of #includes. (Cleanups which are applied to all the other gadget drivers.) - And for the serial gadget ... - And file_storage ... includes some minor sparse fixes. - Finally, for Gadget Zero. This also removes the BSD license option (no point any more) and includes a few other updates. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [patch 2.6.23-rc1-git 2/6] ethernet gadget cleanups, shrinkage
Clean up the ethernet gadget, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the VERBOSE_DEBUG convention - Minor whitespace fixes. - Fix a warning from sparse. Surprisingly, this saved about 2K of code (16%) on a fullspeed-only ARMv4 platform. I'm bit puzzled by that (it's so much!), but approve of the result. Signed-off-by: David Brownell [EMAIL PROTECTED] --- drivers/usb/gadget/ether.c | 147 + 1 file changed, 57 insertions(+), 90 deletions(-) --- g26.orig/drivers/usb/gadget/ether.c 2007-08-01 23:16:10.0 -0700 +++ g26/drivers/usb/gadget/ether.c 2007-08-01 23:18:16.0 -0700 @@ -19,41 +19,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* #define VERBOSE_DEBUG */ -// #define DEBUG 1 -// #define VERBOSE - -#include linux/module.h #include linux/kernel.h -#include linux/delay.h -#include linux/ioport.h -#include linux/slab.h -#include linux/errno.h -#include linux/init.h -#include linux/timer.h -#include linux/list.h -#include linux/interrupt.h #include linux/utsname.h #include linux/device.h -#include linux/moduleparam.h #include linux/ctype.h - -#include asm/byteorder.h -#include asm/io.h -#include asm/irq.h -#include asm/system.h -#include asm/uaccess.h -#include asm/unaligned.h +#include linux/etherdevice.h +#include linux/ethtool.h #include linux/usb/ch9.h #include linux/usb/cdc.h #include linux/usb_gadget.h -#include linux/random.h -#include linux/netdevice.h -#include linux/etherdevice.h -#include linux/ethtool.h - #include gadget_chips.h /*-*/ @@ -356,15 +334,15 @@ module_param (qmult, uint, S_IRUGO|S_IWU #define qlen(gadget) \ (DEFAULT_QLEN*((gadget-speed == USB_SPEED_HIGH) ? qmult : 1)) -/* also defer IRQs on highspeed TX */ -#define TX_DELAY qmult - static inline int BITRATE(struct usb_gadget *g) { return (g-speed == USB_SPEED_HIGH) ? HS_BPS : FS_BPS; } #else /* full speed (low speed doesn't do bulk) */ + +#define qmult 1 + #defineDEVSPEEDUSB_SPEED_FULL #define qlen(gadget) DEFAULT_QLEN @@ -390,7 +368,7 @@ static inline int BITRATE(struct usb_gad do { } while (0) #endif /* DEBUG */ -#ifdef VERBOSE +#ifdef VERBOSE_DEBUG #define VDEBUG DEBUG #else #define VDEBUG(dev,fmt,args...) \ @@ -830,8 +808,6 @@ static const struct usb_descriptor_heade }; #endif -#ifdef CONFIG_USB_GADGET_DUALSPEED - /* * usb 2.0 devices need to expose both high speed and full speed * descriptors, unless they only run at full speed. @@ -934,18 +910,15 @@ static const struct usb_descriptor_heade /* maxpacket and other transfer characteristics vary by speed. */ -#define ep_desc(g,hs,fs) (((g)-speed==USB_SPEED_HIGH)?(hs):(fs)) - -#else - -/* if there's no high speed support, maxpacket doesn't change. */ -#define ep_desc(g,hs,fs) (((void)(g)), (fs)) - -static inline void __init hs_subset_descriptors(void) -{ +static inline struct usb_endpoint_descriptor * +ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, + struct usb_endpoint_descriptor *fs) +{ + if (gadget_is_dualspeed(g) g-speed == USB_SPEED_HIGH) + return hs; + return fs; } -#endif /* !CONFIG_USB_GADGET_DUALSPEED */ /*-*/ @@ -989,22 +962,19 @@ static struct usb_gadget_strings stringt * complications: class descriptors, and an altsetting. */ static int -config_buf (enum usb_device_speed speed, - u8 *buf, u8 type, - unsigned index, int is_otg) +config_buf(struct usb_gadget *g, u8 *buf, u8 type, unsigned index, int is_otg) { int len; const struct usb_config_descriptor *config; const struct usb_descriptor_header **function; -#ifdef CONFIG_USB_GADGET_DUALSPEED - int hs = (speed == USB_SPEED_HIGH); + int hs = 0; - if (type == USB_DT_OTHER_SPEED_CONFIG) - hs = !hs; + if (gadget_is_dualspeed(g)) { + hs = (g-speed == USB_SPEED_HIGH); + if (type == USB_DT_OTHER_SPEED_CONFIG) + hs = !hs; + } #define which_fn(t)(hs ? hs_ ## t ## _function : fs_ ## t ## _function) -#else -#definewhich_fn(t) (fs_ ## t ## _function) -#endif if (index = device_desc.bNumConfigurations) return -EINVAL; @@ -1217,7 +1187,7 @@ eth_set_config (struct eth_dev *dev, uns if (number) eth_reset_config (dev); usb_gadget_vbus_draw(dev-gadget, - dev-gadget-is_otg ? 8 : 100); +
[linux-usb-devel] [patch 2.6.23-rc1-git 3/6] gmidi cleanups
Clean up the midi gadget, using newer APIs and conventions: - Remove many now-needless #includes - Use the DEBUG (from Kconfig+Makefile) and VERBOSE_DEBUG conventions. - Whitespace fixes There should be no effect on object code size. Signed-off-by: David Brownell [EMAIL PROTECTED] Cc: Ben Williamson [EMAIL PROTECTED] --- drivers/usb/gadget/gmidi.c | 80 ++--- 1 file changed, 32 insertions(+), 48 deletions(-) --- g26.orig/drivers/usb/gadget/gmidi.c 2007-08-01 22:27:55.0 -0700 +++ g26/drivers/usb/gadget/gmidi.c 2007-08-01 22:38:17.0 -0700 @@ -18,17 +18,11 @@ * http://www.usb.org/developers/devclass_docs/midi10.pdf */ -#define DEBUG 1 -// #define VERBOSE +/* #define VERBOSE_DEBUG */ -#include linux/module.h #include linux/kernel.h -#include linux/delay.h -#include linux/errno.h -#include linux/init.h #include linux/utsname.h #include linux/device.h -#include linux/moduleparam.h #include sound/driver.h #include sound/core.h @@ -139,30 +133,16 @@ struct gmidi_device { static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req); -#define xprintk(d,level,fmt,args...) \ - dev_printk(level , (d)-gadget-dev , fmt , ## args) - -#ifdef DEBUG -#define DBG(dev,fmt,args...) \ - xprintk(dev , KERN_DEBUG , fmt , ## args) -#else -#define DBG(dev,fmt,args...) \ - do { } while (0) -#endif /* DEBUG */ - -#ifdef VERBOSE -#define VDBG DBG -#else -#define VDBG(dev,fmt,args...) \ - do { } while (0) -#endif /* VERBOSE */ - -#define ERROR(dev,fmt,args...) \ - xprintk(dev , KERN_ERR , fmt , ## args) -#define WARN(dev,fmt,args...) \ - xprintk(dev , KERN_WARNING , fmt , ## args) -#define INFO(dev,fmt,args...) \ - xprintk(dev , KERN_INFO , fmt , ## args) +#define DBG(d, fmt, args...) \ + dev_dbg((d)-gadget-dev , fmt , ## args) +#define VDBG(d, fmt, args...) \ + dev_vdbg((d)-gadget-dev , fmt , ## args) +#define ERROR(d, fmt, args...) \ + dev_err((d)-gadget-dev , fmt , ## args) +#define WARN(d, fmt, args...) \ + dev_warn((d)-gadget-dev , fmt , ## args) +#define INFO(d, fmt, args...) \ + dev_info((d)-gadget-dev , fmt , ## args) static unsigned buflen = 256; @@ -425,7 +405,7 @@ static int config_buf(struct usb_gadget return len; } -static struct usb_request* alloc_ep_req(struct usb_ep *ep, unsigned length) +static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length) { struct usb_request *req; @@ -455,7 +435,7 @@ static const uint8_t gmidi_cin_length[] * Receives a chunk of MIDI data. */ static void gmidi_read_data(struct usb_ep *ep, int cable, - uint8_t* data, int length) + uint8_t *data, int length) { struct gmidi_device *dev = ep-driver_data; /* cable is ignored, because for now we only have one. */ @@ -541,7 +521,7 @@ static int set_gmidi_config(struct gmidi { int err = 0; struct usb_request *req; - struct usb_ep* ep; + struct usb_ep *ep; unsigned i; err = usb_ep_enable(dev-in_ep, bulk_in_desc); @@ -628,7 +608,7 @@ gmidi_set_config(struct gmidi_device *de if (gadget_is_sa1100(gadget) dev-config) { /* tx fifo is full, but we can't clear it...*/ - INFO(dev, can't change configurations\n); + ERROR(dev, can't change configurations\n); return -ESPIPE; } gmidi_reset_config(dev); @@ -843,7 +823,7 @@ static void gmidi_disconnect(struct usb_ static void /* __init_or_exit */ gmidi_unbind(struct usb_gadget *gadget) { struct gmidi_device *dev = get_gadget_data(gadget); - struct snd_card* card; + struct snd_card *card; DBG(dev, unbind\n); @@ -867,12 +847,12 @@ static int gmidi_snd_free(struct snd_dev return 0; } -static void gmidi_transmit_packet(struct usb_request* req, uint8_t p0, +static void gmidi_transmit_packet(struct usb_request *req, uint8_t p0, uint8_t p1, uint8_t p2, uint8_t p3) { unsigned length = req-length; + u8 *buf = (u8 *)req-buf + length; - uint8_t* buf = (uint8_t*)req-buf + length; buf[0] = p0; buf[1] = p1; buf[2] = p2; @@ -883,8 +863,8 @@ static void gmidi_transmit_packet(struct /* * Converts MIDI commands to USB MIDI packets. */ -static void gmidi_transmit_byte(struct usb_request* req, - struct gmidi_in_port* port, uint8_t b) +static void gmidi_transmit_byte(struct usb_request *req, + struct gmidi_in_port *port, uint8_t b) { uint8_t p0 = port-cable; @@ -981,10 +961,10 @@ static void gmidi_transmit_byte(struct u } } -static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req) +static void gmidi_transmit(struct gmidi_device *dev, struct usb_request
[linux-usb-devel] [patch 2.6.23-rc1-git 4/6] serial gadget cleanups
Clean up the serial gadget, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the DEBUG and VERBOSE_DEBUG conventions; turned up a bug in the original debug messaging - Various whitespace fixes. This gave only a minor object code shrinkage, but the source looks much cleaner in various places. Signed-off-by: David Brownell [EMAIL PROTECTED] Cc: Al Borchers [EMAIL PROTECTED] --- drivers/usb/gadget/serial.c | 166 +++- 1 file changed, 73 insertions(+), 93 deletions(-) --- g26.orig/drivers/usb/gadget/serial.c2007-08-01 22:27:55.0 -0700 +++ g26/drivers/usb/gadget/serial.c 2007-08-01 22:38:19.0 -0700 @@ -17,30 +17,11 @@ * */ -#include linux/module.h #include linux/kernel.h -#include linux/delay.h -#include linux/ioport.h -#include linux/slab.h -#include linux/errno.h -#include linux/init.h -#include linux/timer.h -#include linux/list.h -#include linux/interrupt.h #include linux/utsname.h -#include linux/wait.h -#include linux/proc_fs.h #include linux/device.h #include linux/tty.h #include linux/tty_flip.h -#include linux/mutex.h - -#include asm/byteorder.h -#include asm/io.h -#include asm/irq.h -#include asm/system.h -#include asm/unaligned.h -#include asm/uaccess.h #include linux/usb/ch9.h #include linux/usb/cdc.h @@ -89,30 +70,29 @@ #define GS_DEFAULT_PARITY USB_CDC_NO_PARITY #define GS_DEFAULT_CHAR_FORMAT USB_CDC_1_STOP_BITS -/* select highspeed/fullspeed, hiding highspeed if not configured */ -#ifdef CONFIG_USB_GADGET_DUALSPEED -#define GS_SPEED_SELECT(is_hs,hs,fs) ((is_hs) ? (hs) : (fs)) -#else -#define GS_SPEED_SELECT(is_hs,hs,fs) (fs) -#endif /* CONFIG_USB_GADGET_DUALSPEED */ +/* maxpacket and other transfer characteristics vary by speed. */ +static inline struct usb_endpoint_descriptor * +choose_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, + struct usb_endpoint_descriptor *fs) +{ + if (gadget_is_dualspeed(g) g-speed == USB_SPEED_HIGH) + return hs; + return fs; +} + /* debug settings */ -#ifdef GS_DEBUG +#ifdef DEBUG static int debug = 1; +#else +#definedebug 0 +#endif #define gs_debug(format, arg...) \ do { if (debug) printk(KERN_DEBUG format, ## arg); } while(0) #define gs_debug_level(level, format, arg...) \ do { if (debug=level) printk(KERN_DEBUG format, ## arg); } while(0) -#else - -#define gs_debug(format, arg...) \ - do { } while(0) -#define gs_debug_level(level, format, arg...) \ - do { } while(0) - -#endif /* GS_DEBUG */ /* Thanks to NetChip Technologies for donating this product ID. * @@ -147,10 +127,10 @@ struct gs_req_entry { /* the port structure holds info for each port, one for each minor number */ struct gs_port { - struct gs_dev *port_dev; /* pointer to device struct */ + struct gs_dev *port_dev; /* pointer to device struct */ struct tty_struct *port_tty; /* pointer to tty struct */ spinlock_t port_lock; - int port_num; + int port_num; int port_open_count; int port_in_use;/* open/close in progress */ wait_queue_head_t port_write_wait;/* waiting to write */ @@ -188,7 +168,7 @@ static void __exit gs_module_exit(void); /* tty driver */ static int gs_open(struct tty_struct *tty, struct file *file); static void gs_close(struct tty_struct *tty, struct file *file); -static int gs_write(struct tty_struct *tty, +static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count); static void gs_put_char(struct tty_struct *tty, unsigned char ch); static void gs_flush_chars(struct tty_struct *tty); @@ -222,7 +202,7 @@ static void gs_setup_complete(struct usb static void gs_disconnect(struct usb_gadget *gadget); static int gs_set_config(struct gs_dev *dev, unsigned config); static void gs_reset_config(struct gs_dev *dev); -static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed, +static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, u8 type, unsigned int index, int is_otg); static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, @@ -415,18 +395,18 @@ static const struct usb_cdc_header_desc }; static const struct usb_cdc_call_mgmt_descriptor gs_call_mgmt_descriptor = { - .bLength = sizeof(gs_call_mgmt_descriptor), - .bDescriptorType = USB_DT_CS_INTERFACE, - .bDescriptorSubType = USB_CDC_CALL_MANAGEMENT_TYPE, - .bmCapabilities = 0, - .bDataInterface = 1, /* index of data interface */ + .bLength = sizeof(gs_call_mgmt_descriptor), + .bDescriptorType = USB_DT_CS_INTERFACE, +
Re: [linux-usb-devel] [PATCH] USB BIOS early handoff only when the we the driver is configured
Greg KH schrieb: On Wed, Aug 01, 2007 at 09:21:12AM +0200, David Engraf wrote: At the moment I have a Jetway/VIA Mainboard which seems to have a problem with the handoff. Evenwhen I wait about 20 seconds the EHCI_USBLEGSUP_BIOS flag is not cleared. I think this is a BIOS bug and I will have to talk to Jetway/VIA. This sounds like a BIOS bug. I think so too and I have to talk to Jetway/VIA what there is going wrong. On the other hand, I don't need the EHCI controller in my kernel, so I think the kernel shouldn't take the handover for the EHCI controller like other OS which do not have an usb driver and so don't know that there is a EHCI_USBLEGSUP_BIOS flag which should be cleared. We need to do this early to handle a wide range of machines that do very nasty things if we do not grab the device as early as possible. Even if we do not ever get around to loading that usb driver. Yeah, hardware sucks at times :( Ok, but when we don't habe the driver for the usb controller, I think the BIOS should control it because maybe the BIOS found for example a keyboard or mouse and emulates it as an PS2 keayboard/mouse, so we could use it without the usb driver. I think that's why they developed the handoff feature. Are there any known hardware which has problems when we disable the handoff? thanks, greg k-h Thanks David Engraf Netcom Sicherheitstechnik GmbH Rheinallee 189 55120 Mainz Tel:+49 6131 6305 0 Fax:+49 6131 6305 40 Email: [EMAIL PROTECTED] Sitz der Gesellschaft: Mainz Registergericht: Amtsgericht Mainz, 14HRB3411 Geschäftsführer: Peter Otto - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] USB BIOS early handoff only when the we the driver is configured
Alan Stern schrieb: On Wed, 1 Aug 2007, David Engraf wrote: At the moment I have a Jetway/VIA Mainboard which seems to have a problem with the handoff. Even when I wait about 20 seconds the EHCI_USBLEGSUP_BIOS flag is not cleared. I think this is a BIOS bug and I will have to talk to Jetway/VIA. I have the same problem on my Intel motherboard. Which is surprising, considering that Intel invented the BIOS-handoff technique. Ok, so even Intel has problems with the handoff. On the other hand, I don't need the EHCI controller in my kernel, so I think the kernel shouldn't take the handover for the EHCI controller like other OS which do not have an usb driver and so don't know that there is a EHCI_USBLEGSUP_BIOS flag which should be cleared. There ought to be a solution to satisfy everybody. For instance, you could add a Kconfig flag for enabling USB handoff, and make it be selected automatically if any of the PCI USB drivers are configured. Alan Stern This would be solution too, but what if someone uses the uhci controller and don't want the ehci. So a single Kconfig flag wouldn't be enough, we have to add 3 flags for uchi, ohci and ehci. I think this maybe a little bit difficult when configuring the kernel. The best solution would be when we could use the CONFIG_USB__HCD flag, but it seems that some hardware has problems when we disable the handoff and let the BIOS control the usb controller. Do you know any of this hardware? Thanks David Engraf Netcom Sicherheitstechnik GmbH Rheinallee 189 55120 Mainz Tel:+49 6131 6305 0 Fax:+49 6131 6305 40 Email: [EMAIL PROTECTED] Sitz der Gesellschaft: Mainz Registergericht: Amtsgericht Mainz, 14HRB3411 Geschäftsführer: Peter Otto - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] 2.6.23-rc1-mm2
Hello, usb 2-1: USB disconnect, address 2 BUG: atomic counter underflow at: [c010456a] show_trace_log_lvl+0x1a/0x30 [c010508d] show_trace+0x12/0x14 [c01051e0] dump_stack+0x15/0x17 [c01418cf] __free_pages+0x50/0x52 [c01418f0] free_pages+0x1f/0x21 [c010783d] dma_free_coherent+0x43/0x9c [c0315067] hcd_buffer_free+0x43/0x6a [c030b2b4] usb_buffer_free+0x23/0x29 [c0346db4] hid_free_buffers+0x23/0x71 [c0346eb2] hid_disconnect+0xb0/0xc8 [c0313676] usb_unbind_interface+0x30/0x72 [c02c6df0] __device_release_driver+0x6a/0x92 [c02c71c3] device_release_driver+0x20/0x36 [c02c6736] bus_remove_device+0x62/0x85 [c02c49f8] device_del+0x16d/0x27c [c0310f25] usb_disable_device+0x7a/0xe2 [c030d0bc] usb_disconnect+0x94/0xde [c030e030] hub_thread+0x2fe/0xc1b [c0128aee] kthread+0x36/0x58 [c0104233] kernel_thread_helper+0x7/0x14 === uhci_hcd :00:0c.0: dma_pool_free buffer-32, 6b6b6b6b/6b6b6b6b (bad dma) Mariusz, I guess the patch below (which I have just added to my tree) fixes that, right? Thanks. Yes - that's correct. This patch fixes the bug. Thanks. Mariusz - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] How to write a user-space application for usb_skeleton?
I've compiled the usb_skeleton.c module and loaded this module. I've managed to open a USB-device, but that's it. How can I write a application that uses this module? Can I only use the file-operations like (owner, read, write, open and release)? Is there a way to set the baudrate, get the vendor/device ID, search for USB devices, ... - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] How to write a user-space application for usb_skeleton?
Am Donnerstag 02 August 2007 schrieb Thaens Tim: I've compiled the usb_skeleton.c module and loaded this module. I've managed to open a USB-device, but that's it. How can I write a application that uses this module? Can I only use the file-operations like (owner, read, write, open and release)? Yes. Is there a way to set the baudrate, get the vendor/device ID, search for USB devices, ... No, you need a specialised driver for that. Regards Oliver - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] 2.6.23-rc1-mm2
On Thu, 2 Aug 2007, Alan Stern wrote: uhci_hcd :00:0c.0: dma_pool_free buffer-32, 6b6b6b6b/6b6b6b6b (bad dma) I guess the patch below (which I have just added to my tree) fixes that, right? Thanks. Yes - that's correct. This patch fixes the bug. Thanks. Does it also fix the dma_pool_free error? I believe it should -- caused by calling usb_buffer_free() with bogus dma_addr_t, as corresponding usbhid_device has been already kfree()d. -- Jiri Kosina - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] 2.6.23-rc1-mm2
On Thu, 2 Aug 2007, Mariusz Kozlowski wrote: === uhci_hcd :00:0c.0: dma_pool_free buffer-32, 6b6b6b6b/6b6b6b6b (bad dma) Mariusz, I guess the patch below (which I have just added to my tree) fixes that, right? Thanks. Yes - that's correct. This patch fixes the bug. Thanks. Does it also fix the dma_pool_free error? Alan Stern - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] Can't unload uhci_hcd module with 2.6.22 -- also oops
On Wed, 1 Aug 2007, Alan Stern wrote: Okay, good work. Thanks to your careful experiments, plus the hints from Oliver and Tejun, I figured out the problem. In short, the attribute files were registered on the control interface but the driver tried to delete them from the data interface. I'll post a patch tomorrow morning. And here it is. You can remove the earlier diagnostic patches; this one by itself should fix everything. Alan Stern Index: 2.6.22/drivers/usb/class/cdc-acm.c === --- 2.6.22.orig/drivers/usb/class/cdc-acm.c +++ 2.6.22/drivers/usb/class/cdc-acm.c @@ -919,6 +919,10 @@ skip_normal_probe: return -EINVAL; } } + + /* Accept probe requests only for the control interface */ + if (intf != control_interface) + return -ENODEV; if (usb_interface_claimed(data_interface)) { /* valid in this context */ dev_dbg(intf-dev,The data interface isn't available); @@ -1107,10 +,12 @@ static void acm_disconnect(struct usb_in return; } if (acm-country_codes){ - device_remove_file(intf-dev, dev_attr_wCountryCodes); - device_remove_file(intf-dev, dev_attr_iCountryCodeRelDate); + device_remove_file(acm-control-dev, + dev_attr_wCountryCodes); + device_remove_file(acm-control-dev, + dev_attr_iCountryCodeRelDate); } - device_remove_file(intf-dev, dev_attr_bmCapabilities); + device_remove_file(acm-control-dev, dev_attr_bmCapabilities); acm-dev = NULL; usb_set_intfdata(acm-control, NULL); usb_set_intfdata(acm-data, NULL); - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] USB BIOS early handoff only when the we the driver is configured
On Thu, 2 Aug 2007, David Engraf wrote: This would be solution too, but what if someone uses the uhci controller and don't want the ehci. So a single Kconfig flag wouldn't be enough, we have to add 3 flags for uchi, ohci and ehci. I think this maybe a little bit difficult when configuring the kernel. The best solution would be when we could use the CONFIG_USB__HCD flag, but it seems that some hardware has problems when we disable the handoff and let the BIOS control the usb controller. Do you know any of this hardware? The email messages are hidden in the depths of the linux-usb-devel archives. Maybe you can find them by checking the Git history for drivers/usb/host/pci-quirks.c, finding the dates for patches that affected the handoff code, and then searching through the archives near those dates. IIRC the problems arose on some MIPS machines. And I don't think the problem involved letting the firmware manage the USB controller; I think the problem came when the controller driver tried to do the handoff later on. Alan Stern - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] 2.6.23-rc1-mm2
=== uhci_hcd :00:0c.0: dma_pool_free buffer-32, 6b6b6b6b/6b6b6b6b (bad dma) Mariusz, I guess the patch below (which I have just added to my tree) fixes that, right? Thanks. Yes - that's correct. This patch fixes the bug. Thanks. Does it also fix the dma_pool_free error? Yes - it does. Regards, Mariusz - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] Can't unload uhci_hcd module with 2.6.22 -- also oops
Am Donnerstag 02 August 2007 schrieb Alan Stern: On Wed, 1 Aug 2007, Alan Stern wrote: Okay, good work. Thanks to your careful experiments, plus the hints from Oliver and Tejun, I figured out the problem. In short, the attribute files were registered on the control interface but the driver tried to delete them from the data interface. I'll post a patch tomorrow morning. And here it is. You can remove the earlier diagnostic patches; this one by itself should fix everything. Alan Stern Alan, thanks for finding this. I saw sysfs in the trace and switched off mentally. Sorry Oliver - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [patch 2.6.23-rc1-git 5/6] file storage gadget cleanups
On Thu, 2 Aug 2007, David Brownell wrote: Clean up the file storage gadget, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the DEBUG (from Kconfig+Makefile) and VERBOSE_DEBUG conventions. - Remove some sparse warnings (it still dislikes the __user annotations) This gave only a minor object code shrinkage. I'd rather expect to see a minor increase in object code size, since a few data structures and lines of code are now compiled in that previously would have been #ifdef'ed out. Why do you think the code size shrank? Signed-off-by: David Brownell [EMAIL PROTECTED] Cc: Alan Stern [EMAIL PROTECTED] --- drivers/usb/gadget/file_storage.c | 118 ++ 1 file changed, 45 insertions(+), 73 deletions(-) --- g26.orig/drivers/usb/gadget/file_storage.c2007-08-01 23:16:10.0 -0700 +++ g26/drivers/usb/gadget/file_storage.c 2007-08-01 23:29:00.0 -0700 @@ -289,57 +275,51 @@ MODULE_LICENSE(Dual BSD/GPL); /*-*/ -#define xprintk(f,level,fmt,args...) \ - dev_printk(level , (f)-gadget-dev , fmt , ## args) #define yprintk(l,level,fmt,args...) \ dev_printk(level , (l)-dev , fmt , ## args) Is there any particular reason you expanded xprintk inline but not yprintk? Despite these questions, ACK. Alan Stern - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] Virus Email.Phishing.RB-1217 gefunden
Sehr geehrte Damen und Herren, in dem E-Mail mit dem Betreff '[linux-usb-devel] You've received an ecard from a Class mate!' (gesendet am Thu, 2 Aug 2007 19:38:16 +0400) mit der angegebenen Absenderadresse '1LoveCards.Com [EMAIL PROTECTED]' wurde der Virus 'Email.Phishing.RB-1217' gefunden. Aus diesem Grund wurde die E-Mail nicht zugestellt! Ihr Inode-Team -- Dear Ladies and Gentlemen, the mail with the Subject '[linux-usb-devel] You've received an ecard from a Class mate!' (sent on Thu, 2 Aug 2007 19:38:16 +0400) with the sender address specified as '1LoveCards.Com [EMAIL PROTECTED]' contained a virus known as 'Email.Phishing.RB-1217'. Due to this reason the Mail has not been delivered! Your Inode-Team --- Headers of original mail follow: Received: from [66.35.250.225] (port=9468 helo=lists-outbound.sourceforge.net) by smartmx-02.inode.at with esmtp (Exim 4.50) id 1IGckv-0005zz-Q9 for [EMAIL PROTECTED]; Thu, 02 Aug 2007 17:38:30 +0200 Received: from sc8-sf-list1-new.sourceforge.net (sc8-sf-list1-new-b.sourceforge.net [10.3.1.93]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id 540BF132EF; Thu, 2 Aug 2007 08:38:28 -0700 (PDT) Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] helo=mail.sourceforge.net) by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) id 1IGcks-0007Xs-Kn for linux-usb-devel@lists.sourceforge.net; Thu, 02 Aug 2007 08:38:26 -0700 Received: from [89.109.1.177] (helo=89-109-1-177.uac1.unlim.mts-nn.ru) by mail.sourceforge.net with smtp (Exim 4.44) id 1IGckq-0005pL-My for linux-usb-devel@lists.sourceforge.net; Thu, 02 Aug 2007 08:38:26 -0700 Received: from je.nznr ([210.207.31.160]) by 89-109-1-177.uac1.unlim.mts-nn.ru with Microsoft SMTPSVC(6.0.3790.0); Thu, 2 Aug 2007 19:38:16 +0400 Message-ID: [EMAIL PROTECTED] From: 1LoveCards.Com [EMAIL PROTECTED] To: linux-usb-devel@lists.sourceforge.net Date: Thu, 2 Aug 2007 19:38:16 +0400 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4920.2300 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 X-Spam-Score: 0.1 (/) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=addgroup_id=1atid=21 0.1 NORMAL_HTTP_TO_IP URI: Uses a dotted-decimal IP address in URL Subject: [linux-usb-devel] You've received an ecard from a Class mate! X-BeenThere: linux-usb-devel@lists.sourceforge.net X-Mailman-Version: 2.1.8 Precedence: list List-Id: linux-usb-devel.lists.sourceforge.net List-Unsubscribe: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel, mailto:[EMAIL PROTECTED] List-Archive: http://sourceforge.net/mailarchive/forum.php?forum_name=linux-usb-devel List-Post: mailto:linux-usb-devel@lists.sourceforge.net List-Help: mailto:[EMAIL PROTECTED] List-Subscribe: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel, mailto:[EMAIL PROTECTED] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: [EMAIL PROTECTED] Errors-To: [EMAIL PROTECTED] - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [patch 2.6.23-rc1-git 5/6] file storage gadget cleanups
On Thursday 02 August 2007, Alan Stern wrote: On Thu, 2 Aug 2007, David Brownell wrote: Clean up the file storage gadget, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the DEBUG (from Kconfig+Makefile) and VERBOSE_DEBUG conventions. - Remove some sparse warnings (it still dislikes the __user annotations) This gave only a minor object code shrinkage. I'd rather expect to see a minor increase in object code size, since a few data structures and lines of code are now compiled in that previously would have been #ifdef'ed out. GCC dead code optimization ensures they don't cluter up the generated object code. Briefly, in; static struct ... somedata = { ... }; static void fn1(...) { accesses somedata } void fn2(...) { ... if (0) fn1(...); ... } then fn2() will be in the object, but not fn1 or somedata. Why do you think the code size shrank? In this case, because runtime is this an OTG gadget? test was replaced by a compile time of course not, it couldn't be result ... so GCC could detect the dead code. --- g26.orig/drivers/usb/gadget/file_storage.c 2007-08-01 23:16:10.0 -0700 +++ g26/drivers/usb/gadget/file_storage.c 2007-08-01 23:29:00.0 -0700 @@ -289,57 +275,51 @@ MODULE_LICENSE(Dual BSD/GPL); /*-*/ -#define xprintk(f,level,fmt,args...) \ - dev_printk(level , (f)-gadget-dev , fmt , ## args) #define yprintk(l,level,fmt,args...) \ dev_printk(level , (l)-dev , fmt , ## args) Is there any particular reason you expanded xprintk inline but not yprintk? Because I was doing a quick conversion, copy/paste from other code where the xprintk thing got removed. You're right that there's still additional cleanup that can be done. Despite these questions, ACK. Thanks. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] Can't unload uhci_hcd module with 2.6.22 -- also oops
On Thu, 2 Aug 2007 10:42:14 -0400 (EDT) Alan Stern [EMAIL PROTECTED] wrote: And here it is. You can remove the earlier diagnostic patches; this one by itself should fix everything. This solves the problem. I can load and unload the modules without any error. Thanks to all for your attention in this matter. AK - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] USB BIOS early handoff only when the we the driver is configured
On Thu, Aug 02, 2007 at 10:32:21AM -0400, Alan Stern wrote: On Thu, 2 Aug 2007, David Engraf wrote: This would be solution too, but what if someone uses the uhci controller and don't want the ehci. So a single Kconfig flag wouldn't be enough, we have to add 3 flags for uchi, ohci and ehci. I think this maybe a little bit difficult when configuring the kernel. The best solution would be when we could use the CONFIG_USB__HCD flag, but it seems that some hardware has problems when we disable the handoff and let the BIOS control the usb controller. Do you know any of this hardware? The email messages are hidden in the depths of the linux-usb-devel archives. Maybe you can find them by checking the Git history for drivers/usb/host/pci-quirks.c, finding the dates for patches that affected the handoff code, and then searching through the archives near those dates. IIRC the problems arose on some MIPS machines. And I don't think the problem involved letting the firmware manage the USB controller; I think the problem came when the controller driver tried to do the handoff later on. It wasn't just MIPS. IBM has a very popular blade system that has huge issues with this, and I think there are some other IBM systems based on the same BIOS that also do bad things if we don't grab the USB controller away from the BIOS as soon as possible (nasty interrupt and other messes happen...) thanks, greg k-h - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [PATCH] cdc-acm: fix sysfs attribute registration bug
This patch (as950) fixes a bug in the cdc-acm driver. It doesn't keep track of which interface (control or data) the sysfs attributes get registered for, and as a result, during disconnect it will sometimes attempt to remove the attributes from the wrong interface. The left-over attributes can cause a crash later on, particularly if the driver module has been unloaded. Signed-off-by: Alan Stern [EMAIL PROTECTED] CC: Oliver Neukum [EMAIL PROTECTED] --- The same patch applies with a small offset to 2.6.22. Although the bug has been present all along, only the recent changes to the sysfs infrastructure have caused it to manifest. Alan Stern Index: usb-2.6/drivers/usb/class/cdc-acm.c === --- usb-2.6.orig/drivers/usb/class/cdc-acm.c +++ usb-2.6/drivers/usb/class/cdc-acm.c @@ -921,6 +921,10 @@ skip_normal_probe: return -EINVAL; } } + + /* Accept probe requests only for the control interface */ + if (intf != control_interface) + return -ENODEV; if (usb_interface_claimed(data_interface)) { /* valid in this context */ dev_dbg(intf-dev,The data interface isn't available); @@ -1109,10 +1113,12 @@ static void acm_disconnect(struct usb_in return; } if (acm-country_codes){ - device_remove_file(intf-dev, dev_attr_wCountryCodes); - device_remove_file(intf-dev, dev_attr_iCountryCodeRelDate); + device_remove_file(acm-control-dev, + dev_attr_wCountryCodes); + device_remove_file(acm-control-dev, + dev_attr_iCountryCodeRelDate); } - device_remove_file(intf-dev, dev_attr_bmCapabilities); + device_remove_file(acm-control-dev, dev_attr_bmCapabilities); acm-dev = NULL; usb_set_intfdata(acm-control, NULL); usb_set_intfdata(acm-data, NULL); - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] cdc-acm: fix sysfs attribute registration bug
Am Donnerstag 02 August 2007 schrieb Alan Stern: This patch (as950) fixes a bug in the cdc-acm driver. It doesn't keep track of which interface (control or data) the sysfs attributes get registered for, and as a result, during disconnect it will sometimes attempt to remove the attributes from the wrong interface. The left-over attributes can cause a crash later on, particularly if the driver module has been unloaded. Signed-off-by: Alan Stern [EMAIL PROTECTED] Acked-by: Oliver Neukum [EMAIL PROTECTED] - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [PATCH 0/3] USB core URB handling updates
Greg: The following short patch series includes the following: Various cleanups suggested for the previous patches; Rework the spinlock usage in the root-hub URB code; Separate out endpoint queue management and transfer-buffer DMA mapping into their own subroutines. These are all relatively small changes, although that might not be evident from looking at the patch files. Still to come is a somewhat larger change, in which the new endpoint queue routines are called from the HCDs instead of from usbcore. I have the changes broken up by driver -- one for each HCD plus one for the core -- so they can be applied independently. The intermediate stages will compile (with warnings) but they won't run correctly. So what's the best way to submit that stuff? Since the individual patches all affect different files, it would be easy to concatenate them into a single large (not huge, about 50 KB) patch. Or would it be better to submit them as 9 smaller patches? Alan Stern P.S.: Pete, I see what you mean about simplifying usbmon. The part for accessing setup-packet DMA buffers could be removed completely. In addition there seems to be a fair amount of duplicated code, but perhaps you prefer to keep it that way because of the user interface requirements. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [PATCH 1/3] USB: cleanup for previous patches
This patch (as951) cleans up a few loose ends from earlier patches. Redundant checks for non-NULL urb-dev are removed, as are checks of urb-dev-bus (which can never be NULL). Conversely, a check for non-NULL urb-ep is added to the unlink paths. A homegrown round-down-to-power-of-2 loop is simplified by using the ilog2 routine. The comparison in usb_urb_dir_in() is made more transparent. Signed-off-by: Alan Stern [EMAIL PROTECTED] --- Index: usb-2.6/drivers/usb/core/hcd.c === --- usb-2.6.orig/drivers/usb/core/hcd.c +++ usb-2.6/drivers/usb/core/hcd.c @@ -1141,11 +1141,6 @@ int usb_hcd_unlink_urb (struct urb *urb, struct list_head*tmp; int retval; - if (!urb) - return -EINVAL; - if (!urb-dev || !urb-dev-bus) - return -ENODEV; - /* * we contend for urb-status with the hcd core, * which changes it while returning the urb. Index: usb-2.6/drivers/usb/core/urb.c === --- usb-2.6.orig/drivers/usb/core/urb.c +++ usb-2.6/drivers/usb/core/urb.c @@ -3,6 +3,7 @@ #include linux/bitops.h #include linux/slab.h #include linux/init.h +#include linux/log2.h #include linux/usb.h #include linux/wait.h #include hcd.h @@ -441,10 +442,8 @@ int usb_submit_urb(struct urb *urb, gfp_ default: return -EINVAL; } - /* power of two? */ - while (max urb-interval) - max = 1; - urb-interval = max; + /* Round down to a power of 2, no more than max */ + urb-interval = min(max, 1 ilog2(urb-interval)); } return usb_hcd_submit_urb(urb, mem_flags); @@ -513,8 +512,10 @@ int usb_unlink_urb(struct urb *urb) { if (!urb) return -EINVAL; - if (!(urb-dev urb-dev-bus)) + if (!urb-dev) return -ENODEV; + if (!urb-ep) + return -EIDRM; return usb_hcd_unlink_urb(urb, -ECONNRESET); } @@ -541,7 +542,7 @@ int usb_unlink_urb(struct urb *urb) void usb_kill_urb(struct urb *urb) { might_sleep(); - if (!(urb urb-dev urb-dev-bus)) + if (!(urb urb-dev urb-ep)) return; spin_lock_irq(urb-lock); ++urb-reject; Index: usb-2.6/include/linux/usb.h === --- usb-2.6.orig/include/linux/usb.h +++ usb-2.6/include/linux/usb.h @@ -1402,7 +1402,7 @@ extern int usb_wait_anchor_empty_timeout */ static inline int usb_urb_dir_in(struct urb *urb) { - return (urb-transfer_flags URB_DIR_MASK) != URB_DIR_OUT; + return (urb-transfer_flags URB_DIR_MASK) == URB_DIR_IN; } /** - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [PATCH 2/3] USB: update spinlock usage for root-hub URBs
This patch (as952) adjusts the spinlock usage in the root-hub emulation part of usbcore, to make it match more closely the pattern used by regular host controller drivers. To wit: The private lock (usb_hcd_root_hub_lock) is held throughout the important parts, and it is dropped temporarily without re-enabling interrupts around the call to usb_hcd_giveback_urb(). A nice side effect is that the code now avoids calling local_irq_save(), thereby becoming more RT-friendly. Signed-off-by: Alan Stern [EMAIL PROTECTED] --- Index: usb-2.6/drivers/usb/core/hcd.c === --- usb-2.6.orig/drivers/usb/core/hcd.c +++ usb-2.6/drivers/usb/core/hcd.c @@ -356,10 +356,11 @@ static int rh_call_control (struct usb_h const u8*bufp = tbuf; int len = 0; int patch_wakeup = 0; - unsigned long flags; int status = 0; int n; + might_sleep(); + cmd = (struct usb_ctrlrequest *) urb-setup_packet; typeReq = (cmd-bRequestType 8) | cmd-bRequest; wValue = le16_to_cpu (cmd-wValue); @@ -523,13 +524,21 @@ error: } /* any errors get returned through the urb completion */ - local_irq_save (flags); - spin_lock (urb-lock); + spin_lock_irq(hcd_root_hub_lock); + spin_lock(urb-lock); if (urb-status == -EINPROGRESS) urb-status = status; - spin_unlock (urb-lock); - usb_hcd_giveback_urb (hcd, urb); - local_irq_restore (flags); + spin_unlock(urb-lock); + + /* This peculiar use of spinlocks echoes what real HC drivers do. +* Avoiding calls to local_irq_disable/enable makes the code +* RT-friendly. +*/ + spin_unlock(hcd_root_hub_lock); + usb_hcd_giveback_urb(hcd, urb); + spin_lock(hcd_root_hub_lock); + + spin_unlock_irq(hcd_root_hub_lock); return 0; } @@ -559,8 +568,7 @@ void usb_hcd_poll_rh_status(struct usb_h if (length 0) { /* try to complete the status urb */ - local_irq_save (flags); - spin_lock(hcd_root_hub_lock); + spin_lock_irqsave(hcd_root_hub_lock, flags); urb = hcd-status_urb; if (urb) { spin_lock(urb-lock); @@ -574,16 +582,16 @@ void usb_hcd_poll_rh_status(struct usb_h } else /* urb has been unlinked */ length = 0; spin_unlock(urb-lock); + + spin_unlock(hcd_root_hub_lock); + usb_hcd_giveback_urb(hcd, urb); + spin_lock(hcd_root_hub_lock); } else length = 0; - spin_unlock(hcd_root_hub_lock); - /* local irqs are always blocked in completions */ - if (length 0) - usb_hcd_giveback_urb (hcd, urb); - else + if (length = 0) hcd-poll_pending = 1; - local_irq_restore (flags); + spin_unlock_irqrestore(hcd_root_hub_lock, flags); } /* The USB 2.0 spec says 256 ms. This is close enough and won't @@ -651,25 +659,23 @@ static int usb_rh_urb_dequeue (struct us { unsigned long flags; + spin_lock_irqsave(hcd_root_hub_lock, flags); if (usb_endpoint_num(urb-ep-desc) == 0) {/* Control URB */ ; /* Do nothing */ } else {/* Status URB */ if (!hcd-uses_new_polling) del_timer (hcd-rh_timer); - local_irq_save (flags); - spin_lock (hcd_root_hub_lock); if (urb == hcd-status_urb) { hcd-status_urb = NULL; urb-hcpriv = NULL; - } else - urb = NULL; /* wasn't fully queued */ - spin_unlock (hcd_root_hub_lock); - if (urb) - usb_hcd_giveback_urb (hcd, urb); - local_irq_restore (flags); - } + spin_unlock(hcd_root_hub_lock); + usb_hcd_giveback_urb(hcd, urb); + spin_lock(hcd_root_hub_lock); + } + } + spin_unlock_irqrestore(hcd_root_hub_lock, flags); return 0; } - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at:
[linux-usb-devel] [PATCH 3/3] USB: separate out endpoint queue management and DMA mapping routines
This patch (as953) separates out three key portions from usb_hcd_submit_urb(), usb_hcd_unlink_urb(), and usb_hcd_giveback_urb() and puts them in separate functions of their own. In the next patch, these functions will be called directly by host controller drivers while holding their private spinlocks, which will remove the possibility of some unpleasant races. The code responsible for mapping and unmapping DMA buffers is also placed into a couple of separate subroutines, for the sake of cleanliness and consistency. Signed-off-by: Alan Stern [EMAIL PROTECTED] Index: usb-2.6/drivers/usb/core/hcd.c === --- usb-2.6.orig/drivers/usb/core/hcd.c +++ usb-2.6/drivers/usb/core/hcd.c @@ -981,99 +981,117 @@ EXPORT_SYMBOL (usb_calc_bus_time); /*-*/ -static void urb_unlink(struct usb_hcd *hcd, struct urb *urb) +static int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb) { - unsigned long flags; + unsigned long flags; + int rc = 0; - /* clear all state linking urb to this dev (and hcd) */ spin_lock_irqsave(hcd_urb_list_lock, flags); - list_del_init (urb-urb_list); - spin_unlock_irqrestore(hcd_urb_list_lock, flags); - if (hcd-self.uses_dma !is_root_hub(urb-dev)) { - if (usb_endpoint_xfer_control(urb-ep-desc) -!(urb-transfer_flags URB_NO_SETUP_DMA_MAP)) - dma_unmap_single (hcd-self.controller, urb-setup_dma, - sizeof (struct usb_ctrlrequest), - DMA_TO_DEVICE); - if (urb-transfer_buffer_length != 0 -!(urb-transfer_flags URB_NO_TRANSFER_DMA_MAP)) - dma_unmap_single (hcd-self.controller, - urb-transfer_dma, - urb-transfer_buffer_length, - usb_urb_dir_in(urb) - ? DMA_FROM_DEVICE - : DMA_TO_DEVICE); + /* Check that the URB isn't being killed */ + if (unlikely(urb-reject)) { + rc = -EPERM; + goto done; } -} -/* may be called in any context with a valid urb-dev usecount - * caller surrenders ownership of urb - * expects usb_submit_urb() to have sanity checked and conditioned all - * inputs in the urb - */ -int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) -{ - int status; - struct usb_hcd *hcd = bus_to_hcd(urb-dev-bus); - unsigned long flags; - - if (!hcd) - return -ENODEV; - - usbmon_urb_submit(hcd-self, urb); + if (unlikely(!urb-ep-enabled)) { + rc = -ENOENT; + goto done; + } /* -* Atomically queue the urb, first to our records, then to the HCD. -* Access to urb-status is controlled by urb-lock ... changes on -* i/o completion (normal or fault) or unlinking. +* Check the host controller's state and add the URB to the +* endpoint's queue. */ - - // FIXME: verify that quiescing hc works right (RH cleans up) - - spin_lock_irqsave(hcd_urb_list_lock, flags); - if (unlikely(!urb-ep-enabled)) - status = -ENOENT; - else if (unlikely (urb-reject)) - status = -EPERM; - else switch (hcd-state) { + switch (hcd-state) { case HC_STATE_RUNNING: case HC_STATE_RESUMING: - list_add_tail (urb-urb_list, urb-ep-urb_list); - status = 0; + list_add_tail(urb-urb_list, urb-ep-urb_list); break; default: - status = -ESHUTDOWN; - break; + rc = -ESHUTDOWN; + goto done; } + done: spin_unlock_irqrestore(hcd_urb_list_lock, flags); - if (status) { - INIT_LIST_HEAD (urb-urb_list); - usbmon_urb_submit_error(hcd-self, urb, status); - return status; - } + return rc; +} - /* increment urb's reference count as part of giving it to the HCD -* (which now controls it). HCD guarantees that it either returns -* an error or calls giveback(), but not both. +static int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, + int status) +{ + unsigned long flags; + struct list_head*tmp; + int rc = 0; + + /* +* we contend for urb-status with the hcd core, +* which changes it while returning the urb. +* +* Caller guaranteed that the urb pointer hasn't been freed, and +* that it was submitted. But
Re: [linux-usb-devel] [patch 2.6.23-rc1-git 6/6] gadget zero cleanups
Clean up gadget zero, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the VERBOSE_DEBUG convention - Some whitespace fixes. - A few comment updates - Plus a few other small cleanups: don't pass gfp_t around when it's always going to be GFP_ATOMIC, and do static init of serial number. Also go to straight GPL; there's no real point in dual licensing this stuff any more. Signed-off-by: David Brownell [EMAIL PROTECTED] --- ... same as previous version except for cosmetic changes, notably one typo fixed. drivers/usb/gadget/zero.c | 239 ++ 1 file changed, 97 insertions(+), 142 deletions(-) --- g26.orig/drivers/usb/gadget/zero.c 2007-08-01 23:30:07.0 -0700 +++ g26/drivers/usb/gadget/zero.c 2007-08-02 12:18:24.0 -0700 @@ -1,38 +1,22 @@ /* * zero.c -- Gadget Zero, for USB development * - * Copyright (C) 2003-2004 David Brownell + * Copyright (C) 2003-2007 David Brownell * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - *notice, this list of conditions, and the following disclaimer, - *without modification. - * 2. Redistributions in binary form must reproduce the above copyright - *notice, this list of conditions and the following disclaimer in the - *documentation and/or other materials provided with the distribution. - * 3. The names of the above-listed copyright holders may not be used - *to endorse or promote products derived from this software without - *specific prior written permission. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License (GPL) as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS - * IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -57,30 +41,18 @@ * Many drivers will only have one configuration, letting them be much * simpler if they also don't support high speed operation (like this * driver does). + * + * Why is *this* driver using two configurations, rather than setting up + * two interfaces with different functions? To help verify that multiple + * configuration infrastucture is working correctly; also, so that it can + * work with low capability USB controllers without four bulk endpoints. */ -#define DEBUG 1 -// #define VERBOSE +/* #define VERBOSE_DEBUG */ -#include linux/module.h #include linux/kernel.h -#include linux/delay.h -#include linux/ioport.h -#include linux/slab.h -#include linux/errno.h -#include linux/init.h -#include linux/timer.h -#include linux/list.h -#include linux/interrupt.h #include linux/utsname.h #include linux/device.h -#include linux/moduleparam.h - -#include asm/byteorder.h -#include asm/io.h -#include asm/irq.h -#include asm/system.h -#include asm/unaligned.h #include linux/usb/ch9.h #include linux/usb_gadget.h @@ -90,7 +62,7 @@ /*-*/ -#define DRIVER_VERSION St Patrick's Day 2004 +#define DRIVER_VERSION Lughnasadh, 2007 static const char shortname [] = zero; static const char longname [] = Gadget Zero; @@ -131,30 +103,16 @@ struct zero_dev { struct
[linux-usb-devel] patch usb-add-direction-bit-to-urb-transfer_flags.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 3/7] USB: add direction bit to urb-transfer_flags to my gregkh-2.6 tree. Its filename is usb-add-direction-bit-to-urb-transfer_flags.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:03:55 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:06:16 -0400 (EDT) Subject: [PATCH 3/7] USB: add direction bit to urb-transfer_flags To: Greg KH [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as945) adds a bit to urb-transfer_flags for recording the direction of the URB. The bit is set/cleared automatically in usb_submit_urb() so drivers don't have to worry about it (although as a result, it isn't valid until the URB has been submitted). Inline routines are added for easily checking an URB's direction. They replace calls to usb_pipein in the DMA-mapping parts of hcd.c. For non-control endpoints, the direction is determined directly from the endpoint descriptor. However control endpoints are bi-directional; for them the direction is determined from the bRequestType byte and the wLength value in the setup packet. Signed-off-by: Alan Stern [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/core/hcd.c |4 ++-- drivers/usb/core/urb.c | 18 -- include/linux/usb.h| 30 ++ 3 files changed, 48 insertions(+), 4 deletions(-) --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -928,7 +928,7 @@ static void urb_unlink(struct usb_hcd *h dma_unmap_single (hcd-self.controller, urb-transfer_dma, urb-transfer_buffer_length, - usb_pipein (urb-pipe) + usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } @@ -1014,7 +1014,7 @@ int usb_hcd_submit_urb (struct urb *urb, hcd-self.controller, urb-transfer_buffer, urb-transfer_buffer_length, - usb_pipein (urb-pipe) + usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -309,7 +309,21 @@ int usb_submit_urb(struct urb *urb, gfp_ * and don't need to duplicate tests */ xfertype = usb_endpoint_type(ep-desc); - is_out = usb_pipeout(urb-pipe); + if (xfertype == USB_ENDPOINT_XFER_CONTROL) { + struct usb_ctrlrequest *setup = + (struct usb_ctrlrequest *) urb-setup_packet; + + if (!setup) + return -ENOEXEC; + is_out = !(setup-bRequestType USB_DIR_IN) || + !setup-wLength; + } else { + is_out = usb_endpoint_dir_out(ep-desc); + } + + /* Cache the direction for later use */ + urb-transfer_flags = (urb-transfer_flags ~URB_DIR_MASK) | + (is_out ? URB_DIR_OUT : URB_DIR_IN); if (xfertype != USB_ENDPOINT_XFER_CONTROL dev-state USB_STATE_CONFIGURED) @@ -363,7 +377,7 @@ int usb_submit_urb(struct urb *urb, gfp_ /* enforce simple/standard policy */ allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | - URB_NO_INTERRUPT); + URB_NO_INTERRUPT | URB_DIR_MASK); switch (xfertype) { case USB_ENDPOINT_XFER_BULK: if (is_out) --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1021,6 +1021,8 @@ extern int usb_disabled(void); /* * urb-transfer_flags: + * + * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb(). */ #define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ #define URB_ISO_ASAP 0x0002 /* iso-only, urb-start_frame @@ -1033,6 +1035,10 @@ extern int usb_disabled(void); * needed */ #define URB_FREE_BUFFER0x0100 /* Free transfer buffer with the URB */ +#define URB_DIR_IN 0x0200 /* Transfer from device to host */ +#define URB_DIR_OUT0 +#define URB_DIR_MASK URB_DIR_IN + struct usb_iso_packet_descriptor { unsigned int offset; unsigned int length;/* expected length */ @@ -1380,6 +1386,30 @@ extern void usb_unanchor_urb(struct urb extern int usb_wait_anchor_empty_timeout(struct
[linux-usb-devel] patch usb-add-ep-enable.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 2/7] USB: add ep-enable to my gregkh-2.6 tree. Its filename is usb-add-ep-enable.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:03:09 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:05:22 -0400 (EDT) Subject: [PATCH 2/7] USB: add ep-enable To: Greg KH [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as944) adds an explicit enabled field to the usb_host_endpoint structure and uses it in place of the current mechanism. This is merely a time-space tradeoff; it makes checking whether URBs may be submitted to an endpoint simpler. The existing mechanism is efficient when converting urb-pipe to an endpoint pointer, but it's not so efficient when urb-ep is used instead. As a side effect, the procedure for enabling an endpoint is now a little more complicated. The ad-hoc inline code in usb.c and hub.c for enabling ep0 is now replaced with calls to usb_enable_endpoint, which is no longer static. Signed-off-by: Alan Stern [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/core/hcd.c |5 + drivers/usb/core/hub.c |2 +- drivers/usb/core/message.c | 22 +++--- drivers/usb/core/usb.c |2 +- drivers/usb/core/usb.h |2 ++ include/linux/usb.h|2 ++ 6 files changed, 18 insertions(+), 17 deletions(-) --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -943,7 +943,6 @@ int usb_hcd_submit_urb (struct urb *urb, { int status; struct usb_hcd *hcd = bus_to_hcd(urb-dev-bus); - struct usb_host_endpoint *ep; unsigned long flags; if (!hcd) @@ -960,9 +959,7 @@ int usb_hcd_submit_urb (struct urb *urb, // FIXME: verify that quiescing hc works right (RH cleans up) spin_lock_irqsave(hcd_urb_list_lock, flags); - ep = (usb_pipein(urb-pipe) ? urb-dev-ep_in : urb-dev-ep_out) - [usb_pipeendpoint(urb-pipe)]; - if (unlikely(ep != urb-ep)) + if (unlikely(!urb-ep-enabled)) status = -ENOENT; else if (unlikely (urb-reject)) status = -EPERM; --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1996,7 +1996,7 @@ static void ep0_reinit(struct usb_device { usb_disable_endpoint(udev, 0 + USB_DIR_IN); usb_disable_endpoint(udev, 0 + USB_DIR_OUT); - udev-ep_in[0] = udev-ep_out[0] = udev-ep0; + usb_enable_endpoint(udev, udev-ep0); } #define usb_sndaddr0pipe() (PIPE_CONTROL 30) --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1013,8 +1013,10 @@ void usb_disable_endpoint(struct usb_dev ep = dev-ep_in[epnum]; dev-ep_in[epnum] = NULL; } - if (ep dev-bus) + if (ep) { + ep-enabled = 0; usb_hcd_endpoint_disable(dev, ep); + } } /** @@ -1096,23 +1098,21 @@ void usb_disable_device(struct usb_devic * Resets the endpoint toggle, and sets dev-ep_{in,out} pointers. * For control endpoints, both the input and output sides are handled. */ -static void -usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) +void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) { - unsigned int epaddr = ep-desc.bEndpointAddress; - unsigned int epnum = epaddr USB_ENDPOINT_NUMBER_MASK; - int is_control; - - is_control = ((ep-desc.bmAttributes USB_ENDPOINT_XFERTYPE_MASK) - == USB_ENDPOINT_XFER_CONTROL); - if (usb_endpoint_out(epaddr) || is_control) { + int epnum = usb_endpoint_num(ep-desc); + int is_out = usb_endpoint_dir_out(ep-desc); + int is_control = usb_endpoint_xfer_control(ep-desc); + + if (is_out || is_control) { usb_settoggle(dev, epnum, 1, 0); dev-ep_out[epnum] = ep; } - if (!usb_endpoint_out(epaddr) || is_control) { + if (!is_out || is_control) { usb_settoggle(dev, epnum, 0, 0); dev-ep_in[epnum] = ep; } + ep-enabled = 1; } /* --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -260,7 +260,7 @@ usb_alloc_dev(struct usb_device *parent, dev-ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; dev-ep0.desc.bDescriptorType = USB_DT_ENDPOINT; /* ep0 maxpacket comes later, from device descriptor */ - dev-ep_in[0] = dev-ep_out[0] = dev-ep0; + usb_enable_endpoint(dev, dev-ep0); /* Save readable and stable topology id, distinguishing devices * by location for diagnostics, tools, driver model, etc. The --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -8,6 +8,8 @@
[linux-usb-devel] patch usb-add-urb-ep.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 1/7] USB: add urb-ep to my gregkh-2.6 tree. Its filename is usb-add-urb-ep.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:02:53 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:04:37 -0400 (EDT) Subject: [PATCH 1/7] USB: add urb-ep To: Greg KH [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as943) prepares the way for eliminating urb-pipe by introducing an endpoint pointer into struct urb. For now urb-ep is set by usb_submit_urb() from the pipe value; eventually drivers will set it themselves and we will remove urb-pipe completely. The patch also adds new inline routines to retrieve an endpoint descriptor's number and transfer type, essentially as replacements for usb_pipeendpoint and usb_pipetype. usb_submit_urb(), usb_hcd_submit_urb(), and usb_hcd_unlink_urb() are converted to use the new field and new routines. Other parts of usbcore will be converted in later patches. Signed-off-by: Alan Stern [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/core/hcd.c | 13 +++-- drivers/usb/core/urb.c | 65 ++--- include/linux/usb.h| 26 +++ 3 files changed, 65 insertions(+), 39 deletions(-) --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -962,14 +962,14 @@ int usb_hcd_submit_urb (struct urb *urb, spin_lock_irqsave(hcd_urb_list_lock, flags); ep = (usb_pipein(urb-pipe) ? urb-dev-ep_in : urb-dev-ep_out) [usb_pipeendpoint(urb-pipe)]; - if (unlikely (!ep)) + if (unlikely(ep != urb-ep)) status = -ENOENT; else if (unlikely (urb-reject)) status = -EPERM; else switch (hcd-state) { case HC_STATE_RUNNING: case HC_STATE_RESUMING: - list_add_tail (urb-urb_list, ep-urb_list); + list_add_tail (urb-urb_list, urb-ep-urb_list); status = 0; break; default: @@ -1022,7 +1022,7 @@ int usb_hcd_submit_urb (struct urb *urb, : DMA_TO_DEVICE); } - status = hcd-driver-urb_enqueue (hcd, ep, urb, mem_flags); + status = hcd-driver-urb_enqueue (hcd, urb-ep, urb, mem_flags); done: if (unlikely (status)) { urb_unlink(hcd, urb); @@ -1071,7 +1071,6 @@ unlink1 (struct usb_hcd *hcd, struct urb */ int usb_hcd_unlink_urb (struct urb *urb, int status) { - struct usb_host_endpoint*ep; struct usb_hcd *hcd = NULL; struct device *sys = NULL; unsigned long flags; @@ -1082,10 +1081,6 @@ int usb_hcd_unlink_urb (struct urb *urb, return -EINVAL; if (!urb-dev || !urb-dev-bus) return -ENODEV; - ep = (usb_pipein(urb-pipe) ? urb-dev-ep_in : urb-dev-ep_out) - [usb_pipeendpoint(urb-pipe)]; - if (!ep) - return -ENODEV; /* * we contend for urb-status with the hcd core, @@ -1109,7 +1104,7 @@ int usb_hcd_unlink_urb (struct urb *urb, } /* insist the urb is still queued */ - list_for_each(tmp, ep-urb_list) { + list_for_each(tmp, urb-ep-urb_list) { if (tmp == urb-urb_list) break; } --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -277,9 +277,10 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); */ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) { - int pipe, temp, max; - struct usb_device *dev; - int is_out; + int xfertype, max; + struct usb_device *dev; + struct usb_host_endpoint*ep; + int is_out; if (!urb || urb-hcpriv || !urb-complete) return -EINVAL; @@ -291,30 +292,34 @@ int usb_submit_urb(struct urb *urb, gfp_ || dev-state == USB_STATE_SUSPENDED) return -EHOSTUNREACH; + /* For now, get the endpoint from the pipe. Eventually drivers +* will be required to set urb-ep directly and we will eliminate +* urb-pipe. +*/ + ep = (usb_pipein(urb-pipe) ? dev-ep_in : dev-ep_out) + [usb_pipeendpoint(urb-pipe)]; + if (!ep) + return -ENOENT; + + urb-ep = ep; urb-status = -EINPROGRESS; urb-actual_length = 0; /* Lots of sanity checks, so HCDs can rely on clean data * and don't need to duplicate tests */ - pipe = urb-pipe; - temp =
[linux-usb-devel] patch usb-address-0-handling-during-device-initialization.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 5/7] USB: address-0 handling during device initialization to my gregkh-2.6 tree. Its filename is usb-address-0-handling-during-device-initialization.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:04:43 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:08:43 -0400 (EDT) Subject: [PATCH 5/7] USB: address-0 handling during device initialization To: Greg KH [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as947) changes the device initialization and enumeration code in hub.c; now udev-devnum will be set to 0 while the device is being accessed at address 0. Until now this wasn't needed because the address value was passed as part of urb-pipe; without that field the device address must be stored elsewhere. Signed-off-by: Alan Stern [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/core/hub.c | 21 + drivers/usb/core/urb.c |4 +--- 2 files changed, 14 insertions(+), 11 deletions(-) --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1479,6 +1479,7 @@ static int hub_port_reset(struct usb_hub case 0: /* TRSTRCY = 10 ms; plus some extra */ msleep(10 + 40); + udev-devnum = 0; /* Device now at address 0 */ /* FALL THROUGH */ case -ENOTCONN: case -ENODEV: @@ -2002,20 +2003,21 @@ static void ep0_reinit(struct usb_device #define usb_sndaddr0pipe() (PIPE_CONTROL 30) #define usb_rcvaddr0pipe() ((PIPE_CONTROL 30) | USB_DIR_IN) -static int hub_set_address(struct usb_device *udev) +static int hub_set_address(struct usb_device *udev, int devnum) { int retval; - if (udev-devnum == 0) + if (devnum = 1) return -EINVAL; if (udev-state == USB_STATE_ADDRESS) return 0; if (udev-state != USB_STATE_DEFAULT) return -EINVAL; retval = usb_control_msg(udev, usb_sndaddr0pipe(), - USB_REQ_SET_ADDRESS, 0, udev-devnum, 0, + USB_REQ_SET_ADDRESS, 0, devnum, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); if (retval == 0) { + udev-devnum = devnum; /* Device now using proper address */ usb_set_device_state(udev, USB_STATE_ADDRESS); ep0_reinit(udev); } @@ -2042,6 +2044,7 @@ hub_port_init (struct usb_hub *hub, stru unsigneddelay = HUB_SHORT_RESET_TIME; enum usb_device_speed oldspeed = udev-speed; char*speed, *type; + int devnum = udev-devnum; /* root hub ports have a slightly longer reset period * (from USB 2.0 spec, section 7.1.7.5) @@ -2071,7 +2074,7 @@ hub_port_init (struct usb_hub *hub, stru goto fail; } oldspeed = udev-speed; - + /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... * it's fixed size except for full speed devices. * For Wireless USB devices, ep0 max packet is always 512 (tho @@ -2112,7 +2115,7 @@ hub_port_init (struct usb_hub *hub, stru dev_info (udev-dev, %s %s speed %sUSB device using %s and address %d\n, (udev-config) ? reset : new, speed, type, - udev-bus-controller-driver-name, udev-devnum); + udev-bus-controller-driver-name, devnum); /* Set up TT records, if needed */ if (hdev-tt) { @@ -2199,7 +2202,7 @@ hub_port_init (struct usb_hub *hub, stru } for (j = 0; j SET_ADDRESS_TRIES; ++j) { - retval = hub_set_address(udev); + retval = hub_set_address(udev, devnum); if (retval = 0) break; msleep(200); @@ -2207,7 +2210,7 @@ hub_port_init (struct usb_hub *hub, stru if (retval 0) { dev_err(udev-dev, device not accepting address %d, error %d\n, - udev-devnum, retval); + devnum, retval); goto fail; } @@ -2260,8 +2263,10 @@ hub_port_init (struct usb_hub *hub, stru retval = 0; fail: - if (retval) + if (retval) { hub_port_disable(hub, port1, 0); + udev-devnum = devnum; /* for disconnect processing */ + } mutex_unlock(usb_address0_mutex); return retval; } --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -284,9 +284,7 @@ int usb_submit_urb(struct urb
[linux-usb-devel] patch usb-avoid-urb-pipe-in-usbfs.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 6/7] USB: avoid urb-pipe in usbfs to my gregkh-2.6 tree. Its filename is usb-avoid-urb-pipe-in-usbfs.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:05:17 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:09:28 -0400 (EDT) Subject: [PATCH 6/7] USB: avoid urb-pipe in usbfs To: Greg KH [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as948) removes most of the references to urb-pipe from the usbfs routines in devio.c. The one tricky aspect is in snoop_urb(), which can be called before the URB is submitted and which uses usb_urb_dir_in(). For this to work properly, the URB's direction flag must be set manually in proc_do_submiturb(). The patch also fixes a minor bug; the wValue, wIndex, and wLength fields were snooped in proc_do_submiturb() without conversion from le16 to CPU-byte-ordering. Signed-off-by: Alan Stern [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/core/devio.c | 69 +++ 1 file changed, 41 insertions(+), 28 deletions(-) --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -289,10 +289,8 @@ static void snoop_urb(struct urb *urb, v if (!usbfs_snoop) return; - if (urb-pipe USB_DIR_IN) - dev_info(urb-dev-dev, direction=IN\n); - else - dev_info(urb-dev-dev, direction=OUT\n); + dev_info(urb-dev-dev, direction=%s\n, + usb_urb_dir_in(urb) ? IN : OUT); dev_info(urb-dev-dev, userurb=%p\n, userurb); dev_info(urb-dev-dev, transfer_buffer_length=%d\n, urb-transfer_buffer_length); @@ -910,6 +908,7 @@ static int proc_do_submiturb(struct dev_ struct usb_ctrlrequest *dr = NULL; unsigned int u, totlen, isofrmlen; int ret, ifnum = -1; + int is_in; if (uurb-flags ~(USBDEVFS_URB_ISO_ASAP|USBDEVFS_URB_SHORT_NOT_OK| URB_NO_FSBR|URB_ZERO_PACKET)) @@ -924,16 +923,18 @@ static int proc_do_submiturb(struct dev_ if ((ret = checkintf(ps, ifnum))) return ret; } - if ((uurb-endpoint USB_ENDPOINT_DIR_MASK) != 0) - ep = ps-dev-ep_in [uurb-endpoint USB_ENDPOINT_NUMBER_MASK]; - else - ep = ps-dev-ep_out [uurb-endpoint USB_ENDPOINT_NUMBER_MASK]; + if ((uurb-endpoint USB_ENDPOINT_DIR_MASK) != 0) { + is_in = 1; + ep = ps-dev-ep_in[uurb-endpoint USB_ENDPOINT_NUMBER_MASK]; + } else { + is_in = 0; + ep = ps-dev-ep_out[uurb-endpoint USB_ENDPOINT_NUMBER_MASK]; + } if (!ep) return -ENOENT; switch(uurb-type) { case USBDEVFS_URB_TYPE_CONTROL: - if ((ep-desc.bmAttributes USB_ENDPOINT_XFERTYPE_MASK) - != USB_ENDPOINT_XFER_CONTROL) + if (!usb_endpoint_xfer_control(ep-desc)) return -EINVAL; /* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ if (uurb-buffer_length 8 || uurb-buffer_length (8 + MAX_USBFS_BUFFER_SIZE)) @@ -952,23 +953,32 @@ static int proc_do_submiturb(struct dev_ kfree(dr); return ret; } - uurb-endpoint = (uurb-endpoint ~USB_ENDPOINT_DIR_MASK) | (dr-bRequestType USB_ENDPOINT_DIR_MASK); uurb-number_of_packets = 0; uurb-buffer_length = le16_to_cpup(dr-wLength); uurb-buffer += 8; - if (!access_ok((uurb-endpoint USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb-buffer, uurb-buffer_length)) { + if ((dr-bRequestType USB_DIR_IN) uurb-buffer_length) { + is_in = 1; + uurb-endpoint |= USB_DIR_IN; + } else { + is_in = 0; + uurb-endpoint = ~USB_DIR_IN; + } + if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ, + uurb-buffer, uurb-buffer_length)) { kfree(dr); return -EFAULT; } snoop(ps-dev-dev, control urb: bRequest=%02x bRrequestType=%02x wValue=%04x wIndex=%04x wLength=%04x\n, - dr-bRequest, dr-bRequestType, dr-wValue, - dr-wIndex, dr-wLength); + dr-bRequest, dr-bRequestType, + __le16_to_cpup(dr-wValue), + __le16_to_cpup(dr-wIndex), +
[linux-usb-devel] patch usb-avoid-urb-pipe-in-usbmon.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 7/7] USB: avoid urb-pipe in usbmon to my gregkh-2.6 tree. Its filename is usb-avoid-urb-pipe-in-usbmon.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:05:40 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:10:36 -0400 (EDT) Subject: [PATCH 7/7] USB: avoid urb-pipe in usbmon To: Greg KH [EMAIL PROTECTED], Pete Zaitcev [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as949) changes the usbmon driver to use the new urb-ep field rather than urb-pipe. Signed-off-by: Alan Stern [EMAIL PROTECTED] Cc: Pete Zaitcev [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/mon/mon_bin.c | 44 ++ drivers/usb/mon/mon_main.c |4 +-- drivers/usb/mon/mon_text.c | 58 - 3 files changed, 68 insertions(+), 38 deletions(-) --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -354,7 +354,7 @@ static inline char mon_bin_get_setup(uns const struct urb *urb, char ev_type) { - if (!usb_pipecontrol(urb-pipe) || ev_type != 'S') + if (!usb_endpoint_xfer_control(urb-ep-desc) || ev_type != 'S') return '-'; if (urb-dev-bus-uses_dma @@ -410,7 +410,7 @@ static void mon_bin_event(struct mon_rea if (length = rp-b_size/5) length = rp-b_size/5; - if (usb_pipein(urb-pipe)) { + if (usb_urb_dir_in(urb)) { if (ev_type == 'S') { length = 0; data_tag = ''; @@ -440,10 +440,22 @@ static void mon_bin_event(struct mon_rea */ memset(ep, 0, PKT_SIZE); ep-type = ev_type; - ep-xfer_type = usb_pipetype(urb-pipe); - /* We use the fact that usb_pipein() returns 0x80 */ - ep-epnum = usb_pipeendpoint(urb-pipe) | usb_pipein(urb-pipe); - ep-devnum = usb_pipedevice(urb-pipe); + switch (usb_endpoint_type(urb-ep-desc)) { + case USB_ENDPOINT_XFER_CONTROL: + ep-xfer_type = PIPE_CONTROL; + break; + case USB_ENDPOINT_XFER_BULK: + ep-xfer_type = PIPE_BULK; + break; + case USB_ENDPOINT_XFER_INT: + ep-xfer_type = PIPE_INTERRUPT; + break; + default: + ep-xfer_type = PIPE_ISOCHRONOUS; + break; + } + ep-epnum = urb-ep-desc.bEndpointAddress; + ep-devnum = urb-dev-devnum; ep-busnum = urb-dev-bus-busnum; ep-id = (unsigned long) urb; ep-ts_sec = ts.tv_sec; @@ -500,10 +512,22 @@ static void mon_bin_error(void *data, st memset(ep, 0, PKT_SIZE); ep-type = 'E'; - ep-xfer_type = usb_pipetype(urb-pipe); - /* We use the fact that usb_pipein() returns 0x80 */ - ep-epnum = usb_pipeendpoint(urb-pipe) | usb_pipein(urb-pipe); - ep-devnum = usb_pipedevice(urb-pipe); + switch (usb_endpoint_type(urb-ep-desc)) { + case USB_ENDPOINT_XFER_CONTROL: + ep-xfer_type = PIPE_CONTROL; + break; + case USB_ENDPOINT_XFER_BULK: + ep-xfer_type = PIPE_BULK; + break; + case USB_ENDPOINT_XFER_INT: + ep-xfer_type = PIPE_INTERRUPT; + break; + default: + ep-xfer_type = PIPE_ISOCHRONOUS; + break; + } + ep-epnum = urb-ep-desc.bEndpointAddress; + ep-devnum = urb-dev-devnum; ep-busnum = urb-dev-bus-busnum; ep-id = (unsigned long) urb; ep-status = error; --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c @@ -154,8 +154,8 @@ static void mon_complete(struct usb_bus * This should not happen. * At this point we do not even know the bus number... */ - printk(KERN_ERR TAG : Null mon bus in URB, pipe 0x%x\n, - urb-pipe); + printk(KERN_ERR TAG : Null mon bus in URB, address %p\n, + urb); return; } --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -50,10 +50,12 @@ struct mon_iso_desc { struct mon_event_text { struct list_head e_link; int type; /* submit, complete, etc. */ - unsigned int pipe; /* Pipe */ unsigned long id; /* From pointer, most of the time */ unsigned int tstamp; + int xfertype; int busnum; + int devnum; + int epnum; int length; /* Depends on type: xfer length or act length */ int status; int interval; @@ -61,6 +63,7 @@ struct mon_event_text { int error_count; char setup_flag;
[linux-usb-devel] patch usb-avoid-using-urb-pipe-in-usbcore.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled Subject: [PATCH 4/7] USB: avoid using urb-pipe in usbcore to my gregkh-2.6 tree. Its filename is usb-avoid-using-urb-pipe-in-usbcore.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ From [EMAIL PROTECTED] Thu Aug 2 14:04:28 2007 From: Alan Stern [EMAIL PROTECTED] Date: Mon, 30 Jul 2007 17:07:21 -0400 (EDT) Subject: [PATCH 4/7] USB: avoid using urb-pipe in usbcore To: Greg KH [EMAIL PROTECTED] Cc: USB development list linux-usb-devel@lists.sourceforge.net Message-ID: [EMAIL PROTECTED] This patch (as946) eliminates many of the uses of urb-pipe in usbcore. Unfortunately there will have to be a significant API change, affecting all USB drivers, before we can remove it entirely. This patch contents itself with changing only the interface to usb_buffer_map_sg() and friends: The pipe argument is replaced with a direction flag. That can be done easily because those routines get used in only one place. Signed-off-by: Alan Stern [EMAIL PROTECTED] Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED] --- drivers/usb/core/hcd.c | 40 drivers/usb/core/message.c | 14 -- drivers/usb/core/usb.c | 19 +-- include/linux/usb.h|6 +++--- 4 files changed, 44 insertions(+), 35 deletions(-) --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -635,9 +635,9 @@ static int rh_queue_status (struct usb_h static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb) { - if (usb_pipeint (urb-pipe)) + if (usb_endpoint_xfer_int(urb-ep-desc)) return rh_queue_status (hcd, urb); - if (usb_pipecontrol (urb-pipe)) + if (usb_endpoint_xfer_control(urb-ep-desc)) return rh_call_control (hcd, urb); return -EINVAL; } @@ -651,7 +651,7 @@ static int usb_rh_urb_dequeue (struct us { unsigned long flags; - if (usb_pipeendpoint(urb-pipe) == 0) { /* Control URB */ + if (usb_endpoint_num(urb-ep-desc) == 0) {/* Control URB */ ; /* Do nothing */ } else {/* Status URB */ @@ -918,7 +918,7 @@ static void urb_unlink(struct usb_hcd *h spin_unlock_irqrestore(hcd_urb_list_lock, flags); if (hcd-self.uses_dma !is_root_hub(urb-dev)) { - if (usb_pipecontrol (urb-pipe) + if (usb_endpoint_xfer_control(urb-ep-desc) !(urb-transfer_flags URB_NO_SETUP_DMA_MAP)) dma_unmap_single (hcd-self.controller, urb-setup_dma, sizeof (struct usb_ctrlrequest), @@ -1001,7 +1001,7 @@ int usb_hcd_submit_urb (struct urb *urb, * unless it uses pio or talks to another transport. */ if (hcd-self.uses_dma) { - if (usb_pipecontrol (urb-pipe) + if (usb_endpoint_xfer_control(urb-ep-desc) !(urb-transfer_flags URB_NO_SETUP_DMA_MAP)) urb-setup_dma = dma_map_single ( hcd-self.controller, @@ -1201,11 +1201,13 @@ rescan: spin_lock(hcd_urb_list_lock); list_for_each_entry (urb, ep-urb_list, urb_list) { int tmp; + int is_in; /* the urb may already have been unlinked */ if (urb-status != -EINPROGRESS) continue; usb_get_urb (urb); + is_in = usb_urb_dir_in(urb); spin_unlock(hcd_urb_list_lock); spin_lock (urb-lock); @@ -1216,19 +1218,25 @@ rescan: /* kick hcd unless it's already returning this */ if (tmp == -EINPROGRESS) { - tmp = urb-pipe; unlink1 (hcd, urb); dev_dbg (hcd-self.controller, - shutdown urb %p pipe %08x ep%d%s%s\n, - urb, tmp, usb_pipeendpoint (tmp), - (tmp USB_DIR_IN) ? in : out, - ({ char *s; \ -switch (usb_pipetype (tmp)) { \ -case PIPE_CONTROL: s = ; break; \ -case PIPE_BULK:s = -bulk; break; \ -case PIPE_INTERRUPT: s = -intr; break; \ -default: s = -iso; break; \ - }; s;})); + shutdown urb %p ep%d%s%s\n, + urb, usb_endpoint_num(ep-desc), + is_in ? in : out, + ({ char *s; + + switch (usb_endpoint_type(ep-desc)) { +
Re: [linux-usb-devel] High speed, high bandwidth isoc
On Wednesday 01 August 2007, Steve Calfee wrote: At 10:42 PM 7/16/2007, David Brownell wrote: I don't recall testing high bandwidth ISO. In general, ISO support is pretty weak with EHCI ... Actually, now that I think of it I *did* test it, but only using the usbtest driver. In fact, I tested it between an EHCI host and a net2280 gadget with gadgetfs. :) Update, I was able to get the high bandwidth ISO to work. I thought I would report how, for others in the future. When building the isoc array for submission, if it is a 2 or 3 packet per microframe IN or OUT, I thought that I just built more standard packets and ehci.c would know from the endpoint attributes the mult field. Wrong. What Linux wants is to get a packet 2 or 3 times as long as maxpacket in the length request. Yes. I suspect that should be documented somewhere. I have not tested all 3072 possible packet sizes, but certainly 1*3, 512*3 and 1024*3 and several sizes in between work for 20 second burst tests of transfers. All this from a userspace usbdevfs application! Linux (through usbdevfs at least) has a limitation, the max request it will accept is less than 48K per urb - 24K works. ISTR it started out at 16KB then someone said that's not enough. One basic problem is that you can't reliably allocate very many physically contiguous pages for your buffers. So even 24K will be dicey on some systems. I have not tried everything in between. This means that to get iso running without dropouts (the whole point of iso) requires submitting lots of urbs in parallel. I have very successfully used 8 urbs transferring 24K per urb, but that means that the app has to reload at least every 8 ms. Nobody promised streaming to/from userspace would be a speed demon! And even in that model, 8 msec is risky ... if an IRQ or other task gets scheduled at the wrong time, you'd still get dropouts. Probably a production app would need to use 32 or so urbs to be guaranteed the uninterrupted isoc flow. The high bandwidth stuff would really benefit from a zero copy usb kernel. It's basically only high bandwidth streaming that needs that; but you're right that 24 MByte/sec is a lot of memcpy(). The same effect is visible on the peripheral side. - Dave Regards, Steve - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
[linux-usb-devel] [PATCH] USB: Only enable autosuspend by default on certain device classes
We're seeing a large number of problems with devices not appreciating USB autosuspend, especially printers and scanners. According to http://www.microsoft.com/whdc/system/bus/USB/USBFAQ_intro.mspx only a subset of drivers support it in Windows XP, meaning that most devices are probably untested in this situation. This patch alters the behaviour to match that of Windows. Userspace can still whitelist devices as appropriate, and the set of classes supporting autosuspend probably covers pretty much every driver likely to be found on any portable device. Signed-off-by: Matthew Garrett [EMAIL PROTECTED] --- diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index caaa46f..12ba789 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1278,6 +1278,22 @@ int usb_new_device(struct usb_device *udev) { int err; +#ifdef CONFIG_USB_SUSPEND + /* Disable autosuspend for most devices - Windows only enables it + for a small subset of classes, so most hardware hasn't been tested + with it. Userspace can always reenable at a later point */ + + switch (udev-descriptor.bDeviceClass) { + case USB_CLASS_HID: + case USB_CLASS_COMM: + case USB_CLASS_WIRELESS_CONTROLLER: + case USB_CLASS_HUB: + break; + default: + udev-autosuspend_disabled = 1; + } +#endif + /* Determine quirks */ usb_detect_quirks(udev); -- Matthew Garrett | [EMAIL PROTECTED] - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] USB: Only enable autosuspend by default on certain device classes
On Fri, Aug 03, 2007 at 12:56:13AM +0100, Matthew Garrett wrote: We're seeing a large number of problems with devices not appreciating USB autosuspend, especially printers and scanners. According to http://www.microsoft.com/whdc/system/bus/USB/USBFAQ_intro.mspx only a subset of drivers support it in Windows XP, meaning that most devices are probably untested in this situation. This patch alters the behaviour to match that of Windows. Userspace can still whitelist devices as appropriate, and the set of classes supporting autosuspend probably covers pretty much every driver likely to be found on any portable device. Signed-off-by: Matthew Garrett [EMAIL PROTECTED] Well, if you do this, then you can pretty much delete the whole quirk table we have, right? And personally, I want to do better than Windows XP when it comes to power management. This patch is only going to suspend a very tiny subset of devices, including a whole bunch of ones that do not even have drivers in Linux, causing our power footprint to be bigger than needed. Also, we have udev rules for SANE that disables their autosuspend settings, which handles the majority of the devices we have seen with problems. So I really don't want to accept this patch. But, what problems are you seeing with our current suspend logic that you feel we need to be this harsh? thanks, greg k-h - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] autosuspend for asix driver
On Wednesday 01 August 2007, Oliver Neukum wrote: Am Dienstag 31 Juli 2007 schrieb Alan Stern: You assign dev-intf in both the usbnet framework driver and the subdriver. Could the subdriver's assignment be removed? Here we go again. Regards Oliver Signed-off-by: Oliver Neukum [EMAIL PROTECTED] You know that drivers/net/usb patches go to the netdev list, right? They merge through the network queue, not the USB queue. This looks plausible to me, except /* multi-line comments * in the code * should not end like this: */ /* do it like this, with * nice clean line endings: */ --- --- a/drivers/net/usb/asix.c 2007-07-30 14:18:38.0 +0200 +++ b/drivers/net/usb/asix.c 2007-08-01 09:48:10.0 +0200 @@ -1474,6 +1474,7 @@ static struct usb_driver asix_driver = { .suspend = usbnet_suspend, .resume = usbnet_resume, .disconnect = usbnet_disconnect, + .supports_autosuspend = 1, }; static int __init asix_init(void) --- a/drivers/net/usb/usbnet.h2007-07-30 14:23:08.0 +0200 +++ b/drivers/net/usb/usbnet.h2007-07-31 11:08:12.0 +0200 @@ -28,6 +28,7 @@ struct usbnet { /* housekeeping */ struct usb_device *udev; + struct usb_interface*intf; struct driver_info *driver_info; const char *driver_name; wait_queue_head_t *wait; --- a/drivers/net/usb/usbnet.c2007-07-30 14:27:40.0 +0200 +++ b/drivers/net/usb/usbnet.c2007-07-31 11:07:51.0 +0200 @@ -590,6 +590,7 @@ static int usbnet_stop (struct net_devic dev-flags = 0; del_timer_sync (dev-delay); tasklet_kill (dev-bh); + usb_autopm_put_interface(dev-intf); return 0; } @@ -603,9 +604,19 @@ static int usbnet_stop (struct net_devic static int usbnet_open (struct net_device *net) { struct usbnet *dev = netdev_priv(net); - int retval = 0; + int retval; struct driver_info *info = dev-driver_info; + if ((retval = usb_autopm_get_interface(dev-intf)) 0) { + if (netif_msg_ifup (dev)) + devinfo (dev, + resumption fail (%d) usbnet usb-%s-%s, %s, + retval, + dev-udev-bus-bus_name, dev-udev-devpath, + info-description); + goto done_nopm; + } + // put into known safe state if (info-reset (retval = info-reset (dev)) 0) { if (netif_msg_ifup (dev)) @@ -659,7 +670,10 @@ static int usbnet_open (struct net_devic // delay posting reads until we're fully open tasklet_schedule (dev-bh); + return retval; done: + usb_autopm_put_interface(dev-intf); +done_nopm: return retval; } @@ -1143,6 +1157,7 @@ usbnet_probe (struct usb_interface *udev dev = netdev_priv(net); dev-udev = xdev; + dev-intf = udev; dev-driver_info = info; dev-driver_name = name; dev-msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV @@ -1273,6 +1288,9 @@ int usbnet_suspend (struct usb_interface netif_device_detach (dev-net); (void) unlink_urbs (dev, dev-rxq); (void) unlink_urbs (dev, dev-txq); + /* reattach so runtime management can use and + * wake the device */ + netif_device_attach (dev-net); } return 0; } @@ -1282,10 +1300,9 @@ int usbnet_resume (struct usb_interface { struct usbnet *dev = usb_get_intfdata(intf); - if (!--dev-suspend_count) { - netif_device_attach (dev-net); + if (!--dev-suspend_count) tasklet_schedule (dev-bh); - } + return 0; } EXPORT_SYMBOL_GPL(usbnet_resume); - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] USB: Only enable autosuspend by default on certain device classes
On Thu, Aug 02, 2007 at 06:15:05PM -0700, Greg KH wrote: Well, if you do this, then you can pretty much delete the whole quirk table we have, right? At the moment, yes. And personally, I want to do better than Windows XP when it comes to power management. This patch is only going to suspend a very tiny subset of devices, including a whole bunch of ones that do not even have drivers in Linux, causing our power footprint to be bigger than needed. I agree. I'd much rather see us suspending devices whenever possible - it's just that I have concerns over the scalability of the blacklist, given the number of devices that seem to have issues. Also, we have udev rules for SANE that disables their autosuspend settings, which handles the majority of the devices we have seen with problems. Several printers seem to have the issue as well, and the blacklist seems to contain some odd miscellaneous devices like the Blackberry. The main concern I have is that kernel developers just don't tend to be the sort of people that use webcams, printers or scanners, so we're relying on normal users to go to the effort of reporting that their device has stopped working. So I really don't want to accept this patch. But, what problems are you seeing with our current suspend logic that you feel we need to be this harsh? It's definitely a brute force approach, but it's one that means that we get the low hanging fruit (ie, pretty much anything that's likely to be plugged into a laptop) while massively reducing the probability of breaking anyone's system. Saving some power is a nice win, but breaking someone's printer is a pretty big loss. -- Matthew Garrett | [EMAIL PROTECTED] - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Re: [linux-usb-devel] [PATCH] USB: Only enable autosuspend by default on certain device classes
On Fri, 3 Aug 2007, Matthew Garrett wrote: On Thu, Aug 02, 2007 at 06:15:05PM -0700, Greg KH wrote: Well, if you do this, then you can pretty much delete the whole quirk table we have, right? At the moment, yes. And personally, I want to do better than Windows XP when it comes to power management. This patch is only going to suspend a very tiny subset of devices, including a whole bunch of ones that do not even have drivers in Linux, causing our power footprint to be bigger than needed. I agree. I'd much rather see us suspending devices whenever possible - it's just that I have concerns over the scalability of the blacklist, given the number of devices that seem to have issues. While I agree in general, perhaps a different approach would work better. For instance, we could blacklist a few known-bad device classes (maybe even using the existing blacklist) rather than whitelisting a few known-good ones -- or trying to blacklist each member of the bad classes! Also, building something this sweeping into a kernel driver feels like a mistake. It ought to be more easily configurable from userspace, say via a sysfs file. Although this wouldn't be so important if we take the blacklist-classes route. Alan Stern - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel