Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6:
USB: isp1362: fix build failure on ARM systems via irq_flags cleanup
USB: isp1362: better 64bit printf warning fixes
USB: fix usbstorage for 2770:915d delivers no FAT
USB: Fix level of isp1760 Reloading ptd error message
USB: FHCI: avoid NULL pointer dereference
USB: Fix duplicate sysfs problem after device reset.
USB: add speed values for USB 3.0 and wireless controllers
USB: add missing delay during remote wakeup
USB: EHCI & UHCI: fix race between root-hub suspend and port resume
USB: EHCI: fix handling of unusual interrupt intervals
USB: Don't use GFP_KERNEL while we cannot reset a storage device
USB: fix bitmask merge error
usb: serial: fix memory leak in generic driver
USB: serial: fix USB serial fix kfifo_len locking

+112 -48
+1 -1
drivers/usb/core/devices.c
··· 494 494 return 0; 495 495 /* allocate 2^1 pages = 8K (on i386); 496 496 * should be more than enough for one device */ 497 - pages_start = (char *)__get_free_pages(GFP_KERNEL, 1); 497 + pages_start = (char *)__get_free_pages(GFP_NOIO, 1); 498 498 if (!pages_start) 499 499 return -ENOMEM; 500 500
+18
drivers/usb/core/hcd.c
··· 1684 1684 } 1685 1685 } 1686 1686 if (cur_alt && new_alt) { 1687 + struct usb_interface *iface = usb_ifnum_to_if(udev, 1688 + cur_alt->desc.bInterfaceNumber); 1689 + 1690 + if (iface->resetting_device) { 1691 + /* 1692 + * The USB core just reset the device, so the xHCI host 1693 + * and the device will think alt setting 0 is installed. 1694 + * However, the USB core will pass in the alternate 1695 + * setting installed before the reset as cur_alt. Dig 1696 + * out the alternate setting 0 structure, or the first 1697 + * alternate setting if a broken device doesn't have alt 1698 + * setting 0. 1699 + */ 1700 + cur_alt = usb_altnum_to_altsetting(iface, 0); 1701 + if (!cur_alt) 1702 + cur_alt = &iface->altsetting[0]; 1703 + } 1704 + 1687 1705 /* Drop all the endpoints in the current alt setting */ 1688 1706 for (i = 0; i < cur_alt->desc.bNumEndpoints; i++) { 1689 1707 ret = hcd->driver->drop_endpoint(hcd, udev,
+8 -10
drivers/usb/core/hub.c
··· 3347 3347 USB_PORT_FEAT_C_SUSPEND); 3348 3348 udev = hdev->children[i-1]; 3349 3349 if (udev) { 3350 + /* TRSMRCY = 10 msec */ 3351 + msleep(10); 3352 + 3350 3353 usb_lock_device(udev); 3351 3354 ret = remote_wakeup(hdev-> 3352 3355 children[i-1]); ··· 3695 3692 usb_enable_interface(udev, intf, true); 3696 3693 ret = 0; 3697 3694 } else { 3698 - /* We've just reset the device, so it will think alt 3699 - * setting 0 is installed. For usb_set_interface() to 3700 - * work properly, we need to set the current alternate 3701 - * interface setting to 0 (or the first alt setting, if 3702 - * the device doesn't have alt setting 0). 3695 + /* Let the bandwidth allocation function know that this 3696 + * device has been reset, and it will have to use 3697 + * alternate setting 0 as the current alternate setting. 3703 3698 */ 3704 - intf->cur_altsetting = 3705 - usb_find_alt_setting(config, i, 0); 3706 - if (!intf->cur_altsetting) 3707 - intf->cur_altsetting = 3708 - &config->intf_cache[i]->altsetting[0]; 3699 + intf->resetting_device = 1; 3709 3700 ret = usb_set_interface(udev, desc->bInterfaceNumber, 3710 3701 desc->bAlternateSetting); 3702 + intf->resetting_device = 0; 3711 3703 } 3712 3704 if (ret < 0) { 3713 3705 dev_err(&udev->dev, "failed to restore interface %d "
+4 -4
drivers/usb/core/message.c
··· 906 906 if (index <= 0) 907 907 return NULL; 908 908 909 - buf = kmalloc(MAX_USB_STRING_SIZE, GFP_KERNEL); 909 + buf = kmalloc(MAX_USB_STRING_SIZE, GFP_NOIO); 910 910 if (buf) { 911 911 len = usb_string(udev, index, buf, MAX_USB_STRING_SIZE); 912 912 if (len > 0) { 913 - smallbuf = kmalloc(++len, GFP_KERNEL); 913 + smallbuf = kmalloc(++len, GFP_NOIO); 914 914 if (!smallbuf) 915 915 return buf; 916 916 memcpy(smallbuf, buf, len); ··· 1731 1731 if (cp) { 1732 1732 nintf = cp->desc.bNumInterfaces; 1733 1733 new_interfaces = kmalloc(nintf * sizeof(*new_interfaces), 1734 - GFP_KERNEL); 1734 + GFP_NOIO); 1735 1735 if (!new_interfaces) { 1736 1736 dev_err(&dev->dev, "Out of memory\n"); 1737 1737 return -ENOMEM; ··· 1740 1740 for (; n < nintf; ++n) { 1741 1741 new_interfaces[n] = kzalloc( 1742 1742 sizeof(struct usb_interface), 1743 - GFP_KERNEL); 1743 + GFP_NOIO); 1744 1744 if (!new_interfaces[n]) { 1745 1745 dev_err(&dev->dev, "Out of memory\n"); 1746 1746 ret = -ENOMEM;
+6
drivers/usb/core/sysfs.c
··· 115 115 case USB_SPEED_HIGH: 116 116 speed = "480"; 117 117 break; 118 + case USB_SPEED_VARIABLE: 119 + speed = "480"; 120 + break; 121 + case USB_SPEED_SUPER: 122 + speed = "5000"; 123 + break; 118 124 default: 119 125 speed = "unknown"; 120 126 }
+3 -2
drivers/usb/host/ehci-hcd.c
··· 787 787 788 788 /* start 20 msec resume signaling from this port, 789 789 * and make khubd collect PORT_STAT_C_SUSPEND to 790 - * stop that signaling. 790 + * stop that signaling. Use 5 ms extra for safety, 791 + * like usb_port_resume() does. 791 792 */ 792 - ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 793 + ehci->reset_done[i] = jiffies + msecs_to_jiffies(25); 793 794 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 794 795 mod_timer(&hcd->rh_timer, ehci->reset_done[i]); 795 796 }
+19 -1
drivers/usb/host/ehci-hub.c
··· 120 120 del_timer_sync(&ehci->watchdog); 121 121 del_timer_sync(&ehci->iaa_watchdog); 122 122 123 - port = HCS_N_PORTS (ehci->hcs_params); 124 123 spin_lock_irq (&ehci->lock); 124 + 125 + /* Once the controller is stopped, port resumes that are already 126 + * in progress won't complete. Hence if remote wakeup is enabled 127 + * for the root hub and any ports are in the middle of a resume or 128 + * remote wakeup, we must fail the suspend. 129 + */ 130 + if (hcd->self.root_hub->do_remote_wakeup) { 131 + port = HCS_N_PORTS(ehci->hcs_params); 132 + while (port--) { 133 + if (ehci->reset_done[port] != 0) { 134 + spin_unlock_irq(&ehci->lock); 135 + ehci_dbg(ehci, "suspend failed because " 136 + "port %d is resuming\n", 137 + port + 1); 138 + return -EBUSY; 139 + } 140 + } 141 + } 125 142 126 143 /* stop schedules, clean any completed work */ 127 144 if (HC_IS_RUNNING(hcd->state)) { ··· 155 138 */ 156 139 ehci->bus_suspended = 0; 157 140 ehci->owned_ports = 0; 141 + port = HCS_N_PORTS(ehci->hcs_params); 158 142 while (port--) { 159 143 u32 __iomem *reg = &ehci->regs->port_status [port]; 160 144 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
+8 -3
drivers/usb/host/ehci-q.c
··· 849 849 * But interval 1 scheduling is simpler, and 850 850 * includes high bandwidth. 851 851 */ 852 - dbg ("intr period %d uframes, NYET!", 853 - urb->interval); 854 - goto done; 852 + urb->interval = 1; 853 + } else if (qh->period > ehci->periodic_size) { 854 + qh->period = ehci->periodic_size; 855 + urb->interval = qh->period << 3; 855 856 } 856 857 } else { 857 858 int think_time; ··· 875 874 usb_calc_bus_time (urb->dev->speed, 876 875 is_input, 0, max_packet (maxp))); 877 876 qh->period = urb->interval; 877 + if (qh->period > ehci->periodic_size) { 878 + qh->period = ehci->periodic_size; 879 + urb->interval = qh->period; 880 + } 878 881 } 879 882 } 880 883
+2 -1
drivers/usb/host/fhci-hcd.c
··· 242 242 static void fhci_usb_free(void *lld) 243 243 { 244 244 struct fhci_usb *usb = lld; 245 - struct fhci_hcd *fhci = usb->fhci; 245 + struct fhci_hcd *fhci; 246 246 247 247 if (usb) { 248 + fhci = usb->fhci; 248 249 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF); 249 250 fhci_ep0_free(usb); 250 251 kfree(usb->actual_frame);
+16 -9
drivers/usb/host/isp1362-hcd.c
··· 2270 2270 dev_info(hcd->self.controller, "ISP1362 Memory usage:\n"); 2271 2271 dev_info(hcd->self.controller, " ISTL: 2 * %4d: %4d @ $%04x:$%04x\n", 2272 2272 istl_size / 2, istl_size, 0, istl_size / 2); 2273 - dev_info(hcd->self.controller, " INTL: %4d * (%3lu+8): %4d @ $%04x\n", 2273 + dev_info(hcd->self.controller, " INTL: %4d * (%3zu+8): %4d @ $%04x\n", 2274 2274 ISP1362_INTL_BUFFERS, intl_blksize - PTD_HEADER_SIZE, 2275 2275 intl_size, istl_size); 2276 - dev_info(hcd->self.controller, " ATL : %4d * (%3lu+8): %4d @ $%04x\n", 2276 + dev_info(hcd->self.controller, " ATL : %4d * (%3zu+8): %4d @ $%04x\n", 2277 2277 atl_buffers, atl_blksize - PTD_HEADER_SIZE, 2278 2278 atl_size, istl_size + intl_size); 2279 2279 dev_info(hcd->self.controller, " USED/FREE: %4d %4d\n", total, ··· 2697 2697 void __iomem *data_reg; 2698 2698 int irq; 2699 2699 int retval = 0; 2700 + struct resource *irq_res; 2701 + unsigned int irq_flags = 0; 2700 2702 2701 2703 /* basic sanity checks first. board-specific init logic should 2702 2704 * have initialized this the three resources and probably board ··· 2712 2710 2713 2711 data = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2714 2712 addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2715 - irq = platform_get_irq(pdev, 0); 2716 - if (!addr || !data || irq < 0) { 2713 + irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2714 + if (!addr || !data || !irq_res) { 2717 2715 retval = -ENODEV; 2718 2716 goto err1; 2719 2717 } 2718 + irq = irq_res->start; 2720 2719 2721 2720 #ifdef CONFIG_USB_HCD_DMA 2722 2721 if (pdev->dev.dma_mask) { ··· 2784 2781 } 2785 2782 #endif 2786 2783 2787 - #ifdef CONFIG_ARM 2788 - if (isp1362_hcd->board) 2789 - set_irq_type(irq, isp1362_hcd->board->int_act_high ? IRQT_RISING : IRQT_FALLING); 2790 - #endif 2784 + if (irq_res->flags & IORESOURCE_IRQ_HIGHEDGE) 2785 + irq_flags |= IRQF_TRIGGER_RISING; 2786 + if (irq_res->flags & IORESOURCE_IRQ_LOWEDGE) 2787 + irq_flags |= IRQF_TRIGGER_FALLING; 2788 + if (irq_res->flags & IORESOURCE_IRQ_HIGHLEVEL) 2789 + irq_flags |= IRQF_TRIGGER_HIGH; 2790 + if (irq_res->flags & IORESOURCE_IRQ_LOWLEVEL) 2791 + irq_flags |= IRQF_TRIGGER_LOW; 2791 2792 2792 - retval = usb_add_hcd(hcd, irq, IRQF_TRIGGER_LOW | IRQF_DISABLED | IRQF_SHARED); 2793 + retval = usb_add_hcd(hcd, irq, irq_flags | IRQF_DISABLED | IRQF_SHARED); 2793 2794 if (retval != 0) 2794 2795 goto err6; 2795 2796 pr_info("%s, irq %d\n", hcd->product_desc, irq);
+3 -3
drivers/usb/host/isp1760-hcd.c
··· 1039 1039 if (!nakcount && (dw3 & DW3_QTD_ACTIVE)) { 1040 1040 u32 buffstatus; 1041 1041 1042 - /* XXX 1042 + /* 1043 1043 * NAKs are handled in HW by the chip. Usually if the 1044 1044 * device is not able to send data fast enough. 1045 - * This did not trigger for a long time now. 1045 + * This happens mostly on slower hardware. 1046 1046 */ 1047 - printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " 1047 + printk(KERN_NOTICE "Reloading ptd %p/%p... qh %p read: " 1048 1048 "%d of %zu done: %08x cur: %08x\n", qtd, 1049 1049 urb, qh, PTD_XFERRED_LENGTH(dw3), 1050 1050 qtd->length, done_map,
+14 -1
drivers/usb/host/uhci-hcd.c
··· 749 749 spin_lock_irq(&uhci->lock); 750 750 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 751 751 rc = -ESHUTDOWN; 752 - else if (!uhci->dead) 752 + else if (uhci->dead) 753 + ; /* Dead controllers tell no tales */ 754 + 755 + /* Once the controller is stopped, port resumes that are already 756 + * in progress won't complete. Hence if remote wakeup is enabled 757 + * for the root hub and any ports are in the middle of a resume or 758 + * remote wakeup, we must fail the suspend. 759 + */ 760 + else if (hcd->self.root_hub->do_remote_wakeup && 761 + uhci->resuming_ports) { 762 + dev_dbg(uhci_dev(uhci), "suspend failed because a port " 763 + "is resuming\n"); 764 + rc = -EBUSY; 765 + } else 753 766 suspend_rh(uhci, UHCI_RH_SUSPENDED); 754 767 spin_unlock_irq(&uhci->lock); 755 768 return rc;
+1 -1
drivers/usb/host/uhci-hub.c
··· 167 167 /* Port received a wakeup request */ 168 168 set_bit(port, &uhci->resuming_ports); 169 169 uhci->ports_timeout = jiffies + 170 - msecs_to_jiffies(20); 170 + msecs_to_jiffies(25); 171 171 172 172 /* Make sure we see the port again 173 173 * after the resuming period is over. */
+6 -4
drivers/usb/serial/generic.c
··· 386 386 387 387 dbg("%s - port %d", __func__, port->number); 388 388 389 - if (serial->type->max_in_flight_urbs) { 390 - spin_lock_irqsave(&port->lock, flags); 389 + spin_lock_irqsave(&port->lock, flags); 390 + if (serial->type->max_in_flight_urbs) 391 391 chars = port->tx_bytes_flight; 392 - spin_unlock_irqrestore(&port->lock, flags); 393 - } else if (serial->num_bulk_out) 392 + else if (serial->num_bulk_out) 394 393 chars = kfifo_len(&port->write_fifo); 394 + spin_unlock_irqrestore(&port->lock, flags); 395 395 396 396 dbg("%s - returns %d", __func__, chars); 397 397 return chars; ··· 489 489 dbg("%s - port %d", __func__, port->number); 490 490 491 491 if (port->serial->type->max_in_flight_urbs) { 492 + kfree(urb->transfer_buffer); 493 + 492 494 spin_lock_irqsave(&port->lock, flags); 493 495 --port->urbs_in_flight; 494 496 port->tx_bytes_flight -= urb->transfer_buffer_length;
-7
drivers/usb/storage/unusual_devs.h
··· 1807 1807 US_SC_DEVICE, US_PR_DEVICE, NULL, 1808 1808 US_FL_GO_SLOW ), 1809 1809 1810 - /* Reported by Rohan Hart <rohan.hart17@gmail.com> */ 1811 - UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010, 1812 - "INTOVA", 1813 - "Pixtreme", 1814 - US_SC_DEVICE, US_PR_DEVICE, NULL, 1815 - US_FL_FIX_CAPACITY ), 1816 - 1817 1810 /* Reported by Frederic Marchal <frederic.marchal@wowcompany.com> 1818 1811 * Mio Moov 330 1819 1812 */
+2 -1
drivers/usb/storage/usb.c
··· 434 434 u16 vid = le16_to_cpu(us->pusb_dev->descriptor.idVendor); 435 435 u16 pid = le16_to_cpu(us->pusb_dev->descriptor.idProduct); 436 436 unsigned f = 0; 437 - unsigned int mask = (US_FL_SANE_SENSE | US_FL_FIX_CAPACITY | 437 + unsigned int mask = (US_FL_SANE_SENSE | US_FL_BAD_SENSE | 438 + US_FL_FIX_CAPACITY | 438 439 US_FL_CAPACITY_HEURISTICS | US_FL_IGNORE_DEVICE | 439 440 US_FL_NOT_LOCKABLE | US_FL_MAX_SECTORS_64 | 440 441 US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |
+1
include/linux/usb.h
··· 192 192 unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ 193 193 unsigned needs_binding:1; /* needs delayed unbind/rebind */ 194 194 unsigned reset_running:1; 195 + unsigned resetting_device:1; /* true: bandwidth alloc after reset */ 195 196 196 197 struct device dev; /* interface specific device info */ 197 198 struct device *usb_dev;