From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A104235C684; Tue, 21 Jul 2026 21:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668867; cv=none; b=T9+xYlQuu/mXUaUv6SbrpplYoTe2F7aAMI9MHrhMR45bZLUOnUsEnvOy0oir1E4JtoDSWf6KTnP3LMrkIduivTQOxpRwgGxGBhzxMoE73/3kASqETsa64LPjjcL4fi137cPHuFgXPoeurfjNX/YW/m08t8xZ22DSjoZyIQtsiws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668867; c=relaxed/simple; bh=duE+T6X5OsgEef9krzYm+DYRG3XEKCEkKQVwXVns+S4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eSVgqaDQ2RqTpOcvP5+jum3Q0dasfcx3I+P1hWVks5ZhfmLb0GeMTCvI2n8KYnCrHmvTgnnQr1kmHgF2iWz//tRcFE8pXwtA8SN6orzkVVZ34bYVt9dOuS/tu3oqBRNa7XJHytoVskhP8o9ggWNeAY5vhByajciREOOR6STcow0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KrzZMTJv; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KrzZMTJv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C04921F000E9; Tue, 21 Jul 2026 21:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784668866; bh=c7K58nBEe8sjsLKJmfjZ0To2pxmWE26syxBtaNi3LtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KrzZMTJvizGaHsLxYIhYFApuicxpDd+dPVGzb4tEDtDM+QETjqvEZox91Jy+5SHYb hPeTSN8Jy70WBxx9OJ+hWFBzpr/unygl4Skn5pRWQ50zECP0nBVfMk3Qh+jlQz9eEU Wl+zMTlu8eficvOEV+6Gl/gKjOLuqiMlxH0KxE2U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiakai Xu , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.1 0331/1067] PM: sleep: Use complete() in device_pm_sleep_init() Date: Tue, 21 Jul 2026 17:15:32 +0200 Message-ID: <20260721152431.999467926@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiakai Xu [ Upstream commit 3855941f1e4069182c895d5093c5fa589f5b38bd ] Replace complete_all() with complete() in device_pm_sleep_init() to allow it to be called in atomic contexts without triggering a false-positive WARNING from lockdep_assert_RT_in_threaded_ctx() when CONFIG_PROVE_RAW_LOCK_NESTING is enabled. device_pm_sleep_init() may be called during device initialization while holding a raw_spinlock (e.g., from within device_initialize()), and complete_all() is unsafe in atomic contexts on PREEMPT_RT kernels. complete(), which is safe to call from any context, is sufficient here. complete_all() sets the completion count to UINT_MAX/2 (permanently signaled), while complete() increments it by 1. Since no threads can be waiting during device initialization, both are functionally equivalent. The completion is always reinitialized via reinit_completion() in dpm_clear_async_state() before each suspend/resume cycle. However, changing to complete() introduces a potential deadlock for devices with no PM support (dev->power.no_pm = true). Such devices are never added to the dpm_list and never go through dpm_clear_async_state(), so their completion is never reinitialized. A parent device waiting on a no_pm child across multiple suspend phases would consume the single-use token in the first phase and block forever in the second. Fix this by adding an early return in dpm_wait() when dev->power.no_pm is set, since no_pm devices do not participate in system suspend/resume. Fixes: 152e1d592071 ("PM: Prevent waiting forever on asynchronous resume after failing suspend") Signed-off-by: Jiakai Xu [ rjw: Subject adjustment ] Link: https://patch.msgid.link/20260523022314.2657232-1-xujiakai24@mails.ucas.ac.cn Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/base/power/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ef5157fc8dcc51..dc3d30860ef328 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -101,7 +101,7 @@ void device_pm_sleep_init(struct device *dev) dev->power.is_noirq_suspended = false; dev->power.is_late_suspended = false; init_completion(&dev->power.completion); - complete_all(&dev->power.completion); + complete(&dev->power.completion); dev->power.wakeup = NULL; INIT_LIST_HEAD(&dev->power.entry); } @@ -238,6 +238,10 @@ static void dpm_wait(struct device *dev, bool async) if (!dev) return; + /* Devices with no PM support don't use the completion. */ + if (dev->power.no_pm) + return; + if (async || (pm_async_enabled && dev->power.async_suspend)) wait_for_completion(&dev->power.completion); } -- 2.53.0