Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/4] usb: of: Fix root-hub raw port lookups and graph handling
@ 2026-12-04  2:52 Chen-Yu Tsai
  2026-12-04  2:52 ` [PATCH 1/4] usb: of: Ignore 0-based or unnumbered OF graphs in usb_of_get_connect_type() Chen-Yu Tsai
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2026-12-04  2:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Chen-Yu Tsai, Alan Stern, linux-usb, devicetree,
	Matthias Kaehlcke, Stephen Boyd, Rafał Miłecki,
	Johan Hovold, Mathias Nyman, Neil Armstrong, Bjorn Andersson

Hi folks,

This series is targeted at usb-next (v7.5). Note two -next dependencies:
- During auditing for patch 2, a port-numbering mismatch on
  qcs6490-rb3gen2.dts was found and applied to qcom's -next branch
  (arm64-for-7.5, commit eba979cb2d94, [4]). Since that fix is queued
  for v7.5 rather than v7.4 fixes, this series should go through
  usb-next rather than usb-linus (and stable backports of patch 2 also
  require eba979cb2d94).
- Patch 4's hunk in drivers/usb/core/usb.h relies on context from
  commit f7a3812c85c4 ("USB: hub: call ACPI _PRR reset during port
  power-cycle on enumeration failure") in usb-next, so it does not
  apply cleanly to usb-linus.

On xHCI controllers, HighSpeed and SuperSpeed downstream ports are split
across two logical root hubs (primary and secondary HCDs) that share a
single device tree node. As a result, a root hub's logical 1-based port
index does not always match the controller's raw port number used by
device tree child nodes (reg = <N>) and 1-based OF graph ports (port@N).

These issues came up while working on M.2 E-key USB power sequencing
support [1] and downstream port OF graph bindings for USB host
controllers and dwc3 [2]:

- Patch 1 ignores OF graphs with port@0 or an unnumbered "port" node in
  usb_of_get_connect_type(), avoiding false USB_PORT_NOT_USED markings
  on legacy dual-role and 0-based snps,dwc3 device trees (as discussed
  with Neil Armstrong [3]).
- Patch 2 adds usb_of_find_raw_port() and uses it in both
  usb_of_get_device_node() and usb_of_get_connect_type() so all root
  hub OF lookups use raw port numbers.
- Patch 3 stops skipping secondary root hubs in
  onboard_dev_create_pdevs(), allowing standalone USB 3.x onboard
  devices without a peer-hub to be created while keeping dual-speed
  hubs deduplicated on the primary HCD.
- Patch 4 checks that a newly enumerated USB device's VID/PID matches
  its device tree node's compatible string and warns on mismatch
  (which will intentionally flag a few pre-existing mismatched device
  trees, such as verdin-dahlia, mt8390-grinn-genio-sbc, helios64, and
  meson-libretech-cottonwood).

Patch 1, patch 3, and the OF graph raw-port lookup in patch 2 were
flagged during reviews by an AI coding agent (Antigravity). Patches 1
and 3, as well as this cover letter, were drafted by the agent and
reviewed by me; patches 2 and 4 were written by me.

The series was compile-tested with W=1 across arm64 (USB=y/m,
USB_ONBOARD_DEV=y/m/n, USB_LEDS_TRIGGER_USBPORT=y/m/n) and i386
(OF=y/n, USB=y/m, per-commit), and runtime-tested on an MT8195 Cherry
Dojo Chromebook (with pending driver and device tree patches from [1]
and pending USB hub / Type-A connector device tree patches):
- On xhci0 (SS raw port 1, HS raw port 2), onboard-usb-dev created a
  single platform device on usb-hub@2 (parent usb1, usb5e3,610) with
  both 1-1 and 2-1 bound and no duplicate on usb2.
- 1-1 and 2-1 matched usb-hub@2 and usb-hub@1 with no compatible
  mismatch warnings and connect_type=hardwired (removable=fixed).
- External hub ports (port@3) and xhci3's M.2 port (port@1) reported
  connect_type=hotplug (removable=removable) with expected port
  of_nodes; unpopulated hub ports reported "not used" and xhci2
  reported "unknown".
- The port0 != NULL ignore path in patch 1 and the standalone USB 3.x
  onboard device (without peer-hub) path in patch 3 remain
  compile-tested only.


Thanks
ChenYu

[1] https://lore.kernel.org/all/20260916075745.3549953-1-wenst@chromium.org/
[2] https://lore.kernel.org/all/20261014082037.1774672-1-wenst@chromium.org/
[3] https://lore.kernel.org/all/03375a31-0ac6-47a4-b0dc-6327080e1622@linaro.org/
[4] https://lore.kernel.org/all/20261130113021.611298-1-wenst@chromium.org/

Chen-Yu Tsai (4):
  usb: of: Ignore 0-based or unnumbered OF graphs in
    usb_of_get_connect_type()
  usb: of: Use raw port numbers for root hub OF lookups
  usb: misc: onboard_usb_dev: Create pdevs for secondary root hubs
  usb: of: Check compatible string of device node

 drivers/usb/core/hub.c                   |   3 +
 drivers/usb/core/of.c                    | 123 +++++++++++++++++++----
 drivers/usb/core/usb.c                   |   8 +-
 drivers/usb/core/usb.h                   |   8 ++
 drivers/usb/misc/onboard_usb_dev_pdevs.c |  26 ++---
 5 files changed, 124 insertions(+), 44 deletions(-)

-- 
2.56.1.915.g69d5ec7298-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-12-04  3:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  2:52 [PATCH 0/4] usb: of: Fix root-hub raw port lookups and graph handling Chen-Yu Tsai
2026-12-04  2:52 ` [PATCH 1/4] usb: of: Ignore 0-based or unnumbered OF graphs in usb_of_get_connect_type() Chen-Yu Tsai
2026-12-04  2:52 ` [PATCH 2/4] usb: of: Use raw port numbers for root hub OF lookups Chen-Yu Tsai
2026-12-04  3:10   ` sashiko-bot
2026-12-04  2:52 ` [PATCH 3/4] usb: misc: onboard_usb_dev: Create pdevs for secondary root hubs Chen-Yu Tsai
2026-12-04  2:52 ` [PATCH 4/4] usb: of: Check compatible string of device node Chen-Yu Tsai
2026-12-04  3:10 ` [PATCH 0/4] usb: of: Fix root-hub raw port lookups and graph handling sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox