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

Pull USB / Thunderbolt fixes from Greg KH:
"Here are some small USB and Thunderbolt driver fixes for 6.10-rc4.
Included in here are:

- thunderbolt debugfs bugfix

- USB typec bugfixes

- kcov usb bugfix

- xhci bugfixes

- usb-storage bugfix

- dt-bindings bugfix

- cdc-wdm log message spam bugfix

All of these, except for the last cdc-wdm log level change, have been
in linux-next for a while with no reported problems. The cdc-wdm
bugfix has been tested by syzbot and proved to fix the reported cpu
lockup issues when the log is constantly spammed by a broken device"

* tag 'usb-6.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
USB: class: cdc-wdm: Fix CPU lockup caused by excessive log messages
xhci: Handle TD clearing for multiple streams case
xhci: Apply broken streams quirk to Etron EJ188 xHCI host
xhci: Apply reset resume quirk to Etron EJ188 xHCI host
xhci: Set correct transferred length for cancelled bulk transfers
usb-storage: alauda: Check whether the media is initialized
usb: typec: ucsi: Ack also failed Get Error commands
kcov, usb: disable interrupts in kcov_remote_start_usb_softirq
dt-bindings: usb: realtek,rts5411: Add missing "additionalProperties" on child nodes
usb: typec: tcpm: Ignore received Hard Reset in TOGGLING state
usb: typec: tcpm: fix use-after-free case in tcpm_register_source_caps
USB: xen-hcd: Traverse host/ when CONFIG_USB_XEN_HCD is selected
usb: typec: ucsi: glink: increase max ports for x1e80100
Revert "usb: chipidea: move ci_ulpi_init after the phy initialization"
thunderbolt: debugfs: Fix margin debugfs node creation condition

Changed files
+131 -42
Documentation
devicetree
bindings
drivers
thunderbolt
usb
chipidea
class
core
host
storage
typec
include
linux
+1
Documentation/devicetree/bindings/usb/realtek,rts5411.yaml
··· 65 65 description: The hard wired USB devices 66 66 type: object 67 67 $ref: /schemas/usb/usb-device.yaml 68 + additionalProperties: true 68 69 69 70 required: 70 71 - peer-hub
+3 -2
drivers/thunderbolt/debugfs.c
··· 943 943 debugfs_create_file("run", 0600, dir, port, &margining_run_fops); 944 944 debugfs_create_file("results", 0600, dir, port, &margining_results_fops); 945 945 debugfs_create_file("test", 0600, dir, port, &margining_test_fops); 946 - if (independent_voltage_margins(usb4) || 947 - (supports_time(usb4) && independent_time_margins(usb4))) 946 + if (independent_voltage_margins(usb4) == USB4_MARGIN_CAP_0_VOLTAGE_HL || 947 + (supports_time(usb4) && 948 + independent_time_margins(usb4) == USB4_MARGIN_CAP_1_TIME_LR)) 948 949 debugfs_create_file("margin", 0600, dir, port, &margining_margin_fops); 949 950 } 950 951
+1
drivers/usb/Makefile
··· 35 35 obj-$(CONFIG_USB_FSL_USB2) += host/ 36 36 obj-$(CONFIG_USB_FOTG210_HCD) += host/ 37 37 obj-$(CONFIG_USB_MAX3421_HCD) += host/ 38 + obj-$(CONFIG_USB_XEN_HCD) += host/ 38 39 39 40 obj-$(CONFIG_USB_C67X00_HCD) += c67x00/ 40 41
+4 -4
drivers/usb/chipidea/core.c
··· 1084 1084 return -ENODEV; 1085 1085 } 1086 1086 1087 + ret = ci_ulpi_init(ci); 1088 + if (ret) 1089 + return ret; 1090 + 1087 1091 if (ci->platdata->phy) { 1088 1092 ci->phy = ci->platdata->phy; 1089 1093 } else if (ci->platdata->usb_phy) { ··· 1141 1137 dev_err(dev, "unable to init phy: %d\n", ret); 1142 1138 goto ulpi_exit; 1143 1139 } 1144 - 1145 - ret = ci_ulpi_init(ci); 1146 - if (ret) 1147 - return ret; 1148 1140 1149 1141 ci->hw_bank.phys = res->start; 1150 1142
+5
drivers/usb/chipidea/ulpi.c
··· 68 68 if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI) 69 69 return 0; 70 70 71 + /* 72 + * Set PORTSC correctly so we can read/write ULPI registers for 73 + * identification purposes 74 + */ 75 + hw_phymode_configure(ci); 71 76 72 77 ci->ulpi_ops.read = ci_ulpi_read; 73 78 ci->ulpi_ops.write = ci_ulpi_write;
+2 -2
drivers/usb/class/cdc-wdm.c
··· 266 266 dev_err(&desc->intf->dev, "Stall on int endpoint\n"); 267 267 goto sw; /* halt is cleared in work */ 268 268 default: 269 - dev_err(&desc->intf->dev, 269 + dev_err_ratelimited(&desc->intf->dev, 270 270 "nonzero urb status received: %d\n", status); 271 271 break; 272 272 } 273 273 } 274 274 275 275 if (urb->actual_length < sizeof(struct usb_cdc_notification)) { 276 - dev_err(&desc->intf->dev, "wdm_int_callback - %d bytes\n", 276 + dev_err_ratelimited(&desc->intf->dev, "wdm_int_callback - %d bytes\n", 277 277 urb->actual_length); 278 278 goto exit; 279 279 }
+7 -5
drivers/usb/core/hcd.c
··· 1623 1623 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); 1624 1624 struct usb_anchor *anchor = urb->anchor; 1625 1625 int status = urb->unlinked; 1626 + unsigned long flags; 1626 1627 1627 1628 urb->hcpriv = NULL; 1628 1629 if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) && ··· 1641 1640 /* pass ownership to the completion handler */ 1642 1641 urb->status = status; 1643 1642 /* 1644 - * This function can be called in task context inside another remote 1645 - * coverage collection section, but kcov doesn't support that kind of 1646 - * recursion yet. Only collect coverage in softirq context for now. 1643 + * Only collect coverage in the softirq context and disable interrupts 1644 + * to avoid scenarios with nested remote coverage collection sections 1645 + * that KCOV does not support. 1646 + * See the comment next to kcov_remote_start_usb_softirq() for details. 1647 1647 */ 1648 - kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum); 1648 + flags = kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum); 1649 1649 urb->complete(urb); 1650 - kcov_remote_stop_softirq(); 1650 + kcov_remote_stop_softirq(flags); 1651 1651 1652 1652 usb_anchor_resume_wakeups(anchor); 1653 1653 atomic_dec(&urb->use_count);
+7
drivers/usb/host/xhci-pci.c
··· 36 36 37 37 #define PCI_VENDOR_ID_ETRON 0x1b6f 38 38 #define PCI_DEVICE_ID_EJ168 0x7023 39 + #define PCI_DEVICE_ID_EJ188 0x7052 39 40 40 41 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 41 42 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 ··· 396 395 xhci->quirks |= XHCI_RESET_ON_RESUME; 397 396 xhci->quirks |= XHCI_BROKEN_STREAMS; 398 397 } 398 + if (pdev->vendor == PCI_VENDOR_ID_ETRON && 399 + pdev->device == PCI_DEVICE_ID_EJ188) { 400 + xhci->quirks |= XHCI_RESET_ON_RESUME; 401 + xhci->quirks |= XHCI_BROKEN_STREAMS; 402 + } 403 + 399 404 if (pdev->vendor == PCI_VENDOR_ID_RENESAS && 400 405 pdev->device == 0x0014) { 401 406 xhci->quirks |= XHCI_ZERO_64B_REGS;
+45 -14
drivers/usb/host/xhci-ring.c
··· 1031 1031 break; 1032 1032 case TD_DIRTY: /* TD is cached, clear it */ 1033 1033 case TD_HALTED: 1034 + case TD_CLEARING_CACHE_DEFERRED: 1035 + if (cached_td) { 1036 + if (cached_td->urb->stream_id != td->urb->stream_id) { 1037 + /* Multiple streams case, defer move dq */ 1038 + xhci_dbg(xhci, 1039 + "Move dq deferred: stream %u URB %p\n", 1040 + td->urb->stream_id, td->urb); 1041 + td->cancel_status = TD_CLEARING_CACHE_DEFERRED; 1042 + break; 1043 + } 1044 + 1045 + /* Should never happen, but clear the TD if it does */ 1046 + xhci_warn(xhci, 1047 + "Found multiple active URBs %p and %p in stream %u?\n", 1048 + td->urb, cached_td->urb, 1049 + td->urb->stream_id); 1050 + td_to_noop(xhci, ring, cached_td, false); 1051 + cached_td->cancel_status = TD_CLEARED; 1052 + } 1053 + 1034 1054 td->cancel_status = TD_CLEARING_CACHE; 1035 - if (cached_td) 1036 - /* FIXME stream case, several stopped rings */ 1037 - xhci_dbg(xhci, 1038 - "Move dq past stream %u URB %p instead of stream %u URB %p\n", 1039 - td->urb->stream_id, td->urb, 1040 - cached_td->urb->stream_id, cached_td->urb); 1041 1055 cached_td = td; 1042 1056 break; 1043 1057 } ··· 1071 1057 if (err) { 1072 1058 /* Failed to move past cached td, just set cached TDs to no-op */ 1073 1059 list_for_each_entry_safe(td, tmp_td, &ep->cancelled_td_list, cancelled_td_list) { 1074 - if (td->cancel_status != TD_CLEARING_CACHE) 1060 + /* 1061 + * Deferred TDs need to have the deq pointer set after the above command 1062 + * completes, so if that failed we just give up on all of them (and 1063 + * complain loudly since this could cause issues due to caching). 1064 + */ 1065 + if (td->cancel_status != TD_CLEARING_CACHE && 1066 + td->cancel_status != TD_CLEARING_CACHE_DEFERRED) 1075 1067 continue; 1076 - xhci_dbg(xhci, "Failed to clear cancelled cached URB %p, mark clear anyway\n", 1077 - td->urb); 1068 + xhci_warn(xhci, "Failed to clear cancelled cached URB %p, mark clear anyway\n", 1069 + td->urb); 1078 1070 td_to_noop(xhci, ring, td, false); 1079 1071 td->cancel_status = TD_CLEARED; 1080 1072 } ··· 1366 1346 struct xhci_ep_ctx *ep_ctx; 1367 1347 struct xhci_slot_ctx *slot_ctx; 1368 1348 struct xhci_td *td, *tmp_td; 1349 + bool deferred = false; 1369 1350 1370 1351 ep_index = TRB_TO_EP_INDEX(le32_to_cpu(trb->generic.field[3])); 1371 1352 stream_id = TRB_TO_STREAM_ID(le32_to_cpu(trb->generic.field[2])); ··· 1453 1432 xhci_dbg(ep->xhci, "%s: Giveback cancelled URB %p TD\n", 1454 1433 __func__, td->urb); 1455 1434 xhci_td_cleanup(ep->xhci, td, ep_ring, td->status); 1435 + } else if (td->cancel_status == TD_CLEARING_CACHE_DEFERRED) { 1436 + deferred = true; 1456 1437 } else { 1457 1438 xhci_dbg(ep->xhci, "%s: Keep cancelled URB %p TD as cancel_status is %d\n", 1458 1439 __func__, td->urb, td->cancel_status); ··· 1464 1441 ep->ep_state &= ~SET_DEQ_PENDING; 1465 1442 ep->queued_deq_seg = NULL; 1466 1443 ep->queued_deq_ptr = NULL; 1467 - /* Restart any rings with pending URBs */ 1468 - ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 1444 + 1445 + if (deferred) { 1446 + /* We have more streams to clear */ 1447 + xhci_dbg(ep->xhci, "%s: Pending TDs to clear, continuing with invalidation\n", 1448 + __func__); 1449 + xhci_invalidate_cancelled_tds(ep); 1450 + } else { 1451 + /* Restart any rings with pending URBs */ 1452 + xhci_dbg(ep->xhci, "%s: All TDs cleared, ring doorbell\n", __func__); 1453 + ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 1454 + } 1469 1455 } 1470 1456 1471 1457 static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id, ··· 2556 2524 goto finish_td; 2557 2525 case COMP_STOPPED_LENGTH_INVALID: 2558 2526 /* stopped on ep trb with invalid length, exclude it */ 2559 - ep_trb_len = 0; 2560 - remaining = 0; 2561 - break; 2527 + td->urb->actual_length = sum_trb_lengths(xhci, ep_ring, ep_trb); 2528 + goto finish_td; 2562 2529 case COMP_USB_TRANSACTION_ERROR: 2563 2530 if (xhci->quirks & XHCI_NO_SOFT_RETRY || 2564 2531 (ep->err_count++ > MAX_SOFT_RETRY) ||
+1
drivers/usb/host/xhci.h
··· 1276 1276 TD_DIRTY = 0, 1277 1277 TD_HALTED, 1278 1278 TD_CLEARING_CACHE, 1279 + TD_CLEARING_CACHE_DEFERRED, 1279 1280 TD_CLEARED, 1280 1281 }; 1281 1282
+6 -3
drivers/usb/storage/alauda.c
··· 105 105 unsigned char sense_key; 106 106 unsigned long sense_asc; /* additional sense code */ 107 107 unsigned long sense_ascq; /* additional sense code qualifier */ 108 + 109 + bool media_initialized; 108 110 }; 109 111 110 112 #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) ··· 478 476 } 479 477 480 478 /* Check for media change */ 481 - if (status[0] & 0x08) { 479 + if (status[0] & 0x08 || !info->media_initialized) { 482 480 usb_stor_dbg(us, "Media change detected\n"); 483 481 alauda_free_maps(&MEDIA_INFO(us)); 484 - alauda_init_media(us); 485 - 482 + rc = alauda_init_media(us); 483 + if (rc == USB_STOR_TRANSPORT_GOOD) 484 + info->media_initialized = true; 486 485 info->sense_key = UNIT_ATTENTION; 487 486 info->sense_asc = 0x28; 488 487 info->sense_ascq = 0x00;
+4 -1
drivers/usb/typec/tcpm/tcpm.c
··· 3014 3014 memcpy(caps.pdo, port->source_caps, sizeof(u32) * port->nr_source_caps); 3015 3015 caps.role = TYPEC_SOURCE; 3016 3016 3017 - if (cap) 3017 + if (cap) { 3018 3018 usb_power_delivery_unregister_capabilities(cap); 3019 + port->partner_source_caps = NULL; 3020 + } 3019 3021 3020 3022 cap = usb_power_delivery_register_capabilities(port->partner_pd, &caps); 3021 3023 if (IS_ERR(cap)) ··· 6174 6172 port->tcpc->set_bist_data(port->tcpc, false); 6175 6173 6176 6174 switch (port->state) { 6175 + case TOGGLING: 6177 6176 case ERROR_RECOVERY: 6178 6177 case PORT_RESET: 6179 6178 case PORT_RESET_WAIT_OFF:
+6 -1
drivers/usb/typec/ucsi/ucsi.c
··· 153 153 } 154 154 155 155 if (cci & UCSI_CCI_ERROR) { 156 - if (cmd == UCSI_GET_ERROR_STATUS) 156 + if (cmd == UCSI_GET_ERROR_STATUS) { 157 + ret = ucsi_acknowledge(ucsi, false); 158 + if (ret) 159 + return ret; 160 + 157 161 return -EIO; 162 + } 158 163 return ucsi_read_error(ucsi); 159 164 } 160 165
+1 -1
drivers/usb/typec/ucsi/ucsi_glink.c
··· 14 14 #include <linux/soc/qcom/pmic_glink.h> 15 15 #include "ucsi.h" 16 16 17 - #define PMIC_GLINK_MAX_PORTS 2 17 + #define PMIC_GLINK_MAX_PORTS 3 18 18 19 19 #define UCSI_BUF_SIZE 48 20 20
+38 -9
include/linux/kcov.h
··· 55 55 56 56 /* 57 57 * The softirq flavor of kcov_remote_*() functions is introduced as a temporary 58 - * work around for kcov's lack of nested remote coverage sections support in 59 - * task context. Adding support for nested sections is tracked in: 60 - * https://bugzilla.kernel.org/show_bug.cgi?id=210337 58 + * workaround for KCOV's lack of nested remote coverage sections support. 59 + * 60 + * Adding support is tracked in https://bugzilla.kernel.org/show_bug.cgi?id=210337. 61 + * 62 + * kcov_remote_start_usb_softirq(): 63 + * 64 + * 1. Only collects coverage when called in the softirq context. This allows 65 + * avoiding nested remote coverage collection sections in the task context. 66 + * For example, USB/IP calls usb_hcd_giveback_urb() in the task context 67 + * within an existing remote coverage collection section. Thus, KCOV should 68 + * not attempt to start collecting coverage within the coverage collection 69 + * section in __usb_hcd_giveback_urb() in this case. 70 + * 71 + * 2. Disables interrupts for the duration of the coverage collection section. 72 + * This allows avoiding nested remote coverage collection sections in the 73 + * softirq context (a softirq might occur during the execution of a work in 74 + * the BH workqueue, which runs with in_serving_softirq() > 0). 75 + * For example, usb_giveback_urb_bh() runs in the BH workqueue with 76 + * interrupts enabled, so __usb_hcd_giveback_urb() might be interrupted in 77 + * the middle of its remote coverage collection section, and the interrupt 78 + * handler might invoke __usb_hcd_giveback_urb() again. 61 79 */ 62 80 63 - static inline void kcov_remote_start_usb_softirq(u64 id) 81 + static inline unsigned long kcov_remote_start_usb_softirq(u64 id) 64 82 { 65 - if (in_serving_softirq()) 83 + unsigned long flags = 0; 84 + 85 + if (in_serving_softirq()) { 86 + local_irq_save(flags); 66 87 kcov_remote_start_usb(id); 88 + } 89 + 90 + return flags; 67 91 } 68 92 69 - static inline void kcov_remote_stop_softirq(void) 93 + static inline void kcov_remote_stop_softirq(unsigned long flags) 70 94 { 71 - if (in_serving_softirq()) 95 + if (in_serving_softirq()) { 72 96 kcov_remote_stop(); 97 + local_irq_restore(flags); 98 + } 73 99 } 74 100 75 101 #ifdef CONFIG_64BIT ··· 129 103 } 130 104 static inline void kcov_remote_start_common(u64 id) {} 131 105 static inline void kcov_remote_start_usb(u64 id) {} 132 - static inline void kcov_remote_start_usb_softirq(u64 id) {} 133 - static inline void kcov_remote_stop_softirq(void) {} 106 + static inline unsigned long kcov_remote_start_usb_softirq(u64 id) 107 + { 108 + return 0; 109 + } 110 + static inline void kcov_remote_stop_softirq(unsigned long flags) {} 134 111 135 112 #endif /* CONFIG_KCOV */ 136 113 #endif /* _LINUX_KCOV_H */