public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Retain host router DP IN resources during suspend
@ 2022-02-18  7:11 Sanjay R Mehta
  2022-02-18 11:13 ` Mika Westerberg
  0 siblings, 1 reply; 5+ messages in thread
From: Sanjay R Mehta @ 2022-02-18  7:11 UTC (permalink / raw)
  To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
  Cc: Basavaraj.Natikar, jagadish.hadimani, sachinkumar.butte,
	linux-usb, Sanjay R Mehta

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

All DP resources are released during suspend and while
resuming back DP IN resource is not available, therefore
unable to find DP pair to re-establish the DP tunnel.

Hence preserve host routers DP IN resources and
release all other DP resources during suspend.

Suggested-by: Jagadish Hadimani <jagadish.hadimani@amd.com>
Suggested-by: Sachinkumar Butte <sachinkumar.butte@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/thunderbolt/tb.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index cbd0ad8..a11710e 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1022,6 +1022,7 @@ static void tb_disconnect_and_release_dp(struct tb *tb)
 {
 	struct tb_cm *tcm = tb_priv(tb);
 	struct tb_tunnel *tunnel, *n;
+	struct tb_port *port, *tmp;
 
 	/*
 	 * Tear down all DP tunnels and release their resources. They
@@ -1032,11 +1033,10 @@ static void tb_disconnect_and_release_dp(struct tb *tb)
 			tb_deactivate_and_free_tunnel(tunnel);
 	}
 
-	while (!list_empty(&tcm->dp_resources)) {
-		struct tb_port *port;
-
-		port = list_first_entry(&tcm->dp_resources,
-					struct tb_port, list);
+	list_for_each_entry_safe(port, tmp, &tcm->dp_resources, list) {
+		/* Preserve root switch DP IN resource */
+		if (!tb_route(port->sw) && tb_port_is_dpin(port))
+			continue;
 		list_del_init(&port->list);
 	}
 }
-- 
2.7.4


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

* Re: [PATCH] thunderbolt: Retain host router DP IN resources during suspend
  2022-02-18  7:11 [PATCH] thunderbolt: Retain host router DP IN resources during suspend Sanjay R Mehta
@ 2022-02-18 11:13 ` Mika Westerberg
  2022-02-18 14:08   ` Sanjay R Mehta
  0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2022-02-18 11:13 UTC (permalink / raw)
  To: Sanjay R Mehta
  Cc: andreas.noever, michael.jamet, YehezkelShB, Basavaraj.Natikar,
	jagadish.hadimani, sachinkumar.butte, linux-usb

Hi Sanjay,

On Fri, Feb 18, 2022 at 01:11:25AM -0600, Sanjay R Mehta wrote:
> From: Sanjay R Mehta <sanju.mehta@amd.com>
> 
> All DP resources are released during suspend and while
> resuming back DP IN resource is not available, therefore
> unable to find DP pair to re-establish the DP tunnel.

It should get plug event for the DP IN adapters once the router comes
back from sleep. Is that not happening here?

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

* Re: [PATCH] thunderbolt: Retain host router DP IN resources during suspend
  2022-02-18 11:13 ` Mika Westerberg
@ 2022-02-18 14:08   ` Sanjay R Mehta
  2022-02-18 14:25     ` Mika Westerberg
  0 siblings, 1 reply; 5+ messages in thread
From: Sanjay R Mehta @ 2022-02-18 14:08 UTC (permalink / raw)
  To: Mika Westerberg, Sanjay R Mehta
  Cc: andreas.noever, michael.jamet, YehezkelShB, Basavaraj.Natikar,
	jagadish.hadimani, sachinkumar.butte, linux-usb



On 2/18/2022 4:43 PM, Mika Westerberg wrote:
> Hi Sanjay,
> 
> On Fri, Feb 18, 2022 at 01:11:25AM -0600, Sanjay R Mehta wrote:
>> From: Sanjay R Mehta <sanju.mehta@amd.com>
>>
>> All DP resources are released during suspend and while
>> resuming back DP IN resource is not available, therefore
>> unable to find DP pair to re-establish the DP tunnel.
> 
> It should get plug event for the DP IN adapters once the router comes
> back from sleep. Is that not happening here?

Yes, plug event is not happening for the DP IN adapter after resume.

The DP In resources are put into tcm->dp_resources list as part  of host
router enumeration. But when it resumes from sleep, there is no plug
event happening for DP IN, hence DP IN resource will not be in
tcm->dp_resources list.

> 

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

* Re: [PATCH] thunderbolt: Retain host router DP IN resources during suspend
  2022-02-18 14:08   ` Sanjay R Mehta
@ 2022-02-18 14:25     ` Mika Westerberg
  2022-02-20 11:57       ` Sanjay R Mehta
  0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2022-02-18 14:25 UTC (permalink / raw)
  To: Sanjay R Mehta
  Cc: Sanjay R Mehta, andreas.noever, michael.jamet, YehezkelShB,
	Basavaraj.Natikar, jagadish.hadimani, sachinkumar.butte,
	linux-usb

On Fri, Feb 18, 2022 at 07:38:23PM +0530, Sanjay R Mehta wrote:
> 
> 
> On 2/18/2022 4:43 PM, Mika Westerberg wrote:
> > Hi Sanjay,
> > 
> > On Fri, Feb 18, 2022 at 01:11:25AM -0600, Sanjay R Mehta wrote:
> >> From: Sanjay R Mehta <sanju.mehta@amd.com>
> >>
> >> All DP resources are released during suspend and while
> >> resuming back DP IN resource is not available, therefore
> >> unable to find DP pair to re-establish the DP tunnel.
> > 
> > It should get plug event for the DP IN adapters once the router comes
> > back from sleep. Is that not happening here?
> 
> Yes, plug event is not happening for the DP IN adapter after resume.
> 
> The DP In resources are put into tcm->dp_resources list as part  of host
> router enumeration. But when it resumes from sleep, there is no plug
> event happening for DP IN, hence DP IN resource will not be in
> tcm->dp_resources list.

Right but if I understand the spec correctly you should get a new
hotplug event for the DP IN adapters once the host router is moved back
to "enumerated" state. This is how Intel hardware works at least (and
this is the understanding I have from the USB4 spec too). Do you see
anything in the log wrt. this when you resume the domain?

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

* Re: [PATCH] thunderbolt: Retain host router DP IN resources during suspend
  2022-02-18 14:25     ` Mika Westerberg
@ 2022-02-20 11:57       ` Sanjay R Mehta
  0 siblings, 0 replies; 5+ messages in thread
From: Sanjay R Mehta @ 2022-02-20 11:57 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Sanjay R Mehta, andreas.noever, michael.jamet, YehezkelShB,
	Basavaraj.Natikar, jagadish.hadimani, sachinkumar.butte,
	linux-usb



On 2/18/2022 7:55 PM, Mika Westerberg wrote:
> On Fri, Feb 18, 2022 at 07:38:23PM +0530, Sanjay R Mehta wrote:
>>
>>
>> On 2/18/2022 4:43 PM, Mika Westerberg wrote:
>>> Hi Sanjay,
>>>
>>> On Fri, Feb 18, 2022 at 01:11:25AM -0600, Sanjay R Mehta wrote:
>>>> From: Sanjay R Mehta <sanju.mehta@amd.com>
>>>>
>>>> All DP resources are released during suspend and while
>>>> resuming back DP IN resource is not available, therefore
>>>> unable to find DP pair to re-establish the DP tunnel.
>>>
>>> It should get plug event for the DP IN adapters once the router comes
>>> back from sleep. Is that not happening here?
>>
>> Yes, plug event is not happening for the DP IN adapter after resume.
>>
>> The DP In resources are put into tcm->dp_resources list as part  of host
>> router enumeration. But when it resumes from sleep, there is no plug
>> event happening for DP IN, hence DP IN resource will not be in
>> tcm->dp_resources list.
> 
> Right but if I understand the spec correctly you should get a new
> hotplug event for the DP IN adapters once the host router is moved back
> to "enumerated" state. This is how Intel hardware works at least (and
> this is the understanding I have from the USB4 spec too). Do you see
> anything in the log wrt. this when you resume the domain?

Thanks Mika. I'll re-look at this scenario on our system and will check
if anything needs to be taken care of.

Thank you for the valuable input :).

> 

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

end of thread, other threads:[~2022-02-20 11:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18  7:11 [PATCH] thunderbolt: Retain host router DP IN resources during suspend Sanjay R Mehta
2022-02-18 11:13 ` Mika Westerberg
2022-02-18 14:08   ` Sanjay R Mehta
2022-02-18 14:25     ` Mika Westerberg
2022-02-20 11:57       ` Sanjay R Mehta

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