mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chunfeng Yun (云春峰)" <Chunfeng.Yun@mediatek.com>
To: "mika.westerberg@linux.intel.com" <mika.westerberg@linux.intel.com>
Cc: "konrad.dybcio@oss.qualcomm.com" <konrad.dybcio@oss.qualcomm.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"westeri@kernel.org" <westeri@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	"YehezkelShB@gmail.com" <YehezkelShB@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"sven@kernel.org" <sven@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"andreas.noever@gmail.com" <andreas.noever@gmail.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2 7/7] thunderbolt: prevent pcie tunnel activation/teardown warnings
Date: Mon, 16 Nov 2026 03:17:48 +0000	[thread overview]
Message-ID: <af991da994391cea597cc953362d40b1cd6a6a5c.camel@mediatek.com> (raw)
In-Reply-To: <20261110145004.GF259790@black.igk.intel.com>

On 二, 2026-11-10 at 15:50 +0100, Mika Westerberg wrote:
> On Tue, Nov 10, 2026 at 07:48:55PM +0800, Chunfeng Yun wrote:
> > When usb4 enter sleep mode, echo 1 to authorized of sysfile,
> > will wakeup usb4 driver, but fail to create pcie tunnel, cause
> > the warning due to a race condition between router disconnect
> > during resume and user authorization
> 
> This is hard to understand.
> 
> Also PCIe, USB4 and so on.
> 
> > 
> > [  278.831186] usb4_hi NVDA8100:00: 0:1: is unplugged (state: 7),
> > retrying...
> > [  278.943031] usb4_hi NVDA8100:00: 0:1: failed to reach state
> > TB_PORT_UP. Ignoring port...
> > [  278.951125] usb4_hi NVDA8100:00: 0:1: lost during suspend,
> > disconnecting
> > ...
> > [  279.013763] usb4_hi NVDA8100:00: 0:7 <-> 1:9 (PCI): activating
> > [  279.019587] usb4_hi NVDA8100:00: activating PCIe Down path from
> > 0:7 to 1:9
> > [  279.026468] usb4_hi NVDA8100:00: 1:1: Writing hop 1
> > [  279.031335] usb4_hi NVDA8100:00: 1:1:  In HopID: 8 => Out port:
> > 9 Out HopID: 8
> > [  279.038546] usb4_hi NVDA8100:00: 1:1:   Weight: 1 Priority: 3
> > Credits: 32 Drop: 0 PM: 0
> > [  279.046536] usb4_hi NVDA8100:00: 1:1:    Counter enabled: 0
> > Counter index: 2047
> > [  279.053834] usb4_hi NVDA8100:00: 1:1:   Flow Control (In/Eg):
> > 1/0 Shared Buffer (In/Eg): 0/0
> > [  279.062259] usb4_hi NVDA8100:00: 1:1:   Unknown1: 0x0 Unknown2:
> > 0x0 Unknown3: 0x0
> > [  279.069730] ------------[ cut here ]------------
> > [  279.074335] usb4_hi NVDA8100:00: PCIe Down path activation
> > failed
> > [  279.080426] WARNING: CPU: 5 PID: 2433 at
> > drivers/thunderbolt/path.c:587 tb_path_activate+0x1a4/0x5b0
> > ...
> > [  279.220285] Call trace:
> > [  279.222722]  tb_path_activate+0x1a4/0x5b0 (P)
> > [  279.227068]  tb_tunnel_activate+0x140/0x498
> > [  279.231241]  tb_tunnel_pci+0x180/0x490
> > [  279.234980]  tb_domain_approve_switch+0x74/0xb0
> > [  279.239500]  authorized_store+0x214/0x270
> > [  279.243498]  dev_attr_store+0x20/0x70
> > ...
> > [  279.288888] ---[ end trace 0000000000000000 ]---
> > [  279.293497] usb4_hi NVDA8100:00: 0:7 <-> 1:9 (PCI): activation
> > failed
> > 
> > When usb4 enter sleep mode, echo 0 to authorized of sysfile,
> > will wakeup usb4 driver, but fail to disconnect pcie due to
> > the PCIe tunnel had already been torn down and freed if the port
> > is fail to resume,
> 
> Please put the steps like:
> 
> 1) Boot the system, nothing connected.
> 2) Once booted up, connected device.
> 3) Authorize PCIe tunnel via echo 1 > ..
> ...
> 
> So that we can see what are the steps you reproduce this. The above
> is
> really hard to follow at least to me.
> 
case 1:
1. connect a usb4 hub and wait for usb4 enter sleep mode
2. echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

case 2: (based on step 1/2)
3. make sure PCIe tunnel is created, and wait for usb4 entr sleep mode
again
4. echo 0 > /sys/bus/thunderbolt/devices/0-1/authorized

I try to reproduce the case 1, and find there is no WARN log in case 1,

  tb_tunnel_pci()
      --> tb_tunnel_activate()
              --> tb_pci_pre_activate() will return -ENODEV due to
router is unplugged

so it will not call tb_path_activate() anymore, even it is called, it
will not print
dump stack anymore which is fixed by the patch:
"062191adfde0 thunderbolt: Log path activation failures without WARN
backtraces"

[  188.674233] thunderbolt NVDA8100:00: 0:1: is connected, link is not
up (state: 1), retrying...
[  188.745743] usb 1-1: USB disconnect, device number 2
[  188.745751] usb 1-1.5: USB disconnect, device number 3
[  188.778643] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7),
retrying...
[  188.882504] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7),
retrying...
[  188.986645] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7),
retrying...
-bash: echo: write error: Input/[  189.090663] thunderbolt NVDA8100:00:
0:1: is unplugged (state: 7)
[  189.090671] thunderbolt NVDA8100:00: 0:1: lost during suspend,
disconnecting
[  189.090677] thunderbolt NVDA8100:00: 0:4 <-> 1:16 (USB3):
deactivating
[  189.090963] thunderbolt NVDA8100:00: deactivating USB3 Down path
from 0:4 to 1:16
[  189.091109] thunderbolt NVDA8100:00: deactivating USB3 Up path from
1:16 to 0:4
[  189.091163] thunderbolt NVDA8100:00: 0: TMU: mode change off -> bi-
directional, HiFi requested
[  189.091461] thunderbolt NVDA8100:00: 0: TMU: mode set to: bi-
directional, HiFi
[  189.091518] thunderbolt NVDA8100:00: 0:7 <-> 1:9 (PCI): activating
[  189.091532] tb_tunnel_activate pre_act -19
[  189.091534] thunderbolt NVDA8100:00: 1:9: PCIe tunnel activation
failed, aborting
[  189.091598] thunderbolt NVDA8100:00: 0:5: DP IN resource available
after hotplug


for the case 2, still have WARN logs
[  352.346879] thunderbolt NVDA8100:00: 0:1: is connected, link is not
up (state: 1), retrying...
[  352.450898] thunderbolt NVDA8100:00: 0:1: is connected, link is not
up (state: 1), retrying...
[  352.534038] usb 1-1: USB disconnect, device number 6
[  352.534046] usb 1-1.5: USB disconnect, device number 7
[  352.554670] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7),
retrying...
[  352.658951] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7),
retrying...
[  352.763164] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7),
retrying...
[  352.867149] thunderbolt NVDA8100:00: 0:1: is unplugged (state: 7)
[  352.867156] thunderbolt NVDA8100:00: 0:1: lost during suspend,
disconnecting
[  352.867161] thunderbolt NVDA8100:00: 0:4 <-> 1:16 (USB3):
deactivating
[  352.867693] thunderbolt NVDA8100:00: deactivating USB3 Down path
from 0:4 to 1:16
[  352.867719] thunderbolt NVDA8100:00: deactivating USB3 Up path from
1:16 to 0:4
[  352.867761] thunderbolt NVDA8100:00: 0:7 <-> 1:9 (PCI): deactivating
[  352.867779] thunderbolt NVDA8100:00: deactivating PCIe Down path
from 0:7 to 1:9
[  352.867794] thunderbolt NVDA8100:00: deactivating PCIe Up path from
1:9 to 0:7
[  352.867810] thunderbolt NVDA8100:00: 0: TMU: mode change off -> bi-
directional, HiFi requested
[  352.867863] thunderbolt NVDA8100:00: 0: TMU: mode set to: bi-
directional, HiFi
[  352.867907] ------------[ cut here ]------------
[  352.867908] WARNING: drivers/thunderbolt/tb.c:2273 at
tb_disconnect_pci+0x98/0xa0, CPU#7: bash/3497
[  352.952671] Modules linked in: arm_smccc_trng rng_core sbsa_gwdt
i2c_dev ipmi_ssif
[  352.960233] CPU: 7 UID: 0 PID: 3497 Comm: bash Not tainted 7.3.0-
rc7-arm64 #44 PREEMPT(full)
[  352.968745] Hardware name: JMJWOA-Generic 0000-0000/SKU 1, BIOS
2024.5.0-g10bafb2392 07/20/2026
[  352.977429] pstate: 61400009 (nZCv daif +PAN -UAO -TCO +DIT -SSBS
BTYPE=--)
[  352.984379] pc : tb_disconnect_pci+0x98/0xa0
[  352.988638] lr : tb_disconnect_pci+0x90/0xa0
[  352.992897] sp : ffffffc0845dbbb0
[  352.996199] x29: ffffffc0845dbbb0 x28: ffffff80a9083c00 x27:
0000000000000000
[  353.003323] x26: 0000000000000000 x25: 0000000000000000 x24:
0000000000000000
[  353.010445] x23: ffffffc0845dbc7b x22: 0000000000000002 x21:
0000000000000000
[  353.017567] x20: ffffff80b0705800 x19: 0000000000000000 x18:
0000000000000000
[  353.024689] x17: 000000040044ffff x16: 000000b2b5593510 x15:
0000000000000010
[  353.029889] usb 2-1: USB disconnect, device number 4
[  353.036762] x14: 0000000000000000 x13: 203a6f7420746573 x12:
0000000000000000
[  353.043886] x11: ffffffc081928580 x10: 0000000000000000 x9 :
ffffff80a9544b18
[  353.051009] x8 : ffffff80a9083c00 x7 : ffffff80a9083c00 x6 :
0000000000000000
[  353.058131] x5 : ffffff80a9544b68 x4 : ffffff80a9544b68 x3 :
ffffff80b1aba708
[  353.065253] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
0000000000000000
[  353.072376] Call trace:
[  353.074811]  tb_disconnect_pci+0x98/0xa0 (P)
[  353.079071]  tb_domain_disapprove_switch+0x18/0x28
[  353.083853]  disapprove_switch+0x70/0xc0
[  353.087765]  authorized_store+0x114/0x1bc
[  353.091764]  dev_attr_store+0x14/0x24
[  353.095419]  sysfs_kf_write+0x4c/0x64
[  353.099073]  kernfs_fop_write_iter+0xb4/0x168
[  353.103419]  vfs_write+0x118/0x178
[  353.106811]  ksys_write+0x6c/0xd0
[  353.110116]  __arm64_sys_write+0x14/0x1c
[  353.114028]  invoke_syscall+0xa4/0x104
[  353.117766]  el0_svc_common.constprop.0+0xb0/0xcc
[  353.122458]  do_el0_svc+0x1c/0x24
[  353.125762]  el0_svc+0x12c/0x178
[  353.128981]  el0t_64_sync_handler+0x70/0x108
[  353.133241]  el0t_64_sync+0x154/0x158
[  353.136893] ---[ end trace 0000000000000000 ]---

> > 
> > [  545.887822] usb4_hi NVDA8100:00: 0:1: is unplugged (state: 7),
> > retrying...
> > [  545.998689] usb4_hi NVDA8100:00: 0:1: failed to reach state
> > TB_PORT_UP. Ignoring port...
> > [  546.006778] usb4_hi NVDA8100:00: 0:1: lost during suspend,
> > disconnecting
> > [  546.013474] usb4_hi NVDA8100:00: 0:4 <-> 1:16 (USB3):
> > deactivating
> > [  546.020449] usb4_hi NVDA8100:00: deactivating USB3 Down path
> > from 0:4 to 1:16
> > [  546.027959] usb4_hi NVDA8100:00: deactivating USB3 Up path from
> > 1:16 to 0:4
> > [  546.035649] usb4_hi NVDA8100:00: 0:7 <-> 1:9 (PCI): deactivating
> > [  546.042463] usb4_hi NVDA8100:00: deactivating PCIe Down path
> > from 0:7 to 1:9
> > [  546.050320] usb4_hi NVDA8100:00: deactivating PCIe Up path from
> > 1:9 to 0:7
> > [  546.057790] usb4_hi NVDA8100:00: 0: TMU: mode change off -> bi-
> > directional, HiFi requested
> > [  546.067910] usb4_hi NVDA8100:00: 0: TMU: mode set to: bi-
> > directional, HiFi
> > [  546.076120] usb4_hi NVDA8100:00: 0:1: total credits changed 66 -
> > > 66
> > [  546.082844] usb4_hi NVDA8100:00: 1: link width set to symmetric,
> > dual lanes
> > [  546.089815] ------------[ cut here ]------------
> > [  546.094420] WARNING: CPU: 7 PID: 2433 at
> > drivers/thunderbolt/tb.c:2245 tb_disconnect_pci+0x108/0x120
> > ...
> > [  546.238810] Call trace:
> > [  546.241246]  tb_disconnect_pci+0x108/0x120 (P)
> > [  546.245680]  tb_domain_disapprove_switch+0x24/0x60
> > [  546.250464]  disapprove_switch+0xbc/0xe8
> > [  546.254378]  authorized_store+0x19c/0x270
> > [  546.258378]  dev_attr_store+0x20/0x70
> > ...
> > [  546.303767] ---[ end trace 0000000000000000 ]---
> > 
> > The check prevents a redundant lookup and eliminates the warning
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> > v2: no changes
> > ---
> >  drivers/thunderbolt/switch.c | 5 +++++
> >  drivers/thunderbolt/tb.c     | 7 +++++++
> >  2 files changed, 12 insertions(+)
> > 
> > diff --git a/drivers/thunderbolt/switch.c
> > b/drivers/thunderbolt/switch.c
> > index e12546bfb869..6e9f439ebf3f 100644
> > --- a/drivers/thunderbolt/switch.c
> > +++ b/drivers/thunderbolt/switch.c
> > @@ -1850,6 +1850,11 @@ static int tb_switch_set_authorized(struct
> > tb_switch *sw, unsigned int val)
> >  	if (!!sw->authorized == !!val)
> >  		goto unlock;
> >  
> > +	if (sw->is_unplugged) {
> > +		ret = -ENODEV;
> > +		goto unlock;
> > +	}
> > +
> >  	switch (val) {
> >  	/* Disapprove switch */
> >  	case 0:
> > diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> > index 57c11ba13459..69310622d786 100644
> > --- a/drivers/thunderbolt/tb.c
> > +++ b/drivers/thunderbolt/tb.c
> > @@ -2266,6 +2266,10 @@ static int tb_disconnect_pci(struct tb *tb,
> > struct tb_switch *sw)
> >  	struct tb_tunnel *tunnel;
> >  	struct tb_port *up;
> >  
> > +	/* If the switch has already been unplugged, tunnels are
> > already freed */
> 
> router
> 
> everywhere
> 
> > +	if (sw->is_unplugged)
> > +		return 0;
> > +
> 
> Actually I'm thinking that we can just get rid of the WARN_ON()s
> instead.
> If the router is gone we cannot find the upstream port nor the tunnel
> and
> that's fine so just return error instead.
Make sense, I will drop the change for case-1, and modify the change
for case-2

Thanks
> 
> >  	up = tb_switch_find_port(sw, TB_TYPE_PCIE_UP);
> >  	if (WARN_ON(!up))
> >  		return -ENODEV;
> > @@ -2288,6 +2292,9 @@ static int tb_tunnel_pci(struct tb *tb,
> > struct tb_switch *sw)
> >  	struct tb_cm *tcm = tb_priv(tb);
> >  	struct tb_tunnel *tunnel;
> >  
> > +	if (sw->is_unplugged)
> > +		return -ENODEV;
> > +
> >  	up = tb_switch_find_port(sw, TB_TYPE_PCIE_UP);
> >  	if (!up)
> >  		return 0;
> > -- 
> > 2.45.2


      reply	other threads:[~2026-11-16  3:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 11:48 [PATCH 0/7] thunderbolt: Add support platform NHI driver Chunfeng Yun
2026-11-10 11:48 ` [PATCH v2 1/7] thunderbolt: Prefix NHI core functions with tb_ and tb_ring_ Chunfeng Yun
2026-11-10 12:42   ` Konrad Dybcio
2026-11-11  2:26     ` Chunfeng Yun (云春峰)
2026-11-10 11:48 ` [PATCH v2 2/7] thunderbolt: Move ICM mailbox functions to icm.c and internalize interrupt work Chunfeng Yun
2026-11-10 14:24   ` Mika Westerberg
2026-11-11  2:37     ` Chunfeng Yun (云春峰)
2026-11-10 11:48 ` [PATCH v2 3/7] thunderbolt: Make PCIe NHI support opt-in Chunfeng Yun
2026-11-10 11:48 ` [PATCH v2 4/7] thunderbolt: add platform NHI driver Chunfeng Yun
2026-11-10 12:43   ` Konrad Dybcio
2026-11-11 13:29     ` Chunfeng Yun (云春峰)
2026-11-10 14:37   ` Mika Westerberg
2026-11-10 11:48 ` [PATCH v2 5/7] thunderbolt: increase the lane adapter link-up timeout value Chunfeng Yun
2026-11-10 14:39   ` Mika Westerberg
2026-11-12  7:24     ` Chunfeng Yun (云春峰)
2026-11-10 11:48 ` [PATCH v2 6/7] thunderbolt: decouple the waiting time of TB_PORT_UNPLUGGED and TB_PORT_UP Chunfeng Yun
2026-11-10 14:40   ` Mika Westerberg
2026-11-12  8:00     ` Chunfeng Yun (云春峰)
2026-11-10 11:48 ` [PATCH v2 7/7] thunderbolt: prevent pcie tunnel activation/teardown warnings Chunfeng Yun
2026-11-10 14:50   ` Mika Westerberg
2026-11-16  3:17     ` Chunfeng Yun (云春峰) [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=af991da994391cea597cc953362d40b1cd6a6a5c.camel@mediatek.com \
    --to=chunfeng.yun@mediatek.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=sven@kernel.org \
    --cc=westeri@kernel.org \
    /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

all inboxes | Powered by JetHome®