On platforms where S3 cuts power to the WWAN card, the modem boots again while the system sleeps, but the driver still treats it as running. After resume its execution stage reads BOOT, and by the first port open the boot code has crashed into the CD_READY stage: iosm 0000:03:00.0: PORT open refused, phase A-CD_READY The modem then stays unusable until an ACPI reset. Unbind the driver before S3 and bind it again after resume, as commit 0b6f6593aa8c ("net: wwan: iosm: Fix hibernation by re-binding the driver around it") already does for hibernation. The driver is then torn down while the modem still answers, and the modem is probed again once it has booted. The target state isn't known yet when the PM notifier runs, so the default suspend mode decides: the driver is re-bound unless "mem" maps to suspend-to-idle, which keeps using the suspend/resume callbacks. This changes behavior in a few cases: - On platforms that keep the card powered in S3, the modem is now probed again on resume, which drops data sessions and recreates its ports. - Entering suspend-to-idle or standby explicitly while the default is S3 also re-binds the driver. - A suspend to S3 that calls pm_suspend(PM_SUSPEND_MEM) directly while the default is suspend-to-idle is not covered and fails as before. Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support") Cc: stable@vger.kernel.org Signed-off-by: David Westen --- Notes: Changes in v2: - New patch before this one: cancel the ADB timer in ipc_imem_cleanup(). - Describe the changes in behavior and the remaining limits in the changelog, and say in the comment that the modem "may" lose power. - I also tried detecting the power loss on resume instead; my reply to the v1 review explains why v2 keeps unbinding before suspend. - Correction to that reply: the XMM7360 here does use MUX aggregation (CP capability 0x300), so the ADB timer is armed on it too. v1: https://lore.kernel.org/r/20261116031148.333990-1-davidlwesten@gmail.com Tested on an XMM7360 (ThinkPad X1 Carbon 6th gen, deep sleep) with this series applied to 7.2.15: the driver is unbound before suspend, and after resume the modem is probed again and comes up without an ACPI reset. Not tested on the XMM7560. The investigation and the patches were done with an AI coding assistant (Claude Opus 5.5). It read the driver and added temporary debug logging to record the execution stage around suspend and resume. We wrote the changes and the changelogs together, and I ran the tests. drivers/net/wwan/iosm/iosm_ipc_pcie.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_pcie.c b/drivers/net/wwan/iosm/iosm_ipc_pcie.c index 49052eb511ba..13e81012d818 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_pcie.c +++ b/drivers/net/wwan/iosm/iosm_ipc_pcie.c @@ -534,12 +534,17 @@ void ipc_pcie_kfree_skb(struct iosm_pcie *ipc_pcie, struct sk_buff *skb) static int pm_notify(struct notifier_block *nb, unsigned long mode, void *_unused) { - if (mode == PM_HIBERNATION_PREPARE || mode == PM_RESTORE_PREPARE) { + /* The modem may lose power in S3 and S4 and boot again on resume, + * which the suspend/resume callbacks can't handle, so probe it again. + */ + if (mode == PM_HIBERNATION_PREPARE || mode == PM_RESTORE_PREPARE || + (mode == PM_SUSPEND_PREPARE && !pm_suspend_default_s2idle())) { if (pci_registered) { pci_unregister_driver(&iosm_ipc_driver); pci_registered = false; } - } else if (mode == PM_POST_HIBERNATION || mode == PM_POST_RESTORE) { + } else if (mode == PM_POST_HIBERNATION || mode == PM_POST_RESTORE || + mode == PM_POST_SUSPEND) { if (!pci_registered) { int ret; -- 2.56.0