Linux USB
 help / color / mirror / Atom feed
* [PATCH Internal] thunderbolt: Remove enabling/disabling TMU based on CLx
@ 2023-06-21 10:37 Sanjay R Mehta
  2023-06-21 10:52 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Sanjay R Mehta @ 2023-06-21 10:37 UTC (permalink / raw)
  To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
  Cc: linux-usb, Sanath S, Sanjay R Mehta

From: Sanath S <Sanath.S@amd.com>

Since TMU is enabled by default on Intel SOCs for USB4 before Alpine
Ridge, explicit enabling or disabling of TMU is not required.

However, the current implementation of enabling or disabling TMU based
on CLx state is inadequate as not all SOCs with CLx disabled have TMU
enabled by default, such as AMD Yellow Carp and Pink Sardine.

To address this, a quirk named "QUIRK_TMU_DEFAULT_ENABLED" is
implemented to skip the enabling or disabling of TMU for SOCs where it
is already enabled by default, such as Intel SOCs prior to Alpine Ridge.

Fixes: 7af9da8ce8f9 ("thunderbolt: Add quirk to disable CLx")
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Sanath S <Sanath.S@amd.com>
---
 drivers/thunderbolt/tb.c  | 4 ++++
 drivers/thunderbolt/tb.h  | 2 ++
 drivers/thunderbolt/tmu.c | 6 ++++++
 3 files changed, 12 insertions(+)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index aa6e11589c28..5fa9fbf095d2 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -923,6 +923,10 @@ static void tb_scan_port(struct tb_port *port)
 	tb_switch_lane_bonding_enable(sw);
 	/* Set the link configured */
 	tb_switch_configure_link(sw);
+	/* On Alpine Ridge and earlier Platforms, the TMU mode is enabled by default */
+	if (sw->generation < 4 || tb_switch_is_tiger_lake(sw))
+		sw->quirks |= QUIRK_TMU_DEFAULT_ENABLED;
+
 	/*
 	 * CL0s and CL1 are enabled and supported together.
 	 * Silently ignore CLx enabling in case CLx is not supported.
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 58df106aaa5e..9252d3875c08 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -27,6 +27,8 @@
 #define QUIRK_FORCE_POWER_LINK_CONTROLLER		BIT(0)
 /* Disable CLx if not supported */
 #define QUIRK_NO_CLX					BIT(1)
+/* TMU enabled by default */
+#define QUIRK_TMU_DEFAULT_ENABLED			BIT(2)
 
 /**
  * struct tb_nvm - Structure holding NVM information
diff --git a/drivers/thunderbolt/tmu.c b/drivers/thunderbolt/tmu.c
index c926fb71c43d..8e38ab5aae15 100644
--- a/drivers/thunderbolt/tmu.c
+++ b/drivers/thunderbolt/tmu.c
@@ -387,6 +387,9 @@ int tb_switch_tmu_disable(struct tb_switch *sw)
 	if (sw->tmu.rate == TB_SWITCH_TMU_RATE_OFF)
 		return 0;
 
+	if (sw->quirks & QUIRK_TMU_DEFAULT_ENABLED)
+ 		return 0;
+
 	if (tb_route(sw)) {
 		bool unidirectional = sw->tmu.unidirectional;
 		struct tb_port *down, *up;
@@ -643,6 +646,9 @@ int tb_switch_tmu_enable(struct tb_switch *sw)
 	if (tb_switch_tmu_is_enabled(sw))
 		return 0;
 
+	if (sw->quirks & QUIRK_TMU_DEFAULT_ENABLED)
+ 		return 0;
+
 	if (tb_switch_is_titan_ridge(sw) && unidirectional) {
 		ret = tb_switch_tmu_disable_objections(sw);
 		if (ret)
-- 
2.34.1


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

end of thread, other threads:[~2023-07-31  9:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 10:37 [PATCH Internal] thunderbolt: Remove enabling/disabling TMU based on CLx Sanjay R Mehta
2023-06-21 10:52 ` Greg KH
2023-06-21 10:52 ` Greg KH
2023-06-21 10:57   ` Sanjay R Mehta
2023-06-21 11:15 ` Mika Westerberg
2023-06-21 12:18   ` Sanjay R Mehta
2023-06-21 12:54     ` Mika Westerberg
2023-06-21 16:07       ` Sanjay R Mehta
2023-06-22  4:45         ` Mika Westerberg
2023-07-06 13:48         ` Sanjay R Mehta
2023-07-31  9:41           ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox