bus: mhi: Address MHI system suspend abort
cover bus: mhi: Address MHI system suspend abort
For Upstream:
[PATCH 1/2] bus: mhi: pci_generic: Prevent MHI from aborting system suspend
For Debug of underlying MHI issue:
[RFC 2/2] bus: mhi: host: Add diagnostic print for -EBUSY in mhi_pm_suspend()
thanks,
-Len
PATCH v2 1/2 bus: mhi: pci_generic: Prevent MHI from aborting system suspend
From: Len Brown <[email protected]>
mhi sometimes aborts system suspend on the thinkpad T16 gen3:
mhi-pci-generic 0000:08:00.0:
... failed to suspend device: -16
... PM: pci_pm_suspend(): mhi_pci_suspend [mhi_pci_generic] returns -16 ... PM: dpm_run_callback(): pci_pm_suspend returns -16
... PM: pci_pm_suspend returned -16 after 15145 usecs
... PM: failed to suspend async: error -16
Prevent MHI from spreading this device-specific failure to the rest of the system. I.e. "Why is a modem that I don't use preventing me from suspending my laptop?"
This change does not comprehend the internal root cause of the mhi failure, which should be found and fixed.
There is also a risk that ignoring the MHI error and continuing to put the device into PCI D3 will leave it in an error state.
--- drivers/bus/mhi/host/pci_generic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/bus/mhi/host/pci_generic.c +6 -1
@@ -1727,7 +1727,12 @@ static int __maybe_unused mhi_pci_runtime_resume(struct device *dev)static int __maybe_unused mhi_pci_suspend (struct device *dev) {pm_runtime_disable (dev); -return mhi_pci_runtime_suspend (dev); + +/* Ignore errors (e.g. -EBUSY); a failed modem suspend must not abort system suspend */ +mhi_pci_runtime_suspend (dev); + +/* Must return 0 to allow system suspend to continue */ +return 0 ; }static int __maybe_unused mhi_pci_resume (struct device *dev)
Signature · 1 line
2.45.2
RFC 2/2 bus: mhi: host: Add diagnostic print for -EBUSY in mhi_pm_suspend()
From: Len Brown <[email protected]>
mhi_pm_suspend() sometimes returns -EBUSY, but doesn't tell us why.
Print dev_wake and pending_pkts when it does.
--- drivers/bus/mhi/host/pm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/bus/mhi/host/pm.c +8 -1
@@ -871,8 +871,12 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)/* Return busy if there are any pending resources */ if (atomic_read (&mhi_cntrl->dev_wake) || -atomic_read (&mhi_cntrl->pending_pkts)) +atomic_read (&mhi_cntrl->pending_pkts)) { +dev_err (dev,"DEBUG: suspend busy (early): dev_wake: %d pending_pkts: %d\n" , +atomic_read (&mhi_cntrl->dev_wake), +atomic_read (&mhi_cntrl->pending_pkts));return -EBUSY ; + }/* Take MHI out of M2 state */ read_lock_bh (&mhi_cntrl->pm_lock);
@@ -900,6 +904,9 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)if (atomic_read (&mhi_cntrl->dev_wake) ||atomic_read (&mhi_cntrl->pending_pkts)) {write_unlock_irq (&mhi_cntrl->pm_lock); +dev_err (dev,"DEBUG: suspend busy (recheck): dev_wake: %d pending_pkts: %d\n" , +atomic_read (&mhi_cntrl->dev_wake), +atomic_read (&mhi_cntrl->pending_pkts));return -EBUSY ; }
Signature · 1 line
2.45.2
Re: [PATCH v2 1/2] bus: mhi: pci_generic: Prevent MHI from aborting system suspend
In reply to Len BrownQuoted 16 lines · Len Brown
From: Len Brown <[email protected]>
mhi sometimes aborts system suspend on the thinkpad T16 gen3:
mhi-pci-generic 0000:08:00.0:
... failed to suspend device: -16
... PM:pci_pm_suspend():mhi_pci_suspend[mhi_pci_generic] returns -16 ... PM:dpm_run_callback():pci_pm_suspendreturns -16
... PM:pci_pm_suspendreturned -16 after 15145 usecs
... PM: failed to suspend async: error -16Prevent MHI from spreading this device-specific failure to the rest of the system. I.e. "Why is a modem that I don't use preventing me from suspending my laptop?"
Quoted 8 lines
This change does not comprehend the internal root cause of the mhi failure, which should be found and fixed.
There is also a risk that ignoring the MHI error and continuing to put the device into PCI D3 will leave it in an error state.
Fixes d3800c1dce24 ("bus: mhi: pci_generic: Add support for runtime PM")Signed-off-by Len Brown <[email protected]>
Quoted 25 lines
--- drivers/bus/mhi/host/pci_generic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/bus/mhi/host/pci_generic.c +6
-2@@ -1727,7 +1727,12 @@ static int __maybe_unused mhi_pci_runtime_resume(struct device *dev)static int __maybe_unused mhi_pci_suspend (struct device *dev) {pm_runtime_disable (dev); -return mhi_pci_runtime_suspend (dev); + +/* Ignore errors (e.g. -EBUSY); a failed modem suspend must not abort system suspend */ +mhi_pci_runtime_suspend (dev); + +/* Must return 0 to allow system suspend to continue */ +return 0 ; }static int __maybe_unused mhi_pci_resume (struct device *dev) --2.45.2