Skip to contentSkip to conversation

Wake on connect / wake on disconnect

PATCH Mario Limonciello 5 participants 13 messages Apr 3, 2025 – Apr 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Something like this:

drivers/thunderbolt/switch.c +1 -0
index 6a2116cbb06f..f2f6a085a742 100644
@@ -3599,6 +3599,7 @@ void tb_switch_suspend(struct tb_switch *sw, bool runtime)
 		flags |= TB_WAKE_ON_USB4;
 		flags |= TB_WAKE_ON_USB3 | TB_WAKE_ON_PCIE | TB_WAKE_ON_DP;
 	} else if (device_may_wakeup(&sw->dev)) {
+		flags |= TB_WAKE_ON_CONNECT;
 		flags |= TB_WAKE_ON_USB4 | TB_WAKE_ON_USB3 | TB_WAKE_ON_PCIE;
 	}
 

Thanks!

#1 lore raw

Hi Mario,

Quoted 10 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Don't we already have a similar for all usb4_portX devices? That does not work for you?

#2 lore raw
Quoted 9 lines · Mika Westerberg

Hi Mario,

Quoted 6 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Quoted 8 lines
Quoted 4 lines

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Don't we already have a similar for all usb4_portX devices? That does not work for you?

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a udev rule. Could we set the kernel default for those to 'enabled' instead?

#3 lore raw
Quoted 15 lines · Mario Limonciello
Quoted 14 lines · Mika Westerberg

Hi Mario,

Quoted 10 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Quoted 8 lines
Quoted 3 lines

Don't we already have a similar for all usb4_portX devices? That does not work for you?

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a udev rule. Could we set the kernel default for those to 'enabled' instead?

No because that would trigger wakeup each time you unplug/plug and this is certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is supported by the userspace then it can also enable these.

#4 lore raw
Quoted 22 lines · Mika Westerberg
Quoted 21 lines · Mario Limonciello
Quoted 9 lines · Mika Westerberg

Hi Mario,

Quoted 6 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Quoted 8 lines
Quoted 4 lines

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Don't we already have a similar for all usb4_portX devices? That does not work for you?

I think that will functionally work - but I'll double check.

Quoted 7 lines
Quoted 2 lines

However usb_portX power/wakeup defaults are 'disabled' so this would need a udev rule. Could we set the kernel default for those to 'enabled' instead?

No because that would trigger wakeup each time you unplug/plug and this is certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and wake on disconnect.

Is there actually a use case for chrome with wake on disconnect? IE if we didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

#5 lore raw
Quoted 31 lines · Mario Limonciello
Quoted 22 lines · Mika Westerberg
Quoted 21 lines · Mario Limonciello
Quoted 9 lines · Mika Westerberg

Hi Mario,

Quoted 6 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Quoted 8 lines
Quoted 4 lines

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Don't we already have a similar for all usb4_portX devices? That does not work for you?

I think that will functionally work - but I'll double check.

Quoted 7 lines
Quoted 2 lines

However usb_portX power/wakeup defaults are 'disabled' so this would need a udev rule. Could we set the kernel default for those to 'enabled' instead?

No because that would trigger wakeup each time you unplug/plug and this is certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is supported by the userspace then it can also enable these.

Quoted 7 lines

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and wake on disconnect.

Is there actually a use case for chrome with wake on disconnect? IE if we didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose their usecase is specifically that dark resume and I think that's when you unplug a device so disconnect. Not so sure about wake on connect.

#6 lore raw
Quoted 36 lines · Mika Westerberg
Quoted 35 lines · Mario Limonciello
Quoted 22 lines · Mika Westerberg
Quoted 21 lines · Mario Limonciello
Quoted 9 lines · Mika Westerberg

Hi Mario,

Quoted 6 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Quoted 8 lines
Quoted 4 lines

Wake on connect and disconnect are only used for runtime, not for system suspend. Would you be open to adding wake on connect as well for system suspend? This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Don't we already have a similar for all usb4_portX devices? That does not work for you?

I think that will functionally work - but I'll double check.

Quoted 7 lines
Quoted 2 lines

However usb_portX power/wakeup defaults are 'disabled' so this would need a udev rule. Could we set the kernel default for those to 'enabled' instead?

No because that would trigger wakeup each time you unplug/plug and this is certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and wake on disconnect.

Quoted 7 lines
Quoted 3 lines

Is there actually a use case for chrome with wake on disconnect? IE if we didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose their usecase is specifically that dark resume and I think that's when you unplug a device so disconnect. Not so sure about wake on connect.

I found the original patch from Rajat [1].

Rajat, any comments? Could you loop in the right people from the Chrome side to ask? I think my "preference" would be that we make "wake on connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/[email protected]/

#7 lore raw
Quoted 47 lines · Mario Limonciello
Quoted 36 lines · Mika Westerberg
Quoted 35 lines · Mario Limonciello
Quoted 22 lines · Mika Westerberg
Quoted 21 lines · Mario Limonciello
Quoted 9 lines · Mika Westerberg

Hi Mario,

Quoted 6 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/ disconnect happening and I wanted to get some background from you about the current policy set in tb_switch_suspend().

Quoted 8 lines
Quoted 4 lines

Wake on connect and disconnect are only used for runtime, not for system suspend.  Would you be open to adding wake on connect as well for system suspend?  This should help enable use cases like plugging in a closed laptop to a dock (which works on Windows).

Don't we already have a similar for all usb4_portX devices? That does not work for you?

I think that will functionally work - but I'll double check.

Quoted 7 lines
Quoted 2 lines

However usb_portX power/wakeup defaults are 'disabled' so this would need a udev rule.  Could we set the kernel default for those to 'enabled' instead?

No because that would trigger wakeup each time you unplug/plug and this is certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is supported by the userspace then it can also enable these.

Ahhh.  I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and wake on disconnect.

Quoted 7 lines
Quoted 3 lines

Is there actually a use case for chrome with wake on disconnect?  IE if we didn't turn on wake on disconnect but defaulted to wake on connect would things be OK?  Or made the sysfs knob control only wake on disconnect?

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose their usecase is specifically that dark resume and I think that's when you unplug a device so disconnect. Not so sure about wake on connect.

Quoted 5 lines

I found the original patch from Rajat [1].

Rajat, any comments?  Could you loop in the right people from the Chrome side to ask?    I think my "preference" would be that we make "wake on connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/20221101115042.248187-1- [email protected]/

Oh Rajat's email bounced. The only person I know that I've worked on wakeup related stuff is Raul. I'll add him.

Mika, Raul,

Could you pull in current Chrome people from Intel and Google that could comment here?

#8 lore raw
Quoted 75 lines · Mario Limonciello
Quoted 63 lines · Mario Limonciello
Quoted 52 lines · Mika Westerberg
Quoted 46 lines · Mario Limonciello
Quoted 33 lines · Mika Westerberg
Quoted 25 lines · Mario Limonciello
Quoted 19 lines · Mika Westerberg

Hi Mario,

Quoted 8 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/ disconnect
happening and I wanted to get some background from you about the current
policy set in tb_switch_suspend().

Quoted 7 lines

Wake on connect and disconnect are only used for runtime, not for system
suspend. Would you be open to adding wake on connect as well for system
suspend? This should help enable use cases like plugging in a closed laptop
to a dock (which works on Windows).

Quoted 4 lines

Don't we already have a similar for all usb4_portX devices? That does not
work for you?

Quoted 6 lines

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a
udev rule. Could we set the kernel default for those to 'enabled' instead?

Quoted 6 lines

No because that would trigger wakeup each time you unplug/plug and this is
certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is
supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and
wake on disconnect.

Quoted 4 lines

Is there actually a use case for chrome with wake on disconnect? IE if we
didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Quoted 5 lines

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose
their usecase is specifically that dark resume and I think that's when you
unplug a device so disconnect. Not so sure about wake on connect.

I found the original patch from Rajat [1].

Quoted 7 lines

Rajat, any comments? Could you loop in the right people from the Chrome
side to ask? I think my "preference" would be that we make "wake on
connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/20221101115042.248187-1-
[email protected]/

Quoted 7 lines

Oh Rajat's email bounced. The only person I know that I've worked on wakeup related stuff is Raul. I'll add him.

Mika, Raul,

Could you pull in current Chrome people from Intel and Google that could comment here?

+ Opal who should be able to answer the question regarding wake on connect/disconnect.

#9 lore raw
Quoted 79 lines · Raul Rangel
Quoted 78 lines · Mario Limonciello
Quoted 63 lines · Mario Limonciello
Quoted 52 lines · Mika Westerberg
Quoted 46 lines · Mario Limonciello
Quoted 33 lines · Mika Westerberg
Quoted 25 lines · Mario Limonciello
Quoted 19 lines · Mika Westerberg

Hi Mario,

Quoted 8 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/ disconnect
happening and I wanted to get some background from you about the current
policy set in tb_switch_suspend().

Quoted 7 lines

Wake on connect and disconnect are only used for runtime, not for system
suspend. Would you be open to adding wake on connect as well for system
suspend? This should help enable use cases like plugging in a closed laptop
to a dock (which works on Windows).

Quoted 4 lines

Don't we already have a similar for all usb4_portX devices? That does not
work for you?

Quoted 6 lines

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a
udev rule. Could we set the kernel default for those to 'enabled' instead?

Quoted 6 lines

No because that would trigger wakeup each time you unplug/plug and this is
certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is
supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and
wake on disconnect.

Quoted 4 lines

Is there actually a use case for chrome with wake on disconnect? IE if we
didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Quoted 5 lines

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose
their usecase is specifically that dark resume and I think that's when you
unplug a device so disconnect. Not so sure about wake on connect.

I found the original patch from Rajat [1].

Quoted 7 lines

Rajat, any comments? Could you loop in the right people from the Chrome
side to ask? I think my "preference" would be that we make "wake on
connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/20221101115042.248187-1-
[email protected]/

Oh Rajat's email bounced. The only person I know that I've worked on wakeup related stuff is Raul. I'll add him.

Quoted 7 lines
Quoted 4 lines

Mika, Raul,

Could you pull in current Chrome people from Intel and Google that could comment here?

+ Opal who should be able to answer the question regarding wake on connect/disconnect.

Added Utkarsh from Intel side.

#10 lore raw
Quoted 82 lines · Mika Westerberg
Quoted 81 lines · Raul Rangel
Quoted 80 lines · Mario Limonciello
Quoted 63 lines · Mario Limonciello
Quoted 52 lines · Mika Westerberg
Quoted 46 lines · Mario Limonciello
Quoted 33 lines · Mika Westerberg
Quoted 25 lines · Mario Limonciello
Quoted 19 lines · Mika Westerberg

Hi Mario,

Quoted 8 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/ disconnect
happening and I wanted to get some background from you about the current
policy set in tb_switch_suspend().

Quoted 7 lines

Wake on connect and disconnect are only used for runtime, not for system
suspend. Would you be open to adding wake on connect as well for system
suspend? This should help enable use cases like plugging in a closed laptop
to a dock (which works on Windows).

Quoted 4 lines

Don't we already have a similar for all usb4_portX devices? That does not
work for you?

Quoted 6 lines

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a
udev rule. Could we set the kernel default for those to 'enabled' instead?

Quoted 6 lines

No because that would trigger wakeup each time you unplug/plug and this is
certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is
supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and
wake on disconnect.

Quoted 4 lines

Is there actually a use case for chrome with wake on disconnect? IE if we
didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Quoted 5 lines

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose
their usecase is specifically that dark resume and I think that's when you
unplug a device so disconnect. Not so sure about wake on connect.

I found the original patch from Rajat [1].

Quoted 7 lines

Rajat, any comments? Could you loop in the right people from the Chrome
side to ask? I think my "preference" would be that we make "wake on
connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/20221101115042.248187-1-
[email protected]/

Oh Rajat's email bounced. The only person I know that I've worked on wakeup related stuff is Raul. I'll add him.

Mika, Raul,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Could you pull in current Chrome people from Intel and Google that could comment here?

+ Opal who should be able to answer the question regarding wake on connect/disconnect.

Added Utkarsh from Intel side.

I had another look at usb4_port.c the flows used. This is the call path:

tb_switch_suspend()
->tb_switch_set_wake()
->->usb4_switch_set_wake()

The flags for wakeup policy are set in tb_switch_suspend() and then passed as arguments down to usb4_switch_set_wake(). This enumerates whether wake is set for any usb4_port device and applies the flags to that device.

So AFAICT that means that even on ChromeOS there won't be a wake on connect or wake on disconnect event for suspend/resume no matter what the sysfs files for each port are set to.

In summary; my ask is whether we can do this:

drivers/thunderbolt/switch.c +1 -0
index 6a2116cbb06f9..f2f6a085a742b 100644
@@ -3599,6 +3599,7 @@ void tb_switch_suspend(struct tb_switch *sw, bool runtime)
                flags |= TB_WAKE_ON_USB4;
                flags |= TB_WAKE_ON_USB3 | TB_WAKE_ON_PCIE | TB_WAKE_ON_DP;
        } else if (device_may_wakeup(&sw->dev)) {
+               flags |= TB_WAKE_ON_CONNECT;
                flags |= TB_WAKE_ON_USB4 | TB_WAKE_ON_USB3 | 
TB_WAKE_ON_PCIE;
        }

That would allow the use case of "plug in a closed laptop to a dock" and it wakes up.

#11 lore raw
Quoted 123 lines · Mario Limonciello
Quoted 82 lines · Mika Westerberg
Quoted 81 lines · Raul Rangel
Quoted 80 lines · Mario Limonciello
Quoted 63 lines · Mario Limonciello
Quoted 52 lines · Mika Westerberg
Quoted 46 lines · Mario Limonciello
Quoted 33 lines · Mika Westerberg
Quoted 25 lines · Mario Limonciello
Quoted 19 lines · Mika Westerberg

Hi Mario,

Quoted 8 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/ disconnect
happening and I wanted to get some background from you about the current
policy set in tb_switch_suspend().

Quoted 7 lines

Wake on connect and disconnect are only used for runtime, not for system
suspend. Would you be open to adding wake on connect as well for system
suspend? This should help enable use cases like plugging in a closed laptop
to a dock (which works on Windows).

Quoted 4 lines

Don't we already have a similar for all usb4_portX devices? That does not
work for you?

Quoted 6 lines

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a
udev rule. Could we set the kernel default for those to 'enabled' instead?

Quoted 6 lines

No because that would trigger wakeup each time you unplug/plug and this is
certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is
supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and
wake on disconnect.

Quoted 4 lines

Is there actually a use case for chrome with wake on disconnect? IE if we
didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Quoted 5 lines

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose
their usecase is specifically that dark resume and I think that's when you
unplug a device so disconnect. Not so sure about wake on connect.

I found the original patch from Rajat [1].

Quoted 7 lines

Rajat, any comments? Could you loop in the right people from the Chrome
side to ask? I think my "preference" would be that we make "wake on
connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/20221101115042.248187-1-
[email protected]/

Oh Rajat's email bounced. The only person I know that I've worked on wakeup related stuff is Raul. I'll add him.

Mika, Raul,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Could you pull in current Chrome people from Intel and Google that could comment here?

+ Opal who should be able to answer the question regarding wake on connect/disconnect.

Added Utkarsh from Intel side.

I had another look at usb4_port.c the flows used. This is the call path:

tb_switch_suspend()
->tb_switch_set_wake()
->->usb4_switch_set_wake()

The flags for wakeup policy are set in tb_switch_suspend() and then passed as arguments down to usb4_switch_set_wake(). This enumerates whether wake is set for any usb4_port device and applies the flags to that device.

So AFAICT that means that even on ChromeOS there won't be a wake on connect or wake on disconnect event for suspend/resume no matter what the sysfs files for each port are set to.

In summary; my ask is whether we can do this:

drivers/thunderbolt/switch.c +1 -0
index 6a2116cbb06f9..f2f6a085a742b 100644
@@ -3599,6 +3599,7 @@ void tb_switch_suspend(struct tb_switch *sw, bool
 runtime)
                 flags |= TB_WAKE_ON_USB4;
                 flags |= TB_WAKE_ON_USB3 | TB_WAKE_ON_PCIE | TB_WAKE_ON_DP;
         } else if (device_may_wakeup(&sw->dev)) {
+               flags |= TB_WAKE_ON_CONNECT;
                 flags |= TB_WAKE_ON_USB4 | TB_WAKE_ON_USB3 |
 TB_WAKE_ON_PCIE;
         }
Quoted 2 lines

That would allow the use case of "plug in a closed laptop to a dock" and it wakes up.

+ Subrata since they might have more context on the TB stack.

#12 lore raw
In reply to Mario Limonciello
Quoted 93 lines · Mario Limonciello
Quoted 82 lines · Mika Westerberg
Quoted 81 lines · Raul Rangel
Quoted 80 lines · Mario Limonciello
Quoted 63 lines · Mario Limonciello
Quoted 52 lines · Mika Westerberg
Quoted 46 lines · Mario Limonciello
Quoted 33 lines · Mika Westerberg
Quoted 25 lines · Mario Limonciello
Quoted 19 lines · Mika Westerberg

Hi Mario,

Quoted 8 lines · Mario Limonciello

Mika,

Recently there are some conversations about wake-up from connect/ disconnect
happening and I wanted to get some background from you about the current
policy set in tb_switch_suspend().

Quoted 7 lines

Wake on connect and disconnect are only used for runtime, not for system
suspend. Would you be open to adding wake on connect as well for system
suspend? This should help enable use cases like plugging in a closed laptop
to a dock (which works on Windows).

Quoted 4 lines

Don't we already have a similar for all usb4_portX devices? That does not
work for you?

Quoted 6 lines

I think that will functionally work - but I'll double check.

However usb_portX power/wakeup defaults are 'disabled' so this would need a
udev rule. Could we set the kernel default for those to 'enabled' instead?

Quoted 6 lines

No because that would trigger wakeup each time you unplug/plug and this is
certainly not good if you close the lid, unplug from dock and throw the laptop to your backpack. Chrome uses this with "dark resume" so if this is
supported by the userspace then it can also enable these.

Ahhh. I was thinking specifically with wake on connect that's not a problem, but the sysfs knob for the port changes both wake on connect and
wake on disconnect.

Quoted 4 lines

Is there actually a use case for chrome with wake on disconnect? IE if we
didn't turn on wake on disconnect but defaulted to wake on connect would things be OK? Or made the sysfs knob control only wake on disconnect?

Quoted 5 lines

Good guestion - I don't know ;-) The Chrome folks wanted this so I suppose
their usecase is specifically that dark resume and I think that's when you
unplug a device so disconnect. Not so sure about wake on connect.

I found the original patch from Rajat [1].

Quoted 7 lines

Rajat, any comments? Could you loop in the right people from the Chrome
side to ask? I think my "preference" would be that we make "wake on
connect" always enabled and then let the sysfs knob control "wake on disconnect".

[1] https://lore.kernel.org/linux-usb/20221101115042.248187-1-
[email protected]/

Oh Rajat's email bounced. The only person I know that I've worked on wakeup related stuff is Raul. I'll add him.

Mika, Raul,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Could you pull in current Chrome people from Intel and Google that could comment here?

+ Opal who should be able to answer the question regarding wake on connect/disconnect.

Added Utkarsh from Intel side.

I had another look at usb4_port.c the flows used. This is the call path:

Quoted 7 lines

tb_switch_suspend()
->tb_switch_set_wake()
->->usb4_switch_set_wake()

The flags for wakeup policy are set in tb_switch_suspend() and then passed as arguments down to usb4_switch_set_wake(). This enumerates whether wake is set for any usb4_port device and applies the flags to that device.

Indeed. So this actually never worked.

Quoted 20 lines

So AFAICT that means that even on ChromeOS there won't be a wake on connect or wake on disconnect event for suspend/resume no matter what the sysfs files for each port are set to.

In summary; my ask is whether we can do this:

drivers/thunderbolt/switch.c +1 -0
index 6a2116cbb06f9..f2f6a085a742b 100644
@@ -3599,6 +3599,7 @@ void tb_switch_suspend(struct tb_switch *sw, bool
 runtime)
                flags |= TB_WAKE_ON_USB4;
                flags |= TB_WAKE_ON_USB3 | TB_WAKE_ON_PCIE | TB_WAKE_ON_DP;
        } else if (device_may_wakeup(&sw->dev)) {
+               flags |= TB_WAKE_ON_CONNECT;
                flags |= TB_WAKE_ON_USB4 | TB_WAKE_ON_USB3 |
 TB_WAKE_ON_PCIE;
        }
Quoted 2 lines

That would allow the use case of "plug in a closed laptop to a dock" and it wakes up.

I think we should set both here. Someone will want the unplug to behave the same and at that point it is hard to change anymore to avoid breaking things. Then it is up to the userspace to enable per USB4 port, and deal with (e.g dark resume).