[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240106165723.3377789-5-Sanath.S@amd.com>
Date: Sat, 6 Jan 2024 22:27:23 +0530
From: Sanath S <Sanath.S@....com>
To: <mario.limonciello@....com>, <andreas.noever@...il.com>,
<michael.jamet@...el.com>, <mika.westerberg@...ux.intel.com>,
<YehezkelShB@...il.com>, <linux-usb@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: Sanath S <Sanath.S@....com>
Subject: [Patch v3 4/4] thunderbolt: Teardown tunnels and reset downstream ports created by boot firmware
Boot firmware might have created tunnels of its own. Since we cannot
be sure they are usable for us. Tear them down and reset the ports
to handle it as a new hotplug for USB4 v1 routers.
Suggested-by: Mario Limonciello <mario.limonciello@....com>
Signed-off-by: Sanath S <Sanath.S@....com>
---
drivers/thunderbolt/tb.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 740bf2ff1fcd..462616e3075c 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -2596,12 +2596,27 @@ static int tb_start(struct tb *tb, bool reset)
tb_switch_tmu_configure(tb->root_switch, TB_SWITCH_TMU_MODE_LOWRES);
/* Enable TMU if it is off */
tb_switch_tmu_enable(tb->root_switch);
- /* Full scan to discover devices added before the driver was loaded. */
- tb_scan_switch(tb->root_switch);
- /* Find out tunnels created by the boot firmware */
- tb_discover_tunnels(tb);
- /* Add DP resources from the DP tunnels created by the boot firmware */
- tb_discover_dp_resources(tb);
+
+ /*
+ * Boot firmware might have created tunnels of its own. Since we cannot
+ * be sure they are usable for us, Tear them down and reset the ports
+ * to handle it as new hotplug for USB4 routers.
+ */
+ if (reset && usb4_switch_version(tb->root_switch) == 1) {
+ ret = tb_switch_reset(tb->root_switch);
+ if (ret) {
+ tb_sw_warn(tb->root_switch, "failed to reset\n");
+ return ret;
+ }
+ } else {
+ /* Full scan to discover devices added before the driver was loaded. */
+ tb_scan_switch(tb->root_switch);
+ /* Find out tunnels created by the boot firmware */
+ tb_discover_tunnels(tb);
+ /* Add DP resources from the DP tunnels created by the boot firmware */
+ tb_discover_dp_resources(tb);
+ }
+
/*
* If the boot firmware did not create USB 3.x tunnels create them
* now for the whole topology.
--
2.34.1
Powered by blists - more mailing lists