Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull USB fixes from Greg KH:
"Here are a few tiny USB fixes for reported issues with some USB
drivers.

These fixes include:

- gadget driver fixes for regressions

- tcpm driver fix

- dwc3 driver fixes

- xhci renesas firmware loading fix, again.

- usb serial option driver device id addition

- usb serial ch341 revert for regression

All all of these have been in linux-next with no reported problems"

* tag 'usb-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usb: gadget: u_audio: fix race condition on endpoint stop
usb: gadget: f_uac2: fixup feedback endpoint stop
usb: typec: tcpm: Raise vdm_sm_running flag only when VDM SM is running
usb: renesas-xhci: Prefer firmware loading on unknown ROM state
usb: dwc3: gadget: Stop EP0 transfers during pullup disable
usb: dwc3: gadget: Fix dwc3_calc_trbs_left()
Revert "USB: serial: ch341: fix character loss at high transfer rates"
USB: serial: option: add new VID/PID to support Fibocom FG150

+89 -76
+11 -12
drivers/usb/dwc3/gadget.c
··· 940 940 941 941 static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep) 942 942 { 943 - struct dwc3_trb *tmp; 944 943 u8 trbs_left; 945 944 946 945 /* 947 - * If enqueue & dequeue are equal than it is either full or empty. 948 - * 949 - * One way to know for sure is if the TRB right before us has HWO bit 950 - * set or not. If it has, then we're definitely full and can't fit any 951 - * more transfers in our ring. 946 + * If the enqueue & dequeue are equal then the TRB ring is either full 947 + * or empty. It's considered full when there are DWC3_TRB_NUM-1 of TRBs 948 + * pending to be processed by the driver. 952 949 */ 953 950 if (dep->trb_enqueue == dep->trb_dequeue) { 954 - tmp = dwc3_ep_prev_trb(dep, dep->trb_enqueue); 955 - if (tmp->ctrl & DWC3_TRB_CTRL_HWO) 951 + /* 952 + * If there is any request remained in the started_list at 953 + * this point, that means there is no TRB available. 954 + */ 955 + if (!list_empty(&dep->started_list)) 956 956 return 0; 957 957 958 958 return DWC3_TRB_NUM - 1; ··· 2243 2243 2244 2244 ret = wait_for_completion_timeout(&dwc->ep0_in_setup, 2245 2245 msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT)); 2246 - if (ret == 0) { 2247 - dev_err(dwc->dev, "timed out waiting for SETUP phase\n"); 2248 - return -ETIMEDOUT; 2249 - } 2246 + if (ret == 0) 2247 + dev_warn(dwc->dev, "timed out waiting for SETUP phase\n"); 2250 2248 } 2251 2249 2252 2250 /* ··· 2456 2458 /* begin to receive SETUP packets */ 2457 2459 dwc->ep0state = EP0_SETUP_PHASE; 2458 2460 dwc->link_state = DWC3_LINK_STATE_SS_DIS; 2461 + dwc->delayed_status = false; 2459 2462 dwc3_ep0_out_start(dwc); 2460 2463 2461 2464 dwc3_gadget_enable_irq(dwc);
+15 -8
drivers/usb/gadget/function/u_audio.c
··· 230 230 int status = req->status; 231 231 232 232 /* i/f shutting down */ 233 - if (!prm->fb_ep_enabled || req->status == -ESHUTDOWN) 233 + if (!prm->fb_ep_enabled) { 234 + kfree(req->buf); 235 + usb_ep_free_request(ep, req); 236 + return; 237 + } 238 + 239 + if (req->status == -ESHUTDOWN) 234 240 return; 235 241 236 242 /* ··· 394 388 if (!prm->ep_enabled) 395 389 return; 396 390 397 - prm->ep_enabled = false; 398 - 399 391 audio_dev = uac->audio_dev; 400 392 params = &audio_dev->params; 401 393 ··· 411 407 } 412 408 } 413 409 410 + prm->ep_enabled = false; 411 + 414 412 if (usb_ep_disable(ep)) 415 413 dev_err(uac->card->dev, "%s:%d Error!\n", __func__, __LINE__); 416 414 } ··· 424 418 if (!prm->fb_ep_enabled) 425 419 return; 426 420 427 - prm->fb_ep_enabled = false; 428 - 429 421 if (prm->req_fback) { 430 - usb_ep_dequeue(ep, prm->req_fback); 431 - kfree(prm->req_fback->buf); 432 - usb_ep_free_request(ep, prm->req_fback); 422 + if (usb_ep_dequeue(ep, prm->req_fback)) { 423 + kfree(prm->req_fback->buf); 424 + usb_ep_free_request(ep, prm->req_fback); 425 + } 433 426 prm->req_fback = NULL; 434 427 } 428 + 429 + prm->fb_ep_enabled = false; 435 430 436 431 if (usb_ep_disable(ep)) 437 432 dev_err(uac->card->dev, "%s:%d Error!\n", __func__, __LINE__);
+23 -12
drivers/usb/host/xhci-pci-renesas.c
··· 207 207 return 0; 208 208 209 209 case RENESAS_ROM_STATUS_NO_RESULT: /* No result yet */ 210 - return 0; 210 + dev_dbg(&pdev->dev, "Unknown ROM status ...\n"); 211 + return -ENOENT; 211 212 212 213 case RENESAS_ROM_STATUS_ERROR: /* Error State */ 213 214 default: /* All other states are marked as "Reserved states" */ ··· 224 223 { 225 224 u8 fw_state; 226 225 int err; 227 - 228 - /* Check if device has ROM and loaded, if so skip everything */ 229 - err = renesas_check_rom(pdev); 230 - if (err) { /* we have rom */ 231 - err = renesas_check_rom_state(pdev); 232 - if (!err) 233 - return err; 234 - } 235 226 236 227 /* 237 228 * Test if the device is actually needing the firmware. As most ··· 584 591 (struct xhci_driver_data *)id->driver_data; 585 592 const char *fw_name = driver_data->firmware; 586 593 const struct firmware *fw; 594 + bool has_rom; 587 595 int err; 596 + 597 + /* Check if device has ROM and loaded, if so skip everything */ 598 + has_rom = renesas_check_rom(pdev); 599 + if (has_rom) { 600 + err = renesas_check_rom_state(pdev); 601 + if (!err) 602 + return 0; 603 + else if (err != -ENOENT) 604 + has_rom = false; 605 + } 588 606 589 607 err = renesas_fw_check_running(pdev); 590 608 /* Continue ahead, if the firmware is already running. */ 591 609 if (err == 0) 592 610 return 0; 593 611 612 + /* no firmware interface available */ 594 613 if (err != 1) 595 - return err; 614 + return has_rom ? 0 : err; 596 615 597 616 pci_dev_get(pdev); 598 - err = request_firmware(&fw, fw_name, &pdev->dev); 617 + err = firmware_request_nowarn(&fw, fw_name, &pdev->dev); 599 618 pci_dev_put(pdev); 600 619 if (err) { 601 - dev_err(&pdev->dev, "request_firmware failed: %d\n", err); 620 + if (has_rom) { 621 + dev_info(&pdev->dev, "failed to load firmware %s, fallback to ROM\n", 622 + fw_name); 623 + return 0; 624 + } 625 + dev_err(&pdev->dev, "failed to load firmware %s: %d\n", 626 + fw_name, err); 602 627 return err; 603 628 } 604 629
-1
drivers/usb/serial/ch341.c
··· 851 851 .owner = THIS_MODULE, 852 852 .name = "ch341-uart", 853 853 }, 854 - .bulk_in_size = 512, 855 854 .id_table = id_table, 856 855 .num_ports = 1, 857 856 .open = ch341_open,
+2
drivers/usb/serial/option.c
··· 2074 2074 .driver_info = RSVD(4) | RSVD(5) }, 2075 2075 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */ 2076 2076 .driver_info = RSVD(6) }, 2077 + { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0xff, 0x30) }, /* Fibocom FG150 Diag */ 2078 + { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0, 0) }, /* Fibocom FG150 AT */ 2077 2079 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a0, 0xff) }, /* Fibocom NL668-AM/NL652-EU (laptop MBIM) */ 2078 2080 { USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */ 2079 2081 { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */
+38 -43
drivers/usb/typec/tcpm/tcpm.c
··· 341 341 bool vbus_source; 342 342 bool vbus_charge; 343 343 344 + /* Set to true when Discover_Identity Command is expected to be sent in Ready states. */ 344 345 bool send_discover; 345 346 bool op_vsafe5v; 346 347 ··· 371 370 struct hrtimer send_discover_timer; 372 371 struct kthread_work send_discover_work; 373 372 bool state_machine_running; 373 + /* Set to true when VDM State Machine has following actions. */ 374 374 bool vdm_sm_running; 375 375 376 376 struct completion tx_complete; ··· 1433 1431 /* Set ready, vdm state machine will actually send */ 1434 1432 port->vdm_retries = 0; 1435 1433 port->vdm_state = VDM_STATE_READY; 1434 + port->vdm_sm_running = true; 1436 1435 1437 1436 mod_vdm_delayed_work(port, 0); 1438 1437 } ··· 1676 1673 rlen = 1; 1677 1674 } else { 1678 1675 tcpm_register_partner_altmodes(port); 1679 - port->vdm_sm_running = false; 1680 1676 } 1681 1677 break; 1682 1678 case CMD_ENTER_MODE: ··· 1723 1721 (VDO_SVDM_VERS(svdm_version)); 1724 1722 break; 1725 1723 } 1726 - port->vdm_sm_running = false; 1727 1724 break; 1728 1725 default: 1729 1726 response[0] = p[0] | VDO_CMDT(CMDT_RSP_NAK); 1730 1727 rlen = 1; 1731 1728 response[0] = (response[0] & ~VDO_SVDM_VERS_MASK) | 1732 1729 (VDO_SVDM_VERS(svdm_version)); 1733 - port->vdm_sm_running = false; 1734 1730 break; 1735 1731 } 1736 1732 ··· 1769 1769 } 1770 1770 1771 1771 if (PD_VDO_SVDM(p[0]) && (adev || tcpm_vdm_ams(port) || port->nr_snk_vdo)) { 1772 + /* 1773 + * Here a SVDM is received (INIT or RSP or unknown). Set the vdm_sm_running in 1774 + * advance because we are dropping the lock but may send VDMs soon. 1775 + * For the cases of INIT received: 1776 + * - If no response to send, it will be cleared later in this function. 1777 + * - If there are responses to send, it will be cleared in the state machine. 1778 + * For the cases of RSP received: 1779 + * - If no further INIT to send, it will be cleared later in this function. 1780 + * - Otherwise, it will be cleared in the state machine if timeout or it will go 1781 + * back here until no further INIT to send. 1782 + * For the cases of unknown type received: 1783 + * - We will send NAK and the flag will be cleared in the state machine. 1784 + */ 1785 + port->vdm_sm_running = true; 1772 1786 rlen = tcpm_pd_svdm(port, adev, p, cnt, response, &adev_action); 1773 1787 } else { 1774 1788 if (port->negotiated_rev >= PD_REV30) ··· 1851 1837 1852 1838 if (rlen > 0) 1853 1839 tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); 1840 + else 1841 + port->vdm_sm_running = false; 1854 1842 } 1855 1843 1856 1844 static void tcpm_send_vdm(struct tcpm_port *port, u32 vid, int cmd, ··· 1918 1902 * if there's traffic or we're not in PDO ready state don't send 1919 1903 * a VDM. 1920 1904 */ 1921 - if (port->state != SRC_READY && port->state != SNK_READY) 1905 + if (port->state != SRC_READY && port->state != SNK_READY) { 1906 + port->vdm_sm_running = false; 1922 1907 break; 1908 + } 1923 1909 1924 1910 /* TODO: AMS operation for Unstructured VDM */ 1925 1911 if (PD_VDO_SVDM(vdo_hdr) && PD_VDO_CMDT(vdo_hdr) == CMDT_INIT) { ··· 2574 2556 TYPEC_PWR_MODE_PD, 2575 2557 port->pps_data.active, 2576 2558 port->supply_voltage); 2577 - /* Set VDM running flag ASAP */ 2578 - if (port->data_role == TYPEC_HOST && 2579 - port->send_discover) 2580 - port->vdm_sm_running = true; 2581 2559 tcpm_set_state(port, SNK_READY, 0); 2582 2560 } else { 2583 2561 /* ··· 2611 2597 switch (port->state) { 2612 2598 case SNK_NEGOTIATE_CAPABILITIES: 2613 2599 /* USB PD specification, Figure 8-43 */ 2614 - if (port->explicit_contract) { 2600 + if (port->explicit_contract) 2615 2601 next_state = SNK_READY; 2616 - if (port->data_role == TYPEC_HOST && 2617 - port->send_discover) 2618 - port->vdm_sm_running = true; 2619 - } else { 2602 + else 2620 2603 next_state = SNK_WAIT_CAPABILITIES; 2621 - } 2622 2604 2623 2605 /* Threshold was relaxed before sending Request. Restore it back. */ 2624 2606 tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_PD, ··· 2628 2618 port->pps_data.req_op_curr = port->current_limit; 2629 2619 port->pps_status = (type == PD_CTRL_WAIT ? 2630 2620 -EAGAIN : -EOPNOTSUPP); 2631 - 2632 - if (port->data_role == TYPEC_HOST && 2633 - port->send_discover) 2634 - port->vdm_sm_running = true; 2635 2621 2636 2622 /* Threshold was relaxed before sending Request. Restore it back. */ 2637 2623 tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_PD, ··· 2704 2698 } 2705 2699 break; 2706 2700 case DR_SWAP_SEND: 2707 - if (port->data_role == TYPEC_DEVICE && 2708 - port->send_discover) 2709 - port->vdm_sm_running = true; 2710 - 2711 2701 tcpm_set_state(port, DR_SWAP_CHANGE_DR, 0); 2712 2702 break; 2713 2703 case PR_SWAP_SEND: ··· 2741 2739 PD_MSG_CTRL_NOT_SUPP, 2742 2740 NONE_AMS); 2743 2741 } else { 2744 - if (port->vdm_sm_running) { 2742 + if (port->send_discover) { 2745 2743 tcpm_queue_message(port, PD_MSG_CTRL_WAIT); 2746 2744 break; 2747 2745 } ··· 2757 2755 PD_MSG_CTRL_NOT_SUPP, 2758 2756 NONE_AMS); 2759 2757 } else { 2760 - if (port->vdm_sm_running) { 2758 + if (port->send_discover) { 2761 2759 tcpm_queue_message(port, PD_MSG_CTRL_WAIT); 2762 2760 break; 2763 2761 } ··· 2766 2764 } 2767 2765 break; 2768 2766 case PD_CTRL_VCONN_SWAP: 2769 - if (port->vdm_sm_running) { 2767 + if (port->send_discover) { 2770 2768 tcpm_queue_message(port, PD_MSG_CTRL_WAIT); 2771 2769 break; 2772 2770 } ··· 4482 4480 /* DR_Swap states */ 4483 4481 case DR_SWAP_SEND: 4484 4482 tcpm_pd_send_control(port, PD_CTRL_DR_SWAP); 4483 + if (port->data_role == TYPEC_DEVICE || port->negotiated_rev > PD_REV20) 4484 + port->send_discover = true; 4485 4485 tcpm_set_state_cond(port, DR_SWAP_SEND_TIMEOUT, 4486 4486 PD_T_SENDER_RESPONSE); 4487 4487 break; 4488 4488 case DR_SWAP_ACCEPT: 4489 4489 tcpm_pd_send_control(port, PD_CTRL_ACCEPT); 4490 - /* Set VDM state machine running flag ASAP */ 4491 - if (port->data_role == TYPEC_DEVICE && port->send_discover) 4492 - port->vdm_sm_running = true; 4490 + if (port->data_role == TYPEC_DEVICE || port->negotiated_rev > PD_REV20) 4491 + port->send_discover = true; 4493 4492 tcpm_set_state_cond(port, DR_SWAP_CHANGE_DR, 0); 4494 4493 break; 4495 4494 case DR_SWAP_SEND_TIMEOUT: 4496 4495 tcpm_swap_complete(port, -ETIMEDOUT); 4496 + port->send_discover = false; 4497 4497 tcpm_ams_finish(port); 4498 4498 tcpm_set_state(port, ready_state(port), 0); 4499 4499 break; ··· 4507 4503 } else { 4508 4504 tcpm_set_roles(port, true, port->pwr_role, 4509 4505 TYPEC_HOST); 4510 - port->send_discover = true; 4511 4506 } 4512 4507 tcpm_ams_finish(port); 4513 4508 tcpm_set_state(port, ready_state(port), 0); ··· 4649 4646 break; 4650 4647 case VCONN_SWAP_SEND_TIMEOUT: 4651 4648 tcpm_swap_complete(port, -ETIMEDOUT); 4652 - if (port->data_role == TYPEC_HOST && port->send_discover) 4653 - port->vdm_sm_running = true; 4654 4649 tcpm_set_state(port, ready_state(port), 0); 4655 4650 break; 4656 4651 case VCONN_SWAP_START: ··· 4664 4663 case VCONN_SWAP_TURN_ON_VCONN: 4665 4664 tcpm_set_vconn(port, true); 4666 4665 tcpm_pd_send_control(port, PD_CTRL_PS_RDY); 4667 - if (port->data_role == TYPEC_HOST && port->send_discover) 4668 - port->vdm_sm_running = true; 4669 4666 tcpm_set_state(port, ready_state(port), 0); 4670 4667 break; 4671 4668 case VCONN_SWAP_TURN_OFF_VCONN: 4672 4669 tcpm_set_vconn(port, false); 4673 - if (port->data_role == TYPEC_HOST && port->send_discover) 4674 - port->vdm_sm_running = true; 4675 4670 tcpm_set_state(port, ready_state(port), 0); 4676 4671 break; 4677 4672 ··· 4675 4678 case PR_SWAP_CANCEL: 4676 4679 case VCONN_SWAP_CANCEL: 4677 4680 tcpm_swap_complete(port, port->swap_status); 4678 - if (port->data_role == TYPEC_HOST && port->send_discover) 4679 - port->vdm_sm_running = true; 4680 4681 if (port->pwr_role == TYPEC_SOURCE) 4681 4682 tcpm_set_state(port, SRC_READY, 0); 4682 4683 else ··· 5024 5029 switch (port->state) { 5025 5030 case SNK_TRANSITION_SINK_VBUS: 5026 5031 port->explicit_contract = true; 5027 - /* Set the VDM flag ASAP */ 5028 - if (port->data_role == TYPEC_HOST && port->send_discover) 5029 - port->vdm_sm_running = true; 5030 5032 tcpm_set_state(port, SNK_READY, 0); 5031 5033 break; 5032 5034 case SNK_DISCOVERY: ··· 5418 5426 if (!port->send_discover) 5419 5427 goto unlock; 5420 5428 5429 + if (port->data_role == TYPEC_DEVICE && port->negotiated_rev < PD_REV30) { 5430 + port->send_discover = false; 5431 + goto unlock; 5432 + } 5433 + 5421 5434 /* Retry if the port is not idle */ 5422 5435 if ((port->state != SRC_READY && port->state != SNK_READY) || port->vdm_sm_running) { 5423 5436 mod_send_discover_delayed_work(port, SEND_DISCOVER_RETRY_MS); 5424 5437 goto unlock; 5425 5438 } 5426 5439 5427 - /* Only send the Message if the port is host for PD rev2.0 */ 5428 - if (port->data_role == TYPEC_HOST || port->negotiated_rev > PD_REV20) 5429 - tcpm_send_vdm(port, USB_SID_PD, CMD_DISCOVER_IDENT, NULL, 0); 5440 + tcpm_send_vdm(port, USB_SID_PD, CMD_DISCOVER_IDENT, NULL, 0); 5430 5441 5431 5442 unlock: 5432 5443 mutex_unlock(&port->lock);