All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] thunderbolt: Fix wake configurations after device unplug
@ 2024-04-08 12:48 Mika Westerberg
  2024-04-08 12:48 ` [PATCH 2/2] thunderbolt: Avoid notify PM core about runtime PM resume Mika Westerberg
  2024-04-10  7:53 ` [PATCH 1/2] thunderbolt: Fix wake configurations after device unplug Mika Westerberg
  0 siblings, 2 replies; 3+ messages in thread
From: Mika Westerberg @ 2024-04-08 12:48 UTC (permalink / raw)
  To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
  Cc: Gil Fine, linux-usb, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

Currently we don't configure correctly the wake events after unplug of device
router. What can happen is that the downstream ports of host router will be
configured to wake on: USB4-wake and wake-on-disconnect, but not on
wake-on-connect. This may cause the later plugged device not to wake the
domain and fail in enumeration. Fix this by clearing downstream port's "USB4
Port is Configured" bit, after unplug of a device router.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/switch.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 6ffc4e81ffed..4edfd6e34e31 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -3180,22 +3180,29 @@ void tb_switch_unconfigure_link(struct tb_switch *sw)
 {
 	struct tb_port *up, *down;
 
-	if (sw->is_unplugged)
-		return;
 	if (!tb_route(sw) || tb_switch_is_icm(sw))
 		return;
 
+	/*
+	 * Unconfigure downstream port so that wake-on-connect can be
+	 * configured after router unplug. No need to unconfigure upstream port
+	 * since its router is unplugged.
+	 */
 	up = tb_upstream_port(sw);
-	if (tb_switch_is_usb4(up->sw))
-		usb4_port_unconfigure(up);
-	else
-		tb_lc_unconfigure_port(up);
-
 	down = up->remote;
 	if (tb_switch_is_usb4(down->sw))
 		usb4_port_unconfigure(down);
 	else
 		tb_lc_unconfigure_port(down);
+
+	if (sw->is_unplugged)
+		return;
+
+	up = tb_upstream_port(sw);
+	if (tb_switch_is_usb4(up->sw))
+		usb4_port_unconfigure(up);
+	else
+		tb_lc_unconfigure_port(up);
 }
 
 static void tb_switch_credits_init(struct tb_switch *sw)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-10  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-08 12:48 [PATCH 1/2] thunderbolt: Fix wake configurations after device unplug Mika Westerberg
2024-04-08 12:48 ` [PATCH 2/2] thunderbolt: Avoid notify PM core about runtime PM resume Mika Westerberg
2024-04-10  7:53 ` [PATCH 1/2] thunderbolt: Fix wake configurations after device unplug Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.