Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH net] net: wwan: iosm: fix S3 resume by re-binding the driver around it
@ 2026-11-16  3:11 David Westen
  2026-11-18 15:12 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: David Westen @ 2026-11-16  3:11 UTC (permalink / raw)
  To: netdev
  Cc: loic.poulain, ryazanov.s.a, johannes, andrew+netdev, davem,
	edumazet, kuba, pabeni, m.chetan.kumar, linux-kernel, mail,
	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, so the modem is
probed again once it has booted. Suspend-to-idle keeps the modem
powered and is still handled by the suspend/resume callbacks. The
target state isn't known yet when the PM notifier runs, so use the
default suspend mode to tell S3 from suspend-to-idle.

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:
    Tested on an XMM7360 (ThinkPad X1 Carbon 6th gen, deep sleep) with
    this patch applied to 7.2.15: after resume the modem is probed again
    and comes up without an ACPI reset. Not tested on the XMM7560.
    
    The investigation and the patch 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
    change and the changelog 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..ec27d6fd7910 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 loses power in S3 and S4 and boots 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;
 

base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
-- 
2.56.0


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

* Re: [PATCH net] net: wwan: iosm: fix S3 resume by re-binding the driver around it
  2026-11-16  3:11 [PATCH net] net: wwan: iosm: fix S3 resume by re-binding the driver around it David Westen
@ 2026-11-18 15:12 ` netdev-bot+sashiko
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-18 15:12 UTC (permalink / raw)
  To: davidlwesten
  Cc: netdev, loic.poulain, ryazanov.s.a, johannes, andrew+netdev,
	davem, edumazet, kuba, pabeni, m.chetan.kumar, linux-kernel, mail,
	stable

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 2 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] pm_notify() in drivers/net/wwan/iosm/iosm_ipc_pcie.c decides
  whether to unbind the driver on PM_SUSPEND_PREPARE by checking…
- [Medium] The changelog limits the problem to "platforms where S3 cuts
  power to the WWAN card".

Pre-existing issues:
- [High] ipc_imem_cleanup()
  (drivers/net/wwan/iosm/iosm_ipc_imem.c:1231-1266) cancels…

--

net: wwan: iosm: fix S3 resume by re-binding the driver around it

This patch extends pm_notify() in the iosm driver. When the default
suspend mode is not suspend-to-idle, the PCI driver is now unregistered
on PM_SUSPEND_PREPARE and registered again on PM_POST_SUSPEND. This is
the same approach the driver already uses for hibernation, and it means a
modem that lost power in S3 gets probed again after resume.

> diff --git a/drivers/net/wwan/iosm/iosm_ipc_pcie.c b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> index 49052eb511baa..ec27d6fd79100 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 loses power in S3 and S4 and boots again on resume, which
> +	 * the suspend/resume callbacks can't handle, so probe it again.
> +	 */

[Severity: Medium]
The changelog limits the problem to "platforms where S3 cuts power to the
WWAN card". This comment says the modem loses power in S3 everywhere. Is
that true on every iosm platform?

The condition below has no platform, PCI device ID or BIOS RTD3 check. It
therefore also covers INTEL_CP_DEVICE_7560_ID, which the notes say was not
tested.

The driver already treats modem sleep power as platform dependent:

drivers/net/wwan/iosm/iosm_ipc_pcie.c:ipc_pcie_read_bios_cfg() {
    ...
	if (object->integer.value == 3)
		sleep_state = IPC_PCIE_D3L2;
    ...
}

ipc_pcie_suspend_cb() and ipc_pcie_resume_cb() use that setting to pick
the D0L12 or D3L2 path. ipc_imem_pm_resume() also already re-reads the
exec stage:

	if (ipc_protocol_resume(ipc_imem->ipc_protocol)) {
		stage = ipc_mmio_get_exec_stage(ipc_imem->mmio);
		ipc_imem_phase_update_check(ipc_imem, stage);

Because the driver is now unbound before every S3, none of these paths can
run during S3.

Some platforms keep the M.2 slot powered in S3. On those, the endpoint has
no driver during suspend, so pci_pm_suspend_noirq() skips
pci_prepare_to_sleep(). The modem then stays in D0 with no PME armed.
Every S3 cycle would also destroy and recreate the WWAN netdevs and the
/dev/wwan* ports, and drop any active data sessions.

Could this be gated on ipc_pcie->d3l2_support or a platform check? And
since the patch is tagged Cc: stable, could the changelog mention this
change in behaviour?

> +	if (mode == PM_HIBERNATION_PREPARE || mode == PM_RESTORE_PREPARE ||
> +	    (mode == PM_SUSPEND_PREPARE && !pm_suspend_default_s2idle())) {

[Severity: Medium]
Can pm_suspend_default_s2idle() tell S3 apart from s2idle here? It only
reports which state the "mem" label maps to:

kernel/power/suspend.c:pm_suspend_default_s2idle() {
	return mem_sleep_current == PM_SUSPEND_TO_IDLE;
}

state_store() only looks at mem_sleep_current when the string is "mem":

kernel/power/main.c:state_store() {
    ...
		if (state == PM_SUSPEND_MEM)
			state = mem_sleep_current;
    ...
}

"freeze" and "standby" go to pm_suspend() as PM_SUSPEND_TO_IDLE and
PM_SUSPEND_STANDBY directly.

So take mem_sleep=deep with "freeze" or "standby" written to
/sys/power/state, or mem_sleep=shallow with "mem". The system enters
s2idle or S1 and the modem keeps power, but pm_notify() still calls
pci_unregister_driver(). That skips the ipc_pcie_suspend_cb() handling.
With no driver bound, pci_pm_suspend_noirq() then only does this:

	if (!pm) {
		pci_save_state(pci_dev);
		goto set_unknown;
	}

The endpoint stays in D0 with no PME armed. On PM_POST_SUSPEND the modem
is probed again even though it was never power cycled.

The reverse case also exists. Some callers invoke
pm_suspend(PM_SUSPEND_MEM) directly and never consult mem_sleep_current.
Examples are test_wakealarm() for test_suspend=mem,
drivers/char/apm-emulation.c,
drivers/firmware/arm_scmi/scmi_power_control.c and
drivers/soc/xilinx/zynqmp_power.c.

If the default is s2idle, could these paths enter real S3 without the
unbind? That would leave the original "PORT open refused, phase
A-CD_READY" failure reachable.

The changelog says "Suspend-to-idle keeps the modem powered and is still
handled by the suspend/resume callbacks". That doesn't match the cases
above.

>  		if (pci_registered) {
>  			pci_unregister_driver(&iosm_ipc_driver);

[Severity: High]
This is a pre-existing issue and was not introduced by this patch.
However, this teardown path used to run only on rmmod and hibernation.
With this patch it runs on every S3 cycle.

ipc_imem_cleanup() cancels four hrtimers, but not adb_timer:

drivers/net/wwan/iosm/iosm_ipc_imem.c:ipc_imem_cleanup() {
    ...
	hrtimer_cancel(&ipc_imem->td_alloc_timer);
	hrtimer_cancel(&ipc_imem->tdupdate_timer);
	hrtimer_cancel(&ipc_imem->fast_update_timer);
	hrtimer_cancel(&ipc_imem->startup_timer);
    ...
		ipc_mux_deinit(ipc_imem->mux);
    ...
	ipc_imem_device_ipc_uninit(ipc_imem);
    ...
}

With MUX_AGGREGATION (the 7560), the UL path arms adb_timer for 500 us
through ipc_imem_adb_timer_start(). PM_SUSPEND_PREPARE runs before tasks
are frozen, so UL traffic can still be flowing right up to teardown.

The sequence would be:

pm_notify(PM_SUSPEND_PREPARE)
  pci_unregister_driver()
    ipc_pcie_remove()
      ipc_pcie_cleanup()
        ipc_imem_cleanup()
          ipc_mux_deinit()
            kfree(ipc_mux), ipc_imem->mux is not cleared
          ipc_imem_device_ipc_uninit()
            usleep_range() for up to 30 ms, tasklet still alive

adb_timer fires
  ipc_imem_adb_timer_cb()
    ipc_task_queue_send_task(ipc_imem_tq_adb_timer_cb)

tasklet runs
  ipc_imem_tq_adb_timer_cb()
    ipc_mux_ul_adb_finish(ipc_imem->mux)    <- freed mux

Could this write into the freed iosm_mux through ul_adb->adbh, skb_put()
and channel->ul_list?

ipc_imem_cleanup() later does kfree(ipc_imem->ipc_task), and
ipc_pcie_deinit() then frees ipc_pcie->imem. If the timer were still
pending at that point, could the hrtimer embedded in the freed imem also
corrupt the timer base?

Should ipc_imem_cleanup() call hrtimer_cancel(&ipc_imem->adb_timer) along
with the other timers before this path runs on every S3?

>  			pci_registered = false;
>  		}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116031148.333990-1-davidlwesten%40gmail.com

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

end of thread, other threads:[~2026-11-18 15:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16  3:11 [PATCH net] net: wwan: iosm: fix S3 resume by re-binding the driver around it David Westen
2026-11-18 15:12 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox