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

Pull USB fixes from Greg KH:
"Here are a handful of small USB driver fixes for 6.10-rc6 to resolve
some reported issues. Included in here are:

- typec driver bugfixes

- usb gadget driver reverts for commits that were reported to have
problems

- resource leak bugfix

- gadget driver bugfixes

- dwc3 driver bugfixes

- usb atm driver bugfix for when syzbot got loose on it

All of these have been in linux-next this week with no reported issues"

* tag 'usb-6.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usb: dwc3: core: Workaround for CSR read timeout
Revert "usb: gadget: u_ether: Replace netif_stop_queue with netif_device_detach"
Revert "usb: gadget: u_ether: Re-attach netif device to mirror detachment"
usb: gadget: aspeed_udc: fix device address configuration
usb: dwc3: core: remove lock of otg mode during gadget suspend/resume to avoid deadlock
usb: typec: ucsi: glink: fix child node release in probe function
usb: musb: da8xx: fix a resource leak in probe()
usb: typec: ucsi_acpi: Add LG Gram quirk
usb: ucsi: stm32: fix command completion handling
usb: atm: cxacru: fix endpoint checking in cxacru_bind()
usb: gadget: printer: fix races against disable
usb: gadget: printer: SS+ support

+152 -29
+14
drivers/usb/atm/cxacru.c
··· 1131 1131 struct cxacru_data *instance; 1132 1132 struct usb_device *usb_dev = interface_to_usbdev(intf); 1133 1133 struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD]; 1134 + struct usb_endpoint_descriptor *in, *out; 1134 1135 int ret; 1135 1136 1136 1137 /* instance init */ ··· 1174 1173 1175 1174 if (!cmd_ep) { 1176 1175 usb_dbg(usbatm_instance, "cxacru_bind: no command endpoint\n"); 1176 + ret = -ENODEV; 1177 + goto fail; 1178 + } 1179 + 1180 + if (usb_endpoint_xfer_int(&cmd_ep->desc)) 1181 + ret = usb_find_common_endpoints(intf->cur_altsetting, 1182 + NULL, NULL, &in, &out); 1183 + else 1184 + ret = usb_find_common_endpoints(intf->cur_altsetting, 1185 + &in, &out, NULL, NULL); 1186 + 1187 + if (ret) { 1188 + usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n"); 1177 1189 ret = -ENODEV; 1178 1190 goto fail; 1179 1191 }
+19 -7
drivers/usb/dwc3/core.c
··· 957 957 958 958 static void dwc3_core_setup_global_control(struct dwc3 *dwc) 959 959 { 960 + unsigned int power_opt; 961 + unsigned int hw_mode; 960 962 u32 reg; 961 963 962 964 reg = dwc3_readl(dwc->regs, DWC3_GCTL); 963 965 reg &= ~DWC3_GCTL_SCALEDOWN_MASK; 966 + hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); 967 + power_opt = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1); 964 968 965 - switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { 969 + switch (power_opt) { 966 970 case DWC3_GHWPARAMS1_EN_PWROPT_CLK: 967 971 /** 968 972 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an ··· 998 994 /* nothing */ 999 995 break; 1000 996 } 997 + 998 + /* 999 + * This is a workaround for STAR#4846132, which only affects 1000 + * DWC_usb31 version2.00a operating in host mode. 1001 + * 1002 + * There is a problem in DWC_usb31 version 2.00a operating 1003 + * in host mode that would cause a CSR read timeout When CSR 1004 + * read coincides with RAM Clock Gating Entry. By disable 1005 + * Clock Gating, sacrificing power consumption for normal 1006 + * operation. 1007 + */ 1008 + if (power_opt != DWC3_GHWPARAMS1_EN_PWROPT_NO && 1009 + hw_mode != DWC3_GHWPARAMS0_MODE_GADGET && DWC3_VER_IS(DWC31, 200A)) 1010 + reg |= DWC3_GCTL_DSBLCLKGTNG; 1001 1011 1002 1012 /* check if current dwc3 is on simulation board */ 1003 1013 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) { ··· 2268 2250 2269 2251 static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) 2270 2252 { 2271 - unsigned long flags; 2272 2253 u32 reg; 2273 2254 int i; 2274 2255 ··· 2310 2293 break; 2311 2294 2312 2295 if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) { 2313 - spin_lock_irqsave(&dwc->lock, flags); 2314 2296 dwc3_gadget_suspend(dwc); 2315 - spin_unlock_irqrestore(&dwc->lock, flags); 2316 2297 synchronize_irq(dwc->irq_gadget); 2317 2298 } 2318 2299 ··· 2327 2312 2328 2313 static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) 2329 2314 { 2330 - unsigned long flags; 2331 2315 int ret; 2332 2316 u32 reg; 2333 2317 int i; ··· 2380 2366 if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) { 2381 2367 dwc3_otg_host_init(dwc); 2382 2368 } else if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) { 2383 - spin_lock_irqsave(&dwc->lock, flags); 2384 2369 dwc3_gadget_resume(dwc); 2385 - spin_unlock_irqrestore(&dwc->lock, flags); 2386 2370 } 2387 2371 2388 2372 break;
+30 -10
drivers/usb/gadget/function/f_printer.c
··· 213 213 struct usb_endpoint_descriptor *ss) 214 214 { 215 215 switch (gadget->speed) { 216 + case USB_SPEED_SUPER_PLUS: 216 217 case USB_SPEED_SUPER: 217 218 return ss; 218 219 case USB_SPEED_HIGH: ··· 450 449 mutex_lock(&dev->lock_printer_io); 451 450 spin_lock_irqsave(&dev->lock, flags); 452 451 453 - if (dev->interface < 0) { 454 - spin_unlock_irqrestore(&dev->lock, flags); 455 - mutex_unlock(&dev->lock_printer_io); 456 - return -ENODEV; 457 - } 452 + if (dev->interface < 0) 453 + goto out_disabled; 458 454 459 455 /* We will use this flag later to check if a printer reset happened 460 456 * after we turn interrupts back on. ··· 459 461 dev->reset_printer = 0; 460 462 461 463 setup_rx_reqs(dev); 464 + /* this dropped the lock - need to retest */ 465 + if (dev->interface < 0) 466 + goto out_disabled; 462 467 463 468 bytes_copied = 0; 464 469 current_rx_req = dev->current_rx_req; ··· 495 494 wait_event_interruptible(dev->rx_wait, 496 495 (likely(!list_empty(&dev->rx_buffers)))); 497 496 spin_lock_irqsave(&dev->lock, flags); 497 + if (dev->interface < 0) 498 + goto out_disabled; 498 499 } 499 500 500 501 /* We have data to return then copy it to the caller's buffer.*/ ··· 540 537 return -EAGAIN; 541 538 } 542 539 540 + if (dev->interface < 0) 541 + goto out_disabled; 542 + 543 543 /* If we not returning all the data left in this RX request 544 544 * buffer then adjust the amount of data left in the buffer. 545 545 * Othewise if we are done with this RX request buffer then ··· 572 566 return bytes_copied; 573 567 else 574 568 return -EAGAIN; 569 + 570 + out_disabled: 571 + spin_unlock_irqrestore(&dev->lock, flags); 572 + mutex_unlock(&dev->lock_printer_io); 573 + return -ENODEV; 575 574 } 576 575 577 576 static ssize_t ··· 597 586 mutex_lock(&dev->lock_printer_io); 598 587 spin_lock_irqsave(&dev->lock, flags); 599 588 600 - if (dev->interface < 0) { 601 - spin_unlock_irqrestore(&dev->lock, flags); 602 - mutex_unlock(&dev->lock_printer_io); 603 - return -ENODEV; 604 - } 589 + if (dev->interface < 0) 590 + goto out_disabled; 605 591 606 592 /* Check if a printer reset happens while we have interrupts on */ 607 593 dev->reset_printer = 0; ··· 621 613 wait_event_interruptible(dev->tx_wait, 622 614 (likely(!list_empty(&dev->tx_reqs)))); 623 615 spin_lock_irqsave(&dev->lock, flags); 616 + if (dev->interface < 0) 617 + goto out_disabled; 624 618 } 625 619 626 620 while (likely(!list_empty(&dev->tx_reqs)) && len) { ··· 672 662 return -EAGAIN; 673 663 } 674 664 665 + if (dev->interface < 0) 666 + goto out_disabled; 667 + 675 668 list_add(&req->list, &dev->tx_reqs_active); 676 669 677 670 /* here, we unlock, and only unlock, to avoid deadlock. */ ··· 687 674 mutex_unlock(&dev->lock_printer_io); 688 675 return -EAGAIN; 689 676 } 677 + if (dev->interface < 0) 678 + goto out_disabled; 690 679 } 691 680 692 681 spin_unlock_irqrestore(&dev->lock, flags); ··· 700 685 return bytes_copied; 701 686 else 702 687 return -EAGAIN; 688 + 689 + out_disabled: 690 + spin_unlock_irqrestore(&dev->lock, flags); 691 + mutex_unlock(&dev->lock_printer_io); 692 + return -ENODEV; 703 693 } 704 694 705 695 static int
+1 -3
drivers/usb/gadget/function/u_ether.c
··· 1163 1163 if (netif_running(dev->net)) 1164 1164 eth_start(dev, GFP_ATOMIC); 1165 1165 1166 - netif_device_attach(dev->net); 1167 - 1168 1166 /* on error, disable any endpoints */ 1169 1167 } else { 1170 1168 (void) usb_ep_disable(link->out_ep); ··· 1200 1202 1201 1203 DBG(dev, "%s\n", __func__); 1202 1204 1203 - netif_device_detach(dev->net); 1205 + netif_stop_queue(dev->net); 1204 1206 netif_carrier_off(dev->net); 1205 1207 1206 1208 /* disable endpoints, forcing (synchronous) completion
+2 -2
drivers/usb/gadget/udc/aspeed_udc.c
··· 66 66 #define USB_UPSTREAM_EN BIT(0) 67 67 68 68 /* Main config reg */ 69 - #define UDC_CFG_SET_ADDR(x) ((x) & 0x3f) 70 - #define UDC_CFG_ADDR_MASK (0x3f) 69 + #define UDC_CFG_SET_ADDR(x) ((x) & UDC_CFG_ADDR_MASK) 70 + #define UDC_CFG_ADDR_MASK GENMASK(6, 0) 71 71 72 72 /* Interrupt ctrl & status reg */ 73 73 #define UDC_IRQ_EP_POOL_NAK BIT(17)
+6 -2
drivers/usb/musb/da8xx.c
··· 556 556 ret = of_platform_populate(pdev->dev.of_node, NULL, 557 557 da8xx_auxdata_lookup, &pdev->dev); 558 558 if (ret) 559 - return ret; 559 + goto err_unregister_phy; 560 560 561 561 pinfo = da8xx_dev_info; 562 562 pinfo.parent = &pdev->dev; ··· 571 571 ret = PTR_ERR_OR_ZERO(glue->musb); 572 572 if (ret) { 573 573 dev_err(&pdev->dev, "failed to register musb device: %d\n", ret); 574 - usb_phy_generic_unregister(glue->usb_phy); 574 + goto err_unregister_phy; 575 575 } 576 576 577 + return 0; 578 + 579 + err_unregister_phy: 580 + usb_phy_generic_unregister(glue->usb_phy); 577 581 return ret; 578 582 } 579 583
+61
drivers/usb/typec/ucsi/ucsi_acpi.c
··· 25 25 unsigned long flags; 26 26 #define UCSI_ACPI_COMMAND_PENDING 1 27 27 #define UCSI_ACPI_ACK_PENDING 2 28 + #define UCSI_ACPI_CHECK_BOGUS_EVENT 3 28 29 guid_t guid; 29 30 u64 cmd; 30 31 }; ··· 129 128 .async_write = ucsi_acpi_async_write 130 129 }; 131 130 131 + static int ucsi_gram_read(struct ucsi *ucsi, unsigned int offset, 132 + void *val, size_t val_len) 133 + { 134 + u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE | 135 + UCSI_CONSTAT_PDOS_CHANGE; 136 + struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 137 + struct ucsi_connector_status *status; 138 + int ret; 139 + 140 + ret = ucsi_acpi_read(ucsi, offset, val, val_len); 141 + if (ret < 0) 142 + return ret; 143 + 144 + if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS && 145 + test_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags) && 146 + offset == UCSI_MESSAGE_IN) { 147 + status = (struct ucsi_connector_status *)val; 148 + 149 + /* Clear the bogus change */ 150 + if (status->change == bogus_change) 151 + status->change = 0; 152 + 153 + clear_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags); 154 + } 155 + 156 + return ret; 157 + } 158 + 159 + static int ucsi_gram_sync_write(struct ucsi *ucsi, unsigned int offset, 160 + const void *val, size_t val_len) 161 + { 162 + struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); 163 + int ret; 164 + 165 + ret = ucsi_acpi_sync_write(ucsi, offset, val, val_len); 166 + if (ret < 0) 167 + return ret; 168 + 169 + if (UCSI_COMMAND(ua->cmd) == UCSI_GET_PDOS && 170 + ua->cmd & UCSI_GET_PDOS_PARTNER_PDO(1) && 171 + ua->cmd & UCSI_GET_PDOS_SRC_PDOS) 172 + set_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags); 173 + 174 + return ret; 175 + } 176 + 177 + static const struct ucsi_operations ucsi_gram_ops = { 178 + .read = ucsi_gram_read, 179 + .sync_write = ucsi_gram_sync_write, 180 + .async_write = ucsi_acpi_async_write 181 + }; 182 + 132 183 static const struct dmi_system_id ucsi_acpi_quirks[] = { 133 184 { 134 185 .matches = { ··· 188 135 DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325UA_UM325UA"), 189 136 }, 190 137 .driver_data = (void *)&ucsi_zenbook_ops, 138 + }, 139 + { 140 + .matches = { 141 + DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), 142 + DMI_MATCH(DMI_PRODUCT_FAMILY, "LG gram PC"), 143 + DMI_MATCH(DMI_PRODUCT_NAME, "90Q"), 144 + }, 145 + .driver_data = (void *)&ucsi_gram_ops, 191 146 }, 192 147 { } 193 148 };
+4 -1
drivers/usb/typec/ucsi/ucsi_glink.c
··· 372 372 ret = fwnode_property_read_u32(fwnode, "reg", &port); 373 373 if (ret < 0) { 374 374 dev_err(dev, "missing reg property of %pOFn\n", fwnode); 375 + fwnode_handle_put(fwnode); 375 376 return ret; 376 377 } 377 378 ··· 387 386 if (!desc) 388 387 continue; 389 388 390 - if (IS_ERR(desc)) 389 + if (IS_ERR(desc)) { 390 + fwnode_handle_put(fwnode); 391 391 return dev_err_probe(dev, PTR_ERR(desc), 392 392 "unable to acquire orientation gpio\n"); 393 + } 393 394 ucsi->port_orientation[port] = desc; 394 395 } 395 396
+15 -4
drivers/usb/typec/ucsi/ucsi_stm32g0.c
··· 65 65 struct device *dev; 66 66 unsigned long flags; 67 67 #define COMMAND_PENDING 1 68 + #define ACK_PENDING 2 68 69 const char *fw_name; 69 70 struct ucsi *ucsi; 70 71 bool suspended; ··· 397 396 size_t len) 398 397 { 399 398 struct ucsi_stm32g0 *g0 = ucsi_get_drvdata(ucsi); 399 + bool ack = UCSI_COMMAND(*(u64 *)val) == UCSI_ACK_CC_CI; 400 400 int ret; 401 401 402 - set_bit(COMMAND_PENDING, &g0->flags); 402 + if (ack) 403 + set_bit(ACK_PENDING, &g0->flags); 404 + else 405 + set_bit(COMMAND_PENDING, &g0->flags); 403 406 404 407 ret = ucsi_stm32g0_async_write(ucsi, offset, val, len); 405 408 if (ret) ··· 411 406 412 407 if (!wait_for_completion_timeout(&g0->complete, msecs_to_jiffies(5000))) 413 408 ret = -ETIMEDOUT; 409 + else 410 + return 0; 414 411 415 412 out_clear_bit: 416 - clear_bit(COMMAND_PENDING, &g0->flags); 413 + if (ack) 414 + clear_bit(ACK_PENDING, &g0->flags); 415 + else 416 + clear_bit(COMMAND_PENDING, &g0->flags); 417 417 418 418 return ret; 419 419 } ··· 439 429 if (UCSI_CCI_CONNECTOR(cci)) 440 430 ucsi_connector_change(g0->ucsi, UCSI_CCI_CONNECTOR(cci)); 441 431 442 - if (test_bit(COMMAND_PENDING, &g0->flags) && 443 - cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE)) 432 + if (cci & UCSI_CCI_ACK_COMPLETE && test_and_clear_bit(ACK_PENDING, &g0->flags)) 433 + complete(&g0->complete); 434 + if (cci & UCSI_CCI_COMMAND_COMPLETE && test_and_clear_bit(COMMAND_PENDING, &g0->flags)) 444 435 complete(&g0->complete); 445 436 446 437 return IRQ_HANDLED;