[PATCH RFC DNM 09/15] thunderbolt: nhi: Resume the domain if the NHI suspend op fails
From: Konrad Dybcio
Date: Tue Nov 24 2026 - 15:03:08 EST
nhi_suspend_noirq() and nhi_runtime_suspend() suspend the domain first
and then call the NHI specific suspend op. If that op fails, the error
is returned with the domain still suspended. The control channel is
stopped and the switches are marked as suspended, but the PM core
treats the device as active: it does not call resume_noirq for a device
whose suspend_noirq failed, nor runtime_resume after a failed
runtime_suspend. Nothing ever resumes the domain. Hotplug and config
space accesses stop working, and the next runtime suspend attempt
suspends an already suspended domain.
This happens on Qualcomm USB4 routers whenever the router firmware does
not acknowledge the sleep request in time. The op then returns -EBUSY
with the router still up.
Resume the domain before returning the error.
---
drivers/thunderbolt/nhi.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index bcc2b959e3b1a6b014c13a4938ed6f68cb0d0fd8..e2578740d569a7ee1d5ab22e8effc153cb7d4632 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1177,8 +1177,15 @@ static int __nhi_suspend_noirq(struct device *dev, bool wakeup)
if (nhi->ops->suspend_noirq) {
ret = nhi->ops->suspend_noirq(tb->nhi, wakeup);
- if (ret)
+ if (ret) {
+ /*
+ * The PM core does not call resume_noirq for a
+ * device whose suspend_noirq failed, so resume
+ * the domain here.
+ */
+ tb_domain_resume_noirq(tb);
return ret;
+ }
}
return 0;
@@ -1281,8 +1288,14 @@ static int nhi_runtime_suspend(struct device *dev)
if (nhi->ops->runtime_suspend) {
ret = nhi->ops->runtime_suspend(tb->nhi);
- if (ret)
+ if (ret) {
+ /*
+ * The PM core does not call runtime_resume after a
+ * failed runtime_suspend, so resume the domain here.
+ */
+ tb_domain_runtime_resume(tb);
return ret;
+ }
}
return 0;
}
--
2.55.0