From: sashiko-bot@kernel.org
To: "Chunfeng Yun" <chunfeng.yun@mediatek.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v4 13/14] thunderbolt: Decouple the waiting time of TB_PORT_UNPLUGGED and TB_PORT_UP
Date: Sat, 05 Dec 2026 08:56:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-251318@kernel.org> (raw)
In-Reply-To: <20261205083342.4009278-14-chunfeng.yun@mediatek.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] thunderbolt: tb_wait_for_port() cuts TB_PORT_UNPLUGGED
timeout to 400ms
--
commit 05565fb12a80e9ccebefeee4587f7154d13fd01e
Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
thunderbolt: Decouple the waiting time of TB_PORT_UNPLUGGED and TB_PORT_UP
This commit caps the time tb_wait_for_port() spends waiting in
TB_PORT_UNPLUGGED at 400 ms instead of using the full 2 second retry
budget.
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index e0bbdc5fb2f66..f25c358181dd3 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
[ ... ]
> @@ -500,6 +501,7 @@ int tb_port_state(struct tb_port *port)
> */
> int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged)
> {
> + int unplugged_retries = 4;
> int retries = 20;
> int state;
> if (!port->cap_phy) {
> @@ -519,7 +521,7 @@ int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged)
> return 0;
>
> case TB_PORT_UNPLUGGED:
> - if (wait_if_unplugged) {
> + if (wait_if_unplugged && unplugged_retries--) {
> /* used during resume */
> tb_port_dbg(port,
> "is unplugged (state: 7), retrying...\n");
[Severity: Medium]
Can cutting unplugged_retries to 4 (400 ms) regress resume on slower
hardware that relied on the previous 1000 ms timeout?
The 400 ms limit is based on empirical USB4 timing, but
tb_wait_for_port(port, true) is also used on legacy Thunderbolt 1/2/3
resume paths (after tb_switch_reset() in tb_resume_noirq() and lane
init in tb_port_resume()) and in tb_xdomain_lane_bonding_enable().
If a port stays in TB_PORT_UNPLUGGED between 400 ms and 1000 ms,
tb_wait_for_port() now returns 0 early, causing tb_switch_resume() to
mark the downstream subtree unplugged and tear down its active tunnels.
Setting unplugged_retries to 10 would decouple TB_PORT_UNPLUGGED from
the new 2 second TB_PORT_UP timeout without shrinking the existing
1000 ms window, or a shorter timeout could be restricted to USB4
disconnect wakes via PORT_CS_18_WODS.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205083342.4009278-1-chunfeng.yun@mediatek.com?part=13
next prev parent reply other threads:[~2026-12-05 8:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 8:33 [PATCH v4 00/14] thunderbolt: Add platform NHI driver and modularize PCIe NHI Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 01/14] thunderbolt: Fix error handling and unwind paths in nhi_probe() Chunfeng Yun
2026-12-05 8:50 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 02/14] thunderbolt: Prefix NHI core symbols with tb_ and tb_ring_ Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 03/14] thunderbolt: Internalize non-MSI-X interrupt request and work in NHI core Chunfeng Yun
2026-12-05 8:51 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 04/14] thunderbolt: Encapsulate router device type checks in switch.c Chunfeng Yun
2026-12-05 8:41 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 05/14] thunderbolt: Move rpm_complete bus walk to domain.c Chunfeng Yun
2026-12-05 8:50 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 06/14] thunderbolt: Consolidate domain and NHI teardown into tb_nhi_remove() Chunfeng Yun
2026-12-05 8:50 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 07/14] thunderbolt: Move ICM mailbox functions to icm.c Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 08/14] thunderbolt: Decouple ICM probe from NHI core via .select_cm hook Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 09/14] thunderbolt: Make PCIe NHI support opt-in Chunfeng Yun
2026-12-05 8:58 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 10/14] thunderbolt: Make nhi->ops optional Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 11/14] thunderbolt: Add platform NHI driver Chunfeng Yun
2026-12-05 8:56 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 12/14] thunderbolt: Increase the lane adapter link-up timeout value Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 13/14] thunderbolt: Decouple the waiting time of TB_PORT_UNPLUGGED and TB_PORT_UP Chunfeng Yun
2026-12-05 8:56 ` sashiko-bot [this message]
2026-12-05 8:33 ` [PATCH v4 14/14] thunderbolt: Drop WARN_ON() in tb_disconnect_pci() Chunfeng Yun
2026-12-05 8:55 ` sashiko-bot
2026-12-05 8:58 ` [PATCH v4 00/14] thunderbolt: Add platform NHI driver and modularize PCIe NHI sashiko-bot
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-251318@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chunfeng.yun@mediatek.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