From nobody Mon Feb 9 15:24:08 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 8230786337; Wed, 4 Jun 2025 03:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749006645; cv=none; b=a7NIfuGHvPn/s/OtYiBMcNJfI9PxyNiZWv9w6mQ8+KyTGGI/ogC62XUPeIEdYzoHiifZk0aKUFjy29lbgEokiJuI6LSwp2MvcyXtAQ/vIudnXfNrhmTFVF2ybI4jKwsXhwCdqORRIZvnrcGhFMqh2k8QBPCM69BuigGjOfq3Rkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749006645; c=relaxed/simple; bh=y2uzoZ5QOSb6Z3GzmpyquAH2fLVaaVeh57OqZC7M0X0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jSxR7lHaWzdPQMV1zIVldiWdyHXItBpOgFeQloAV9N9EX4TJIsqWZpJy/EXiRVsg/VQdveR0L5yEg6X5o3Ef/R3NKq2xsW5e4e+R+BzLcClPA9PklXv0lreYSHREz6M4lrfJKnYyZToEH0hpqiupgn2xvtca8Lmj0szH3Ttz6K0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 7c7a188640f111f0b29709d653e92f7d-20250604 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:b2d976f4-0b6b-4079-baee-20b183da6a7f,IP:0,U RL:0,TC:0,Content:0,EDM:-25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6493067,CLOUDID:44588aa358188fd8e5850a09b38d0a28,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:1,IP:n il,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LE S:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 7c7a188640f111f0b29709d653e92f7d-20250604 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1566144030; Wed, 04 Jun 2025 11:10:36 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 9D2FFE00891C; Wed, 4 Jun 2025 11:10:36 +0800 (CST) X-ns-mid: postfix-683FB92C-49256015 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 14F78E00891B; Wed, 4 Jun 2025 11:10:36 +0800 (CST) From: Zihuan Zhang To: rafael@kernel.org, pavel@kernel.org, len.brown@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v1 1/2] PM: suspend: Assign pm_suspend_target_state earlier for valid debug logs Date: Wed, 4 Jun 2025 11:10:23 +0800 Message-Id: <20250604031024.13093-2-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250604031024.13093-1-zhangzihuan@kylinos.cn> References: <20250604031024.13093-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pm_suspend_target_state is used in debug logs inside enter_state(), but it is only assigned inside suspend_devices_and_enter(), which is too late. This causes early pm_pr_dbg() output to either show incorrect state or nothing at all, making suspend debugging harder. Assign pm_suspend_target_state at the beginning of enter_state() to ensure early log output is meaningful. Signed-off-by: Zihuan Zhang --- kernel/power/suspend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 76b141b9aac0..16172ca22f21 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -584,6 +584,8 @@ static int enter_state(suspend_state_t state) if (!mutex_trylock(&system_transition_mutex)) return -EBUSY; =20 + pm_suspend_target_state =3D state; + if (state =3D=3D PM_SUSPEND_TO_IDLE) s2idle_begin(); =20 @@ -616,6 +618,7 @@ static int enter_state(suspend_state_t state) suspend_finish(); Unlock: filesystems_thaw(); + pm_suspend_target_state =3D PM_SUSPEND_ON; mutex_unlock(&system_transition_mutex); return error; } --=20 2.25.1 From nobody Mon Feb 9 15:24:08 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 2E03C86337; Wed, 4 Jun 2025 03:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749006649; cv=none; b=BxxZW+E5cNIn9trD1pSRcxnA/zBbCKcHZ3WI/FcwRd8o0Mrl5IuQdIjDkwLJoAR5k/gHJ6wweLaDs09z6H0wssS0M6Tlu6QZGckCFULT3ZoCAQj3Nz/itiRKoqaZcll9OfZVY025LdM8DRbQSJtlrRNPBpTeheYzgOUQHui89p0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749006649; c=relaxed/simple; bh=wkBwDWReUmC3WJ88+crUEMgmlSBBufXjXXl67nIvoRo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=okb3TJ9wPwyGW9GzzCtBOLcSakJw/9kZqbmqKKcRCQGVfqo9/G8QAyY+WSrW2JROYmTvTsFdyKiRcEnEPZJ5sfF3Gudfiv/+naJuDbORUZJumwrdVVyS9PgxAOmgZ02JsoJtCBL7V/erasCsPoHaRQczSLYOw+PC//qpyS58ty8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 7ebff8cc40f111f0b29709d653e92f7d-20250604 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:af640aba-a206-4dcb-88b9-2ce078e2ace6,IP:0,U RL:0,TC:0,Content:0,EDM:-25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6493067,CLOUDID:632c23e79c9f330fd9d664a4eb7f0627,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:1,IP:n il,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LE S:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 7ebff8cc40f111f0b29709d653e92f7d-20250604 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1464635936; Wed, 04 Jun 2025 11:10:40 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 6F2E2E00891C; Wed, 4 Jun 2025 11:10:40 +0800 (CST) X-ns-mid: postfix-683FB92E-82958516 Received: from localhost.localdomain (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 6671CE00891B; Wed, 4 Jun 2025 11:10:38 +0800 (CST) From: Zihuan Zhang To: rafael@kernel.org, pavel@kernel.org, len.brown@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Zihuan Zhang Subject: [PATCH v1 2/2] PM: suspend: Simplify state check using sleep_state_supported() Date: Wed, 4 Jun 2025 11:10:24 +0800 Message-Id: <20250604031024.13093-3-zhangzihuan@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250604031024.13093-1-zhangzihuan@kylinos.cn> References: <20250604031024.13093-1-zhangzihuan@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently enter_state() open-codes state validation using `if (state =3D=3D PM_SUSPEND_TO_IDLE) ... else if (!valid_state(state)) ...= `. This can be simplified by calling sleep_state_supported(), which already encodes this logic. This improves clarity and reduces duplication. Signed-off-by: Zihuan Zhang --- kernel/power/suspend.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 16172ca22f21..b95c7a80ef20 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -571,16 +571,10 @@ static int enter_state(suspend_state_t state) int error; =20 trace_suspend_resume(TPS("suspend_enter"), state, true); - if (state =3D=3D PM_SUSPEND_TO_IDLE) { -#ifdef CONFIG_PM_DEBUG - if (pm_test_level !=3D TEST_NONE && pm_test_level <=3D TEST_CPUS) { - pr_warn("Unsupported test mode for suspend to idle, please choose none/= freezer/devices/platform.\n"); - return -EAGAIN; - } -#endif - } else if (!valid_state(state)) { - return -EINVAL; - } + + if (!sleep_state_supported(state)) + return -ENOSYS; + if (!mutex_trylock(&system_transition_mutex)) return -EBUSY; =20 --=20 2.25.1