linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: mario.limonciello@amd.com, andreas.noever@gmail.com,
	westeri@kernel.org, YehezkelShB@gmail.com, Sanath.S@amd.com,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH] thunderbolt: Reset NHI during S4 restore_noirq() callback
Date: Thu, 23 Oct 2025 09:13:15 -0500	[thread overview]
Message-ID: <02191522-b3f7-459e-ae46-12788f36209a@kernel.org> (raw)
In-Reply-To: <20251023055603.GU2912318@black.igk.intel.com>

On 10/23/25 12:56 AM, Mika Westerberg wrote:
> Hi,
> 
> On Thu, Oct 23, 2025 at 12:03:26AM -0500, Mario Limonciello (AMD) wrote:
>> When a machine is restored from S4 if the firmware CM has created
>> tunnels there can be an incongruity of expectation from the kernel
>> when compared to booting from S5.
>>
>> For example this incongruity can lead to problems like the display
>> not working properly if the firmware CM didn't turn it on pre-OS
>> but the OS had it on before entering S4.
>>
>> Add an extra restore_noirq() callback to explicitly reset the NHI
>> before running the rest of the resume sequence.  This will allow
>> the standard discovery and probing routines to run and create the
>> tunnels as expected.
>>
>> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
>> ---
>> Cc: Sanath.S@amd.com
>> ---
>>   drivers/thunderbolt/nhi.c | 15 ++++++++++++++-
>>   1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
>> index 5f63f9b9cf405..042d184637a93 100644
>> --- a/drivers/thunderbolt/nhi.c
>> +++ b/drivers/thunderbolt/nhi.c
>> @@ -51,6 +51,8 @@ static bool host_reset = true;
>>   module_param(host_reset, bool, 0444);
>>   MODULE_PARM_DESC(host_reset, "reset USB4 host router (default: true)");
>>   
>> +static void nhi_reset(struct tb_nhi *nhi);
> 
> Please move the whole function above nhi_restore_noirq() then.

OK - wasn't sure that would be OK to do.

> 
>> +
>>   static int ring_interrupt_index(const struct tb_ring *ring)
>>   {
>>   	int bit = ring->hop;
>> @@ -1077,6 +1079,17 @@ static int nhi_resume_noirq(struct device *dev)
>>   	return tb_domain_resume_noirq(tb);
>>   }
>>   
>> +static int nhi_restore_noirq(struct device *dev)
>> +{
>> +	struct pci_dev *pdev = to_pci_dev(dev);
>> +	struct tb *tb = pci_get_drvdata(pdev);
>> +	struct tb_nhi *nhi = tb->nhi;
>> +
>> +	nhi_reset(nhi);
>> +
> 
> Now that we do this, should ge get rid of the S4 things we do in
> tb_resume_noirq()? Especially this block:
> 
> 	/*
> 	 * If we get here from suspend to disk the boot firmware or the
> 	 * restore kernel might have created tunnels of its own. Since
> 	 * we cannot be sure they are usable for us we find and tear
> 	 * them down.
> 	 */
> 	tb_switch_discover_tunnels(tb->root_switch, &tunnels, false);
> 	list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) {
> 		if (tb_tunnel_is_usb3(tunnel))
> 			usb3_delay = 500;
> 		tb_tunnel_deactivate(tunnel);
> 		tb_tunnel_put(tunnel);
> 	}
> 

Yeah; I agree this block should go now.

> Also have you checked that this works when you have tunnels such as P2P
> (networking)?

I didn't check this, I'll spin a v2 and get that checked before posting it.

> 
>> +	return nhi_resume_noirq(dev);
>> +}
>> +
>>   static int nhi_suspend(struct device *dev)
>>   {
>>   	struct pci_dev *pdev = to_pci_dev(dev);
>> @@ -1449,7 +1462,7 @@ static const struct dev_pm_ops nhi_pm_ops = {
>>   					    * pci-tunnels stay alive.
>>   					    */
>>   	.thaw_noirq = nhi_thaw_noirq,
>> -	.restore_noirq = nhi_resume_noirq,
>> +	.restore_noirq = nhi_restore_noirq,
>>   	.suspend = nhi_suspend,
>>   	.poweroff_noirq = nhi_poweroff_noirq,
>>   	.poweroff = nhi_suspend,
>> -- 
>> 2.43.0


  reply	other threads:[~2025-10-23 14:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  5:03 [PATCH] thunderbolt: Reset NHI during S4 restore_noirq() callback Mario Limonciello (AMD)
2025-10-23  5:56 ` Mika Westerberg
2025-10-23 14:13   ` Mario Limonciello [this message]
2025-11-04 19:11     ` Kenneth Crudup
2025-11-04 19:12       ` Mario Limonciello
2025-11-04 20:22         ` Kenneth Crudup
2025-11-04 20:31           ` Mario Limonciello
2025-11-04 21:19             ` Kenneth Crudup
2025-11-04 21:21               ` Mario Limonciello
2025-11-05 19:06                 ` Kenneth Crudup
2025-11-05 19:16                   ` Mario Limonciello (AMD) (kernel.org)

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=02191522-b3f7-459e-ae46-12788f36209a@kernel.org \
    --to=superm1@kernel.org \
    --cc=Sanath.S@amd.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=westeri@kernel.org \
    /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).