Article View: linux.kernel.netdev
Article #21984[PATCH net v2 2/3] net: wwan: iosm: fix the wait for the modem in the host sleep handshake
From: David Westen
Date: Tue, 24 Nov 2026 17:26
Date: Tue, 24 Nov 2026 17:26
76 lines
13793 bytes
13793 bytes
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
Technical Details
Message-ID:
<20261124172627.41847-3-davidlwesten@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370619-linux-kernel-netdev=dewy.ruReferences:
<20261124172627.41847-1-davidlwesten@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370619-linux-kernel-netdev=dewy.ru
From: davidlwesten@gmail.com (David Westen)
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <20261124172627.41847-3-davidlwesten@gmail.com>
References: <20261124172627.41847-1-davidlwesten@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="4190009"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ZQA9m6qSkhNA/64wyqEwHxqAV+A= sha256:k7NFRHxviP0rNWlcbYvmfRg9v/wCMuTTYWhiDRYRiUs=
sha1:32ErFtXglURcILP+a0QNencMpKA= sha256:/2UN+soNEnATjF2E0jecv2ehrqx6BY/nYEOuqAh0wNk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id A565D125E2D; Tue, 24 Nov 2026 20:27:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 4F_xLR5AaHIj;
Tue, 24 Nov 2026 20:26:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370619-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 62264125E29; Tue, 24 Nov 2026 20:26:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 4E9CA38936; Tue, 24 Nov 2026 17:26:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795541197;
b=OymVennCZVGBChAmDxpwtAlWv3o/QOMTN673WWj2sBMLfmDYSkhIFo7QlfRw1VXshMMj
5vBBABHNWlmq+Iraw3khTMg+rcdirFIGhEUQUwlNWAtnYqAMQFJRbCo8dKa3lBup1+DtG
ff2Pn7NDTdAlV3LF97Nss/8S8UopFQTFh252kDzSMMDQscZRgPB+MjiOTyABhoI5rXxWW
oD+eUfIefvaSCPfDXkliibujKsXW9X8sN3ZGXYbh6QBIRfi/TQNOhp7KcDcqN8H9fTFzG
raPjhpX8Gx0AeuBNXAdACOvKdr8QjDOURDZolJXen7hlftUYQCIybYluXMPDYlwrefQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795541197;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=FpWUGjcPMl9tABfpkKC4qXoGZbOjyu2JY/vXM9uQYgU=;
b=nGOt8fb8pLIiVR7b38aXJIgEXZHIDf9RtbK5K+iocFzO3y3PEBqfQDXySmc6cuWliH++
CbrkOM5VmD1pOTJmiQBKZO4mQDsFqwQ4+6lBocx7+h/jVFI7A8qY+td64DD3vt+a0lkDE
b0RAcrfuCBENgG8QUlHnTl3ViGd0TH3GniuemF7oQ6JE2YS7dYQ0Qhl3qGb4d2hrl+mFn
I7vrqQrWplD2q4POxsCoI9eR7m/Wrn42TgoFvltfcAg/hxmGiGdnRSGTT9FnXDv8IOFjm
s9fPKUK9JLDlf6hKid86iJ+MOkKXz2OMROWc+fsrJ3VjYhkYunfgNchXmD9PkC+0+DA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hjQo36Vm;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 24798606A326;
Tue, 24 Nov 2026 17:26:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hjQo36Vm
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.181
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795541196;
b=dpZc+OOZD8Hyw9/IX39mCSjTCRoAUHjIcf6E3Mv3sCoBQ6I6RCP9X4dBPnCoIbY9V7XI
S8x/FmX7t2YdbINpR/DDDhU5mYi8A3kQLkot6iXPUynj5ibgrH9E8gtDVXoQ0tfAGWeXW
uyrUaTNzPoy55AajCjHAFI/buo7p4NHWmEkAbJq8f57g0ouFEKi3YfzuC08Ab4QR+d1mP
n2cpaeY2ALLc7YvhncdIvHDPi438ACPn6kAN5BV8SYnu6at10SEW3QCgwl/CUqHCDgBL+
XJ+h8ucUm2QaCUvlB37w1N/ZlxMTMkS+N78d3SVfSB1+MCnd2KDv6N+z/C8rcCVSFrw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795541196;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=FpWUGjcPMl9tABfpkKC4qXoGZbOjyu2JY/vXM9uQYgU=;
b=ROBBAc+OoyDLEzkJkz1xMmmMN+BGtoFEw4P3/iDXh8Db5pwH7lZXiWnJtfpcCvji0Pef
85Nvfbg34pzg9GGsFCjD33rLGqxjqmzGxKW7WqiEEirOorY3TnOjLP+wmhvqXVb0duhDI
Q12i6l5VH+ikE+Y6UC9MF2IFG1dMu5sC5lHQ2k6wupBDS+Myf1v5sIGxt5Sa1IRtq/SMp
mr0uA/W05F9/huXB6iTCox81W9Xon6zSxyJm/8W9QO92f92pEFl2oLRfIS1JgfZ2vvwq9
As709yrjSHiZnFdv1USn+ZhDOg9vsJe167q4IAQutTS1PLIoL+VL6pGdJY1YSrHyLiA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hjQo36Vm;
arc=none smtp.remote-ip=209.85.214.181
X-Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7492606A330
for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 17:26:35 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7492606A330
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2f04ad2c46dso28539375ad.2
for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 09:26:35 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795541195; x=1796145995; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=FpWUGjcPMl9tABfpkKC4qXoGZbOjyu2JY/vXM9uQYgU=;
b=hjQo36Vmposs2on1n6HQ97KnO55dvR2Pepn+qh301mQXFpC/BppNqNm8HdTmIjjg2j
bkjx9N5oPrsgnq2qyckPqSsXgIun0w1J9UQVkBitJULo54QN1V1zq0zbZMJBD80aWfnQ
d9/gu8wWJLbpYf4Nd1qsOhOOzStekEJ8CK0joA8HpmMsKVhQycfutV/04VPLUW/31Qxt
WoldKUwz53rycmknKLP4Xs1l5LHcRddIrKgXsAMAbGMQYLkdpB37a2IdsLa2lqi4TfzR
z+Zc3xWCpPEBTiorA+F5vimSGq7+k/8kwPL/7bzAzgyof8EWV93OTjKFYo/yYvF7JqCO
mDLA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795541195; x=1796145995;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=FpWUGjcPMl9tABfpkKC4qXoGZbOjyu2JY/vXM9uQYgU=;
b=UmEqoszuhM/bVVxNO5CJ+g73DZoX4lwFPYClkN9+SbwfggbVbdGq/Wr1rxa0qfc4jz
0om4MfaENDWw9UHQgAPSFtTb5W0W8swFxHRyfRnYdQ/8K2DLqLicc3BRlX0ERTw2jcPM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-2f03f1e0d4amr151002195ad.54.1795541195221;
Tue, 24 Nov 2026 09:26:35 -0800 (PST)
X-Received: from x1.hsd1.wa.comcast.net ([2601:600:a482:7d70::b4f9])
by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f04f8aca00sm63052795ad.38.2026.11.24.09.26.34
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 24 Nov 2026 09:26:34 -0800 (PST)
X-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>
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261124172627.41847-1-davidlwesten@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list