From: David Westen <davidlwesten@gmail.com>
To: netdev@vger.kernel.org
Cc: mail@maciej.szmigiero.name,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Sergey Ryazanov <ryazanov.s.a@gmail.com>,
Johannes Berg <johannes@sipsolutions.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Abdun Nihaal <nihaal@cse.iitm.ac.in>,
M Chetan Kumar <m.chetan.kumar@intel.com>,
David Westen <davidlwesten@gmail.com>
Subject: [PATCH net v2 2/3] net: wwan: iosm: fix the wait for the modem in the host sleep handshake
Date: Tue, 24 Nov 2026 09:26:26 -0800 [thread overview]
Message-ID: <20261124172627.41847-3-davidlwesten@gmail.com> (raw)
In-Reply-To: <20261124172627.41847-1-davidlwesten@gmail.com>
Before the ENTER_SLEEP message is sent, ipc_pm_wait_for_device_active()
waits for the modem to report itself active, but:
- it tests ap_state before it sets the bit that asks the tasklet for a
wake-up, so a wake-up in between is lost and the wait times out
- a wake-up that arrives after a timeout leaves the completion done, so
a later wait returns at once
- an -ERESTARTSYS return from the interruptible wait counts as success
Set the bit first, paired with a barrier in the tasklet, reinitialize
the completion before each wait, and wait uninterruptibly, like the
wait for the ENTER_SLEEP reply does.
Found by an AI code review agent, not reproduced. Tested on an XMM7360
with suspend-to-idle.
Fixes: be8c936e540f ("net: iosm: power management")
Signed-off-by: David Westen <davidlwesten@gmail.com>
---
drivers/net/wwan/iosm/iosm_ipc_pm.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_pm.c b/drivers/net/wwan/iosm/iosm_ipc_pm.c
index 413601c72dcd..c76cb9663039 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_pm.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_pm.c
@@ -72,19 +72,25 @@ bool ipc_pm_wait_for_device_active(struct iosm_pm *ipc_pm)
{
bool ret_val = false;
- if (ipc_pm->ap_state != IPC_MEM_DEV_PM_ACTIVE) {
- /* Complete all memory stores before setting bit */
- smp_mb__before_atomic();
+ /* Drop a completion left over from an earlier timeout */
+ reinit_completion(&ipc_pm->host_sleep_complete);
+ /* Complete all memory stores before setting bit */
+ smp_mb__before_atomic();
+
+ set_bit(0, &ipc_pm->host_sleep_pend);
+
+ /* Set the bit before testing ap_state, so that a wake-up after the
+ * test completes host_sleep_complete. Pairs with the barrier in
+ * ipc_pm_on_link_wake().
+ */
+ smp_mb__after_atomic();
+
+ if (ipc_pm->ap_state != IPC_MEM_DEV_PM_ACTIVE) {
/* Wait for IPC_PM_ACTIVE_TIMEOUT_MS for Device sleep state
* machine to enter ACTIVE state.
*/
- set_bit(0, &ipc_pm->host_sleep_pend);
-
- /* Complete all memory stores after setting bit */
- smp_mb__after_atomic();
-
- if (!wait_for_completion_interruptible_timeout
+ if (!wait_for_completion_timeout
(&ipc_pm->host_sleep_complete,
msecs_to_jiffies(IPC_PM_ACTIVE_TIMEOUT_MS))) {
dev_err(ipc_pm->dev,
@@ -130,6 +136,11 @@ static void ipc_pm_on_link_wake(struct iosm_pm *ipc_pm, bool ack)
ipc_cp_irq_sleep_control(ipc_pm->pcie, IPC_MEM_DEV_PM_ACTIVE);
+ /* Order the ap_state store before the bit test, pairs with
+ * ipc_pm_wait_for_device_active().
+ */
+ smp_mb();
+
/* check the consume state !!! */
if (test_bit(CONSUME_STATE, &ipc_pm->host_sleep_pend))
complete(&ipc_pm->host_sleep_complete);
--
2.56.0
next prev parent reply other threads:[~2026-11-24 17:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:26 [PATCH net v2 0/3] net: wwan: iosm: send the host sleep message on every suspend David Westen
2026-11-24 17:26 ` [PATCH net v2 1/3] net: wwan: iosm: reset the host PM state when the sleep handshake times out David Westen
2026-11-27 5:28 ` netdev-bot+sashiko
2026-11-27 18:56 ` David Westen
2026-11-24 17:26 ` David Westen [this message]
2026-11-24 17:26 ` [PATCH net v2 3/3] net: wwan: iosm: always send the host sleep message on suspend David Westen
2026-11-27 5:28 ` netdev-bot+sashiko
2026-11-27 19:07 ` David Westen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124172627.41847-3-davidlwesten@gmail.com \
--to=davidlwesten@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=m.chetan.kumar@intel.com \
--cc=mail@maciej.szmigiero.name \
--cc=netdev@vger.kernel.org \
--cc=nihaal@cse.iitm.ac.in \
--cc=pabeni@redhat.com \
--cc=ryazanov.s.a@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.