linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Reset NHI during S4 restore_noirq() callback
@ 2025-10-23  5:03 Mario Limonciello (AMD)
  2025-10-23  5:56 ` Mika Westerberg
  0 siblings, 1 reply; 11+ messages in thread
From: Mario Limonciello (AMD) @ 2025-10-23  5:03 UTC (permalink / raw)
  To: mario.limonciello, andreas.noever, westeri, YehezkelShB
  Cc: Mario Limonciello (AMD), Sanath.S, linux-usb

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);
+
 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);
+
+	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


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

end of thread, other threads:[~2025-11-05 19:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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)

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).