Skip to contentSkip to conversation

thunderbolt: Retain host router DP IN resources during suspend

PATCH In review Sanjay R Mehta 3 participants 5 messages Feb 18, 2022 – Feb 20, 2022

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

PATCH 1/1 thunderbolt: Retain host router DP IN resources during suspend

From: Sanjay R Mehta <[email protected]>

All DP resources are released during suspend and while resuming back DP IN resource is not available, therefore unable to find DP pair to re-establish the DP tunnel.

Hence preserve host routers DP IN resources and release all other DP resources during suspend.

---
 drivers/thunderbolt/tb.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thunderbolt/tb.c +5 -5
index cbd0ad8..a11710e 100644
@@ -1022,6 +1022,7 @@ static void tb_disconnect_and_release_dp(struct tb *tb)
 {
 	struct tb_cm *tcm = tb_priv(tb);
 	struct tb_tunnel *tunnel, *n;
+	struct tb_port *port, *tmp;
 
 	/*
 	 * Tear down all DP tunnels and release their resources. They
@@ -1032,11 +1033,10 @@ static void tb_disconnect_and_release_dp(struct tb *tb)
 			tb_deactivate_and_free_tunnel(tunnel);
 	}
 
-	while (!list_empty(&tcm->dp_resources)) {
-		struct tb_port *port;
-
-		port = list_first_entry(&tcm->dp_resources,
-					struct tb_port, list);
+	list_for_each_entry_safe(port, tmp, &tcm->dp_resources, list) {
+		/* Preserve root switch DP IN resource */
+		if (!tb_route(port->sw) && tb_port_is_dpin(port))
+			continue;
 		list_del_init(&port->list);
 	}
 }
Signature · 1 line
2.7.4
#1 lore raw

Hi Sanjay,

Quoted 5 lines · Sanjay R Mehta

From: Sanjay R Mehta <[email protected]>

All DP resources are released during suspend and while resuming back DP IN resource is not available, therefore unable to find DP pair to re-establish the DP tunnel.

It should get plug event for the DP IN adapters once the router comes back from sleep. Is that not happening here?

#2 lore raw
Quoted 11 lines · Mika Westerberg

Hi Sanjay,

Quoted 5 lines · Sanjay R Mehta

From: Sanjay R Mehta <[email protected]>

All DP resources are released during suspend and while resuming back DP IN resource is not available, therefore unable to find DP pair to re-establish the DP tunnel.

It should get plug event for the DP IN adapters once the router comes back from sleep. Is that not happening here?

Yes, plug event is not happening for the DP IN adapter after resume.

The DP In resources are put into tcm->dp_resources list as part of host router enumeration. But when it resumes from sleep, there is no plug event happening for DP IN, hence DP IN resource will not be in tcm->dp_resources list.

Quoted 1 line
#3 lore raw
Quoted 15 lines · Sanjay R Mehta
Quoted 11 lines · Mika Westerberg

Hi Sanjay,

Quoted 5 lines · Sanjay R Mehta

From: Sanjay R Mehta <[email protected]>

All DP resources are released during suspend and while resuming back DP IN resource is not available, therefore unable to find DP pair to re-establish the DP tunnel.

It should get plug event for the DP IN adapters once the router comes back from sleep. Is that not happening here?

Quoted 6 lines

Yes, plug event is not happening for the DP IN adapter after resume.

The DP In resources are put into tcm->dp_resources list as part of host router enumeration. But when it resumes from sleep, there is no plug event happening for DP IN, hence DP IN resource will not be in tcm->dp_resources list.

Right but if I understand the spec correctly you should get a new hotplug event for the DP IN adapters once the host router is moved back to "enumerated" state. This is how Intel hardware works at least (and this is the understanding I have from the USB4 spec too). Do you see anything in the log wrt. this when you resume the domain?

#4 lore raw
Quoted 23 lines · Mika Westerberg
Quoted 15 lines · Sanjay R Mehta
Quoted 11 lines · Mika Westerberg

Hi Sanjay,

Quoted 5 lines · Sanjay R Mehta

From: Sanjay R Mehta <[email protected]>

All DP resources are released during suspend and while resuming back DP IN resource is not available, therefore unable to find DP pair to re-establish the DP tunnel.

It should get plug event for the DP IN adapters once the router comes back from sleep. Is that not happening here?

Quoted 6 lines

Yes, plug event is not happening for the DP IN adapter after resume.

The DP In resources are put into tcm->dp_resources list as part of host router enumeration. But when it resumes from sleep, there is no plug event happening for DP IN, hence DP IN resource will not be in tcm->dp_resources list.

Quoted 5 lines

Right but if I understand the spec correctly you should get a new hotplug event for the DP IN adapters once the host router is moved back to "enumerated" state. This is how Intel hardware works at least (and this is the understanding I have from the USB4 spec too). Do you see anything in the log wrt. this when you resume the domain?

Thanks Mika. I'll re-look at this scenario on our system and will check if anything needs to be taken care of.

Thank you for the valuable input :).

Quoted 1 line