Merge tag 'usb-5.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are some small USB fixes that have been in linux-next this past
week for 5.3-rc7

They fix the usual xhci, syzbot reports, and other small issues that
have come up last week.

All have been in linux-next with no reported issues"

* tag 'usb-5.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
USB: cdc-wdm: fix race between write and disconnect due to flag abuse
usb: host: xhci: rcar: Fix typo in compatible string matching
usb: host: xhci-tegra: Set DMA mask correctly
USB: storage: ums-realtek: Whitelist auto-delink support
USB: storage: ums-realtek: Update module parameter description for auto_delink_en
usb: host: ohci: fix a race condition between shutdown and irq
usb: hcd: use managed device resources
typec: tcpm: fix a typo in the comparison of pdo_max_voltage
usb-storage: Add new JMS567 revision to unusual_devs
usb: chipidea: udc: don't do hardware access if gadget has stopped
usbtmc: more sanity checking for packet size
usb: udc: lpc32xx: silence fall-through warning

Changed files
+82 -47
drivers
+24 -8
drivers/usb/chipidea/udc.c
··· 709 709 struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget); 710 710 unsigned long flags; 711 711 712 - spin_lock_irqsave(&ci->lock, flags); 713 - ci->gadget.speed = USB_SPEED_UNKNOWN; 714 - ci->remote_wakeup = 0; 715 - ci->suspended = 0; 716 - spin_unlock_irqrestore(&ci->lock, flags); 717 - 718 712 /* flush all endpoints */ 719 713 gadget_for_each_ep(ep, gadget) { 720 714 usb_ep_fifo_flush(ep); ··· 725 731 usb_ep_free_request(&ci->ep0in->ep, ci->status); 726 732 ci->status = NULL; 727 733 } 734 + 735 + spin_lock_irqsave(&ci->lock, flags); 736 + ci->gadget.speed = USB_SPEED_UNKNOWN; 737 + ci->remote_wakeup = 0; 738 + ci->suspended = 0; 739 + spin_unlock_irqrestore(&ci->lock, flags); 728 740 729 741 return 0; 730 742 } ··· 1303 1303 return -EBUSY; 1304 1304 1305 1305 spin_lock_irqsave(hwep->lock, flags); 1306 + if (hwep->ci->gadget.speed == USB_SPEED_UNKNOWN) { 1307 + spin_unlock_irqrestore(hwep->lock, flags); 1308 + return 0; 1309 + } 1306 1310 1307 1311 /* only internal SW should disable ctrl endpts */ 1308 1312 ··· 1396 1392 return -EINVAL; 1397 1393 1398 1394 spin_lock_irqsave(hwep->lock, flags); 1395 + if (hwep->ci->gadget.speed == USB_SPEED_UNKNOWN) { 1396 + spin_unlock_irqrestore(hwep->lock, flags); 1397 + return 0; 1398 + } 1399 1399 retval = _ep_queue(ep, req, gfp_flags); 1400 1400 spin_unlock_irqrestore(hwep->lock, flags); 1401 1401 return retval; ··· 1423 1415 return -EINVAL; 1424 1416 1425 1417 spin_lock_irqsave(hwep->lock, flags); 1426 - 1427 - hw_ep_flush(hwep->ci, hwep->num, hwep->dir); 1418 + if (hwep->ci->gadget.speed != USB_SPEED_UNKNOWN) 1419 + hw_ep_flush(hwep->ci, hwep->num, hwep->dir); 1428 1420 1429 1421 list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) { 1430 1422 dma_pool_free(hwep->td_pool, node->ptr, node->dma); ··· 1495 1487 } 1496 1488 1497 1489 spin_lock_irqsave(hwep->lock, flags); 1490 + if (hwep->ci->gadget.speed == USB_SPEED_UNKNOWN) { 1491 + spin_unlock_irqrestore(hwep->lock, flags); 1492 + return; 1493 + } 1498 1494 1499 1495 hw_ep_flush(hwep->ci, hwep->num, hwep->dir); 1500 1496 ··· 1571 1559 int ret = 0; 1572 1560 1573 1561 spin_lock_irqsave(&ci->lock, flags); 1562 + if (ci->gadget.speed == USB_SPEED_UNKNOWN) { 1563 + spin_unlock_irqrestore(&ci->lock, flags); 1564 + return 0; 1565 + } 1574 1566 if (!ci->remote_wakeup) { 1575 1567 ret = -EOPNOTSUPP; 1576 1568 goto out;
+12 -4
drivers/usb/class/cdc-wdm.c
··· 587 587 { 588 588 struct wdm_device *desc = file->private_data; 589 589 590 - wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); 590 + wait_event(desc->wait, 591 + /* 592 + * needs both flags. We cannot do with one 593 + * because resetting it would cause a race 594 + * with write() yet we need to signal 595 + * a disconnect 596 + */ 597 + !test_bit(WDM_IN_USE, &desc->flags) || 598 + test_bit(WDM_DISCONNECTING, &desc->flags)); 591 599 592 600 /* cannot dereference desc->intf if WDM_DISCONNECTING */ 593 - if (desc->werr < 0 && !test_bit(WDM_DISCONNECTING, &desc->flags)) 601 + if (test_bit(WDM_DISCONNECTING, &desc->flags)) 602 + return -ENODEV; 603 + if (desc->werr < 0) 594 604 dev_err(&desc->intf->dev, "Error in flush path: %d\n", 595 605 desc->werr); 596 606 ··· 984 974 spin_lock_irqsave(&desc->iuspin, flags); 985 975 set_bit(WDM_DISCONNECTING, &desc->flags); 986 976 set_bit(WDM_READ, &desc->flags); 987 - /* to terminate pending flushes */ 988 - clear_bit(WDM_IN_USE, &desc->flags); 989 977 spin_unlock_irqrestore(&desc->iuspin, flags); 990 978 wake_up_all(&desc->wait); 991 979 mutex_lock(&desc->rlock);
+3
drivers/usb/class/usbtmc.c
··· 2362 2362 goto err_put; 2363 2363 } 2364 2364 2365 + retcode = -EINVAL; 2365 2366 data->bulk_in = bulk_in->bEndpointAddress; 2366 2367 data->wMaxPacketSize = usb_endpoint_maxp(bulk_in); 2368 + if (!data->wMaxPacketSize) 2369 + goto err_put; 2367 2370 dev_dbg(&intf->dev, "Found bulk in endpoint at %u\n", data->bulk_in); 2368 2371 2369 2372 data->bulk_out = bulk_out->bEndpointAddress;
+8 -22
drivers/usb/core/hcd-pci.c
··· 216 216 /* EHCI, OHCI */ 217 217 hcd->rsrc_start = pci_resource_start(dev, 0); 218 218 hcd->rsrc_len = pci_resource_len(dev, 0); 219 - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 220 - driver->description)) { 219 + if (!devm_request_mem_region(&dev->dev, hcd->rsrc_start, 220 + hcd->rsrc_len, driver->description)) { 221 221 dev_dbg(&dev->dev, "controller already in use\n"); 222 222 retval = -EBUSY; 223 223 goto put_hcd; 224 224 } 225 - hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); 225 + hcd->regs = devm_ioremap_nocache(&dev->dev, hcd->rsrc_start, 226 + hcd->rsrc_len); 226 227 if (hcd->regs == NULL) { 227 228 dev_dbg(&dev->dev, "error mapping memory\n"); 228 229 retval = -EFAULT; 229 - goto release_mem_region; 230 + goto put_hcd; 230 231 } 231 232 232 233 } else { ··· 241 240 242 241 hcd->rsrc_start = pci_resource_start(dev, region); 243 242 hcd->rsrc_len = pci_resource_len(dev, region); 244 - if (request_region(hcd->rsrc_start, hcd->rsrc_len, 245 - driver->description)) 243 + if (devm_request_region(&dev->dev, hcd->rsrc_start, 244 + hcd->rsrc_len, driver->description)) 246 245 break; 247 246 } 248 247 if (region == PCI_ROM_RESOURCE) { ··· 276 275 } 277 276 278 277 if (retval != 0) 279 - goto unmap_registers; 278 + goto put_hcd; 280 279 device_wakeup_enable(hcd->self.controller); 281 280 282 281 if (pci_dev_run_wake(dev)) 283 282 pm_runtime_put_noidle(&dev->dev); 284 283 return retval; 285 284 286 - unmap_registers: 287 - if (driver->flags & HCD_MEMORY) { 288 - iounmap(hcd->regs); 289 - release_mem_region: 290 - release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 291 - } else 292 - release_region(hcd->rsrc_start, hcd->rsrc_len); 293 285 put_hcd: 294 286 usb_put_hcd(hcd); 295 287 disable_pci: ··· 341 347 dev_set_drvdata(&dev->dev, NULL); 342 348 up_read(&companions_rwsem); 343 349 } 344 - 345 - if (hcd->driver->flags & HCD_MEMORY) { 346 - iounmap(hcd->regs); 347 - release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 348 - } else { 349 - release_region(hcd->rsrc_start, hcd->rsrc_len); 350 - } 351 - 352 350 usb_put_hcd(hcd); 353 351 pci_disable_device(dev); 354 352 }
+1 -1
drivers/usb/gadget/udc/lpc32xx_udc.c
··· 2265 2265 default: 2266 2266 break; 2267 2267 } 2268 - 2268 + break; 2269 2269 2270 2270 case USB_REQ_SET_ADDRESS: 2271 2271 if (reqtype == (USB_TYPE_STANDARD | USB_RECIP_DEVICE)) {
+12 -3
drivers/usb/host/ohci-hcd.c
··· 419 419 * other cases where the next software may expect clean state from the 420 420 * "firmware". this is bus-neutral, unlike shutdown() methods. 421 421 */ 422 - static void 423 - ohci_shutdown (struct usb_hcd *hcd) 422 + static void _ohci_shutdown(struct usb_hcd *hcd) 424 423 { 425 424 struct ohci_hcd *ohci; 426 425 ··· 433 434 434 435 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval); 435 436 ohci->rh_state = OHCI_RH_HALTED; 437 + } 438 + 439 + static void ohci_shutdown(struct usb_hcd *hcd) 440 + { 441 + struct ohci_hcd *ohci = hcd_to_ohci(hcd); 442 + unsigned long flags; 443 + 444 + spin_lock_irqsave(&ohci->lock, flags); 445 + _ohci_shutdown(hcd); 446 + spin_unlock_irqrestore(&ohci->lock, flags); 436 447 } 437 448 438 449 /*-------------------------------------------------------------------------* ··· 769 760 died: 770 761 usb_hc_died(ohci_to_hcd(ohci)); 771 762 ohci_dump(ohci); 772 - ohci_shutdown(ohci_to_hcd(ohci)); 763 + _ohci_shutdown(ohci_to_hcd(ohci)); 773 764 goto done; 774 765 } else { 775 766 /* No write back because the done queue was empty */
+1 -1
drivers/usb/host/xhci-rcar.c
··· 104 104 return of_device_is_compatible(node, "renesas,xhci-r8a7790") || 105 105 of_device_is_compatible(node, "renesas,xhci-r8a7791") || 106 106 of_device_is_compatible(node, "renesas,xhci-r8a7793") || 107 - of_device_is_compatible(node, "renensas,rcar-gen2-xhci"); 107 + of_device_is_compatible(node, "renesas,rcar-gen2-xhci"); 108 108 } 109 109 110 110 static int xhci_rcar_is_gen3(struct device *dev)
+10
drivers/usb/host/xhci-tegra.c
··· 1194 1194 1195 1195 tegra_xusb_config(tegra, regs); 1196 1196 1197 + /* 1198 + * The XUSB Falcon microcontroller can only address 40 bits, so set 1199 + * the DMA mask accordingly. 1200 + */ 1201 + err = dma_set_mask_and_coherent(tegra->dev, DMA_BIT_MASK(40)); 1202 + if (err < 0) { 1203 + dev_err(&pdev->dev, "failed to set DMA mask: %d\n", err); 1204 + goto put_rpm; 1205 + } 1206 + 1197 1207 err = tegra_xusb_load_firmware(tegra); 1198 1208 if (err < 0) { 1199 1209 dev_err(&pdev->dev, "failed to load firmware: %d\n", err);
+9 -6
drivers/usb/storage/realtek_cr.c
··· 38 38 39 39 static int auto_delink_en = 1; 40 40 module_param(auto_delink_en, int, S_IRUGO | S_IWUSR); 41 - MODULE_PARM_DESC(auto_delink_en, "enable auto delink"); 41 + MODULE_PARM_DESC(auto_delink_en, "auto delink mode (0=firmware, 1=software [default])"); 42 42 43 43 #ifdef CONFIG_REALTEK_AUTOPM 44 44 static int ss_en = 1; ··· 996 996 goto INIT_FAIL; 997 997 } 998 998 999 - if (CHECK_FW_VER(chip, 0x5888) || CHECK_FW_VER(chip, 0x5889) || 1000 - CHECK_FW_VER(chip, 0x5901)) 1001 - SET_AUTO_DELINK(chip); 1002 - if (STATUS_LEN(chip) == 16) { 1003 - if (SUPPORT_AUTO_DELINK(chip)) 999 + if (CHECK_PID(chip, 0x0138) || CHECK_PID(chip, 0x0158) || 1000 + CHECK_PID(chip, 0x0159)) { 1001 + if (CHECK_FW_VER(chip, 0x5888) || CHECK_FW_VER(chip, 0x5889) || 1002 + CHECK_FW_VER(chip, 0x5901)) 1004 1003 SET_AUTO_DELINK(chip); 1004 + if (STATUS_LEN(chip) == 16) { 1005 + if (SUPPORT_AUTO_DELINK(chip)) 1006 + SET_AUTO_DELINK(chip); 1007 + } 1005 1008 } 1006 1009 #ifdef CONFIG_REALTEK_AUTOPM 1007 1010 if (ss_en)
+1 -1
drivers/usb/storage/unusual_devs.h
··· 2100 2100 US_FL_IGNORE_RESIDUE ), 2101 2101 2102 2102 /* Reported by Michael Büsch <m@bues.ch> */ 2103 - UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x0116, 2103 + UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x0117, 2104 2104 "JMicron", 2105 2105 "USB to ATA/ATAPI Bridge", 2106 2106 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+1 -1
drivers/usb/typec/tcpm/tcpm.c
··· 1446 1446 else if ((pdo_min_voltage(pdo[i]) == 1447 1447 pdo_min_voltage(pdo[i - 1])) && 1448 1448 (pdo_max_voltage(pdo[i]) == 1449 - pdo_min_voltage(pdo[i - 1]))) 1449 + pdo_max_voltage(pdo[i - 1]))) 1450 1450 return PDO_ERR_DUPE_PDO; 1451 1451 break; 1452 1452 /*