linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP tunnel is discovered.
@ 2022-08-04 10:48 Sanjay R Mehta
  2022-08-10 21:52 ` Limonciello, Mario
  0 siblings, 1 reply; 3+ messages in thread
From: Sanjay R Mehta @ 2022-08-04 10:48 UTC (permalink / raw)
  To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
  Cc: Basavaraj.Natikar, mario.limonciello, linux-usb, Sanjay R Mehta

From: Sanjay R Mehta <sanju.mehta@amd.com>

If the boot firmware implements a connection manager of its
own it may create a DP tunnel and will be handed off to Linux
CM, but the DP out resource is not saved in the dp_resource
list.

This patch adds tunnelled DP out port to the dp_resource list
once the DP tunnel is discovered.

Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

---
v3:
- Change function name to tb_discover_dp_resources & making it
  as static function as per Mika's comment.
- Move call to tb_discover_dp_resources() from tb_start().

v2: Re-ordering the function declaration as per Greg's comment.
---
 drivers/thunderbolt/tb.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 9a3214f..0d420dd 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -105,6 +105,32 @@ static void tb_remove_dp_resources(struct tb_switch *sw)
 	}
 }
 
+static void tb_discover_dp_resource(struct tb *tb, struct tb_port *port)
+{
+	struct tb_cm *tcm = tb_priv(tb);
+	struct tb_port *p;
+
+	list_for_each_entry(p, &tcm->dp_resources, list) {
+		if (p == port)
+			return;
+	}
+
+	tb_port_dbg(port, "DP %s resource available discovered\n",
+		    tb_port_is_dpin(port) ? "IN" : "OUT");
+	list_add_tail(&port->list, &tcm->dp_resources);
+}
+
+static void tb_discover_dp_resources(struct tb *tb)
+{
+	struct tb_cm *tcm = tb_priv(tb);
+	struct tb_tunnel *tunnel;
+
+	list_for_each_entry(tunnel, &tcm->tunnel_list, list) {
+		if (tb_tunnel_is_dp(tunnel))
+			tb_discover_dp_resource(tb, tunnel->dst_port);
+	}
+}
+
 static void tb_switch_discover_tunnels(struct tb_switch *sw,
 				       struct list_head *list,
 				       bool alloc_hopids)
@@ -1414,6 +1440,8 @@ static int tb_start(struct tb *tb)
 	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.7.4


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

* RE: [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP tunnel is discovered.
  2022-08-04 10:48 [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP tunnel is discovered Sanjay R Mehta
@ 2022-08-10 21:52 ` Limonciello, Mario
  2022-08-15 12:59   ` mika.westerberg
  0 siblings, 1 reply; 3+ messages in thread
From: Limonciello, Mario @ 2022-08-10 21:52 UTC (permalink / raw)
  To: mika.westerberg
  Cc: Natikar, Basavaraj, linux-usb, Pananchikkal, Renjith, Mehta,
	Sanju, andreas.noever, michael.jamet, YehezkelShB

[Public]

> -----Original Message-----
> From: Mehta, Sanju <Sanju.Mehta@amd.com>
> Sent: Thursday, August 4, 2022 05:49
> To: mika.westerberg@linux.intel.com; andreas.noever@gmail.com;
> michael.jamet@intel.com; YehezkelShB@gmail.com
> Cc: Natikar, Basavaraj <Basavaraj.Natikar@amd.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>; linux-usb@vger.kernel.org; Mehta, Sanju
> <Sanju.Mehta@amd.com>
> Subject: [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP
> tunnel is discovered.
> 
> From: Sanjay R Mehta <sanju.mehta@amd.com>
> 
> If the boot firmware implements a connection manager of its
> own it may create a DP tunnel and will be handed off to Linux
> CM, but the DP out resource is not saved in the dp_resource
> list.
> 
> This patch adds tunnelled DP out port to the dp_resource list
> once the DP tunnel is discovered.
> 
> Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

Another one of my colleagues validated this patch this morning, here
is a tag for him.

Tested-by: Renjith Pananchikkal <Renjith.Pananchikkal@amd.com>

> 
> ---
> v3:
> - Change function name to tb_discover_dp_resources & making it
>   as static function as per Mika's comment.
> - Move call to tb_discover_dp_resources() from tb_start().
> 
> v2: Re-ordering the function declaration as per Greg's comment.
> ---
>  drivers/thunderbolt/tb.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index 9a3214f..0d420dd 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
> @@ -105,6 +105,32 @@ static void tb_remove_dp_resources(struct
> tb_switch *sw)
>  	}
>  }
> 
> +static void tb_discover_dp_resource(struct tb *tb, struct tb_port *port)
> +{
> +	struct tb_cm *tcm = tb_priv(tb);
> +	struct tb_port *p;
> +
> +	list_for_each_entry(p, &tcm->dp_resources, list) {
> +		if (p == port)
> +			return;
> +	}
> +
> +	tb_port_dbg(port, "DP %s resource available discovered\n",
> +		    tb_port_is_dpin(port) ? "IN" : "OUT");
> +	list_add_tail(&port->list, &tcm->dp_resources);
> +}
> +
> +static void tb_discover_dp_resources(struct tb *tb)
> +{
> +	struct tb_cm *tcm = tb_priv(tb);
> +	struct tb_tunnel *tunnel;
> +
> +	list_for_each_entry(tunnel, &tcm->tunnel_list, list) {
> +		if (tb_tunnel_is_dp(tunnel))
> +			tb_discover_dp_resource(tb, tunnel->dst_port);
> +	}
> +}
> +
>  static void tb_switch_discover_tunnels(struct tb_switch *sw,
>  				       struct list_head *list,
>  				       bool alloc_hopids)
> @@ -1414,6 +1440,8 @@ static int tb_start(struct tb *tb)
>  	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.7.4

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

* Re: [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP tunnel is discovered.
  2022-08-10 21:52 ` Limonciello, Mario
@ 2022-08-15 12:59   ` mika.westerberg
  0 siblings, 0 replies; 3+ messages in thread
From: mika.westerberg @ 2022-08-15 12:59 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Natikar, Basavaraj, linux-usb, Pananchikkal, Renjith, Mehta,
	Sanju, andreas.noever, michael.jamet, YehezkelShB

On Wed, Aug 10, 2022 at 09:52:46PM +0000, Limonciello, Mario wrote:
> [Public]
> 
> > -----Original Message-----
> > From: Mehta, Sanju <Sanju.Mehta@amd.com>
> > Sent: Thursday, August 4, 2022 05:49
> > To: mika.westerberg@linux.intel.com; andreas.noever@gmail.com;
> > michael.jamet@intel.com; YehezkelShB@gmail.com
> > Cc: Natikar, Basavaraj <Basavaraj.Natikar@amd.com>; Limonciello, Mario
> > <Mario.Limonciello@amd.com>; linux-usb@vger.kernel.org; Mehta, Sanju
> > <Sanju.Mehta@amd.com>
> > Subject: [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP
> > tunnel is discovered.
> > 
> > From: Sanjay R Mehta <sanju.mehta@amd.com>
> > 
> > If the boot firmware implements a connection manager of its
> > own it may create a DP tunnel and will be handed off to Linux
> > CM, but the DP out resource is not saved in the dp_resource
> > list.
> > 
> > This patch adds tunnelled DP out port to the dp_resource list
> > once the DP tunnel is discovered.
> > 
> > Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
> > Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> 
> Another one of my colleagues validated this patch this morning, here
> is a tag for him.
> 
> Tested-by: Renjith Pananchikkal <Renjith.Pananchikkal@amd.com>

Applied to thunderbolt.git/next, thanks!

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

end of thread, other threads:[~2022-08-15 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 10:48 [PATCH v3/RESEND] thunderbolt: Add DP out resource when DP tunnel is discovered Sanjay R Mehta
2022-08-10 21:52 ` Limonciello, Mario
2022-08-15 12:59   ` 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).