From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v6 3/3] usb: hub: Retry SuperSpeed for a device stuck on its USB 2.0 peer
Date: Thu, 19 Nov 2026 10:23:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-222947@kernel.org> (raw)
In-Reply-To: <20261119-usb-port-pairing-v6-3-32bd7e36e426@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: hub: missing sync with peer hub init in
hub_reset_peer_child()
--
commit 7d4ffb5084a3369e5c00127c3a48cf92988241d0
Author: Arun Iyengar <aiyengar1990@gmail.com>
usb: hub: Retry SuperSpeed for a device stuck on its USB 2.0 peer
When a SuperSpeed root hub starts, this commit resets the USB 2.0 peer
port of any SuperSpeed-capable device so that it can move to the
SuperSpeed port.
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 199d3f535a891..65d0728d43306 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
[ ... ]
> @@ -3278,6 +3289,116 @@ static void usb_unlock_port(struct usb_port *port_dev)
> __release(&port_dev->status_lock);
> }
>
> +static void hub_reset_peer_child(struct usb_hub *hub, int port1,
> + struct usb_device *peer_hdev, int peer_port1)
> +{
> + struct usb_port *ss_port = hub->ports[port1 - 1];
> + struct usb_port *port_dev;
> + struct usb_hub *peer_hub;
> + struct usb_device *udev;
> + u16 portstatus, portchange;
> +
> + /* Keep hub_wq off the SuperSpeed port until the USB 2.0 device is gone */
> + mutex_lock_nested(&ss_port->status_lock, SINGLE_DEPTH_NESTING);
> + usb_lock_device(peer_hdev);
> + if (hub->quiescing)
> + goto out;
> + peer_hub = usb_hub_to_struct_hub(peer_hdev);
> + if (!peer_hub || peer_port1 > peer_hdev->maxchild)
> + goto out;
> +
> + port_dev = peer_hub->ports[peer_port1 - 1];
> + udev = port_dev->child;
> + if (!udev || udev->speed != USB_SPEED_HIGH ||
> + udev->descriptor.bDeviceClass == USB_CLASS_HUB)
> + goto out;
[Severity: Medium]
Can hub_reset_peer_child() observe port_dev->child == NULL and bail out
before peer_hub has finished enumerating a boot-connected device?
In hub_activate(peer_hub, HUB_INIT2), a USB 2.0 root hub with a connected
device sees USB_PORT_STAT_C_CONNECTION, sets need_debounce_delay = true,
queues peer_hub->init_work for HUB_DEBOUNCE_STABLE (100 ms), and unlocks
peer_hdev->dev. Even after hub_init_func3() runs kick_hub_wq(peer_hub),
peer_hdev->dev is unlocked again before hub_event() enumerates the device
and assigns port_dev->child.
Meanwhile, the SuperSpeed root hub has no connection on its port during
HUB_INIT2, so it skips the 100 ms debounce delay and queues
peer_reset_work immediately:
peer_hub (USB 2.0) hub (SuperSpeed)
------------------ ----------------
hub_activate(HUB_INIT2)
need_debounce_delay = true
queue_delayed_work(init_work,
100 ms)
device_unlock(&peer_hdev->dev)
hub_activate(HUB_INIT2)
need_debounce_delay = false
hub_queue_peer_reset(hub)
hub_peer_reset_work()
hub_reset_peer_child()
usb_lock_device(peer_hdev)
udev = port_dev->child; <-- NULL
goto out;
hub_init_func3()
...
hub_port_connect()
port_dev->child = udev;
Whenever the SuperSpeed root hub probes while peer_hub->init_work or
peer_hub->events is still pending, hub_reset_peer_child() exits without
resetting the peer port, leaving the device at high speed. Flushing
peer_hub->init_work and peer_hub->events before checking port_dev->child
would avoid this race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-usb-port-pairing-v6-0-32bd7e36e426@gmail.com?part=3
prev parent reply other threads:[~2026-11-19 10:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 10:03 [PATCH v6 0/3] usb: core: Pair ports of different host controllers through their connector Arun Iyengar via B4 Relay
2026-11-19 10:03 ` [PATCH v6 1/3] usb: core: Pair ports of different hubs " Arun Iyengar via B4 Relay
2026-11-19 10:34 ` sashiko-bot
2026-11-19 10:03 ` [PATCH v6 2/3] usb: core: Prefer the graph for a dwc3 SuperSpeed port's connect_type Arun Iyengar via B4 Relay
2026-11-19 10:09 ` sashiko-bot
2026-11-19 10:03 ` [PATCH v6 3/3] usb: hub: Retry SuperSpeed for a device stuck on its USB 2.0 peer Arun Iyengar via B4 Relay
2026-11-19 10:23 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-222947@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aiyengar1990@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox