linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Lukas Wunner <lukas@wunner.de>,
	Andreas Noever <andreas.noever@gmail.com>,
	Gil Fine <gil.fine@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH 12/13] thunderbolt: Create multiple DisplayPort tunnels if there are more DP IN/OUT pairs
Date: Tue,  3 Oct 2023 12:40:04 +0300	[thread overview]
Message-ID: <20231003094005.2676823-13-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20231003094005.2676823-1-mika.westerberg@linux.intel.com>

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

Currently we only create one DisplayPort tunnel even if there would be
more DP IN/OUT pairs available. Specifically this happens when a router
is unplugged and we check if a new DisplayPort tunnel can be created. To
cover this create tunnels as long as we find suitable DP IN/OUT pairs.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 3b3f46edfb70..238156358849 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1284,18 +1284,13 @@ static struct tb_port *tb_find_dp_out(struct tb *tb, struct tb_port *in)
 	return NULL;
 }
 
-static void tb_tunnel_dp(struct tb *tb)
+static bool tb_tunnel_one_dp(struct tb *tb)
 {
 	int available_up, available_down, ret, link_nr;
 	struct tb_cm *tcm = tb_priv(tb);
 	struct tb_port *port, *in, *out;
 	struct tb_tunnel *tunnel;
 
-	if (!tb_acpi_may_tunnel_dp()) {
-		tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n");
-		return;
-	}
-
 	/*
 	 * Find pair of inactive DP IN and DP OUT adapters and then
 	 * establish a DP tunnel between them.
@@ -1323,11 +1318,11 @@ static void tb_tunnel_dp(struct tb *tb)
 
 	if (!in) {
 		tb_dbg(tb, "no suitable DP IN adapter available, not tunneling\n");
-		return;
+		return false;
 	}
 	if (!out) {
 		tb_dbg(tb, "no suitable DP OUT adapter available, not tunneling\n");
-		return;
+		return false;
 	}
 
 	/*
@@ -1400,7 +1395,7 @@ static void tb_tunnel_dp(struct tb *tb)
 	 * TMU mode to HiFi for CL0s to work.
 	 */
 	tb_increase_tmu_accuracy(tunnel);
-	return;
+	return true;
 
 err_free:
 	tb_tunnel_free(tunnel);
@@ -1415,6 +1410,19 @@ static void tb_tunnel_dp(struct tb *tb)
 	pm_runtime_put_autosuspend(&out->sw->dev);
 	pm_runtime_mark_last_busy(&in->sw->dev);
 	pm_runtime_put_autosuspend(&in->sw->dev);
+
+	return false;
+}
+
+static void tb_tunnel_dp(struct tb *tb)
+{
+	if (!tb_acpi_may_tunnel_dp()) {
+		tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n");
+		return;
+	}
+
+	while (tb_tunnel_one_dp(tb))
+		;
 }
 
 static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port)
-- 
2.40.1


  parent reply	other threads:[~2023-10-03  9:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03  9:39 [PATCH 00/13] thunderbolt: DisplayPort and logging improvements & cleanups Mika Westerberg
2023-10-03  9:39 ` [PATCH 01/13] thunderbolt: dma_test: Use enum tb_link_width Mika Westerberg
2023-10-03  9:39 ` [PATCH 02/13] thunderbolt: Get rid of usb4_usb3_port_actual_link_rate() Mika Westerberg
2023-10-03  9:39 ` [PATCH 03/13] thunderbolt: Make tb_switch_clx_is_supported() static Mika Westerberg
2023-10-03  9:39 ` [PATCH 04/13] thunderbolt: Check for unplugged router in tb_switch_clx_disable() Mika Westerberg
2023-10-03  9:39 ` [PATCH 05/13] thunderbolt: Fix debug log when DisplayPort adapter not available for pairing Mika Westerberg
2023-10-03  9:39 ` [PATCH 06/13] thunderbolt: Fix typo in enum tb_link_width kernel-doc Mika Westerberg
2023-10-03  9:39 ` [PATCH 07/13] thunderbolt: Fix typo of HPD bit for Hot Plug Detect Mika Westerberg
2023-10-03  9:40 ` [PATCH 08/13] thunderbolt: Use tb_tunnel_dbg() where possible to make logging more consistent Mika Westerberg
2023-10-03  9:40 ` [PATCH 09/13] thunderbolt: Expose tb_tunnel_xxx() log macros to the rest of the driver Mika Westerberg
2023-10-03  9:40 ` [PATCH 10/13] thunderbolt: Use tb_tunnel_xxx() log macros in tb.c Mika Westerberg
2023-10-03  9:40 ` [PATCH 11/13] thunderbolt: Log NVM version of routers and retimers Mika Westerberg
2023-10-03  9:40 ` Mika Westerberg [this message]
2023-10-03  9:40 ` [PATCH 13/13] thunderbolt: Add DP IN added last in the head of the list of DP resources Mika Westerberg
2023-10-13  5:55 ` [PATCH 00/13] thunderbolt: DisplayPort and logging improvements & cleanups Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231003094005.2676823-13-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=gil.fine@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).