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-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are some small USB driver fixes for 6.15-rc6. Included in here
are:

- typec driver fixes

- usbtmc ioctl fixes

- xhci driver fixes

- cdnsp driver fixes

- some gadget driver fixes

Nothing really major, just all little stuff that people have reported
being issues. All of these have been in linux-next this week with no
reported issues"

* tag 'usb-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
xhci: dbc: Avoid event polling busyloop if pending rx transfers are inactive.
usb: xhci: Don't trust the EP Context cycle bit when moving HW dequeue
usb: usbtmc: Fix erroneous generic_read ioctl return
usb: usbtmc: Fix erroneous wait_srq ioctl return
usb: usbtmc: Fix erroneous get_stb ioctl error returns
usb: typec: tcpm: delay SNK_TRY_WAIT_DEBOUNCE to SRC_TRYWAIT transition
USB: usbtmc: use interruptible sleep in usbtmc_read
usb: cdnsp: fix L1 resume issue for RTL_REVISION_NEW_LPM version
usb: typec: ucsi: displayport: Fix NULL pointer access
usb: typec: ucsi: displayport: Fix deadlock
usb: misc: onboard_usb_dev: fix support for Cypress HX3 hubs
usb: uhci-platform: Make the clock really optional
usb: dwc3: gadget: Make gadget_wakeup asynchronous
usb: gadget: Use get_status callback to set remote wakeup capability
usb: gadget: f_ecm: Add get_status callback
usb: host: tegra: Prevent host controller crash when OTG port is used
usb: cdnsp: Fix issue with resuming from L1
usb: gadget: tegra-xudc: ACK ST_RC after clearing CTRL_RUN

+221 -95
+31
drivers/usb/cdns3/cdnsp-gadget.c
··· 139 139 (portsc & PORT_CHANGE_BITS), port_regs); 140 140 } 141 141 142 + static void cdnsp_set_apb_timeout_value(struct cdnsp_device *pdev) 143 + { 144 + struct cdns *cdns = dev_get_drvdata(pdev->dev); 145 + __le32 __iomem *reg; 146 + void __iomem *base; 147 + u32 offset = 0; 148 + u32 val; 149 + 150 + if (!cdns->override_apb_timeout) 151 + return; 152 + 153 + base = &pdev->cap_regs->hc_capbase; 154 + offset = cdnsp_find_next_ext_cap(base, offset, D_XEC_PRE_REGS_CAP); 155 + reg = base + offset + REG_CHICKEN_BITS_3_OFFSET; 156 + 157 + val = le32_to_cpu(readl(reg)); 158 + val = CHICKEN_APB_TIMEOUT_SET(val, cdns->override_apb_timeout); 159 + writel(cpu_to_le32(val), reg); 160 + } 161 + 142 162 static void cdnsp_set_chicken_bits_2(struct cdnsp_device *pdev, u32 bit) 143 163 { 144 164 __le32 __iomem *reg; ··· 1793 1773 reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP); 1794 1774 pdev->rev_cap = reg; 1795 1775 1776 + pdev->rtl_revision = readl(&pdev->rev_cap->rtl_revision); 1777 + 1796 1778 dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n", 1797 1779 readl(&pdev->rev_cap->ctrl_revision), 1798 1780 readl(&pdev->rev_cap->rtl_revision), ··· 1819 1797 pdev->hcc_params = readl(&pdev->cap_regs->hc_capbase); 1820 1798 pdev->hci_version = HC_VERSION(pdev->hcc_params); 1821 1799 pdev->hcc_params = readl(&pdev->cap_regs->hcc_params); 1800 + 1801 + /* 1802 + * Override the APB timeout value to give the controller more time for 1803 + * enabling UTMI clock and synchronizing APB and UTMI clock domains. 1804 + * This fix is platform specific and is required to fixes issue with 1805 + * reading incorrect value from PORTSC register after resuming 1806 + * from L1 state. 1807 + */ 1808 + cdnsp_set_apb_timeout_value(pdev); 1822 1809 1823 1810 cdnsp_get_rev_cap(pdev); 1824 1811
+6
drivers/usb/cdns3/cdnsp-gadget.h
··· 520 520 #define REG_CHICKEN_BITS_2_OFFSET 0x48 521 521 #define CHICKEN_XDMA_2_TP_CACHE_DIS BIT(28) 522 522 523 + #define REG_CHICKEN_BITS_3_OFFSET 0x4C 524 + #define CHICKEN_APB_TIMEOUT_SET(p, val) (((p) & ~GENMASK(21, 0)) | (val)) 525 + 523 526 /* XBUF Extended Capability ID. */ 524 527 #define XBUF_CAP_ID 0xCB 525 528 #define XBUF_RX_TAG_MASK_0_OFFSET 0x1C ··· 1360 1357 * @rev_cap: Controller Capabilities Registers. 1361 1358 * @hcs_params1: Cached register copies of read-only HCSPARAMS1 1362 1359 * @hcc_params: Cached register copies of read-only HCCPARAMS1 1360 + * @rtl_revision: Cached controller rtl revision. 1363 1361 * @setup: Temporary buffer for setup packet. 1364 1362 * @ep0_preq: Internal allocated request used during enumeration. 1365 1363 * @ep0_stage: ep0 stage during enumeration process. ··· 1415 1411 __u32 hcs_params1; 1416 1412 __u32 hcs_params3; 1417 1413 __u32 hcc_params; 1414 + #define RTL_REVISION_NEW_LPM 0x2700 1415 + __u32 rtl_revision; 1418 1416 /* Lock used in interrupt thread context. */ 1419 1417 spinlock_t lock; 1420 1418 struct usb_ctrlrequest setup;
+10 -2
drivers/usb/cdns3/cdnsp-pci.c
··· 28 28 #define PCI_DRIVER_NAME "cdns-pci-usbssp" 29 29 #define PLAT_DRIVER_NAME "cdns-usbssp" 30 30 31 + #define CHICKEN_APB_TIMEOUT_VALUE 0x1C20 32 + 31 33 static struct pci_dev *cdnsp_get_second_fun(struct pci_dev *pdev) 32 34 { 33 35 /* ··· 141 139 cdnsp->otg_irq = pdev->irq; 142 140 } 143 141 142 + /* 143 + * Cadence PCI based platform require some longer timeout for APB 144 + * to fixes domain clock synchronization issue after resuming 145 + * controller from L1 state. 146 + */ 147 + cdnsp->override_apb_timeout = CHICKEN_APB_TIMEOUT_VALUE; 148 + pci_set_drvdata(pdev, cdnsp); 149 + 144 150 if (pci_is_enabled(func)) { 145 151 cdnsp->dev = dev; 146 152 cdnsp->gadget_init = cdnsp_gadget_init; ··· 157 147 if (ret) 158 148 goto free_cdnsp; 159 149 } 160 - 161 - pci_set_drvdata(pdev, cdnsp); 162 150 163 151 device_wakeup_enable(&pdev->dev); 164 152 if (pci_dev_run_wake(pdev))
+2 -1
drivers/usb/cdns3/cdnsp-ring.c
··· 308 308 309 309 writel(db_value, reg_addr); 310 310 311 - cdnsp_force_l0_go(pdev); 311 + if (pdev->rtl_revision < RTL_REVISION_NEW_LPM) 312 + cdnsp_force_l0_go(pdev); 312 313 313 314 /* Doorbell was set. */ 314 315 return true;
+3
drivers/usb/cdns3/core.h
··· 79 79 * @pdata: platform data from glue layer 80 80 * @lock: spinlock structure 81 81 * @xhci_plat_data: xhci private data structure pointer 82 + * @override_apb_timeout: hold value of APB timeout. For value 0 the default 83 + * value in CHICKEN_BITS_3 will be preserved. 82 84 * @gadget_init: pointer to gadget initialization function 83 85 */ 84 86 struct cdns { ··· 119 117 struct cdns3_platform_data *pdata; 120 118 spinlock_t lock; 121 119 struct xhci_plat_priv *xhci_plat_data; 120 + u32 override_apb_timeout; 122 121 123 122 int (*gadget_init)(struct cdns *cdns); 124 123 };
+36 -23
drivers/usb/class/usbtmc.c
··· 482 482 u8 *buffer; 483 483 u8 tag; 484 484 int rv; 485 + long wait_rv; 485 486 486 487 dev_dbg(dev, "Enter ioctl_read_stb iin_ep_present: %d\n", 487 488 data->iin_ep_present); ··· 512 511 } 513 512 514 513 if (data->iin_ep_present) { 515 - rv = wait_event_interruptible_timeout( 514 + wait_rv = wait_event_interruptible_timeout( 516 515 data->waitq, 517 516 atomic_read(&data->iin_data_valid) != 0, 518 517 file_data->timeout); 519 - if (rv < 0) { 520 - dev_dbg(dev, "wait interrupted %d\n", rv); 518 + if (wait_rv < 0) { 519 + dev_dbg(dev, "wait interrupted %ld\n", wait_rv); 520 + rv = wait_rv; 521 521 goto exit; 522 522 } 523 523 524 - if (rv == 0) { 524 + if (wait_rv == 0) { 525 525 dev_dbg(dev, "wait timed out\n"); 526 526 rv = -ETIMEDOUT; 527 527 goto exit; ··· 540 538 } 541 539 542 540 dev_dbg(dev, "stb:0x%02x received %d\n", (unsigned int)*stb, rv); 541 + 542 + rv = 0; 543 543 544 544 exit: 545 545 /* bump interrupt bTag */ ··· 606 602 { 607 603 struct usbtmc_device_data *data = file_data->data; 608 604 struct device *dev = &data->intf->dev; 609 - int rv; 610 605 u32 timeout; 611 606 unsigned long expire; 607 + long wait_rv; 612 608 613 609 if (!data->iin_ep_present) { 614 610 dev_dbg(dev, "no interrupt endpoint present\n"); ··· 622 618 623 619 mutex_unlock(&data->io_mutex); 624 620 625 - rv = wait_event_interruptible_timeout( 626 - data->waitq, 627 - atomic_read(&file_data->srq_asserted) != 0 || 628 - atomic_read(&file_data->closing), 629 - expire); 621 + wait_rv = wait_event_interruptible_timeout( 622 + data->waitq, 623 + atomic_read(&file_data->srq_asserted) != 0 || 624 + atomic_read(&file_data->closing), 625 + expire); 630 626 631 627 mutex_lock(&data->io_mutex); 632 628 633 629 /* Note! disconnect or close could be called in the meantime */ 634 630 if (atomic_read(&file_data->closing) || data->zombie) 635 - rv = -ENODEV; 631 + return -ENODEV; 636 632 637 - if (rv < 0) { 638 - /* dev can be invalid now! */ 639 - pr_debug("%s - wait interrupted %d\n", __func__, rv); 640 - return rv; 633 + if (wait_rv < 0) { 634 + dev_dbg(dev, "%s - wait interrupted %ld\n", __func__, wait_rv); 635 + return wait_rv; 641 636 } 642 637 643 - if (rv == 0) { 638 + if (wait_rv == 0) { 644 639 dev_dbg(dev, "%s - wait timed out\n", __func__); 645 640 return -ETIMEDOUT; 646 641 } ··· 833 830 unsigned long expire; 834 831 int bufcount = 1; 835 832 int again = 0; 833 + long wait_rv; 836 834 837 835 /* mutex already locked */ 838 836 ··· 946 942 if (!(flags & USBTMC_FLAG_ASYNC)) { 947 943 dev_dbg(dev, "%s: before wait time %lu\n", 948 944 __func__, expire); 949 - retval = wait_event_interruptible_timeout( 945 + wait_rv = wait_event_interruptible_timeout( 950 946 file_data->wait_bulk_in, 951 947 usbtmc_do_transfer(file_data), 952 948 expire); 953 949 954 - dev_dbg(dev, "%s: wait returned %d\n", 955 - __func__, retval); 950 + dev_dbg(dev, "%s: wait returned %ld\n", 951 + __func__, wait_rv); 956 952 957 - if (retval <= 0) { 958 - if (retval == 0) 959 - retval = -ETIMEDOUT; 953 + if (wait_rv < 0) { 954 + retval = wait_rv; 960 955 goto error; 961 956 } 957 + 958 + if (wait_rv == 0) { 959 + retval = -ETIMEDOUT; 960 + goto error; 961 + } 962 + 962 963 } 963 964 964 965 urb = usb_get_from_anchor(&file_data->in_anchor); ··· 1389 1380 if (!buffer) 1390 1381 return -ENOMEM; 1391 1382 1392 - mutex_lock(&data->io_mutex); 1383 + retval = mutex_lock_interruptible(&data->io_mutex); 1384 + if (retval < 0) 1385 + goto exit_nolock; 1386 + 1393 1387 if (data->zombie) { 1394 1388 retval = -ENODEV; 1395 1389 goto exit; ··· 1515 1503 1516 1504 exit: 1517 1505 mutex_unlock(&data->io_mutex); 1506 + exit_nolock: 1518 1507 kfree(buffer); 1519 1508 return retval; 1520 1509 }
+4
drivers/usb/dwc3/core.h
··· 1164 1164 * @gsbuscfg0_reqinfo: store GSBUSCFG0.DATRDREQINFO, DESRDREQINFO, 1165 1165 * DATWRREQINFO, and DESWRREQINFO value passed from 1166 1166 * glue driver. 1167 + * @wakeup_pending_funcs: Indicates whether any interface has requested for 1168 + * function wakeup in bitmap format where bit position 1169 + * represents interface_id. 1167 1170 */ 1168 1171 struct dwc3 { 1169 1172 struct work_struct drd_work; ··· 1397 1394 int num_ep_resized; 1398 1395 struct dentry *debug_root; 1399 1396 u32 gsbuscfg0_reqinfo; 1397 + u32 wakeup_pending_funcs; 1400 1398 }; 1401 1399 1402 1400 #define INCRX_BURST_MODE 0
+23 -37
drivers/usb/dwc3/gadget.c
··· 276 276 return ret; 277 277 } 278 278 279 - static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async); 280 - 281 279 /** 282 280 * dwc3_send_gadget_ep_cmd - issue an endpoint command 283 281 * @dep: the endpoint to which the command is going to be issued ··· 2357 2359 return __dwc3_gadget_get_frame(dwc); 2358 2360 } 2359 2361 2360 - static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async) 2362 + static int __dwc3_gadget_wakeup(struct dwc3 *dwc) 2361 2363 { 2362 - int retries; 2363 - 2364 2364 int ret; 2365 2365 u32 reg; 2366 2366 ··· 2386 2390 return -EINVAL; 2387 2391 } 2388 2392 2389 - if (async) 2390 - dwc3_gadget_enable_linksts_evts(dwc, true); 2393 + dwc3_gadget_enable_linksts_evts(dwc, true); 2391 2394 2392 2395 ret = dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV); 2393 2396 if (ret < 0) { ··· 2405 2410 2406 2411 /* 2407 2412 * Since link status change events are enabled we will receive 2408 - * an U0 event when wakeup is successful. So bail out. 2413 + * an U0 event when wakeup is successful. 2409 2414 */ 2410 - if (async) 2411 - return 0; 2412 - 2413 - /* poll until Link State changes to ON */ 2414 - retries = 20000; 2415 - 2416 - while (retries--) { 2417 - reg = dwc3_readl(dwc->regs, DWC3_DSTS); 2418 - 2419 - /* in HS, means ON */ 2420 - if (DWC3_DSTS_USBLNKST(reg) == DWC3_LINK_STATE_U0) 2421 - break; 2422 - } 2423 - 2424 - if (DWC3_DSTS_USBLNKST(reg) != DWC3_LINK_STATE_U0) { 2425 - dev_err(dwc->dev, "failed to send remote wakeup\n"); 2426 - return -EINVAL; 2427 - } 2428 - 2429 2415 return 0; 2430 2416 } 2431 2417 ··· 2427 2451 spin_unlock_irqrestore(&dwc->lock, flags); 2428 2452 return -EINVAL; 2429 2453 } 2430 - ret = __dwc3_gadget_wakeup(dwc, true); 2454 + ret = __dwc3_gadget_wakeup(dwc); 2431 2455 2432 2456 spin_unlock_irqrestore(&dwc->lock, flags); 2433 2457 ··· 2455 2479 */ 2456 2480 link_state = dwc3_gadget_get_link_state(dwc); 2457 2481 if (link_state == DWC3_LINK_STATE_U3) { 2458 - ret = __dwc3_gadget_wakeup(dwc, false); 2459 - if (ret) { 2460 - spin_unlock_irqrestore(&dwc->lock, flags); 2461 - return -EINVAL; 2462 - } 2463 - dwc3_resume_gadget(dwc); 2464 - dwc->suspended = false; 2465 - dwc->link_state = DWC3_LINK_STATE_U0; 2482 + dwc->wakeup_pending_funcs |= BIT(intf_id); 2483 + ret = __dwc3_gadget_wakeup(dwc); 2484 + spin_unlock_irqrestore(&dwc->lock, flags); 2485 + return ret; 2466 2486 } 2467 2487 2468 2488 ret = dwc3_send_gadget_generic_command(dwc, DWC3_DGCMD_DEV_NOTIFICATION, ··· 4325 4353 { 4326 4354 enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK; 4327 4355 unsigned int pwropt; 4356 + int ret; 4357 + int intf_id; 4328 4358 4329 4359 /* 4330 4360 * WORKAROUND: DWC3 < 2.50a have an issue when configured without ··· 4402 4428 4403 4429 switch (next) { 4404 4430 case DWC3_LINK_STATE_U0: 4405 - if (dwc->gadget->wakeup_armed) { 4431 + if (dwc->gadget->wakeup_armed || dwc->wakeup_pending_funcs) { 4406 4432 dwc3_gadget_enable_linksts_evts(dwc, false); 4407 4433 dwc3_resume_gadget(dwc); 4408 4434 dwc->suspended = false; ··· 4425 4451 } 4426 4452 4427 4453 dwc->link_state = next; 4454 + 4455 + /* Proceed with func wakeup if any interfaces that has requested */ 4456 + while (dwc->wakeup_pending_funcs && (next == DWC3_LINK_STATE_U0)) { 4457 + intf_id = ffs(dwc->wakeup_pending_funcs) - 1; 4458 + ret = dwc3_send_gadget_generic_command(dwc, DWC3_DGCMD_DEV_NOTIFICATION, 4459 + DWC3_DGCMDPAR_DN_FUNC_WAKE | 4460 + DWC3_DGCMDPAR_INTF_SEL(intf_id)); 4461 + if (ret) 4462 + dev_err(dwc->dev, "Failed to send DN wake for intf %d\n", intf_id); 4463 + 4464 + dwc->wakeup_pending_funcs &= ~BIT(intf_id); 4465 + } 4428 4466 } 4429 4467 4430 4468 static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,
+5 -7
drivers/usb/gadget/composite.c
··· 2011 2011 2012 2012 if (f->get_status) { 2013 2013 status = f->get_status(f); 2014 + 2014 2015 if (status < 0) 2015 2016 break; 2016 - } else { 2017 - /* Set D0 and D1 bits based on func wakeup capability */ 2018 - if (f->config->bmAttributes & USB_CONFIG_ATT_WAKEUP) { 2019 - status |= USB_INTRF_STAT_FUNC_RW_CAP; 2020 - if (f->func_wakeup_armed) 2021 - status |= USB_INTRF_STAT_FUNC_RW; 2022 - } 2017 + 2018 + /* if D5 is not set, then device is not wakeup capable */ 2019 + if (!(f->config->bmAttributes & USB_CONFIG_ATT_WAKEUP)) 2020 + status &= ~(USB_INTRF_STAT_FUNC_RW_CAP | USB_INTRF_STAT_FUNC_RW); 2023 2021 } 2024 2022 2025 2023 put_unaligned_le16(status & 0x0000ffff, req->buf);
+7
drivers/usb/gadget/function/f_ecm.c
··· 892 892 gether_resume(&ecm->port); 893 893 } 894 894 895 + static int ecm_get_status(struct usb_function *f) 896 + { 897 + return (f->func_wakeup_armed ? USB_INTRF_STAT_FUNC_RW : 0) | 898 + USB_INTRF_STAT_FUNC_RW_CAP; 899 + } 900 + 895 901 static void ecm_free(struct usb_function *f) 896 902 { 897 903 struct f_ecm *ecm; ··· 966 960 ecm->port.func.disable = ecm_disable; 967 961 ecm->port.func.free_func = ecm_free; 968 962 ecm->port.func.suspend = ecm_suspend; 963 + ecm->port.func.get_status = ecm_get_status; 969 964 ecm->port.func.resume = ecm_resume; 970 965 971 966 return &ecm->port.func;
+4
drivers/usb/gadget/udc/tegra-xudc.c
··· 1749 1749 val = xudc_readl(xudc, CTRL); 1750 1750 val &= ~CTRL_RUN; 1751 1751 xudc_writel(xudc, val, CTRL); 1752 + 1753 + val = xudc_readl(xudc, ST); 1754 + if (val & ST_RC) 1755 + xudc_writel(xudc, ST_RC, ST); 1752 1756 } 1753 1757 1754 1758 dev_info(xudc->dev, "ep %u disabled\n", ep->index);
+1 -1
drivers/usb/host/uhci-platform.c
··· 121 121 } 122 122 123 123 /* Get and enable clock if any specified */ 124 - uhci->clk = devm_clk_get(&pdev->dev, NULL); 124 + uhci->clk = devm_clk_get_optional(&pdev->dev, NULL); 125 125 if (IS_ERR(uhci->clk)) { 126 126 ret = PTR_ERR(uhci->clk); 127 127 goto err_rmr;
+16 -3
drivers/usb/host/xhci-dbgcap.c
··· 823 823 { 824 824 dma_addr_t deq; 825 825 union xhci_trb *evt; 826 + enum evtreturn ret = EVT_DONE; 826 827 u32 ctrl, portsc; 827 828 bool update_erdp = false; 828 829 ··· 910 909 break; 911 910 case TRB_TYPE(TRB_TRANSFER): 912 911 dbc_handle_xfer_event(dbc, evt); 912 + ret = EVT_XFER_DONE; 913 913 break; 914 914 default: 915 915 break; ··· 929 927 lo_hi_writeq(deq, &dbc->regs->erdp); 930 928 } 931 929 932 - return EVT_DONE; 930 + return ret; 933 931 } 934 932 935 933 static void xhci_dbc_handle_events(struct work_struct *work) ··· 938 936 struct xhci_dbc *dbc; 939 937 unsigned long flags; 940 938 unsigned int poll_interval; 939 + unsigned long busypoll_timelimit; 941 940 942 941 dbc = container_of(to_delayed_work(work), struct xhci_dbc, event_work); 943 942 poll_interval = dbc->poll_interval; ··· 957 954 dbc->driver->disconnect(dbc); 958 955 break; 959 956 case EVT_DONE: 960 - /* set fast poll rate if there are pending data transfers */ 957 + /* 958 + * Set fast poll rate if there are pending out transfers, or 959 + * a transfer was recently processed 960 + */ 961 + busypoll_timelimit = dbc->xfer_timestamp + 962 + msecs_to_jiffies(DBC_XFER_INACTIVITY_TIMEOUT); 963 + 961 964 if (!list_empty(&dbc->eps[BULK_OUT].list_pending) || 962 - !list_empty(&dbc->eps[BULK_IN].list_pending)) 965 + time_is_after_jiffies(busypoll_timelimit)) 963 966 poll_interval = 0; 967 + break; 968 + case EVT_XFER_DONE: 969 + dbc->xfer_timestamp = jiffies; 970 + poll_interval = 0; 964 971 break; 965 972 default: 966 973 dev_info(dbc->dev, "stop handling dbc events\n");
+3
drivers/usb/host/xhci-dbgcap.h
··· 96 96 #define DBC_WRITE_BUF_SIZE 8192 97 97 #define DBC_POLL_INTERVAL_DEFAULT 64 /* milliseconds */ 98 98 #define DBC_POLL_INTERVAL_MAX 5000 /* milliseconds */ 99 + #define DBC_XFER_INACTIVITY_TIMEOUT 10 /* milliseconds */ 99 100 /* 100 101 * Private structure for DbC hardware state: 101 102 */ ··· 143 142 enum dbc_state state; 144 143 struct delayed_work event_work; 145 144 unsigned int poll_interval; /* ms */ 145 + unsigned long xfer_timestamp; 146 146 unsigned resume_required:1; 147 147 struct dbc_ep eps[2]; 148 148 ··· 189 187 enum evtreturn { 190 188 EVT_ERR = -1, 191 189 EVT_DONE, 190 + EVT_XFER_DONE, 192 191 EVT_GSER, 193 192 EVT_DISC, 194 193 };
+9 -10
drivers/usb/host/xhci-ring.c
··· 699 699 int new_cycle; 700 700 dma_addr_t addr; 701 701 u64 hw_dequeue; 702 - bool cycle_found = false; 702 + bool hw_dequeue_found = false; 703 703 bool td_last_trb_found = false; 704 704 u32 trb_sct = 0; 705 705 int ret; ··· 715 715 hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id); 716 716 new_seg = ep_ring->deq_seg; 717 717 new_deq = ep_ring->dequeue; 718 - new_cycle = hw_dequeue & 0x1; 718 + new_cycle = le32_to_cpu(td->end_trb->generic.field[3]) & TRB_CYCLE; 719 719 720 720 /* 721 - * We want to find the pointer, segment and cycle state of the new trb 722 - * (the one after current TD's end_trb). We know the cycle state at 723 - * hw_dequeue, so walk the ring until both hw_dequeue and end_trb are 724 - * found. 721 + * Walk the ring until both the next TRB and hw_dequeue are found (don't 722 + * move hw_dequeue back if it went forward due to a HW bug). Cycle state 723 + * is loaded from a known good TRB, track later toggles to maintain it. 725 724 */ 726 725 do { 727 - if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq) 726 + if (!hw_dequeue_found && xhci_trb_virt_to_dma(new_seg, new_deq) 728 727 == (dma_addr_t)(hw_dequeue & ~0xf)) { 729 - cycle_found = true; 728 + hw_dequeue_found = true; 730 729 if (td_last_trb_found) 731 730 break; 732 731 } 733 732 if (new_deq == td->end_trb) 734 733 td_last_trb_found = true; 735 734 736 - if (cycle_found && trb_is_link(new_deq) && 735 + if (td_last_trb_found && trb_is_link(new_deq) && 737 736 link_trb_toggles_cycle(new_deq)) 738 737 new_cycle ^= 0x1; 739 738 ··· 744 745 return -EINVAL; 745 746 } 746 747 747 - } while (!cycle_found || !td_last_trb_found); 748 + } while (!hw_dequeue_found || !td_last_trb_found); 748 749 749 750 /* Don't update the ring cycle state for the producer (us). */ 750 751 addr = xhci_trb_virt_to_dma(new_seg, new_deq);
+3
drivers/usb/host/xhci-tegra.c
··· 1364 1364 tegra->otg_usb3_port = tegra_xusb_padctl_get_usb3_companion(tegra->padctl, 1365 1365 tegra->otg_usb2_port); 1366 1366 1367 + pm_runtime_get_sync(tegra->dev); 1367 1368 if (tegra->host_mode) { 1368 1369 /* switch to host mode */ 1369 1370 if (tegra->otg_usb3_port >= 0) { ··· 1394 1393 } 1395 1394 1396 1395 tegra_xhci_set_port_power(tegra, true, true); 1396 + pm_runtime_mark_last_busy(tegra->dev); 1397 1397 1398 1398 } else { 1399 1399 if (tegra->otg_usb3_port >= 0) ··· 1402 1400 1403 1401 tegra_xhci_set_port_power(tegra, true, false); 1404 1402 } 1403 + pm_runtime_put_autosuspend(tegra->dev); 1405 1404 } 1406 1405 1407 1406 #if IS_ENABLED(CONFIG_PM) || IS_ENABLED(CONFIG_PM_SLEEP)
+8 -2
drivers/usb/misc/onboard_usb_dev.c
··· 569 569 } 570 570 571 571 static const struct usb_device_id onboard_dev_id_table[] = { 572 - { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6504) }, /* CYUSB33{0,1,2}x/CYUSB230x 3.0 HUB */ 573 - { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6506) }, /* CYUSB33{0,1,2}x/CYUSB230x 2.0 HUB */ 572 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6500) }, /* CYUSB330x 3.0 HUB */ 573 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6502) }, /* CYUSB330x 2.0 HUB */ 574 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6503) }, /* CYUSB33{0,1}x 2.0 HUB, Vendor Mode */ 575 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6504) }, /* CYUSB331x 3.0 HUB */ 576 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6506) }, /* CYUSB331x 2.0 HUB */ 577 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6507) }, /* CYUSB332x 2.0 HUB, Vendor Mode */ 578 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6508) }, /* CYUSB332x 3.0 HUB */ 579 + { USB_DEVICE(VENDOR_ID_CYPRESS, 0x650a) }, /* CYUSB332x 2.0 HUB */ 574 580 { USB_DEVICE(VENDOR_ID_CYPRESS, 0x6570) }, /* CY7C6563x 2.0 HUB */ 575 581 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0608) }, /* Genesys Logic GL850G USB 2.0 HUB */ 576 582 { USB_DEVICE(VENDOR_ID_GENESYS, 0x0610) }, /* Genesys Logic GL852G USB 2.0 HUB */
+1 -1
drivers/usb/typec/tcpm/tcpm.c
··· 5965 5965 case SNK_TRY_WAIT_DEBOUNCE: 5966 5966 if (!tcpm_port_is_sink(port)) { 5967 5967 port->max_wait = 0; 5968 - tcpm_set_state(port, SRC_TRYWAIT, 0); 5968 + tcpm_set_state(port, SRC_TRYWAIT, PD_T_PD_DEBOUNCE); 5969 5969 } 5970 5970 break; 5971 5971 case SRC_TRY_WAIT:
+13 -8
drivers/usb/typec/ucsi/displayport.c
··· 54 54 u8 cur = 0; 55 55 int ret; 56 56 57 - mutex_lock(&dp->con->lock); 57 + if (!ucsi_con_mutex_lock(dp->con)) 58 + return -ENOTCONN; 58 59 59 60 if (!dp->override && dp->initialized) { 60 61 const struct typec_altmode *p = typec_altmode_get_partner(alt); ··· 101 100 schedule_work(&dp->work); 102 101 ret = 0; 103 102 err_unlock: 104 - mutex_unlock(&dp->con->lock); 103 + ucsi_con_mutex_unlock(dp->con); 105 104 106 105 return ret; 107 106 } ··· 113 112 u64 command; 114 113 int ret = 0; 115 114 116 - mutex_lock(&dp->con->lock); 115 + if (!ucsi_con_mutex_lock(dp->con)) 116 + return -ENOTCONN; 117 117 118 118 if (!dp->override) { 119 119 const struct typec_altmode *p = typec_altmode_get_partner(alt); ··· 146 144 schedule_work(&dp->work); 147 145 148 146 out_unlock: 149 - mutex_unlock(&dp->con->lock); 147 + ucsi_con_mutex_unlock(dp->con); 150 148 151 149 return ret; 152 150 } ··· 204 202 int cmd = PD_VDO_CMD(header); 205 203 int svdm_version; 206 204 207 - mutex_lock(&dp->con->lock); 205 + if (!ucsi_con_mutex_lock(dp->con)) 206 + return -ENOTCONN; 208 207 209 208 if (!dp->override && dp->initialized) { 210 209 const struct typec_altmode *p = typec_altmode_get_partner(alt); 211 210 212 211 dev_warn(&p->dev, 213 212 "firmware doesn't support alternate mode overriding\n"); 214 - mutex_unlock(&dp->con->lock); 213 + ucsi_con_mutex_unlock(dp->con); 215 214 return -EOPNOTSUPP; 216 215 } 217 216 218 217 svdm_version = typec_altmode_get_svdm_version(alt); 219 218 if (svdm_version < 0) { 220 - mutex_unlock(&dp->con->lock); 219 + ucsi_con_mutex_unlock(dp->con); 221 220 return svdm_version; 222 221 } 223 222 ··· 262 259 break; 263 260 } 264 261 265 - mutex_unlock(&dp->con->lock); 262 + ucsi_con_mutex_unlock(dp->con); 266 263 267 264 return 0; 268 265 } ··· 298 295 dp = typec_altmode_get_drvdata(alt); 299 296 if (!dp) 300 297 return; 298 + 299 + cancel_work_sync(&dp->work); 301 300 302 301 dp->data.conf = 0; 303 302 dp->data.status = 0;
+34
drivers/usb/typec/ucsi/ucsi.c
··· 1923 1923 EXPORT_SYMBOL_GPL(ucsi_set_drvdata); 1924 1924 1925 1925 /** 1926 + * ucsi_con_mutex_lock - Acquire the connector mutex 1927 + * @con: The connector interface to lock 1928 + * 1929 + * Returns true on success, false if the connector is disconnected 1930 + */ 1931 + bool ucsi_con_mutex_lock(struct ucsi_connector *con) 1932 + { 1933 + bool mutex_locked = false; 1934 + bool connected = true; 1935 + 1936 + while (connected && !mutex_locked) { 1937 + mutex_locked = mutex_trylock(&con->lock) != 0; 1938 + connected = UCSI_CONSTAT(con, CONNECTED); 1939 + if (connected && !mutex_locked) 1940 + msleep(20); 1941 + } 1942 + 1943 + connected = connected && con->partner; 1944 + if (!connected && mutex_locked) 1945 + mutex_unlock(&con->lock); 1946 + 1947 + return connected; 1948 + } 1949 + 1950 + /** 1951 + * ucsi_con_mutex_unlock - Release the connector mutex 1952 + * @con: The connector interface to unlock 1953 + */ 1954 + void ucsi_con_mutex_unlock(struct ucsi_connector *con) 1955 + { 1956 + mutex_unlock(&con->lock); 1957 + } 1958 + 1959 + /** 1926 1960 * ucsi_create - Allocate UCSI instance 1927 1961 * @dev: Device interface to the PPM (Platform Policy Manager) 1928 1962 * @ops: I/O routines
+2
drivers/usb/typec/ucsi/ucsi.h
··· 94 94 void ucsi_unregister(struct ucsi *ucsi); 95 95 void *ucsi_get_drvdata(struct ucsi *ucsi); 96 96 void ucsi_set_drvdata(struct ucsi *ucsi, void *data); 97 + bool ucsi_con_mutex_lock(struct ucsi_connector *con); 98 + void ucsi_con_mutex_unlock(struct ucsi_connector *con); 97 99 98 100 void ucsi_connector_change(struct ucsi *ucsi, u8 num); 99 101