* USB4 thunderbolt device suspend/resume problems. Unplug during suspend.
@ 2025-02-17 20:44 James Dutton
2025-03-13 20:45 ` Lukas Wunner
0 siblings, 1 reply; 4+ messages in thread
From: James Dutton @ 2025-02-17 20:44 UTC (permalink / raw)
To: Linux PM mailing list
Hi,
I have a thunderbolt / usb4 10Gbps ethernet adapter.
While plugged in, it appears to handle suspend and resume OK.
The problem is the following:
1) Thunderbolt device plugged in. Device appears in "lscpi".
2) Suspend Laptop
3) Unplug the device while it is asleep.
4) Resume the Laptop
5) Laptop locks up, no stack trace, nothing output.
Further diagnosis has found the following:
I locks up in:
drivers/base/power/main.c:
static void device_resume(struct device *dev, pm_message_t state, bool async)
at the line that says:
"device_lock(dev);"
where "dev" is the dev of the 10Gbps ethernet adapter.
I don't have any other usb4 / thunderbolt devices but I am thinking
that this might affect all usb4 / thunderbolt devices that appear in
lspci.
Essentially, it looks to the OS like a PCIe card is removed during suspend.
Does anyone have any hints of where in the code to look for a fix for this?
Kind Regards
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: USB4 thunderbolt device suspend/resume problems. Unplug during suspend.
2025-02-17 20:44 USB4 thunderbolt device suspend/resume problems. Unplug during suspend James Dutton
@ 2025-03-13 20:45 ` Lukas Wunner
2025-03-22 13:38 ` James Dutton
0 siblings, 1 reply; 4+ messages in thread
From: Lukas Wunner @ 2025-03-13 20:45 UTC (permalink / raw)
To: James Dutton; +Cc: Linux PM mailing list
On Mon, Feb 17, 2025 at 08:44:19PM +0000, James Dutton wrote:
> I have a thunderbolt / usb4 10Gbps ethernet adapter.
> While plugged in, it appears to handle suspend and resume OK.
> The problem is the following:
> 1) Thunderbolt device plugged in. Device appears in "lscpi".
> 2) Suspend Laptop
> 3) Unplug the device while it is asleep.
> 4) Resume the Laptop
> 5) Laptop locks up, no stack trace, nothing output.
There's a fix for a similar issue queued up for v6.15-rc1 in pci.git:
https://git.kernel.org/pci/pci/c/876d4518a87d
Does it help if you apply that small change?
It should get backported to v6.14 and v6.12 stable kernels once
v6.15-rc1 is tagged.
Thanks,
Lukas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: USB4 thunderbolt device suspend/resume problems. Unplug during suspend.
2025-03-13 20:45 ` Lukas Wunner
@ 2025-03-22 13:38 ` James Dutton
2025-04-25 16:22 ` Lukas Wunner
0 siblings, 1 reply; 4+ messages in thread
From: James Dutton @ 2025-03-22 13:38 UTC (permalink / raw)
To: Lukas Wunner; +Cc: Linux PM mailing list
On Thu, 13 Mar 2025 at 20:45, Lukas Wunner <lukas@wunner.de> wrote:
>
> On Mon, Feb 17, 2025 at 08:44:19PM +0000, James Dutton wrote:
> > I have a thunderbolt / usb4 10Gbps ethernet adapter.
> > While plugged in, it appears to handle suspend and resume OK.
> > The problem is the following:
> > 1) Thunderbolt device plugged in. Device appears in "lscpi".
> > 2) Suspend Laptop
> > 3) Unplug the device while it is asleep.
> > 4) Resume the Laptop
> > 5) Laptop locks up, no stack trace, nothing output.
>
> There's a fix for a similar issue queued up for v6.15-rc1 in pci.git:
>
> https://git.kernel.org/pci/pci/c/876d4518a87d
>
> Does it help if you apply that small change?
>
> It should get backported to v6.14 and v6.12 stable kernels once
> v6.15-rc1 is tagged.
>
Thank you Lukas.
I found something that worked for me.
I found an infinite loop and adding a timeout to it fixed my problem:
E.g.
diff --git a/net/core/dev.c b/net/core/dev.c
index 2b09714761c6..580f74db8631 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6832,6 +6832,7 @@ EXPORT_SYMBOL(netif_napi_add_weight);
void napi_disable(struct napi_struct *n)
{
unsigned long val, new;
+ u64 loop_counter = 0;
might_sleep();
set_bit(NAPI_STATE_DISABLE, &n->state);
@@ -6840,8 +6841,16 @@ void napi_disable(struct napi_struct *n)
do {
while (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
usleep_range(20, 200);
+ loop_counter++;
+ if (loop_counter > 625) {
+ break;
+ }
val = READ_ONCE(n->state);
}
+ if (loop_counter > 625) {
+ pr_warn("dev.c:napi_disable() timed out\n");
+ break;
+ }
new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC;
new &= ~(NAPIF_STATE_THREADED | NAPIF_STATE_PREFER_BUSY_POLL);
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: USB4 thunderbolt device suspend/resume problems. Unplug during suspend.
2025-03-22 13:38 ` James Dutton
@ 2025-04-25 16:22 ` Lukas Wunner
0 siblings, 0 replies; 4+ messages in thread
From: Lukas Wunner @ 2025-04-25 16:22 UTC (permalink / raw)
To: James Dutton; +Cc: Linux PM mailing list
On Sat, Mar 22, 2025 at 01:38:34PM +0000, James Dutton wrote:
> > On Mon, Feb 17, 2025 at 08:44:19PM +0000, James Dutton wrote:
> > > I have a thunderbolt / usb4 10Gbps ethernet adapter.
> > > While plugged in, it appears to handle suspend and resume OK.
> > > The problem is the following:
> > > 1) Thunderbolt device plugged in. Device appears in "lscpi".
> > > 2) Suspend Laptop
> > > 3) Unplug the device while it is asleep.
> > > 4) Resume the Laptop
> > > 5) Laptop locks up, no stack trace, nothing output.
>
> I found something that worked for me.
> I found an infinite loop and adding a timeout to it fixed my problem:
> E.g.
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -6840,8 +6841,16 @@ void napi_disable(struct napi_struct *n)
> do {
> while (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
> usleep_range(20, 200);
> + loop_counter++;
> + if (loop_counter > 625) {
> + break;
> + }
> val = READ_ONCE(n->state);
> }
> + if (loop_counter > 625) {
> + pr_warn("dev.c:napi_disable() timed out\n");
> + break;
> + }
>
> new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC;
> new &= ~(NAPIF_STATE_THREADED | NAPIF_STATE_PREFER_BUSY_POLL);
I'm afraid that's a hack, not a proper fix. You can insert a call
to "dump_stack();" before the "break;" to see where the call to
napi_disable() is coming from.
It seems the driver of the network adapter built into the dock
gets confused if the adapter is no longer present on resume.
It would be good if you could report this to the maintainers of that
driver and/or netdev maintainers, as well as netdev@vger.kernel.org.
Thanks,
Lukas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-25 16:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-17 20:44 USB4 thunderbolt device suspend/resume problems. Unplug during suspend James Dutton
2025-03-13 20:45 ` Lukas Wunner
2025-03-22 13:38 ` James Dutton
2025-04-25 16:22 ` Lukas Wunner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox