* [PATCH 00/11] Improvements and Lunar Lake support
@ 2023-12-04 10:38 Mika Westerberg
2023-12-04 10:38 ` [PATCH 01/11] thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails Mika Westerberg
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
Hi all,
This series adds improvements around USB4 v2 support, PCIe tunneling,
some minor fixes and also adds Intel Lunar Lake support.
Gil Fine (7):
thunderbolt: Handle lane bonding of Gen 4 XDomain links properly
thunderbolt: Move width_name() helper to tb.h
thunderbolt: Log XDomain link speed and width
thunderbolt: Transition link to asymmetric only when both sides support it
thunderbolt: Improve logging when DisplayPort resource is added due to hotplug
thunderbolt: Make PCIe tunnel setup and teardown follow CM guide
thunderbolt: Disable PCIe extended encapsulation upon teardown properly
Mika Westerberg (4):
thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails
thunderbolt: Disable CL states only when actually needed
thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well
thunderbolt: Add support for Intel Lunar Lake
drivers/thunderbolt/nhi.c | 4 +++
drivers/thunderbolt/nhi.h | 2 ++
drivers/thunderbolt/switch.c | 20 ++-----------
drivers/thunderbolt/tb.c | 46 ++++++++++++++++++-----------
drivers/thunderbolt/tb.h | 16 +++++++++++
drivers/thunderbolt/tmu.c | 2 +-
drivers/thunderbolt/tunnel.c | 44 ++++++++++++++++++++--------
drivers/thunderbolt/xdomain.c | 54 ++++++++++++++++++++++++++++++++++-
8 files changed, 139 insertions(+), 49 deletions(-)
--
2.42.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 01/11] thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 02/11] thunderbolt: Handle lane bonding of Gen 4 XDomain links properly Mika Westerberg
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
Dan reported that the kernel test robot found an issue with the TMU code
namely in tb_switch_tmu_change_mode() where we should actually go back
to the previous mode in case of failure instead of just returning back
the error. Fix this by unwinding the configuration as we do with the
other error paths in this function.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202311030814.AXtCk7PO-lkp@intel.com/
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/tmu.c b/drivers/thunderbolt/tmu.c
index 11f2aec2a5d3..9a259c72e5a7 100644
--- a/drivers/thunderbolt/tmu.c
+++ b/drivers/thunderbolt/tmu.c
@@ -894,7 +894,7 @@ static int tb_switch_tmu_change_mode(struct tb_switch *sw)
ret = tb_switch_set_tmu_mode_params(sw, sw->tmu.mode_request);
if (ret)
- return ret;
+ goto out;
/* Program the new mode and the downstream router lane adapter */
switch (sw->tmu.mode_request) {
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 02/11] thunderbolt: Handle lane bonding of Gen 4 XDomain links properly
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
2023-12-04 10:38 ` [PATCH 01/11] thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 03/11] thunderbolt: Move width_name() helper to tb.h Mika Westerberg
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
Gen 4 links come up as bonded already so we are not supposed to initiate
lane bonding on them. However, we should still update the port
structures accordingly. Split these into their own functions to make it
easier to follow.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tb.c | 2 --
drivers/thunderbolt/xdomain.c | 49 ++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index fd49f86e0353..3dabc1ac9ab3 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -513,8 +513,6 @@ static void tb_port_unconfigure_xdomain(struct tb_port *port)
usb4_port_unconfigure_xdomain(port);
else
tb_lc_unconfigure_xdomain(port);
-
- tb_port_enable(port->dual_link_port);
}
static void tb_scan_xdomain(struct tb_port *port)
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index 9803f0bbf20d..0a885ee5788d 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -1895,6 +1895,50 @@ struct device_type tb_xdomain_type = {
};
EXPORT_SYMBOL_GPL(tb_xdomain_type);
+static void tb_xdomain_link_init(struct tb_xdomain *xd, struct tb_port *down)
+{
+ if (!down->dual_link_port)
+ return;
+
+ /*
+ * Gen 4 links come up already as bonded so only update the port
+ * structures here.
+ */
+ if (tb_port_get_link_generation(down) >= 4) {
+ down->bonded = true;
+ down->dual_link_port->bonded = true;
+ } else {
+ xd->bonding_possible = true;
+ }
+}
+
+static void tb_xdomain_link_exit(struct tb_xdomain *xd)
+{
+ struct tb_port *down = tb_xdomain_downstream_port(xd);
+
+ if (!down->dual_link_port)
+ return;
+
+ if (tb_port_get_link_generation(down) >= 4) {
+ down->bonded = false;
+ down->dual_link_port->bonded = false;
+ } else if (xd->link_width > TB_LINK_WIDTH_SINGLE) {
+ /*
+ * Just return port structures back to way they were and
+ * update credits. No need to update userspace because
+ * the XDomain is removed soon anyway.
+ */
+ tb_port_lane_bonding_disable(down);
+ tb_port_update_credits(down);
+ } else if (down->dual_link_port) {
+ /*
+ * Re-enable the lane 1 adapter we disabled at the end
+ * of tb_xdomain_get_properties().
+ */
+ tb_port_enable(down->dual_link_port);
+ }
+}
+
/**
* tb_xdomain_alloc() - Allocate new XDomain object
* @tb: Domain where the XDomain belongs
@@ -1945,7 +1989,8 @@ struct tb_xdomain *tb_xdomain_alloc(struct tb *tb, struct device *parent,
goto err_free_local_uuid;
} else {
xd->needs_uuid = true;
- xd->bonding_possible = !!down->dual_link_port;
+
+ tb_xdomain_link_init(xd, down);
}
device_initialize(&xd->dev);
@@ -2014,6 +2059,8 @@ void tb_xdomain_remove(struct tb_xdomain *xd)
device_for_each_child_reverse(&xd->dev, xd, unregister_service);
+ tb_xdomain_link_exit(xd);
+
/*
* Undo runtime PM here explicitly because it is possible that
* the XDomain was never added to the bus and thus device_del()
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 03/11] thunderbolt: Move width_name() helper to tb.h
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
2023-12-04 10:38 ` [PATCH 01/11] thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails Mika Westerberg
2023-12-04 10:38 ` [PATCH 02/11] thunderbolt: Handle lane bonding of Gen 4 XDomain links properly Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 04/11] thunderbolt: Log XDomain link speed and width Mika Westerberg
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
We are going to use it in subsequent patches, so make it available outside of
switch.c. Also, change the name to tb_width_name() to follow the naming
conventions.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/switch.c | 20 ++------------------
drivers/thunderbolt/tb.h | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 44e9b09de47a..dbab551ac7b3 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -941,22 +941,6 @@ int tb_port_get_link_generation(struct tb_port *port)
}
}
-static const char *width_name(enum tb_link_width width)
-{
- switch (width) {
- case TB_LINK_WIDTH_SINGLE:
- return "symmetric, single lane";
- case TB_LINK_WIDTH_DUAL:
- return "symmetric, dual lanes";
- case TB_LINK_WIDTH_ASYM_TX:
- return "asymmetric, 3 transmitters, 1 receiver";
- case TB_LINK_WIDTH_ASYM_RX:
- return "asymmetric, 3 receivers, 1 transmitter";
- default:
- return "unknown";
- }
-}
-
/**
* tb_port_get_link_width() - Get current link width
* @port: Port to check (USB4 or CIO)
@@ -2769,7 +2753,7 @@ static void tb_switch_link_init(struct tb_switch *sw)
return;
tb_sw_dbg(sw, "current link speed %u.0 Gb/s\n", sw->link_speed);
- tb_sw_dbg(sw, "current link width %s\n", width_name(sw->link_width));
+ tb_sw_dbg(sw, "current link width %s\n", tb_width_name(sw->link_width));
bonded = sw->link_width >= TB_LINK_WIDTH_DUAL;
@@ -3029,7 +3013,7 @@ int tb_switch_set_link_width(struct tb_switch *sw, enum tb_link_width width)
tb_switch_update_link_attributes(sw);
- tb_sw_dbg(sw, "link width set to %s\n", width_name(width));
+ tb_sw_dbg(sw, "link width set to %s\n", tb_width_name(width));
return ret;
}
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index e299e53473ae..1760c21e5b12 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -568,6 +568,22 @@ static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw)
return &sw->ports[port];
}
+static inline const char *tb_width_name(enum tb_link_width width)
+{
+ switch (width) {
+ case TB_LINK_WIDTH_SINGLE:
+ return "symmetric, single lane";
+ case TB_LINK_WIDTH_DUAL:
+ return "symmetric, dual lanes";
+ case TB_LINK_WIDTH_ASYM_TX:
+ return "asymmetric, 3 transmitters, 1 receiver";
+ case TB_LINK_WIDTH_ASYM_RX:
+ return "asymmetric, 3 receivers, 1 transmitter";
+ default:
+ return "unknown";
+ }
+}
+
/**
* tb_port_has_remote() - Does the port have switch connected downstream
* @port: Port to check
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 04/11] thunderbolt: Log XDomain link speed and width
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (2 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 03/11] thunderbolt: Move width_name() helper to tb.h Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 05/11] thunderbolt: Transition link to asymmetric only when both sides support it Mika Westerberg
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
In the same way we do for routers. This is useful for debugging
purposes.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/xdomain.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index 0a885ee5788d..9495742913d5 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -1462,6 +1462,11 @@ static int tb_xdomain_get_properties(struct tb_xdomain *xd)
tb_port_disable(port->dual_link_port);
}
+ dev_dbg(&xd->dev, "current link speed %u.0 Gb/s\n",
+ xd->link_speed);
+ dev_dbg(&xd->dev, "current link width %s\n",
+ tb_width_name(xd->link_width));
+
if (device_add(&xd->dev)) {
dev_err(&xd->dev, "failed to add XDomain device\n");
return -ENODEV;
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 05/11] thunderbolt: Transition link to asymmetric only when both sides support it
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (3 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 04/11] thunderbolt: Log XDomain link speed and width Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 06/11] thunderbolt: Disable CL states only when actually needed Mika Westerberg
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
We can transition Gen 4 link to asymmetric only when both sides of the
link support it in the required direction. For this reason make sure
that the downstream adapter also supports asymmetric link before
starting the transition.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tb.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 3dabc1ac9ab3..6c5e8ce95f8d 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1104,8 +1104,9 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
clx = tb_disable_clx(sw);
tb_for_each_upstream_port_on_path(src_port, dst_port, up) {
+ struct tb_port *down = tb_switch_downstream_port(up->sw);
+ enum tb_link_width width_up, width_down;
int consumed_up, consumed_down;
- enum tb_link_width width;
ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, up,
&consumed_up, &consumed_down);
@@ -1126,7 +1127,8 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
if (consumed_down + requested_down < asym_threshold)
continue;
- width = TB_LINK_WIDTH_ASYM_RX;
+ width_up = TB_LINK_WIDTH_ASYM_RX;
+ width_down = TB_LINK_WIDTH_ASYM_TX;
} else {
/* Upstream, the opposite of above */
if (consumed_down + requested_down >= TB_ASYM_MIN) {
@@ -1136,13 +1138,15 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
if (consumed_up + requested_up < asym_threshold)
continue;
- width = TB_LINK_WIDTH_ASYM_TX;
+ width_up = TB_LINK_WIDTH_ASYM_TX;
+ width_down = TB_LINK_WIDTH_ASYM_RX;
}
- if (up->sw->link_width == width)
+ if (up->sw->link_width == width_up)
continue;
- if (!tb_port_width_supported(up, width))
+ if (!tb_port_width_supported(up, width_up) ||
+ !tb_port_width_supported(down, width_down))
continue;
tb_sw_dbg(up->sw, "configuring asymmetric link\n");
@@ -1151,7 +1155,7 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
* Here requested + consumed > threshold so we need to
* transtion the link into asymmetric now.
*/
- ret = tb_switch_set_link_width(up->sw, width);
+ ret = tb_switch_set_link_width(up->sw, width_up);
if (ret) {
tb_sw_warn(up->sw, "failed to set link width\n");
break;
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 06/11] thunderbolt: Disable CL states only when actually needed
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (4 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 05/11] thunderbolt: Transition link to asymmetric only when both sides support it Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 07/11] thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well Mika Westerberg
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
If there is not going to be an actual transition to asymmetric or
symmetric, there is no point to disable and re-enable CL states either.
So instead disable them only when we know that an actual transition is
going to take place.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tb.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 6c5e8ce95f8d..1308f7872f97 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1085,15 +1085,14 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port, int requested_up,
int requested_down)
{
+ bool clx = false, clx_disabled = false, downstream;
struct tb_switch *sw;
- bool clx, downstream;
struct tb_port *up;
int ret = 0;
if (!asym_threshold)
return 0;
- /* Disable CL states before doing any transitions */
downstream = tb_port_path_direction_downstream(src_port, dst_port);
/* Pick up router deepest in the hierarchy */
if (downstream)
@@ -1101,8 +1100,6 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
else
sw = src_port->sw;
- clx = tb_disable_clx(sw);
-
tb_for_each_upstream_port_on_path(src_port, dst_port, up) {
struct tb_port *down = tb_switch_downstream_port(up->sw);
enum tb_link_width width_up, width_down;
@@ -1149,6 +1146,16 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
!tb_port_width_supported(down, width_down))
continue;
+ /*
+ * Disable CL states before doing any transitions. We
+ * delayed it until now that we know there is a real
+ * transition taking place.
+ */
+ if (!clx_disabled) {
+ clx = tb_disable_clx(sw);
+ clx_disabled = true;
+ }
+
tb_sw_dbg(up->sw, "configuring asymmetric link\n");
/*
@@ -1185,15 +1192,14 @@ static int tb_configure_sym(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port, int requested_up,
int requested_down)
{
+ bool clx = false, clx_disabled = false, downstream;
struct tb_switch *sw;
- bool clx, downstream;
struct tb_port *up;
int ret = 0;
if (!asym_threshold)
return 0;
- /* Disable CL states before doing any transitions */
downstream = tb_port_path_direction_downstream(src_port, dst_port);
/* Pick up router deepest in the hierarchy */
if (downstream)
@@ -1201,8 +1207,6 @@ static int tb_configure_sym(struct tb *tb, struct tb_port *src_port,
else
sw = src_port->sw;
- clx = tb_disable_clx(sw);
-
tb_for_each_upstream_port_on_path(src_port, dst_port, up) {
int consumed_up, consumed_down;
@@ -1235,6 +1239,12 @@ static int tb_configure_sym(struct tb *tb, struct tb_port *src_port,
if (up->sw->link_width == TB_LINK_WIDTH_DUAL)
continue;
+ /* Disable CL states before doing any transitions */
+ if (!clx_disabled) {
+ clx = tb_disable_clx(sw);
+ clx_disabled = true;
+ }
+
tb_sw_dbg(up->sw, "configuring symmetric link\n");
ret = tb_switch_set_link_width(up->sw, TB_LINK_WIDTH_DUAL);
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 07/11] thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (5 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 06/11] thunderbolt: Disable CL states only when actually needed Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 08/11] thunderbolt: Improve logging when DisplayPort resource is added due to hotplug Mika Westerberg
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
There is no point doing this separately as the register layout is the
same. For this reason rename tb_dp_read_dprx() to tb_dp_wait_dprx() and
call tb_dp_read_cap() instead.
While there add debug log if the DPRX capability read times out.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tunnel.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index 7534cd3a81f4..a46ae3f598c5 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -1067,8 +1067,7 @@ static int tb_dp_alloc_bandwidth(struct tb_tunnel *tunnel, int *alloc_up,
return 0;
}
-static int tb_dp_read_dprx(struct tb_tunnel *tunnel, u32 *rate, u32 *lanes,
- int timeout_msec)
+static int tb_dp_wait_dprx(struct tb_tunnel *tunnel, int timeout_msec)
{
ktime_t timeout = ktime_add_ms(ktime_get(), timeout_msec);
struct tb_port *in = tunnel->src_port;
@@ -1087,15 +1086,13 @@ static int tb_dp_read_dprx(struct tb_tunnel *tunnel, u32 *rate, u32 *lanes,
return ret;
if (val & DP_COMMON_CAP_DPRX_DONE) {
- *rate = tb_dp_cap_get_rate(val);
- *lanes = tb_dp_cap_get_lanes(val);
-
tb_tunnel_dbg(tunnel, "DPRX read done\n");
return 0;
}
usleep_range(100, 150);
} while (ktime_before(ktime_get(), timeout));
+ tb_tunnel_dbg(tunnel, "DPRX read timeout\n");
return -ETIMEDOUT;
}
@@ -1110,6 +1107,7 @@ static int tb_dp_read_cap(struct tb_tunnel *tunnel, unsigned int cap, u32 *rate,
switch (cap) {
case DP_LOCAL_CAP:
case DP_REMOTE_CAP:
+ case DP_COMMON_CAP:
break;
default:
@@ -1182,7 +1180,7 @@ static int tb_dp_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,
* reduced one). Otherwise return the remote (possibly
* reduced) caps.
*/
- ret = tb_dp_read_dprx(tunnel, &rate, &lanes, 150);
+ ret = tb_dp_wait_dprx(tunnel, 150);
if (ret) {
if (ret == -ETIMEDOUT)
ret = tb_dp_read_cap(tunnel, DP_REMOTE_CAP,
@@ -1190,6 +1188,9 @@ static int tb_dp_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,
if (ret)
return ret;
}
+ ret = tb_dp_read_cap(tunnel, DP_COMMON_CAP, &rate, &lanes);
+ if (ret)
+ return ret;
} else if (sw->generation >= 2) {
ret = tb_dp_read_cap(tunnel, DP_REMOTE_CAP, &rate, &lanes);
if (ret)
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 08/11] thunderbolt: Improve logging when DisplayPort resource is added due to hotplug
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (6 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 07/11] thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 09/11] thunderbolt: Make PCIe tunnel setup and teardown follow CM guide Mika Westerberg
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
To allow us differentiate how DisplayPort resource is added to the
DisplayPort resources list make the debug log to append "hotplug" when
this was due to an actual hotplug.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 1308f7872f97..0a32e7ec4dc0 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1913,7 +1913,7 @@ static void tb_dp_resource_available(struct tb *tb, struct tb_port *port)
return;
}
- tb_port_dbg(port, "DP %s resource available\n",
+ tb_port_dbg(port, "DP %s resource available after hotplug\n",
tb_port_is_dpin(port) ? "IN" : "OUT");
list_add_tail(&port->list, &tcm->dp_resources);
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 09/11] thunderbolt: Make PCIe tunnel setup and teardown follow CM guide
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (7 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 08/11] thunderbolt: Improve logging when DisplayPort resource is added due to hotplug Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 10/11] thunderbolt: Disable PCIe extended encapsulation upon teardown properly Mika Westerberg
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
The USB4 Connection Manager guide suggests that the PCIe paths are
enabled from the upstream adapter to the downstream adapter and vice
versa on disable so make the driver follows this sequence.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tunnel.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index a46ae3f598c5..f0fde79b3b02 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -199,14 +199,21 @@ static int tb_pci_activate(struct tb_tunnel *tunnel, bool activate)
return res;
}
- res = tb_pci_port_enable(tunnel->src_port, activate);
+ if (activate)
+ res = tb_pci_port_enable(tunnel->dst_port, activate);
+ else
+ res = tb_pci_port_enable(tunnel->src_port, activate);
if (res)
return res;
- if (tb_port_is_pcie_up(tunnel->dst_port)) {
- res = tb_pci_port_enable(tunnel->dst_port, activate);
+
+ if (activate) {
+ res = tb_pci_port_enable(tunnel->src_port, activate);
if (res)
return res;
+ } else {
+ /* Downstream router could be unplugged */
+ tb_pci_port_enable(tunnel->dst_port, activate);
}
return activate ? 0 : tb_pci_set_ext_encapsulation(tunnel, activate);
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 10/11] thunderbolt: Disable PCIe extended encapsulation upon teardown properly
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (8 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 09/11] thunderbolt: Make PCIe tunnel setup and teardown follow CM guide Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-04 10:38 ` [PATCH 11/11] thunderbolt: Add support for Intel Lunar Lake Mika Westerberg
2023-12-14 6:13 ` [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
From: Gil Fine <gil.fine@linux.intel.com>
In case of PCIe tunnel teardown (including if caused by router unplug),
PCIe extended encapsulation bit should be cleared in downstream and
upstream routers accordingly.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tunnel.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index f0fde79b3b02..96b238b06f9d 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -173,16 +173,28 @@ static int tb_pci_set_ext_encapsulation(struct tb_tunnel *tunnel, bool enable)
int ret;
/* Only supported of both routers are at least USB4 v2 */
- if (tb_port_get_link_generation(port) < 4)
+ if ((usb4_switch_version(tunnel->src_port->sw) < 2) ||
+ (usb4_switch_version(tunnel->dst_port->sw) < 2))
+ return 0;
+
+ if (enable && tb_port_get_link_generation(port) < 4)
return 0;
ret = usb4_pci_port_set_ext_encapsulation(tunnel->src_port, enable);
if (ret)
return ret;
+ /*
+ * Downstream router could be unplugged so disable of encapsulation
+ * in upstream router is still possible.
+ */
ret = usb4_pci_port_set_ext_encapsulation(tunnel->dst_port, enable);
- if (ret)
- return ret;
+ if (ret) {
+ if (enable)
+ return ret;
+ if (ret != -ENODEV)
+ return ret;
+ }
tb_tunnel_dbg(tunnel, "extended encapsulation %s\n",
str_enabled_disabled(enable));
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 11/11] thunderbolt: Add support for Intel Lunar Lake
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (9 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 10/11] thunderbolt: Disable PCIe extended encapsulation upon teardown properly Mika Westerberg
@ 2023-12-04 10:38 ` Mika Westerberg
2023-12-14 6:13 ` [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-04 10:38 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter, Mika Westerberg
Intel Lunar Lake has similar integrated Thunderbolt/USB4 controller as
Intel Meteor Lake with some small differences in the host router (it has
3 DP IN adapters for instance). Add the Intel Lunar Lake PCI IDs to the
driver list of supported devices.
Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/nhi.c | 4 ++++
drivers/thunderbolt/nhi.h | 2 ++
2 files changed, 6 insertions(+)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 4b7bec74e89f..fb4f46e51753 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1517,6 +1517,10 @@ static struct pci_device_id nhi_ids[] = {
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL_P_NHI1),
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
+ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_LNL_NHI0),
+ .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+ { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_LNL_NHI1),
+ .driver_data = (kernel_ulong_t)&icl_nhi_ops },
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI) },
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI) },
diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h
index 0f029ce75882..7a07c7c1a9c2 100644
--- a/drivers/thunderbolt/nhi.h
+++ b/drivers/thunderbolt/nhi.h
@@ -90,6 +90,8 @@ extern const struct tb_nhi_ops icl_nhi_ops;
#define PCI_DEVICE_ID_INTEL_TGL_H_NHI1 0x9a21
#define PCI_DEVICE_ID_INTEL_RPL_NHI0 0xa73e
#define PCI_DEVICE_ID_INTEL_RPL_NHI1 0xa76d
+#define PCI_DEVICE_ID_INTEL_LNL_NHI0 0xa833
+#define PCI_DEVICE_ID_INTEL_LNL_NHI1 0xa834
#define PCI_CLASS_SERIAL_USB_USB4 0x0c0340
--
2.42.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 00/11] Improvements and Lunar Lake support
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
` (10 preceding siblings ...)
2023-12-04 10:38 ` [PATCH 11/11] thunderbolt: Add support for Intel Lunar Lake Mika Westerberg
@ 2023-12-14 6:13 ` Mika Westerberg
11 siblings, 0 replies; 13+ messages in thread
From: Mika Westerberg @ 2023-12-14 6:13 UTC (permalink / raw)
To: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever
Cc: linux-usb, Gil Fine, Pengfei Xu, Dan Carpenter
On Mon, Dec 04, 2023 at 12:38:17PM +0200, Mika Westerberg wrote:
> Hi all,
>
> This series adds improvements around USB4 v2 support, PCIe tunneling,
> some minor fixes and also adds Intel Lunar Lake support.
>
> Gil Fine (7):
> thunderbolt: Handle lane bonding of Gen 4 XDomain links properly
> thunderbolt: Move width_name() helper to tb.h
> thunderbolt: Log XDomain link speed and width
> thunderbolt: Transition link to asymmetric only when both sides support it
> thunderbolt: Improve logging when DisplayPort resource is added due to hotplug
> thunderbolt: Make PCIe tunnel setup and teardown follow CM guide
> thunderbolt: Disable PCIe extended encapsulation upon teardown properly
>
> Mika Westerberg (4):
> thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails
> thunderbolt: Disable CL states only when actually needed
> thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well
> thunderbolt: Add support for Intel Lunar Lake
All applied to thunderbolt.git/next.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-12-14 6:13 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 10:38 [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
2023-12-04 10:38 ` [PATCH 01/11] thunderbolt: Unwind TMU configuration if tb_switch_set_tmu_mode_params() fails Mika Westerberg
2023-12-04 10:38 ` [PATCH 02/11] thunderbolt: Handle lane bonding of Gen 4 XDomain links properly Mika Westerberg
2023-12-04 10:38 ` [PATCH 03/11] thunderbolt: Move width_name() helper to tb.h Mika Westerberg
2023-12-04 10:38 ` [PATCH 04/11] thunderbolt: Log XDomain link speed and width Mika Westerberg
2023-12-04 10:38 ` [PATCH 05/11] thunderbolt: Transition link to asymmetric only when both sides support it Mika Westerberg
2023-12-04 10:38 ` [PATCH 06/11] thunderbolt: Disable CL states only when actually needed Mika Westerberg
2023-12-04 10:38 ` [PATCH 07/11] thunderbolt: Use tb_dp_read_cap() to read DP_COMMON_CAP as well Mika Westerberg
2023-12-04 10:38 ` [PATCH 08/11] thunderbolt: Improve logging when DisplayPort resource is added due to hotplug Mika Westerberg
2023-12-04 10:38 ` [PATCH 09/11] thunderbolt: Make PCIe tunnel setup and teardown follow CM guide Mika Westerberg
2023-12-04 10:38 ` [PATCH 10/11] thunderbolt: Disable PCIe extended encapsulation upon teardown properly Mika Westerberg
2023-12-04 10:38 ` [PATCH 11/11] thunderbolt: Add support for Intel Lunar Lake Mika Westerberg
2023-12-14 6:13 ` [PATCH 00/11] Improvements and Lunar Lake support Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).