* [PATCH net v2 1/2] net: wwan: iosm: cancel the ADB timer on cleanup
@ 2026-11-19 4:27 David Westen
2026-11-19 4:27 ` [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it David Westen
0 siblings, 1 reply; 4+ messages in thread
From: David Westen @ 2026-11-19 4:27 UTC (permalink / raw)
To: netdev
Cc: loic.poulain, ryazanov.s.a, johannes, andrew+netdev, davem,
edumazet, kuba, pabeni, m.chetan.kumar, linux-kernel, mail,
nihaal, David Westen, stable
ipc_imem_cleanup() cancels the other imem hrtimers but not adb_timer,
which the UL aggregation path arms for 500 us. If it is still pending
when the device is removed, its callback queues a task that finishes
the ADB on the freed MUX, and the hrtimer itself is freed with the
imem.
Cancel it along with the other timers.
Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support")
Cc: stable@vger.kernel.org
Signed-off-by: David Westen <davidlwesten@gmail.com>
---
Notes:
Build-tested, and run as part of this series on an XMM7360 that uses
MUX aggregation, so the timer is armed there. I haven't reproduced the
race itself.
It comes before the S3 fix in the next patch, which makes this teardown
run on every S3.
drivers/net/wwan/iosm/iosm_ipc_imem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c
index 4405c8531888..20f8da53a3ea 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_imem.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c
@@ -1239,6 +1239,7 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem)
hrtimer_cancel(&ipc_imem->tdupdate_timer);
hrtimer_cancel(&ipc_imem->fast_update_timer);
hrtimer_cancel(&ipc_imem->startup_timer);
+ hrtimer_cancel(&ipc_imem->adb_timer);
/* cancel the workqueue */
cancel_work_sync(&ipc_imem->run_state_worker);
base-commit: e203d8a4751d48aa00eda31e3b320ba8e0d47dbf
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it 2026-11-19 4:27 [PATCH net v2 1/2] net: wwan: iosm: cancel the ADB timer on cleanup David Westen @ 2026-11-19 4:27 ` David Westen 2026-11-22 20:01 ` Maciej S. Szmigiero 0 siblings, 1 reply; 4+ messages in thread From: David Westen @ 2026-11-19 4:27 UTC (permalink / raw) To: netdev Cc: loic.poulain, ryazanov.s.a, johannes, andrew+netdev, davem, edumazet, kuba, pabeni, m.chetan.kumar, linux-kernel, mail, nihaal, David Westen, stable 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 <davidlwesten@gmail.com> --- 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it 2026-11-19 4:27 ` [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it David Westen @ 2026-11-22 20:01 ` Maciej S. Szmigiero 2026-11-23 3:17 ` David Westen 0 siblings, 1 reply; 4+ messages in thread From: Maciej S. Szmigiero @ 2026-11-22 20:01 UTC (permalink / raw) To: David Westen Cc: loic.poulain, ryazanov.s.a, johannes, andrew+netdev, davem, edumazet, kuba, pabeni, linux-kernel, nihaal, stable, netdev On 19.11.2026 05:27, David Westen wrote: > 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. I think this re-binding should never happen on s2idle, even though S3 might be the default mem sleep method. It looks to me that the only remaining case here is the "opportunistic sleep" code which does not use mem_sleep_current (so won't be covered by pm_suspend_default_s2idle()) - but uses autosleep_state instead. > - 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. Are there any such pm_suspend(PM_SUSPEND_MEM) calls in the kernel (outside some test code)? > > Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support") > Cc: stable@vger.kernel.org > Signed-off-by: David Westen <davidlwesten@gmail.com> > --- > > 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; > Thanks, Maciej ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it 2026-11-22 20:01 ` Maciej S. Szmigiero @ 2026-11-23 3:17 ` David Westen 0 siblings, 0 replies; 4+ messages in thread From: David Westen @ 2026-11-23 3:17 UTC (permalink / raw) To: Maciej S. Szmigiero Cc: loic.poulain, ryazanov.s.a, johannes, andrew+netdev, davem, edumazet, kuba, pabeni, linux-kernel, nihaal, stable, netdev Hi Maciej, Thanks for the review! On 11/22/26 12:01 PM, Maciej S. Szmigiero wrote: > On 19.11.2026 05:27, David Westen wrote: >> - Entering suspend-to-idle or standby explicitly while the default is >> S3 also re-binds the driver. > > I think this re-binding should never happen on s2idle, even though S3 > might be the default mem sleep method. > > It looks to me that the only remaining case here is the "opportunistic > sleep" code which does not use mem_sleep_current (so won't be covered by > pm_suspend_default_s2idle()) - but uses autosleep_state instead. Agreed, that would be better. The problem is that the PM notifier isn't told the target state, and pm_suspend_target_state is only set after PM_SUSPEND_PREPARE, so the default was the closest the driver could get on its own. Covering both cases would need the PM core to make the target state available before the notifiers run, like pm_suspend_notify_state in your earlier S3 patch. Do you think that's needed for this fix, or would it be acceptable as a follow-up? >> - 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. > > Are there any such pm_suspend(PM_SUSPEND_MEM) calls in the kernel (outside > some test code)? I found a few: APM emulation, pseries, via-pmu, ZynqMP, SCMI power control and the SPI slave system control driver. None of them seem to be x86 ones. David ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 3:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-19 4:27 [PATCH net v2 1/2] net: wwan: iosm: cancel the ADB timer on cleanup David Westen 2026-11-19 4:27 ` [PATCH net v2 2/2] net: wwan: iosm: fix S3 resume by re-binding the driver around it David Westen 2026-11-22 20:01 ` Maciej S. Szmigiero 2026-11-23 3:17 ` David Westen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox