Loading drivers/usb/misc/usbtest.c +341 −324 Original line number Diff line number Diff line Loading @@ -13,17 +13,16 @@ /*-------------------------------------------------------------------------*/ // FIXME make these public somewhere; usbdevfs.h? // /* FIXME make these public somewhere; usbdevfs.h? */ struct usbtest_param { // inputs /* inputs */ unsigned test_num; /* 0..(TEST_CASES-1) */ unsigned iterations; unsigned length; unsigned vary; unsigned sglen; // outputs /* outputs */ struct timeval duration; }; #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) Loading Loading @@ -115,7 +114,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) case USB_ENDPOINT_XFER_ISOC: if (dev->info->iso) goto try_iso; // FALLTHROUGH /* FALLTHROUGH */ default: continue; } Loading Loading @@ -215,7 +214,7 @@ static struct urb *simple_alloc_urb ( return urb; } static unsigned pattern = 0; static unsigned pattern; static unsigned mod_pattern; module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); Loading @@ -228,7 +227,7 @@ static inline void simple_fill_buf (struct urb *urb) switch (pattern) { default: // FALLTHROUGH /* FALLTHROUGH */ case 0: memset(buf, 0, len); break; Loading Loading @@ -299,7 +298,8 @@ static int simple_io ( init_completion(&completion); if (usb_pipeout(urb->pipe)) simple_fill_buf(urb); if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) retval = usb_submit_urb(urb, GFP_KERNEL); if (retval != 0) break; /* NOTE: no timeouts; can't be broken out of by interrupt */ Loading Loading @@ -426,9 +426,9 @@ static int perform_sglist ( /* FIXME if endpoint halted, clear halt (and log) */ } // FIXME for unlink or fault handling tests, don't report // failure if retval is as we expected ... /* FIXME for unlink or fault handling tests, don't report * failure if retval is as we expected ... */ if (retval) ERROR(tdev, "perform_sglist failed, " "iterations left %d, status %d\n", Loading Loading @@ -470,7 +470,7 @@ static int get_altsetting (struct usbtest_dev *dev) return dev->buf[0]; case 0: retval = -ERANGE; // FALLTHROUGH /* FALLTHROUGH */ default: return retval; } Loading Loading @@ -621,8 +621,9 @@ static int ch9_postconfig (struct usbtest_dev *dev) return (retval < 0) ? retval : -EDOM; } // FIXME cross-checking udev->config[i] to make sure usbcore // parsed it right (etc) would be good testing paranoia /* FIXME cross-checking udev->config[i] to make sure usbcore * parsed it right (etc) would be good testing paranoia */ } /* and sometimes [9.2.6.6] speed dependent descriptors */ Loading Loading @@ -663,7 +664,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) } } } // FIXME fetch strings from at least the device descriptor /* FIXME fetch strings from at least the device descriptor */ /* [9.4.5] get_status always works */ retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf); Loading @@ -672,8 +673,9 @@ static int ch9_postconfig (struct usbtest_dev *dev) return (retval < 0) ? retval : -EDOM; } // FIXME configuration.bmAttributes says if we could try to set/clear // the device's remote wakeup feature ... if we can, test that here /* FIXME configuration.bmAttributes says if we could try to set/clear * the device's remote wakeup feature ... if we can, test that here */ retval = usb_get_status(udev, USB_RECIP_INTERFACE, iface->altsetting[0].desc.bInterfaceNumber, dev->buf); Loading @@ -681,7 +683,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) dev_err(&iface->dev, "get interface status --> %d\n", retval); return (retval < 0) ? retval : -EDOM; } // FIXME get status for each endpoint in the interface /* FIXME get status for each endpoint in the interface */ return 0; } Loading Loading @@ -812,7 +814,8 @@ static void ctrl_complete (struct urb *urb) /* resubmit if we need to, else mark this as done */ if ((status == 0) && (ctx->pending < ctx->count)) { if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { status = usb_submit_urb(urb, GFP_ATOMIC); if (status != 0) { ERROR(ctx->dev, "can't resubmit ctrl %02x.%02x, err %d\n", reqp->bRequestType, reqp->bRequest, status); Loading Loading @@ -874,99 +877,103 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; switch (i % NUM_SUBCASES) { case 0: // get device descriptor case 0: /* get device descriptor */ req.wValue = cpu_to_le16(USB_DT_DEVICE << 8); len = sizeof(struct usb_device_descriptor); break; case 1: // get first config descriptor (only) case 1: /* get first config descriptor (only) */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = sizeof(struct usb_config_descriptor); break; case 2: // get altsetting (OFTEN STALLS) case 2: /* get altsetting (OFTEN STALLS) */ req.bRequest = USB_REQ_GET_INTERFACE; req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; // index = 0 means first interface /* index = 0 means first interface */ len = 1; expected = EPIPE; break; case 3: // get interface status case 3: /* get interface status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; // interface 0 /* interface 0 */ len = 2; break; case 4: // get device status case 4: /* get device status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; len = 2; break; case 5: // get device qualifier (MAY STALL) case 5: /* get device qualifier (MAY STALL) */ req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); len = sizeof(struct usb_qualifier_descriptor); if (udev->speed != USB_SPEED_HIGH) expected = EPIPE; break; case 6: // get first config descriptor, plus interface case 6: /* get first config descriptor, plus interface */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = sizeof(struct usb_config_descriptor); len += sizeof(struct usb_interface_descriptor); break; case 7: // get interface descriptor (ALWAYS STALLS) case 7: /* get interface descriptor (ALWAYS STALLS) */ req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); // interface == 0 /* interface == 0 */ len = sizeof(struct usb_interface_descriptor); expected = -EPIPE; break; // NOTE: two consecutive stalls in the queue here. // that tests fault recovery a bit more aggressively. case 8: // clear endpoint halt (MAY STALL) /* NOTE: two consecutive stalls in the queue here. * that tests fault recovery a bit more aggressively. */ case 8: /* clear endpoint halt (MAY STALL) */ req.bRequest = USB_REQ_CLEAR_FEATURE; req.bRequestType = USB_RECIP_ENDPOINT; // wValue 0 == ep halt // wIndex 0 == ep0 (shouldn't halt!) /* wValue 0 == ep halt */ /* wIndex 0 == ep0 (shouldn't halt!) */ len = 0; pipe = usb_sndctrlpipe(udev, 0); expected = EPIPE; break; case 9: // get endpoint status case 9: /* get endpoint status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; // endpoint 0 /* endpoint 0 */ len = 2; break; case 10: // trigger short read (EREMOTEIO) case 10: /* trigger short read (EREMOTEIO) */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = 1024; expected = -EREMOTEIO; break; // NOTE: two consecutive _different_ faults in the queue. case 11: // get endpoint descriptor (ALWAYS STALLS) /* NOTE: two consecutive _different_ faults in the queue. */ case 11: /* get endpoint descriptor (ALWAYS STALLS) */ req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8); // endpoint == 0 /* endpoint == 0 */ len = sizeof(struct usb_interface_descriptor); expected = EPIPE; break; // NOTE: sometimes even a third fault in the queue! case 12: // get string 0 descriptor (MAY STALL) /* NOTE: sometimes even a third fault in the queue! */ case 12: /* get string 0 descriptor (MAY STALL) */ req.wValue = cpu_to_le16(USB_DT_STRING << 8); // string == 0, for language IDs /* string == 0, for language IDs */ len = sizeof(struct usb_interface_descriptor); // may succeed when > 4 languages expected = EREMOTEIO; // or EPIPE, if no strings /* may succeed when > 4 languages */ expected = EREMOTEIO; /* or EPIPE, if no strings */ break; case 13: // short read, resembling case 10 case 13: /* short read, resembling case 10 */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); // last data packet "should" be DATA1, not DATA0 /* last data packet "should" be DATA1, not DATA0 */ len = 1024 - udev->descriptor.bMaxPacketSize0; expected = -EREMOTEIO; break; case 14: // short read; try to fill the last packet case 14: /* short read; try to fill the last packet */ req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0); /* device descriptor size == 18 bytes */ len = udev->descriptor.bMaxPacketSize0; switch (len) { case 8: len = 24; break; case 16: len = 32; break; case 8: len = 24; break; case 16: len = 32; break; } expected = -EREMOTEIO; break; Loading Loading @@ -1033,7 +1040,7 @@ static void unlink1_callback (struct urb *urb) { int status = urb->status; // we "know" -EPIPE (stall) never happens /* we "know" -EPIPE (stall) never happens */ if (!status) status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { Loading Loading @@ -1061,7 +1068,8 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) * FIXME want additional tests for when endpoint is STALLing * due to errors, or is just NAKing requests. */ if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { retval = usb_submit_urb(urb, GFP_KERNEL); if (retval != 0) { dev_err(&dev->intf->dev, "submit fail %d\n", retval); return retval; } Loading Loading @@ -1434,7 +1442,7 @@ static struct urb *iso_alloc_urb ( } urb->complete = iso_callback; // urb->context = SET BY CALLER /* urb->context = SET BY CALLER */ urb->interval = 1 << (desc->bInterval - 1); urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; return urb; Loading Loading @@ -1569,7 +1577,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) struct timeval start; unsigned i; // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */ pattern = mod_pattern; Loading Loading @@ -1634,7 +1642,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); simple_free_urb(urb); break; Loading @@ -1649,7 +1657,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); simple_free_urb(urb); break; Loading @@ -1664,7 +1672,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = simple_io(dev, urb, param->iterations, param->vary, 0, "test3"); simple_free_urb(urb); Loading @@ -1680,7 +1688,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = simple_io(dev, urb, param->iterations, param->vary, 0, "test4"); simple_free_urb(urb); Loading @@ -1699,7 +1707,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = perform_sglist(dev, param->iterations, dev->out_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading @@ -1717,7 +1725,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = perform_sglist(dev, param->iterations, dev->in_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading @@ -1734,7 +1742,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = perform_sglist(dev, param->iterations, dev->out_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading @@ -1751,7 +1759,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = perform_sglist(dev, param->iterations, dev->in_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading Loading @@ -1844,7 +1852,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) "TEST 15: write %d iso, %d entries of %d bytes\n", param->iterations, param->sglen, param->length); // FIRMWARE: iso sink /* FIRMWARE: iso sink */ retval = test_iso_queue(dev, param, dev->out_iso_pipe, dev->iso_out); break; Loading @@ -1857,14 +1865,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) "TEST 16: read %d iso, %d entries of %d bytes\n", param->iterations, param->sglen, param->length); // FIRMWARE: iso source /* FIRMWARE: iso source */ retval = test_iso_queue(dev, param, dev->in_iso_pipe, dev->iso_in); break; // FIXME unlink from queue (ring with N urbs) /* FIXME unlink from queue (ring with N urbs) */ // FIXME scatterlist cancel (needs helper thread) /* FIXME scatterlist cancel (needs helper thread) */ } do_gettimeofday(¶m->duration); Loading @@ -1880,7 +1888,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) /*-------------------------------------------------------------------------*/ static unsigned force_interrupt = 0; static unsigned force_interrupt; module_param(force_interrupt, uint, 0); MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt"); Loading Loading @@ -1930,7 +1938,8 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) dev->intf = intf; /* cacheline-aligned scratch for i/o */ if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) { dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); if (dev->buf == NULL) { kfree(dev); return -ENOMEM; } Loading Loading @@ -1984,10 +1993,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", ({ char *tmp; switch (udev->speed) { case USB_SPEED_LOW: tmp = "low"; break; case USB_SPEED_FULL: tmp = "full"; break; case USB_SPEED_HIGH: tmp = "high"; break; default: tmp = "unknown"; break; case USB_SPEED_LOW: tmp = "low"; break; case USB_SPEED_FULL: tmp = "full"; break; case USB_SPEED_HIGH: tmp = "high"; break; default: tmp = "unknown"; break; }; tmp; }), info->ctrl_out ? " in/out" : "", rtest, wtest, Loading Loading @@ -2050,9 +2067,9 @@ static struct usbtest_info fw_info = { .ep_in = 2, .ep_out = 2, .alt = 1, .autoconf = 1, // iso and ctrl_out need autoconf .autoconf = 1, /* iso and ctrl_out need autoconf */ .ctrl_out = 1, .iso = 1, // iso_ep's are #8 in/out .iso = 1, /* iso_ep's are #8 in/out */ }; /* peripheral running Linux and 'zero.c' test firmware, or Loading Loading @@ -2145,7 +2162,7 @@ static const struct usb_device_id id_table[] = { #ifdef KEYSPAN_19Qi /* Keyspan 19qi uses an21xx (original EZ-USB) */ // this does not coexist with the real Keyspan 19qi driver! /* this does not coexist with the real Keyspan 19qi driver! */ { USB_DEVICE(0x06cd, 0x010b), .driver_info = (unsigned long) &ez1_info, }, Loading @@ -2155,7 +2172,7 @@ static const struct usb_device_id id_table[] = { #ifdef IBOT2 /* iBOT2 makes a nice source of high speed bulk-in data */ // this does not coexist with a real iBOT2 driver! /* this does not coexist with a real iBOT2 driver! */ { USB_DEVICE(0x0b62, 0x0059), .driver_info = (unsigned long) &ibot2_info, }, Loading Loading
drivers/usb/misc/usbtest.c +341 −324 Original line number Diff line number Diff line Loading @@ -13,17 +13,16 @@ /*-------------------------------------------------------------------------*/ // FIXME make these public somewhere; usbdevfs.h? // /* FIXME make these public somewhere; usbdevfs.h? */ struct usbtest_param { // inputs /* inputs */ unsigned test_num; /* 0..(TEST_CASES-1) */ unsigned iterations; unsigned length; unsigned vary; unsigned sglen; // outputs /* outputs */ struct timeval duration; }; #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) Loading Loading @@ -115,7 +114,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf) case USB_ENDPOINT_XFER_ISOC: if (dev->info->iso) goto try_iso; // FALLTHROUGH /* FALLTHROUGH */ default: continue; } Loading Loading @@ -215,7 +214,7 @@ static struct urb *simple_alloc_urb ( return urb; } static unsigned pattern = 0; static unsigned pattern; static unsigned mod_pattern; module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)"); Loading @@ -228,7 +227,7 @@ static inline void simple_fill_buf (struct urb *urb) switch (pattern) { default: // FALLTHROUGH /* FALLTHROUGH */ case 0: memset(buf, 0, len); break; Loading Loading @@ -299,7 +298,8 @@ static int simple_io ( init_completion(&completion); if (usb_pipeout(urb->pipe)) simple_fill_buf(urb); if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) retval = usb_submit_urb(urb, GFP_KERNEL); if (retval != 0) break; /* NOTE: no timeouts; can't be broken out of by interrupt */ Loading Loading @@ -426,9 +426,9 @@ static int perform_sglist ( /* FIXME if endpoint halted, clear halt (and log) */ } // FIXME for unlink or fault handling tests, don't report // failure if retval is as we expected ... /* FIXME for unlink or fault handling tests, don't report * failure if retval is as we expected ... */ if (retval) ERROR(tdev, "perform_sglist failed, " "iterations left %d, status %d\n", Loading Loading @@ -470,7 +470,7 @@ static int get_altsetting (struct usbtest_dev *dev) return dev->buf[0]; case 0: retval = -ERANGE; // FALLTHROUGH /* FALLTHROUGH */ default: return retval; } Loading Loading @@ -621,8 +621,9 @@ static int ch9_postconfig (struct usbtest_dev *dev) return (retval < 0) ? retval : -EDOM; } // FIXME cross-checking udev->config[i] to make sure usbcore // parsed it right (etc) would be good testing paranoia /* FIXME cross-checking udev->config[i] to make sure usbcore * parsed it right (etc) would be good testing paranoia */ } /* and sometimes [9.2.6.6] speed dependent descriptors */ Loading Loading @@ -663,7 +664,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) } } } // FIXME fetch strings from at least the device descriptor /* FIXME fetch strings from at least the device descriptor */ /* [9.4.5] get_status always works */ retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf); Loading @@ -672,8 +673,9 @@ static int ch9_postconfig (struct usbtest_dev *dev) return (retval < 0) ? retval : -EDOM; } // FIXME configuration.bmAttributes says if we could try to set/clear // the device's remote wakeup feature ... if we can, test that here /* FIXME configuration.bmAttributes says if we could try to set/clear * the device's remote wakeup feature ... if we can, test that here */ retval = usb_get_status(udev, USB_RECIP_INTERFACE, iface->altsetting[0].desc.bInterfaceNumber, dev->buf); Loading @@ -681,7 +683,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) dev_err(&iface->dev, "get interface status --> %d\n", retval); return (retval < 0) ? retval : -EDOM; } // FIXME get status for each endpoint in the interface /* FIXME get status for each endpoint in the interface */ return 0; } Loading Loading @@ -812,7 +814,8 @@ static void ctrl_complete (struct urb *urb) /* resubmit if we need to, else mark this as done */ if ((status == 0) && (ctx->pending < ctx->count)) { if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) { status = usb_submit_urb(urb, GFP_ATOMIC); if (status != 0) { ERROR(ctx->dev, "can't resubmit ctrl %02x.%02x, err %d\n", reqp->bRequestType, reqp->bRequest, status); Loading Loading @@ -874,99 +877,103 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; switch (i % NUM_SUBCASES) { case 0: // get device descriptor case 0: /* get device descriptor */ req.wValue = cpu_to_le16(USB_DT_DEVICE << 8); len = sizeof(struct usb_device_descriptor); break; case 1: // get first config descriptor (only) case 1: /* get first config descriptor (only) */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = sizeof(struct usb_config_descriptor); break; case 2: // get altsetting (OFTEN STALLS) case 2: /* get altsetting (OFTEN STALLS) */ req.bRequest = USB_REQ_GET_INTERFACE; req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; // index = 0 means first interface /* index = 0 means first interface */ len = 1; expected = EPIPE; break; case 3: // get interface status case 3: /* get interface status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE; // interface 0 /* interface 0 */ len = 2; break; case 4: // get device status case 4: /* get device status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE; len = 2; break; case 5: // get device qualifier (MAY STALL) case 5: /* get device qualifier (MAY STALL) */ req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8); len = sizeof(struct usb_qualifier_descriptor); if (udev->speed != USB_SPEED_HIGH) expected = EPIPE; break; case 6: // get first config descriptor, plus interface case 6: /* get first config descriptor, plus interface */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = sizeof(struct usb_config_descriptor); len += sizeof(struct usb_interface_descriptor); break; case 7: // get interface descriptor (ALWAYS STALLS) case 7: /* get interface descriptor (ALWAYS STALLS) */ req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8); // interface == 0 /* interface == 0 */ len = sizeof(struct usb_interface_descriptor); expected = -EPIPE; break; // NOTE: two consecutive stalls in the queue here. // that tests fault recovery a bit more aggressively. case 8: // clear endpoint halt (MAY STALL) /* NOTE: two consecutive stalls in the queue here. * that tests fault recovery a bit more aggressively. */ case 8: /* clear endpoint halt (MAY STALL) */ req.bRequest = USB_REQ_CLEAR_FEATURE; req.bRequestType = USB_RECIP_ENDPOINT; // wValue 0 == ep halt // wIndex 0 == ep0 (shouldn't halt!) /* wValue 0 == ep halt */ /* wIndex 0 == ep0 (shouldn't halt!) */ len = 0; pipe = usb_sndctrlpipe(udev, 0); expected = EPIPE; break; case 9: // get endpoint status case 9: /* get endpoint status */ req.bRequest = USB_REQ_GET_STATUS; req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT; // endpoint 0 /* endpoint 0 */ len = 2; break; case 10: // trigger short read (EREMOTEIO) case 10: /* trigger short read (EREMOTEIO) */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); len = 1024; expected = -EREMOTEIO; break; // NOTE: two consecutive _different_ faults in the queue. case 11: // get endpoint descriptor (ALWAYS STALLS) /* NOTE: two consecutive _different_ faults in the queue. */ case 11: /* get endpoint descriptor (ALWAYS STALLS) */ req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8); // endpoint == 0 /* endpoint == 0 */ len = sizeof(struct usb_interface_descriptor); expected = EPIPE; break; // NOTE: sometimes even a third fault in the queue! case 12: // get string 0 descriptor (MAY STALL) /* NOTE: sometimes even a third fault in the queue! */ case 12: /* get string 0 descriptor (MAY STALL) */ req.wValue = cpu_to_le16(USB_DT_STRING << 8); // string == 0, for language IDs /* string == 0, for language IDs */ len = sizeof(struct usb_interface_descriptor); // may succeed when > 4 languages expected = EREMOTEIO; // or EPIPE, if no strings /* may succeed when > 4 languages */ expected = EREMOTEIO; /* or EPIPE, if no strings */ break; case 13: // short read, resembling case 10 case 13: /* short read, resembling case 10 */ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0); // last data packet "should" be DATA1, not DATA0 /* last data packet "should" be DATA1, not DATA0 */ len = 1024 - udev->descriptor.bMaxPacketSize0; expected = -EREMOTEIO; break; case 14: // short read; try to fill the last packet case 14: /* short read; try to fill the last packet */ req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0); /* device descriptor size == 18 bytes */ len = udev->descriptor.bMaxPacketSize0; switch (len) { case 8: len = 24; break; case 16: len = 32; break; case 8: len = 24; break; case 16: len = 32; break; } expected = -EREMOTEIO; break; Loading Loading @@ -1033,7 +1040,7 @@ static void unlink1_callback (struct urb *urb) { int status = urb->status; // we "know" -EPIPE (stall) never happens /* we "know" -EPIPE (stall) never happens */ if (!status) status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { Loading Loading @@ -1061,7 +1068,8 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) * FIXME want additional tests for when endpoint is STALLing * due to errors, or is just NAKing requests. */ if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) { retval = usb_submit_urb(urb, GFP_KERNEL); if (retval != 0) { dev_err(&dev->intf->dev, "submit fail %d\n", retval); return retval; } Loading Loading @@ -1434,7 +1442,7 @@ static struct urb *iso_alloc_urb ( } urb->complete = iso_callback; // urb->context = SET BY CALLER /* urb->context = SET BY CALLER */ urb->interval = 1 << (desc->bInterval - 1); urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; return urb; Loading Loading @@ -1569,7 +1577,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) struct timeval start; unsigned i; // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */ pattern = mod_pattern; Loading Loading @@ -1634,7 +1642,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = simple_io(dev, urb, param->iterations, 0, 0, "test1"); simple_free_urb(urb); break; Loading @@ -1649,7 +1657,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = simple_io(dev, urb, param->iterations, 0, 0, "test2"); simple_free_urb(urb); break; Loading @@ -1664,7 +1672,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = simple_io(dev, urb, param->iterations, param->vary, 0, "test3"); simple_free_urb(urb); Loading @@ -1680,7 +1688,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = simple_io(dev, urb, param->iterations, param->vary, 0, "test4"); simple_free_urb(urb); Loading @@ -1699,7 +1707,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = perform_sglist(dev, param->iterations, dev->out_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading @@ -1717,7 +1725,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = perform_sglist(dev, param->iterations, dev->in_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading @@ -1734,7 +1742,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk sink (maybe accepts short writes) /* FIRMWARE: bulk sink (maybe accepts short writes) */ retval = perform_sglist(dev, param->iterations, dev->out_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading @@ -1751,7 +1759,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) retval = -ENOMEM; break; } // FIRMWARE: bulk source (maybe generates short writes) /* FIRMWARE: bulk source (maybe generates short writes) */ retval = perform_sglist(dev, param->iterations, dev->in_pipe, &req, sg, param->sglen); free_sglist(sg, param->sglen); Loading Loading @@ -1844,7 +1852,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) "TEST 15: write %d iso, %d entries of %d bytes\n", param->iterations, param->sglen, param->length); // FIRMWARE: iso sink /* FIRMWARE: iso sink */ retval = test_iso_queue(dev, param, dev->out_iso_pipe, dev->iso_out); break; Loading @@ -1857,14 +1865,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) "TEST 16: read %d iso, %d entries of %d bytes\n", param->iterations, param->sglen, param->length); // FIRMWARE: iso source /* FIRMWARE: iso source */ retval = test_iso_queue(dev, param, dev->in_iso_pipe, dev->iso_in); break; // FIXME unlink from queue (ring with N urbs) /* FIXME unlink from queue (ring with N urbs) */ // FIXME scatterlist cancel (needs helper thread) /* FIXME scatterlist cancel (needs helper thread) */ } do_gettimeofday(¶m->duration); Loading @@ -1880,7 +1888,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) /*-------------------------------------------------------------------------*/ static unsigned force_interrupt = 0; static unsigned force_interrupt; module_param(force_interrupt, uint, 0); MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt"); Loading Loading @@ -1930,7 +1938,8 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) dev->intf = intf; /* cacheline-aligned scratch for i/o */ if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) { dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL); if (dev->buf == NULL) { kfree(dev); return -ENOMEM; } Loading Loading @@ -1984,10 +1993,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n", ({ char *tmp; switch (udev->speed) { case USB_SPEED_LOW: tmp = "low"; break; case USB_SPEED_FULL: tmp = "full"; break; case USB_SPEED_HIGH: tmp = "high"; break; default: tmp = "unknown"; break; case USB_SPEED_LOW: tmp = "low"; break; case USB_SPEED_FULL: tmp = "full"; break; case USB_SPEED_HIGH: tmp = "high"; break; default: tmp = "unknown"; break; }; tmp; }), info->ctrl_out ? " in/out" : "", rtest, wtest, Loading Loading @@ -2050,9 +2067,9 @@ static struct usbtest_info fw_info = { .ep_in = 2, .ep_out = 2, .alt = 1, .autoconf = 1, // iso and ctrl_out need autoconf .autoconf = 1, /* iso and ctrl_out need autoconf */ .ctrl_out = 1, .iso = 1, // iso_ep's are #8 in/out .iso = 1, /* iso_ep's are #8 in/out */ }; /* peripheral running Linux and 'zero.c' test firmware, or Loading Loading @@ -2145,7 +2162,7 @@ static const struct usb_device_id id_table[] = { #ifdef KEYSPAN_19Qi /* Keyspan 19qi uses an21xx (original EZ-USB) */ // this does not coexist with the real Keyspan 19qi driver! /* this does not coexist with the real Keyspan 19qi driver! */ { USB_DEVICE(0x06cd, 0x010b), .driver_info = (unsigned long) &ez1_info, }, Loading @@ -2155,7 +2172,7 @@ static const struct usb_device_id id_table[] = { #ifdef IBOT2 /* iBOT2 makes a nice source of high speed bulk-in data */ // this does not coexist with a real iBOT2 driver! /* this does not coexist with a real iBOT2 driver! */ { USB_DEVICE(0x0b62, 0x0059), .driver_info = (unsigned long) &ibot2_info, }, Loading