From nobody Thu Sep 24 17:02:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2A8236EA88; Tue, 22 Sep 2026 01:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040285; cv=none; b=JdggTpeFMQEsmelCcCFddrCa+q5aJnEkVIKTQMM7DBSMo8J/Vwfn36M3UvcC4q8P46LEQiesBwwY87bTV5vNJyw+NiRpzSI3LC7sA+lF4XEGRyX44w0M6J6JkaGn9lvkRVqLuMTX2tU2z/dNJA7K+RETKfX2/tVAguFxUzecFzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040285; c=relaxed/simple; bh=9zCLaBHANTRL5xorvVG/TxnrCgCcu3PPyV46iQEFDPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E4unibMlpdsdR77rUEUf9R0B/9+Y6OExQVemh2qVvq/TcnoTH9ks57S21iDvC4cnHgIjgZNw6A0o30ll91AdnMQ57Eedwza03JYIscKVbFYY4SbDOJOlKUrbDULrGthZsCnTH9gwmYI8K0yZvC7/j9NfGo9WsqEXtISUOjAEaJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SE5WO0aR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SE5WO0aR" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4FFBAC2BCF7; Tue, 22 Sep 2026 01:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1790040285; bh=9zCLaBHANTRL5xorvVG/TxnrCgCcu3PPyV46iQEFDPU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SE5WO0aRgOy3iqpTBe8Hf3Wbk2EA2xnhn16DDeDCfmBl28FNT72u61gBE1i+u/pNh woUjQgR2IbIUIEjYUjk9LSdQ5ulA+VZWjQzM6sb7ijlSV6zA0WicyjECzz+bTWQyk7 zEkxU0iX+ZJ6Fe5V9om16UqMJBwYwcKgU8GFOkkK+cpyUbYO9dKeowOdu4BksX9Ocm hFAT2s3AMJ/e4T7odr0VO/QS9ltUKRIw9UYpYH/6QbeLyR4MFmtLXFpUMTXb+GJY2j xnpPLbHoTUbiWKgP9Ttr7ovru7lchH4qc262YNIzEpMabyu2UI982c6vFH3Z2kWtHC BRhA7iGGrLcIA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 271C8C982FC; Tue, 22 Sep 2026 01:24:45 +0000 (UTC) From: Jaidev Shastri via B4 Relay Date: Mon, 21 Sep 2026 21:24:42 -0400 Subject: [PATCH 1/2] PM: sleep: publish pm_transition with release semantics Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260921-mb-pm-main-v1-1-1d4cbd9d2b2c@vt.edu> References: <20260921-mb-pm-main-v1-0-1d4cbd9d2b2c@vt.edu> In-Reply-To: <20260921-mb-pm-main-v1-0-1d4cbd9d2b2c@vt.edu> To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Danilo Krummrich Cc: linux-pm@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, Jaidev Shastri X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790040284; l=3715; i=jaidevshastri@vt.edu; s=20260921; h=from:subject:message-id; bh=azdyUjMWNlvyw0fWXxRiaZkcMY5OCgItug2q1XG165w=; b=6VABRbjIMJcJxQBTxhBhk1XqpoAWb0JsYa9rkb5VV9NS+MSMw8qAdiMDgVPVMixaoOUY3aFkj sJY7Uv6cz0PBDbNMU9Ze44+p8qhRScze0mGb1kxLuSnpc3nHbSVoX1l X-Developer-Key: i=jaidevshastri@vt.edu; a=ed25519; pk=J7+xYJRlTPds+pv5hbqFFRqGCpDeJDzmZT1ggRwj7/0= X-Endpoint-Received: by B4 Relay for jaidevshastri@vt.edu/20260921 with auth_id=1044 X-Original-From: Jaidev Shastri Reply-To: jaidevshastri@vt.edu From: Jaidev Shastri Each dpm_*() phase function stores the current transition to pm_transition with a plain store before it schedules the asynchronous device callbacks. dev_pm_skip_resume() and pm_hibernate_is_recovering() read pm_transition.event from those callbacks, on other CPUs, with plain loads. Store the event with smp_store_release() and read it with smp_load_acquire(). Found with MBCheck, a static herd7-based memory consistency checker. Signed-off-by: Jaidev Shastri --- drivers/base/power/main.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index e130da428..bf4b4fd1b 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -78,7 +78,8 @@ static int async_error; */ bool pm_hibernate_is_recovering(void) { - return pm_transition.event =3D=3D PM_EVENT_RECOVER; + /* Pairs with the smp_store_release() in the dpm_*() phase functions. */ + return smp_load_acquire(&pm_transition.event) =3D=3D PM_EVENT_RECOVER; } EXPORT_SYMBOL_GPL(pm_hibernate_is_recovering); =20 @@ -682,10 +683,13 @@ static void dpm_watchdog_clear(struct dpm_watchdog *w= d) */ bool dev_pm_skip_resume(struct device *dev) { - if (pm_transition.event =3D=3D PM_EVENT_RESTORE) + /* Pairs with the smp_store_release() in the dpm_*() phase functions. */ + int event =3D smp_load_acquire(&pm_transition.event); + + if (event =3D=3D PM_EVENT_RESTORE) return false; =20 - if (pm_transition.event =3D=3D PM_EVENT_THAW) + if (event =3D=3D PM_EVENT_THAW) return dev_pm_skip_suspend(dev); =20 return !dev->power.must_resume; @@ -902,7 +906,8 @@ static void dpm_noirq_resume_devices(pm_message_t state) trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, true); =20 async_error =3D 0; - pm_transition =3D state; + /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ + smp_store_release(&pm_transition.event, state.event); =20 mutex_lock(&dpm_list_mtx); =20 @@ -1052,7 +1057,8 @@ void dpm_resume_early(pm_message_t state) trace_suspend_resume(TPS("dpm_resume_early"), state.event, true); =20 async_error =3D 0; - pm_transition =3D state; + /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ + smp_store_release(&pm_transition.event, state.event); =20 mutex_lock(&dpm_list_mtx); =20 @@ -1230,7 +1236,8 @@ void dpm_resume(pm_message_t state) =20 trace_suspend_resume(TPS("dpm_resume"), state.event, true); =20 - pm_transition =3D state; + /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ + smp_store_release(&pm_transition.event, state.event); async_error =3D 0; =20 mutex_lock(&dpm_list_mtx); @@ -1595,7 +1602,8 @@ static int dpm_noirq_suspend_devices(pm_message_t sta= te) =20 trace_suspend_resume(TPS("dpm_suspend_noirq"), state.event, true); =20 - pm_transition =3D state; + /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ + smp_store_release(&pm_transition.event, state.event); async_error =3D 0; =20 mutex_lock(&dpm_list_mtx); @@ -1798,7 +1806,8 @@ int dpm_suspend_late(pm_message_t state) =20 trace_suspend_resume(TPS("dpm_suspend_late"), state.event, true); =20 - pm_transition =3D state; + /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ + smp_store_release(&pm_transition.event, state.event); async_error =3D 0; =20 wake_up_all_idle_cpus(); @@ -2091,7 +2100,8 @@ int dpm_suspend(pm_message_t state) devfreq_suspend(); cpufreq_suspend(); =20 - pm_transition =3D state; + /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ + smp_store_release(&pm_transition.event, state.event); async_error =3D 0; =20 mutex_lock(&dpm_list_mtx); --=20 2.43.0 From nobody Thu Sep 24 17:02:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A29FA36D9F9; Tue, 22 Sep 2026 01:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040285; cv=none; b=k7yvIbDCxMq7YabYKsQdHCARdQ1lLZh1AUw12aat33vuCxAAYA7X4VTVYAKbAo/Gdi8VzI/mD5Lovb1HMVzbggrgT4klVhxhMpsOJymsG+3A6gz+DHSCgvscUXPDs7LMajIbQdOnPhdqXw5SbCPnB+bM/UWTRTlD1N8lNr9gstY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040285; c=relaxed/simple; bh=TQneHJ/bZcX6S+vxi41JFPQ6lhtFincFVc+Qnq9ZE70=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PE78GOr1tpnpRyj5HvM+Q2pgain8M/uop+QRhqxDBjOHMdTt5c7UBD7C9XCWMGFpWENuCl0zQUi5uQU0PPnDHt+5rYMMCe2ml7LdNeKDY0NeoLcuL/ZmOMupa2Z9sQvRX0M42e639zPHJ9W5ThGWa+v948K1AvZc/ePES2rxj7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hszhwrTb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hszhwrTb" Received: by smtp.kernel.org (Postfix) with ESMTPS id 59D13C2BCFC; Tue, 22 Sep 2026 01:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1790040285; bh=TQneHJ/bZcX6S+vxi41JFPQ6lhtFincFVc+Qnq9ZE70=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hszhwrTb+AFBfav2KeaK+MgjNsIzAr7Qzuh0daUpJNpDbeL5WVdP0UHdU3g9INExv 3iaDjzLsSGhIKrbM0yQFLqG5AGYnm7OpeSLCRZz5J4JV/w3L74vvLvgLlNTpS0vzQH rQ7xI+7Nsx2rFM6elWtM3rZlvNtYf9/qaJnmYb5sJ1FKvHNtdyF/KEeOmdHB1fg15A CkqEQun8BlVQI7Nkv1mZBmI/k43LFDe/2d/ZwR+xQhPLDKV9maZ130ULM3eKAsT1wi YEgyotZfRC/ssnQRpDbj2uZSbecBYLm5N4sl+WUUwRHWI7fFrhTTtjcWyxqNHiy/cQ XBe0qICAlwX4w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 340B8C982FE; Tue, 22 Sep 2026 01:24:45 +0000 (UTC) From: Jaidev Shastri via B4 Relay Date: Mon, 21 Sep 2026 21:24:43 -0400 Subject: [PATCH 2/2] PM: sleep: reset async_error with WRITE_ONCE() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260921-mb-pm-main-v1-2-1d4cbd9d2b2c@vt.edu> References: <20260921-mb-pm-main-v1-0-1d4cbd9d2b2c@vt.edu> In-Reply-To: <20260921-mb-pm-main-v1-0-1d4cbd9d2b2c@vt.edu> To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Danilo Krummrich Cc: linux-pm@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, Jaidev Shastri X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790040284; l=2514; i=jaidevshastri@vt.edu; s=20260921; h=from:subject:message-id; bh=FjB7xS3+qARVsXk4Wq7dhtfdezLpl2Z4zIUoXhuVxW8=; b=wtO0ax58zemrWNGn4XyWf2ptQ0cjYdcW4tMj3UNAN6Wk39c7xqXTdq8E+ji3J/vVTuRdPFV7C BSVjGs3F5cKBTnT0BotNoYF1ImhC3ECem01CQtDCmfE95vaLpYjgBH9 X-Developer-Key: i=jaidevshastri@vt.edu; a=ed25519; pk=J7+xYJRlTPds+pv5hbqFFRqGCpDeJDzmZT1ggRwj7/0= X-Endpoint-Received: by B4 Relay for jaidevshastri@vt.edu/20260921 with auth_id=1044 X-Original-From: Jaidev Shastri Reply-To: jaidevshastri@vt.edu From: Jaidev Shastri The device PM callbacks record failures with WRITE_ONCE(async_error, ...) and every reader uses READ_ONCE(), but the six phase functions reset the variable with a plain store before they schedule the asynchronous callbacks. Use WRITE_ONCE() for the reset so that every access to async_error follows the same convention. Found with MBCheck, a static herd7-based memory consistency checker. Signed-off-by: Jaidev Shastri --- drivers/base/power/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index bf4b4fd1b..24b56aaa3 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -905,7 +905,7 @@ static void dpm_noirq_resume_devices(pm_message_t state) =20 trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, true); =20 - async_error =3D 0; + WRITE_ONCE(async_error, 0); /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ smp_store_release(&pm_transition.event, state.event); =20 @@ -1056,7 +1056,7 @@ void dpm_resume_early(pm_message_t state) =20 trace_suspend_resume(TPS("dpm_resume_early"), state.event, true); =20 - async_error =3D 0; + WRITE_ONCE(async_error, 0); /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ smp_store_release(&pm_transition.event, state.event); =20 @@ -1238,7 +1238,7 @@ void dpm_resume(pm_message_t state) =20 /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ smp_store_release(&pm_transition.event, state.event); - async_error =3D 0; + WRITE_ONCE(async_error, 0); =20 mutex_lock(&dpm_list_mtx); =20 @@ -1604,7 +1604,7 @@ static int dpm_noirq_suspend_devices(pm_message_t sta= te) =20 /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ smp_store_release(&pm_transition.event, state.event); - async_error =3D 0; + WRITE_ONCE(async_error, 0); =20 mutex_lock(&dpm_list_mtx); =20 @@ -1808,7 +1808,7 @@ int dpm_suspend_late(pm_message_t state) =20 /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ smp_store_release(&pm_transition.event, state.event); - async_error =3D 0; + WRITE_ONCE(async_error, 0); =20 wake_up_all_idle_cpus(); =20 @@ -2102,7 +2102,7 @@ int dpm_suspend(pm_message_t state) =20 /* Pairs with the smp_load_acquire() in dev_pm_skip_resume(). */ smp_store_release(&pm_transition.event, state.event); - async_error =3D 0; + WRITE_ONCE(async_error, 0); =20 mutex_lock(&dpm_list_mtx); =20 --=20 2.43.0