summaryrefslogtreecommitdiff
path: root/drivers/usb/host
AgeCommit message (Collapse)Author
5 daysMerge tag 'usb-7.3-rc4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB/Thunderbolt fixes from Greg KH: "Here are a bunch of USB (and one Thunderbolt) fixes. Sorry for the delay on them, been stuck in travel hell for a bit and these have been sitting all ready to be merged for too long. Included in here are: - lots of tiny USB fixes found by anthropic scans - usb-serial bugfixes - xhci driver fixes for issues regressions by many people - dwc3 driver fixes for reported problems - some usb gadget driver fixes for reported problems - other minor USB driver fixes Most of these have been in linux-next for weeks with no reported issues, the others have been in linux-next for 11 days, also with no reported problems" * tag 'usb-7.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (45 commits) usb: xhci: fix 'num_active_eps' accounting on allocation failure usb: xhci: clear stale bandwidth data after hibernation usb: pci-quirks: always assert xHCI OS ownership usb: xhci: disable the correct slot on alloc_dev failure xhci: keep port link_inactive and connected flags in sync when polled usb: typec: ucsi: retry init only while the PPM is not ready xhci: give back TDs and clean up ep0 after disconnect USB: serial: garmin_gps: fix deadlock on reset request USB: serial: oti6858: fix the teardown order in close USB: serial: io_edgeport: serialise MCR accesses USB: serial: io_edgeport: fix potential use-after-free on disconnect USB: serial: io_edgeport: fix potential fifo corruption USB: serial: io_edgeport: move initial termios update to open() USB: serial: io_edgeport: fix potential NULL-deref at open USB: serial: io_edgeport: fix potential close() use-after-free USB: serial: io_edgeport: fix NULL-deref on early status USB: serial: upd78f0730: fix NULL-deref on hangup USB: serial: sierra: validate URB length in instat callback USB: serial: garmin_gps: validate packet data length in nat_receive() usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty ...
8 daysMerge tag 'net-7.4-rc3' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net Pull networking fixes from Jakub Kicinski: "Including fixes from netfilter, wireless and bluetooth. Previous releases - regressions: - tcp: rate limit receive queue collapsing - raw: fix ICMP unreachable sent when receive queue is full - eth: bnxt_en: take RTNL before netif_close() when aborting FW reset Previous releases - always broken: - tcp: - bound snd_cwnd_clamp to TCP_MAX_SND_CWND - number of fixes for TCP Fast Open - gro: - invalidate frag0 after a pull - avoid parsing headers from shared fragments - cipso: stop modifying live ip_options_rcu - udp: do not use a cross-family sk_rx_dst in early demux - fou: gue: check IP version of held packets for direct IP encapsulation - skbuff: preserve fclone lifetime when freeing stolen heads - eth: - mlx5e: - fix crashes on queue stats access to queues without stats - SHAMPO, disable end padding when relaxed ordering is - ena: keep the RX buffer mapped if skb allocation fails" * tag 'net-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (227 commits) selftests: net: add a test for NSH GSO nsh: limit recursion in nsh_gso_segment() selftests: tls: Cover the cap on consecutive empty records selftests: tls: Extend coverage for zero-length records selftests: tls: Skip the zero_len tests when TLS is unavailable tls: Consume empty data records in tls_sw_splice_read() tls: Break the connection after a burst of empty data records net: phy: c45: select BASE-T1 type for the forced speed net/mlx5e: Fix false WARN_ON_ONCE in flow steering cleanup on RX init failure net/mlx5e: IPsec, don't match upper proto selectors in crypto offload TX tcp: fix request_sock use-after-free during Fast Open accept() net: usb: cdc_ncm: don't underflow the NDP room check net: netns: fix INT_MAX nsid cleanup amt: use ipv6_hdr() in amt_mldv1_leave_handler() af_unix: Inherit SO_INQ in unix_stream_connect() tcp: Pass req->rsk_listener to inet_csk_reqsk_queue_drop() in tcp_check_req(). mailmap: add entries for Hangbin Liu net: virtio: validate outer protocol of UDP tunnel GSO packets tun: clear stale skb->protocol of NAPI frags skbs net: virtio: fix UDP tunnel GSO header of VLAN tagged packets ...
11 dayswireless: Remove me as ssb maintainerMichael Büsch
and remove all my E-Mail address references from the wireless sources. Signed-off-by: Michael Büsch <m@bues.ch> Link: https://patch.msgid.link/20261101121325.7c334d78@barney Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-11-05treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() familyKees Cook
Mirroring the earlier kmalloc_obj() conversion, convert the device-managed allocators over to the type-based API using the now updated scripts/coccinelle/api/kmalloc_objs.cocci. The size is derived from the type rather than written out as a sizeof(), and the result is a pointer to that type rather than void *, so a mismatch between the size requested and the variable assigned becomes a build error instead of being silently accepted. The conversions break down as: 6713 devm_kzalloc_obj() 1749 devm_kzalloc_objs() 307 devm_kzalloc_flex() 91 devm_kmalloc_objs() 82 devm_kmalloc_obj() 2 devm_kmalloc_flex() The rules deliberately leave alone allocations sized by a string or a byte-sized type, or assigned to a pointer to a byte-sized type, since those are byte buffers rather than objects. Allocations sized by a multi-byte integer type are only converted when they are assigned to a pointer to that same type, and allocations of pointers to integers or of void pointers are left alone too. After this change, 528 files still call devm_kmalloc(), devm_kzalloc(), devm_kcalloc(), or devm_kmalloc_array(). Build tested with allmodconfig on x86_64, arm64, i386, arm, riscv, s390, m68k, mips, parisc, sparc, loongarch, arc, xtensa, and openrisc with GCC 16.2.0 with no new warnings. Signed-off-by: Kees Cook <kees+treewide@kernel.org>
2026-11-05usb: xhci: fix 'num_active_eps' accounting on allocation failureNiklas Neronin
For controllers affected by XHCI_EP_LIMIT_QUIRK, endpoint resources for the default control endpoint are accounted before the virtual device is allocated. If xhci_alloc_virt_device() fails, the slot is disabled and cleanup is handled through the Disable Slot completion path. However, because no virtual device is installed in 'xhci->devs', the endpoint accounting is never released and 'num_active_eps' remains incremented. As a result, each allocation failure leaks one endpoint from the driver's accounting. Fix this by undoing the endpoint reservation when virtual device allocation fails. Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261105175106.241182-6-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-11-05usb: xhci: clear stale bandwidth data after hibernationNiklas Neronin
Controllers using software managed bandwidth accounting maintain periodic endpoint bandwidth information in struct 'xhci_interval_bw_table'. Each root hub port owns a bandwidth table and a list of TT bandwidth domains, where each TT has its own bandwidth table. Virtual devices reference the bandwidth table of their current bandwidth domain through 'bw_table' or 'tt_info'. Historically, resume from S4 reinitialized the entire xHCI driver state, which implicitly cleared all bandwidth accounting data. After the hibernation resume path was optimized to preserve parts of the driver state, virtual devices and TT bandwidth information were freed and recreated, but the root hub bandwidth tables were left intact. As a result, stale bandwidth accounting data could remain in the root hub bandwidth tables across hibernation resume, leading to incorrect bandwidth calculations after devices were rediscovered. Fix this by resetting all bandwidth accounting data in xhci_rh_bw_cleanup() so that resume starts with a clean bandwidth state, and resetting the total active endpoints count. Fixes: 2a70e5dc0301 ("usb: xhci: optimize resuming from S4 (suspend-to-disk)") Reported-by: Harald Judt <h.judt@gmx.at> Link: https://bugzilla.kernel.org/show_bug.cgi?id=222071 Suggested-by: Lovekesh Solanki <lovekeshsolanki00@gmail.com> Tested-by: Harald Judt <h.judt@gmx.at> Cc: stable <stable@kernel.org> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261105175106.241182-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-11-05usb: pci-quirks: always assert xHCI OS ownershipRishabh Jain
The xHCI ownership protocol requires the OS driver to assert the HC OS Owned semaphore before using the host controller, then wait for HC BIOS Owned to clear if firmware owns it. quirk_usb_handoff_xhci() currently asserts OS Owned only when BIOS Owned is already set. If firmware leaves BIOS Owned clear, Linux uses the xHC while both ownership semaphores remain clear. The timeout fallback also clears BIOS Owned using the original register value, which can clear OS Owned at the same time. On an AMD PROM21 xHCI controller (1022:43fc), this caused every S3 resume to terminate Controller Restore State with USBSTS 0x401. Linux then reset the host controller, both root hubs and the USB Bluetooth adapter. The controller entered resume ready and halted with USBSTS 0x1. Endpoint state, 100 ms save/restore delays, scratchpads, the DCBAA, device contexts and command, event and transfer rings were verified not to cause the restore error. Across four S3 cycles, asserting only HC OS Owned changed USBLEGSUP from 0x00000801 to 0x01000801 and eliminated the restore failure. Testing included the unmodified 7.1.8-ogc1.1.fc44.x86_64 distribution kernel using a test module that set the HC OS Owned semaphore. The same test was repeated after review with the same result. Clearing USBLEGCTLSTS was independently verified to be unnecessary. Always assert OS Owned for controllers using the standard xHCI handoff, and leave the existing TI/Renesas forced handoff unchanged. Keep OS Owned asserted after the standard handoff, including when forcing BIOS Owned clear after a timeout, to prevent firmware from reclaiming the controller during subsequent suspends. Fixes: 66d4eadd8d06 ("USB: xhci: BIOS handoff and HW initialization.") Cc: stable@vger.kernel.org Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Tested-by: McKenna Fan <blue_sun@tuta.io> Tested-by: Quinn Schive <quinnschive@hotmail.com> Tested-by: Bruno Filipe <bmilreu@gmail.com> Tested-by: Maciej Zonski <me@zonni.pl> Signed-off-by: Rishabh Jain <rishabh.jain1198@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261105175106.241182-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-11-05usb: xhci: disable the correct slot on alloc_dev failureXu Rao
xhci_alloc_dev() stores the Slot ID returned by the Enable Slot command in the local slot_id variable. udev->slot_id is updated only after xhci_alloc_virt_device() succeeds. If endpoint resource reservation or virtual device allocation fails before that update, the error path passes udev->slot_id to xhci_disable_and_free_slot(). During initial enumeration this is slot 0. When reallocating a device whose virtual device is missing or belongs to another usb_device, udev->slot_id may contain a stale Slot ID. The newly enabled slot can therefore remain active, or the wrong slot can be disabled. Pass slot_id, which identifies the slot enabled by this invocation. xhci_disable_and_free_slot() already handles a missing xhci->devs entry. Fixes: 3ffbba9511b4 ("USB: xhci: Allocate and address USB devices") Cc: stable@vger.kernel.org Signed-off-by: Xu Rao <raoxu@uniontech.com> Reviewed-by: Niklas Neronin <niklas.neronin@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261105175106.241182-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-11-05xhci: keep port link_inactive and connected flags in sync when polledMathias Nyman
Update port 'link_inactive' and 'connected' flags even if xHC isn't generating port change events. xHC only generates port change events on port changes after old port change bits are cleared. Hub driver is often kept up to date by polling the port status. Sashiko reported a possible case where all port changes after a port reset take place before hub driver clears the reset change bit. This way the port can end up connected and fully running with link in u0 without a port event clearing the 'link_inactive' or setting the 'connected' flags. A protocol STALL in this state would set EP_DROP_PENDING, and prevent all future URBs for the endpoint. Fix this by also updating the flags during get_port_status(), when hub driver is polling the port state. Fixes: 6895dbdc19d9 ("xhci: give back TDs and clean up ep0 after disconnect") Link: https://lore.kernel.org/linux-usb/sashiko-outbox-190046@kernel.org/ Cc: stable <stable@kernel.org> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261105175106.241182-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-30xhci: give back TDs and clean up ep0 after disconnectYiyu Zhou
Fix a regression in v7.3 introduced by the commits in the Fixes tags. Those patches avoid endpoint recovery and rapid state changes after the root port link is lost. This caused a regression in device enumeration. It turns out that a subset of USB HID devices briefly disconnect during enumeration. USB core manages to resuscitate these devices without reallocating them, and thus continue using the same udev, xhci vdev and default control endpoint (ep0) of the device. xhci didn't give back or clean up halted TDs behind disconnected ports as it assumed that the disconnect cancels all URBs, and drops and frees all endpoints. This is not the case, so cancel and give back TDs on halted endpoint behind disconnected ports, make sure ep0 is cleared and in a proper state to continue working even after a link error or disconnect is detected. Also prevent new URBs until device is reset. One issue related to the TDs not being given back was seen on a PFU HHKB Professional HYBRID Type-S keyboard (04fe:0021). It drops off the bus about 300 ms after its first enumeration, while usbhid is still probing its third interface. The probe runs in hub_wq, so the disconnect is not handled until the probe returns. On a root port the HID descriptor request and its four retries in hid_get_class_descriptor() each wait for the full 5 second USB_CTRL_GET_TIMEOUT: [57685.006036] usb 3-2: new full-speed USB device number 24 using xhci_hcd ... [57685.291304] hid-generic 0003:04FE:0021.0017: input,hidraw1: USB HID v1.11 Keyboard [PFU Limited HHKB-Hybrid] on usb-0000:00:14.0-2/input1 [57711.221083] usbhid 3-2:1.2: can't add hid device: -110 [57711.221613] usbhid 3-2:1.2: probe with driver usbhid failed with error -110 [57711.221842] usb 3-2: USB disconnect, device number 24 [mn: merge EP_DROP_PENDING and link_inactive checks in xhci_urb_enqueue(), return TDs and clean up ep0 on disconnect, rewrite commit message] Fixes: 042aad8d0db6 ("xhci: prevent endpoint recovery after roothub disconnect") Fixes: 7e0ef4332ed9 ("xhci: avoid xHC endpoint changes after disconnect or link error.") Cc: stable <stable@kernel.org> Closes: https://lore.kernel.org/all/20261010071811.20483-1-yiyu@yiyuzhou.io/ Closes: https://lore.kernel.org/linux-usb/4MjB9K-2SoiA85WbI9iEig@dsine.de/ Tested-by: Yiyu Zhou <yiyu@yiyuzhou.io> Tested-by: Dennis Wissel <dennis@dsine.de> Signed-off-by: Yiyu Zhou <yiyu@yiyuzhou.io> Co-developed-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261029204324.658845-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-24Merge tag 'usb-7.4-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB / Thunderbolt update from Greg KH: "Here is the big set of USB and Thunderbolt changes for 7.4-rc1. Included in here are: - thunderbolt driver updates and fixes - lots of dt schema conversions - usb gadget driver fixes (and a new maintainer!) - usb core fixups with some interactions with the driver core - usb serial updates and fixes for scan-found "issues" - xhci driver updates - typec driver updates - dwc3 driver updates - lots of usb gadget driver fixes for syzbot found "problems" - lots of other small USB driver fixes for randomly reported problems. All of these have been in linux-next with no reported issues" * tag 'usb-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (158 commits) usb: gadget: dummy_hcd: prevent unbind via sysfs usb: gadget: dummy_hcd: add tick_us module parameter for timer-rate tuning usb: gadget: dummy_hcd: set no_sg_constraint only on the SuperSpeed bus usb: gadget: dummy_hcd: fix SuperSpeed ep0 maxpacket usb: gadget: fix refcount underflow in gadgetfs_bind() error path USB: core: document purpose of interface parent reference MAINTAINERS: add Neill Kapron as USB Gadget maintainer USB: Documentation: Update description of completion callback context USB: serial: mxuport: support RS485 mode configuration USB: serial: mxuport: handle SEND_NEXT transmit flow control USB: serial: add generic write control callbacks USB: serial: mxuport: add MUX50U-based device support USB: serial: mxuport: clean up firmware version handling USB: serial: mxuport: clean up product ID definitions and device table USB: serial: sierra: fix urb leak on write completion usb: typec: ucsi_ccg: Add retry mechanism in ccg_read usb: host: xhci-tegra: Add Tegra264 XHCI support usb: host: xhci-tegra: Skip MBOX MSG_ENABLED on Tegra264 dt-bindings: usb: Add Tegra264 XUSB host support usb: xhci-pci: Add TUSB73x0 definitions ...
2026-10-22Merge tag 'soc-drivers-7.4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc Pull SoC driver updates from Arnd Bergmann: "There are lots of minor updates for driver subsystems managed through the soc tree (turris-omnia platform, cache driver, tee drivers, arm-cci, bus, memory) as well as soc vendor specific drivers (starfive, xilinx, microchip, nxp, amlogic, imx, renesas, samsung, ti, nvidia). The more notable changes are: - Larger updates for Qualcomm SoCs including support for SM8950 (Maili) SM8975 (Hawi), Glymur, Shikra, and IPQ5424 - Added SoC support for Exynos5515, Tegra264, Tegra410, R8A774A3, and MT8167 in existing drivers - Arm SCMI firmware driver support for ACPI PCC transport and module autoloading of protocol specific drivers - Apple crash log support for CrgA embedded controller" * tag 'soc-drivers-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (176 commits) platform: cznic: turris-omnia-mcu: stop button emulation producers cache: Make cpu_cache_invalidate_memregion() error out if there are no handlers soc: mpfs: use kref cleanup on probe failure arm64: enable HAVE_SHARED_GPIOS for all ARM64 platforms bus: arm-cci: Drop cci-control-port node reference in __cci_ace_get_port() bus: arm-cci: Drop CPU node reference in cci_ace_init_ports() soc: fsl: dpio: Free the IRQ before releasing the I/O object soc: fsl: dpio: Fix cleanup on IRQ registration failure bus: fsl-mc: Annotate fsl_mc_io.portal_virt_addr with __counted_by_ptr bus: fsl-mc: drop the fwnode links of the dpmacs nodes soc: fsl: cpm1: tsa: Fix clock leak in tsa_of_parse_tdms() soc: qcom: geni-se: Drop unused icc_ddr parameter from geni_icc_get() firmware: qcom: scm: Allow QSEECOM on ThinkPad T14s Gen 7 dt-bindings: mailbox: qcom: Document Maili CPUCP mailbox controller dt-bindings: spmi: glymur-spmi-pmic-arb: Add compatible for Qualcomm Maili SoC soc: qcom: pmic_pdcharger_ulog: prevent work requeue during remove ASoC: dt-bindings: qcom,apr: Add modem_apps GLINK channel for shikra firmware: qcom: tzmem: disable SHM bridge for SM7125 platform soc: qcom: ubwc: Add Kalambo UBWC config firmware: qcom: scm: Allow QSEECOM on Kalambo CRD ...
2026-10-11usb: host: xhci-tegra: Add Tegra264 XHCI supportWayne Chang
This change adds Tegra264 XUSB host mode controller support. The host controller is very similar to the existing Tegra234 XHCI, except the number of max_num_wakes. Signed-off-by: Wayne Chang <waynec@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Link: https://patch.msgid.link/20260903074539.613220-4-waynec@nvidia.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: host: xhci-tegra: Skip MBOX MSG_ENABLED on Tegra264Wayne Chang
Tegra264 XUSB does not use the firmware mailbox handshake to enable controller messages (MBOX_CMD_MSG_ENABLED). Add a per-SoC flag and short-circuit __tegra_xusb_enable_firmware_messages() so both probe and resume avoid sending the command. Signed-off-by: Wayne Chang <waynec@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Link: https://patch.msgid.link/20260903074539.613220-3-waynec@nvidia.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci-pci: Add TUSB73x0 definitionsFabio Estevam
Instead of hard-coding the TUSB73X0 PCI ID, USB_CTRL register address and the PWRON_POLARITY, introduce definitions for them to make the code easier to read. No functional change. Signed-off-by: Fabio Estevam <festevam@gmail.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> # pci_ids.h Link: https://patch.msgid.link/20261009125154.266435-1-festevam@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci-pci: Add AMD 600 series to xhci-pci-prom21Stephen Horvath
It seems the xhci-pci-prom21 module only has IDs for the 800 series chipsets. However, the 600 series chipsets also have Promontory 21 chips, so we should add their IDs to the list as well. I have tested this on my X670 board featuring DID `0x43f7`. `1022:43f7` also appears on the PCI ID database (https://pci-ids.ucw.cz/read/PC/1022/43f7). Device IDs `0x43f9` (B665) & `0x43fa` (A620) were suggested by Shyam. Also list the new IDs in Documentation/hwmon/prom21-xhci.rst. Cc: stable@vger.kernel.org # 7.2.x Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Cc: Jihong Min <hurryman2212@gmail.com> Signed-off-by: Stephen Horvath <linux@stevetech.au> Tested-by: Mirko Jechow <mirko.jechow@gmx.de> [mirko.jechow@gmx.de: add new IDs to prom21-xhci.rst] Signed-off-by: Mirko Jechow <mirko.jechow@gmx.de> Link: https://patch.msgid.link/20261004002731.49927-1-mirko.jechow@gmx.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11xhci: Prevent invalid vdev dereference during sideband unregisterMathias Nyman
Offloaded USB audio devices using the xhci-sideband API store a pointer to the xhci virtual device (vdev) in the sideband structure when registering. This pointer typically remains valid throughout the lifetime of the USB device. If a configured offloaded device requires a reset, the USB core usually unbinds or notifies the audio driver beforehand, ensuring that the sideband is unregistered before the vdev is freed. An exception occurs when the USB core resets a device to recover from a failed resume, but a subsequent 'address device' request also fails. To recover in this specific scenario, the xHCI driver disables and re-enables the slot, which frees and re-allocates the vdev. xhci_sideband_unregister() later dereferences the stale, previously freed vdev pointer during disconnect, triggering a kernel oops: Unable to handle kernel paging request at virtual address dead000000000122 Call trace: xhci_get_ep_ctx+0x0/0x38 xhci_sideband_unregister+0x68/0xf0 uaudio_disconnect+0x70/0x144 usb_audio_disconnect+0x7c/0x268 usb_unbind_interface+0x13c/0x340 device_release_driver_internal+0x1c4/0x2bc usb_disable_device+0x84/0x190 usb_disconnect+0xe8/0x338 hub_event+0xbd8/0x19ac Fix this by preventing the reallocation of the vdev in this specific error path if the device is registered for sideband use. Just propagate the error directly to the USB core. It should either retry enumeration or detect the disconnected device, and handle it accordingly. Debugging this issue to the dangling vdev pointer, reporting it, testing, and initial patch with different solution by Lianqin Hu Reported-by: Lianqin Hu <hulianqin@vivo.com> Closes: https://lore.kernel.org/linux-usb/TYUPR06MB6217000B59003EDF233D7246D2B22@TYUPR06MB6217.apcprd06.prod.outlook.com/ Tested-by: Lianqin Hu <hulianqin@vivo.com> Fixes: de66754e9f80 ("xhci: sideband: add initial api to register a secondary interrupter entity") Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-12-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: Fix bounce buffer overflowMichal Pecio
High-speed devices with out of spec 1024 byte bulk endpoints exist and are allowed by USB core, but xhci-hcd always sets packet size to 512. The exact nature of these devices isn't documented, commit fb5ee84ea72c ("USB: Accept bulk endpoints with 1024-byte maxpacket") only states that they "don't work with xHCI host controllers", whatever it means. But somebody (or a malicious device) can try, and then the driver will allocate a 512 byte bounce buffer for this endpoint and may write up to 1024 bytes into it if particular scatter-gather URBs are used, because xhci_align_td() obtains packet size from the descriptor. Fix this. As a side effect, TRBs will be aligned to the packet size chosen by the driver on all endpoints of all speeds. Alignment serves the xHC, not device, so this is fine. Only out of spec devices are affected anyway. Reported-by: co+fd80bc5967eb22c3@bugs.sh Link: https://lore.kernel.org/linux-usb/D4tcSGerkYkIV1DmaUo1t8TaR5qQElDLkidn@bugs.sh/ Fixes: f9c589e142d0 ("xhci: TD-fragment, align the unsplittable case with a bounce buffer") Cc: stable@vger.kernel.org Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-11-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: Rework and improve the TD matching and skipping logicMichal Pecio
Matching events with TDs and giving back missed TDs is carried out by a complicated loop. Replace it with a simpler linear logic: 0. Having verified that 'td_list' isn't empty, 1. Scan it to find the matching TD and count missed TDs, 2. Perform necessary adjustments for corner cases, 3. Give back missed TDs, if applicable, using a short and tidy loop, 4. Check if the event refers to the expected TD and proceed as usual. Besides cleaning up the code, this provides a few improvements: - when the skip flag is set, no TD is given back unless we found a match or otherwise know how many TDs should be given back - when the skip flag is clear, we know if the event refers to a "future" TD so we can log this in the Scary Error Message to aid debugging. While altering the error message, drop a pointless goto. Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-10-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: Shorten the TD skipping loopMichal Pecio
Half of this loop is code which only executes once to deal with cases where no TD matches the event and then it returns. This code needs not to be in any kind of loop, so get it out. Optimize conditionals remaining in the loop body. Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-9-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: Don't set the skip flag on non-isoc endpointsMichal Pecio
These events are unique to isochronous endpoints, ignore them otherwise. Update debug messages to reflect new policies. We could also log invalid events as errors, but it seems nobody has ever had problems with that, so don't bother. This allows dropping the isoc check when skipping TDs. Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-8-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: Guarantee URB giveback on Ring Underrun/OverrunMichal Pecio
In this case we know that the xHC has released ownership of all missed TDs, we only don't know which were missed and which were queued later. URBs are queued atomically, so we can safely give back all TDs of the currently executing URB. Unlike the previous policy, this does actually ensure that the class driver will learn about the error and won't see all of its URBs still in progress when all TDs are missed on xHCI 1.0. Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-7-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11xhci: dbc: lock the minor IDR on registration failureSang-Hoon Choi
dbc_tty_minors is protected by dbc_tty_minors_lock when entries are allocated and during normal device removal. The registration error path removes an entry without taking that lock. Different DbC instances have separate event work items, so this removal can race with an IDR update for another instance. Take the same mutex around the error-path removal. Fixes: e1ec140f273e ("xhci: dbgtty: use IDR to support several dbc instances.") Reported-by: Changyul Lee <lcy8047@gmail.com> Assisted-by: LLM Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-6-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11xhci: check device notification type before forwarding wake eventHongyu Xie
The xHCI driver programs the Device Notification Control register to only enable the Function Wake device notification (N1), so any Device Notification Event TRB received is expected to be a function wake notification. handle_device_notification() does however not check the Notification Type field of the event (xHCI 1.2 section 6.4.2.7, DW0 bits 7:4), and forwards every device notification event as a function wake. A host controller that delivers an unexpected notification type (e.g. due to broken firmware or emulation) would trigger a spurious wake notification on the parent hub. Parse the notification type and drop events other than Function Wake with a warning, mirroring the slot ID validation in the same function. DEV_NOTE_FWAKE is the DNCTRL register bit for notification type 1 (N1), while the event TRB carries the notification type value itself, so add a separate DEV_NOTE_TYPE_FWAKE constant for the comparison. [mn:] reduce warning to a debug message Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: fix typos in commentsZain Aboobacker
Fix various spelling mistakes in comments found by codespell. Assisted-by: Claude:claude-opus-5-5 codespell Signed-off-by: Zain Aboobacker <zainaboobacker33@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: Unlock for command abort pollingMichal Pecio
xhci_abort_cmd_ring() requests abort, waits for the CRR bit to clear, drops xhci->lock and waits for the Command Ring Stopped event. The CRR wait timeout is 5 seconds as suggested by xHCI 4.6.1.2, which means that if the xHC fails to complete the operation at all, we poll with the lock held and IRQs disabled for several seconds. If any other CPU tries to acquire the lock, it will spin likewise. IRQs get delays, drivers log errors, tasks freeze, it's a mess. So drop the lock earlier, before waiting for the CRR bit. It should be safe - the sole caller sets cmd_ring_state to CMD_RING_STATE_ABORTED before calling us, which will prevent others from ringing the command doorbell and interfering with the abort. Queuing new commands during this time poses no danger, and if the command we try to abort actually completes concurrently, existing code already needs to deal with this. And in my testing it does - it's trivial to trigger this on ASM1042, where Address Device can't be aborted, but it completes as soon as the offending device is unplugged, including during abort attempt. Note that the lock still covers reinit_completion(), so it won't race with complete() being called by the event handler. And works are not reentrant, so another timeout can't expire while the lock is dropped. We will configure timeout anew when restarting the ring. One other difference is that now we also drop the lock if abort fails. This too should be harmless. Commands queued during this time will be released like any other pending commands. If the aborted command does complete before we regain the lock, it's a waste, but not regression. Reported-by: Pedro Fonseca <pedro@fonseca.com.pt> Link: https://lore.kernel.org/linux-usb/16f65081-5a3c-4c30-9811-9017796a3373@fonseca.com.pt/ Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: xhci: return an error if the host is not haltedHenry Tseng
xhci_reset() returns 0 when the host is not halted, without ever writing CMD_RESET. Every other path that fails to reset the host returns an error, so callers that check the return value are told the reset succeeded on the one path where it did not happen. Return -EBUSY when the reset is aborted because the host is not halted. Signed-off-by: Henry Tseng <henrytseng@qnap.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261009151624.618967-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: octeon-hcd: keep SOF interrupts while a pipe needs themOrgad Shaneh
cvmx_usb_schedule() now sleeps on an hrtimer until the nearest future periodic deadline instead of counting frames down on every SOF. The scan that finds that deadline only looks at pipes with next_tx_frame > usb->frame_number which is right for picking the deadline, but two kinds of pipe that need a SOF to make progress are invisible to the decision: - A periodic pipe that is due and was *not* started: no idle hardware channel this round, its split window is closed (cvmx_usb_find_ready_pipe() rejects both), or another pipe owns usb->active_split. cvmx_usb_next_pipe() looks at the isochronous and interrupt lists only when is_sof is true. - Any pipe that has sent its start split and waits for the frame its split complete may go out in (split_sc_frame, also checked by cvmx_usb_find_ready_pipe()). A control or bulk pipe on a full or low speed device behind a hub is in this state between its two halves, and with SOF masked nothing guarantees an interrupt that brings frame_number there. When some other periodic pipe sets a far deadline - a hub's status pipe, whenever a hub is attached - the driver masks SOF, arms the timer for that deadline and these pipes wait for it. That is hundreds of frames; the code allows up to 8000 (one second) before it falls back to SOF. Before the hrtimer this could not happen: any pipe with a future deadline set need_sof, so SOF stayed enabled every frame and the pipe was retried on the next one. Note such a pipe and keep SOF enabled while there is one, whether or not another pipe has a future deadline. Nothing changes when there is none, which is the case the timer was added for. Other control and bulk pipes are excluded deliberately: their next_tx_frame is not updated on completion, so they are almost always "due" and would keep SOF enabled permanently. Fixes: aebbc7d63407 ("usb: octeon-hcd: sleep on an hrtimer for far-off periodic transfers") Cc: stable <stable@kernel.org> Assisted-by: LLM Signed-off-by: Orgad Shaneh <orgads@gmail.com> Link: https://patch.msgid.link/20261011080506.2394708-1-orgads@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-11usb: octeon-hcd: release the USB block when initialization failsOrgad Shaneh
cvmx_usb_initialize() gets as far as selecting the reference clock, enabling USBN_CLK_CTL and taking the PHY out of reset (steps 2b-2e) before anything can go wrong, and its only caller frees the HCD and returns without touching the hardware. Both of its error returns therefore leave the USB block clocked and out of reset on a failed probe. Release it on the way out with cvmx_usb_shutdown(), which is the undo the retry path a few lines above already uses. It cannot refuse with -EBUSY here: the pipe lists it checks are initialised by octeon_usb_probe() before cvmx_usb_initialize() is called, and no pipe can have been opened yet. Fixes: 22bce6d2b3fd ("usb: octeon-hcd: fail the probe when the USB core does not respond") Cc: stable <stable@kernel.org> Assisted-by: LLM Signed-off-by: Orgad Shaneh <orgads@gmail.com> Link: https://patch.msgid.link/20261011072238.2381564-1-orgads@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-05Merge 7.3-rc6 into usb-nextGreg Kroah-Hartman
We need the usb/thunderbolt fixes in here to work off of. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-16usb: ohci-st: disable controller wakeup on removalMyeonghun Pak
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind. Disable controller wakeup after removing the HCD. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: d115837259ad ("usb: host: ohci-st: Add OHCI driver support for ST STB devices") Cc: stable <stable@kernel.org> Assisted-by: LLM Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260915012011.61874-5-mhun512@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-16usb: ohci-spear: disable controller wakeup on removalMyeonghun Pak
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind. Disable controller wakeup after removing the HCD. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: a6eeeb9f45b5 ("USB: Update USB default wakeup settings") Cc: stable <stable@kernel.org> Assisted-by: LLM Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260915012011.61874-4-mhun512@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-16usb: ohci-s3c2410: disable controller wakeup on removalMyeonghun Pak
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind. Disable controller wakeup after removing the HCD. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: a6eeeb9f45b5 ("USB: Update USB default wakeup settings") Cc: stable <stable@kernel.org> Assisted-by: LLM Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260915012011.61874-3-mhun512@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-16usb: ohci-da8xx: disable controller wakeup on cleanupMyeonghun Pak
The OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Probe enables wakeup, but neither removal nor a later notifier registration failure disables it, leaving the wakeup source attached. Disable controller wakeup after removing the HCD on both paths. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: a6eeeb9f45b5 ("USB: Update USB default wakeup settings") Cc: stable <stable@kernel.org> Assisted-by: LLM Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260915012011.61874-2-mhun512@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: octeon-hcd: sleep on an hrtimer for far-off periodic transfersOrgad Shaneh
cvmx_usb_schedule() enables the SOF interrupt whenever any pipe has next_tx_frame in the future, and leaves it enabled until the transfer is due. An interrupt endpoint keeps such a deadline pending permanently, so a single attached hub (status pipe polled every 256ms) costs an interrupt on every SOF - 8000/s in high-speed mode, forever. On a 300MHz CN5020 that is measurably ~20% of one core spent counting frames. The frame counter is resynchronized from HFNUM at the top of every poll, so the driver does not actually need to see every SOF to know when a deadline arrives. Sleep on an hrtimer when the nearest deadline is more than a few frames away (one high-speed frame is 125us) and keep SOF interrupts only for deadlines that are imminent - or far enough away to risk the 16383-frame HFNUM wrap, where the interrupt path still tracks the counter extension. Measured on a CN5020 board with one 4-port hub attached and idle: 8200 -> 4 USB interrupts/s, with no change in enumeration or transfer behavior. Assisted-by: Claude:claude-opus-5 Signed-off-by: Orgad Shaneh <orgads@gmail.com> Link: https://patch.msgid.link/20260901193100.1352110-3-orgads@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: octeon-hcd: fail the probe when the USB core does not respondOrgad Shaneh
If the USBN clock/PHY setup did not actually bring the core up (wrong board reference-clock configuration, for instance), every USBC CSR reads as all-ones and initialization marches on programming garbage, ending in timeouts or a wedge deep in the FIFO flush. Read GHWCFG3 - a hardwired configuration register that can be neither 0 nor all-ones on a live core - right before core initialization, and give up cleanly if the core is not answering. Assisted-by: Claude:claude-opus-5 Signed-off-by: Orgad Shaneh <orgads@gmail.com> Link: https://patch.msgid.link/20260901193100.1352110-2-orgads@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: octeon-hcd: fix the FIFO-flush timeout computationOrgad Shaneh
cvmx_wait_tx_rx() computes its 100us deadline from (u64)octeon_get_clock_rate - the address of the function, not its return value; the parentheses have been missing since the CVMX_WAIT_FOR_FIELD32 macro became a function. The cast makes it compile silently, and the resulting deadline is effectively infinite. On a healthy controller the flush bit clears on the first read and nothing is noticed. On a controller whose PHY did not come up (for example when the reference-clock configuration is wrong for the board), txfflsh/rxfflsh never clear and probe spins forever in __delay() - observed as a hard hang with a soft-lockup splat on a CN5020 board, where the board watchdog then resets the system with no console output. Call the function, restoring the 100us timeout the code always intended. Fixes: 3e195a80e096 ("Staging: octeon-usb: Replaces CVMX_WAIT_FOR_FIELD32 macro with a function") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: Orgad Shaneh <orgads@gmail.com> Link: https://patch.msgid.link/20260901193100.1352110-1-orgads@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVEBartosz Golaszewski
The GPIOD_FLAGS_BIT_NONEXCLUSIVE flag for gpiod_get() is deprecated. For actually shared GPIOs, it should be replaced by using the functionality provided by gpio-shared-proxy. The Freescale QUICC Engine GPIO driver uses it as a workaround to access the GPIO descriptor already requested by the caller of qe_pin_request() in order to access the private GPIO chip data. As the existing comment itself states, the user already requested this GPIO and the only user in tree is the FHCI USB driver which does in fact request it, we can safely modify the function to take the *exclusive* GPIO descriptor as argument and stop using the deprecated flag. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20260908-usb-fhci-drop-gpio-nonexclusive-v1-1-8e405dc67874@oss.qualcomm.com Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
2026-09-10usb: ehci: support additional controller quirksLinus Walleij
Some EHCI implementations omit CONFIGFLAG and USBMODE, or have an integrated transaction translator that cannot schedule siTDs. Add quirks to skip CONFIGFLAG and TDI mode accesses and to reject full- and low-speed isochronous transfers. Standard controllers retain their current behavior. Suggested-by: Daniel Palmer <daniel@thingy.jp> Assisted-by: LLM Signed-off-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260903-gemini-usb-fotg2-v3-4-dd92ecf5675b@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: ehci: add port speed hookLinus Walleij
Some EHCI implementations report device speed in implementation-defined registers. Add an optional hook for port speed reporting. Move the common integrated-TT speed decoding into the hub code, preserving the PORTSC and HOSTPC paths when no hook is supplied. Gate the callback behind the hidden USB_EHCI_PORT_SPEED_HOOK option so controllers using standard speed reporting incur no extra state or runtime checks. The hook is only meaningful for controllers with an integrated root hub transaction translator, so make the option depend on USB_EHCI_ROOT_HUB_TT. Suggested-by: Alan Stern <stern@rowland.harvard.edu> Suggested-by: Daniel Palmer <daniel@thingy.jp> Assisted-by: LLM Signed-off-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260903-gemini-usb-fotg2-v3-3-dd92ecf5675b@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: ehci: add port reset hooksLinus Walleij
Some EHCI implementations need controller-specific sequencing around port reset. Add optional hooks for reset preparation and completion. Controllers without the hooks retain the existing behavior. Gate the callbacks behind the hidden USB_EHCI_PORT_RESET_HOOKS option so controllers using standard reset sequencing incur no extra state or runtime checks. Suggested-by: Alan Stern <stern@rowland.harvard.edu> Suggested-by: Daniel Palmer <daniel@thingy.jp> Assisted-by: LLM Signed-off-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260903-gemini-usb-fotg2-v3-2-dd92ecf5675b@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: ehci: support non-standard port status registersLinus Walleij
Some EHCI implementations place the port status registers outside the standard operational register layout. Add a per-controller port status base and use a helper for all PORTSC accesses, while preserving the standard location by default. Gate the alternate member and lookup behind the hidden USB_EHCI_DEVIANT_PORT_STATUS_REG option. This avoids growing struct ehci_hcd or adding a runtime branch on systems using the standard port status register location. Suggested-by: Alan Stern <stern@rowland.harvard.edu> Suggested-by: Daniel Palmer <daniel@thingy.jp> Assisted-by: LLM Signed-off-by: Linus Walleij <linusw@kernel.org> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260903-gemini-usb-fotg2-v3-1-dd92ecf5675b@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10USB: pci-quirks: Release EHCI device referenceYuho Choi
for_each_pci_dev() holds a reference to the current device. The Intel EHCI lookup breaks as soon as it finds a match, so the iterator does not get a chance to drop that reference on its next iteration. Release the reference before leaving the loop. Fixes: 26b76798e050 ("Intel xhci: refactor EHCI/xHCI port switching") Signed-off-by: Yuho Choi <dbgh9129@gmail.com> Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260807024304.928708-1-dbgh9129@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10USB: OHCI: drop unneeded semicolonJulia Lawall
When a function-like macro expands to an expression, that expression doesn't need a semicolon after it. All uses have been verified to have their own semicolons. This was found using the following Coccinelle semantic patch: @r@ identifier i : script:ocaml() { String.lowercase_ascii i = i }; expression e; @@ *#define i(...) e; Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Link: https://patch.msgid.link/20260801191002.1383835-1-Julia.Lawall@inria.fr Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: ohci-ppc-of: use platform for irq and ioremapRosen Penev
Replace the open-coded of_address_to_resource() plus devm_ioremap_resource() sequence with devm_platform_get_and_ioremap_resource(), which looks up the resource and maps it in one call. The helper returns a pointer to the resource, so update rsrc_start / rsrc_len to dereference it and assign the mapped address to hcd->regs. Use a separate on-stack resource (ehci_res) for the unrelated ibm,usb-ehci-440epx erratum lookup rather than aliasing the returned resource pointer. Switch IRQ acquisition from irq_of_parse_and_map() to platform_get_irq(), which only retrieves the interrupt the OF/platform core has already set up rather than transferring mapping ownership to the driver. Drop the now unneeded irq_dispose_mapping() calls (probe error path and ohci_hcd_ppc_of_remove()) and the now-unused of_irq.h include, keeping linux/of_address.h for the erratum block's of_address_to_resource(). Behaviorally equivalent with respect to region reservation: the prior code used devm_ioremap_resource(), which already reserved the region. Built for PowerPC (ppc44x_defconfig + CONFIG_USB_OHCI_HCD_PPC_OF) with LLVM=1; drivers/usb/host/ohci-hcd.o (which includes ohci-ppc-of.c) compiles cleanly. Assisted-by: opencode:hy3-free Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20260713231604.1090044-1-rosenp@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-10usb: ehci-ppc-of: use platform for irq and ioremapRosen Penev
Replace the open-coded of_address_to_resource() plus devm_ioremap_resource() sequence with devm_platform_get_and_ioremap_resource(), which looks up the resource and maps it in one call. The helper returns a pointer to the resource, so update rsrc_start / rsrc_len to dereference it, assign the mapped address to hcd->regs, and use a separate on-stack resource (ohci_res) for the unrelated ibm,usb-ohci-440epx erratum lookup rather than aliasing the returned resource pointer. Switch IRQ acquisition from irq_of_parse_and_map() to platform_get_irq(), which only retrieves the interrupt the OF/platform core has already set up rather than transferring mapping ownership to the driver. Drop the now unneeded irq_dispose_mapping() calls (probe error path and ehci_hcd_ppc_of_remove()) and the now-unused of_irq.h and of_platform.h includes, keeping linux/of_address.h for the erratum block's of_address_to_resource(). Behaviorally equivalent with respect to region reservation: the prior code used devm_ioremap_resource(), which already reserved the region. Built for PowerPC (ppc44x_defconfig + CONFIG_USB_EHCI_HCD_PPC_OF) with LLVM=1; drivers/usb/host/ehci-hcd.o (which includes ehci-ppc-of.c) compiles cleanly. Assisted-by: opencode:hy3-free Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20260713231302.1076740-1-rosenp@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-07Merge 7.3-rc2 into usb-nextGreg Kroah-Hartman
We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-01usb: host: xhci-tegra: Remove redundant dev_err()Pan Chuang
Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in devm_request_*_irq()"), devm_request_threaded_irq() automatically logs detailed error messages on failure. Remove the now-redundant driver-specific dev_err() calls. Signed-off-by: Pan Chuang <panchuang@vivo.com> Link: https://patch.msgid.link/20260731035448.252289-7-panchuang@vivo.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-08-31xhci: fix lost bounce buffers on TDs spanning several ring segmentsArthur Gautier
When a TD reaches a link TRB with data that is not aligned to the endpoint's wMaxPacketSize, xhci_align_td() stages the unalignable tail through the bounce buffer of the ring segment holding that link TRB. xhci_unmap_td_bounce_buffer() later unmaps it and, for IN transfers, copies the data back into the URB's buffer. The enqueue path records the segment that was bounced in td->bounce_seg, under the assumption that a TD never spans more than two ring segments. That assumption does not hold: a TD large enough to span three or more segments crosses several link TRBs and can be bounced at each of them. Only the last one survives in td->bounce_seg, so every earlier bounce buffer is neither copied back nor DMA unmapped. The URB still completes with actual_length equal to the requested length and no error, so the transfer looks successful while a wMaxPacketSize sized hole in the destination buffer silently keeps its previous contents. It also leaks a DMA mapping per dropped bounce. Any sufficiently large and fragmented bulk transfer can hit this. It was found with a USB mass storage device behind xHCI backing a dm-verity target with 512 byte hash blocks, where the stale data is detected rather than silently consumed. The device enumerates as SuperSpeed, so wMaxPacketSize is 1024, while dm-bufio issues one 512 byte bio per hash block. verity_prefetch_io() makes the block layer merge hundreds of them into a single request of up to 512 scatterlist entries of 512 bytes each. At 256 TRBs per ring segment such a TD spans three segments, and every segment boundary falls on an odd multiple of 512, i.e. unaligned to wMaxPacketSize. dm-bufio then caches a hash block holding stale data and dm-verity declares the metadata block corrupted: device-mapper: verity: 8:2: metadata block 10850 is corrupted A reproducer running this under qemu is available at https://github.com/baloo/xhci-verity The bounce state (bounce_buf, bounce_dma, bounce_len, bounce_offs) already lives on the ring segment, so there is nothing extra to track. Keep recording the last bounced segment in td->bounce_seg and, on completion, walk the segments from td->start_seg up to it, unmapping every segment that still has a pending bounce. Stopping at td->bounce_seg rather than td->end_seg matters: a bounce implies the TD continues past that segment's link TRB, so bounce_seg is always strictly before end_seg, and a later TD may already have started in end_seg and been bounced there. Walking that far would copy a foreign bounce buffer into this URB and unmap it twice. It also keeps the walk correct if a TD ever wraps the whole ring so that end_seg == start_seg. [mn: Add ring->num_segs check to prevent unlikely infinite for loop.] Fixes: f9c589e142d0 ("xhci: TD-fragment, align the unsplittable case with a bounce buffer") Cc: stable@vger.kernel.org Suggested-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Arthur Gautier <baloo@superbaloo.net> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20260831090448.95644-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-08-31usb: xhci: Fix isochronous scheduling regressionMichal Pecio
An isoc URB without URB_ISO_ASAP should be scheduled immediately after the previous one, unless it's the first submission or prior URBs have completed without resubmitting and the endpoint became idle. An HCD_BH driver must consider URBs pending completion in the BH queue in addition to its own queue. Regrettably, core doesn't provide much information, we can only know if we are being called by completion now. This issue is as old as HCD_BH, affects ehci-hcd too and has no known reproducible impact, as drivers generally resubmit from completion. A recent patch tried to address it by looking at xHCI HW state instead. Obviously, HW has no knowledge of the BH giveback queue either, and the whole solution amounts to testing whether prior URBs have been unlinked instead of completing normally - then a new stream is assumed. This leads to false negatives when a driver simply allows the endpoint to empty out and begins a new stream. New URBs are scheduled into the past and promptly fail with -EXDEV status, causing data loss and worse, because drivers get confused by premature completion, particularly when multiple endpoints are started at once and required to stay in sync. snd-usb-audio underruns the OUT endpoint when userspace fails to supply playback data in time. If this is detected in duplex mode, IN URBs are unlinked and both streams restarted. OUT underruns again before IN even begins, another recovery is attempted and the cycle repeats. Fix this by using the best criteria we can muster, taken from ehci-hcd. This brings false negative rate back to zero and false positive rate to less than ever before in xhci-hcd. Traditional logic was equivalent to: if (list_empty(&ep_ring->td_list) || GET_EP_CTX_STATE(ep_ctx) != EP_STATE_RUNNING) // consider this URB a new stream While free of false negatives, it had easily avoidable false positives: * no check for completion in progress when the list is empty * the ep_ctx check doesn't make up for it at all, but it adds a race - EP state can remain "stopped" for a while after the first submission [mn: add debug message in possible false positive case where driver might incorrectly assume new stream starts mid stream just because td list is empty (URB enqueue is late), and workqueue isn't processing URB completions for this endpoint at the moment] Link: https://lore.kernel.org/linux-usb/20260813005635.34750f8c.michal.pecio@gmail.com/ Fixes: add8469b3e00 ("xhci: fix frame id calculation and checks for isoc URBs") Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20260831090448.95644-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>