From nobody Tue Oct 7 19:26:33 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) (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 5996E29ACF6; Tue, 8 Jul 2025 07:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751961110; cv=fail; b=kH6oZ37IKvBpXQ3piYTJwruHhOnnpbwphvJdWP6mh5ZGLReDlQ9ZZMTBwOKdsGOwnsE57zD36RedpowStMLi8mO96W7E1ScREZsw2BemkR5xGD+sMfF/mbJdJCksnUpHpoqps9p/rsksQOjokxqmsd64MltMq4G/uoIfhu90xYc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751961110; c=relaxed/simple; bh=Ii4xOTze/jRpA51AM6oyoV2pRMaj765JlPRChupbZ3Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=akzligLhM80xurLf2QPkSlq4N1SK5TGkHatFz7yCm4Gl0vMZRPA80PNJ49VQlVm9EeQcAnoPQB2rFi9THmncrdZedflvnh0e37HOwWfOXBg0U93XXuAD3uOMoit3yV4j3VESiwB5aWxxIQcAzSWAC5y4WiYzIE4qUGAg6IWWKt8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=u1l/KZC5; arc=fail smtp.client-ip=40.107.94.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="u1l/KZC5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hGq4uWCK1QfU1QCFS3sptApn3aYgf9J3Hq/wWeBSTGfX1zmWC09JX9UYadQwQlwoqI5M8+cPrz9u4tCfDcmjvKyeEEuWGVXyeEJC8THEOC1UEEvD81+IhjThuDiGV1rNf94iUpZUXsNkigX5UT/F0/0/Nk1Tb0pxbtBfPK/Eb6Q97snOhoVvVKXXU7dS+EJ3JNdSr6KwAPVVwyP5exmdYlkJRDx43qu2Gxda1hNPZSla+GAPYJkbFH5U68x2xFMmCXUOFaeR4jF7EpOjJ/3NnpoHVRdyGfrxfBrgQye06dSwjnCgXb+ynNrcFcpC00EZYZn3yMhFxlP5oFv/NIfGTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xym4mZavriymwDV6mHeMq+tNK9ckXmzB+clUJPzQqXM=; b=dMuoatZqucOff3ZeWXGhsjb4mfUDNfmqMA6WWk6WfR749B6XF6XPv9pC7pqhm/9zJPFxgKk97lcJNx5uZrmhOHMCQBKYsgCZY+DvqcFbwSOCgaZVEc+j3VzwuYnj7BwR+KJc/Roab1Pqno8VYlKm4Oex5wVHPifWSkorOUdYSXR2IIqu8tqPPQdycRbVLVfrIFHemkUPXWP6zxMDZ6flwTk2zefRzWovyZVjZyIoQu5Ix1UYTNFMBkPFYkU8RUle2M1NaC+21ZM93EtFHoQs3UsBiZHd0Bb7MhHIqYxkkPVRSRYprxvrdU5nr3rvLfR5eg5kkShemczG9rDlKH/eLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xym4mZavriymwDV6mHeMq+tNK9ckXmzB+clUJPzQqXM=; b=u1l/KZC5o8wI/ug0OrXzaYOuZxpOeI32gCAPf1ND6+9c3qXvA30hKNYkckhUDCx6PTiCnI1g7Ek5076G0+fuWiUswJy4NeUiddGcLg3I11n46HIyFTcFagwA2dMpqGk9U+kZNNndWEFPnAGtG8NcOiVQ8rmL13MNl/4uivW961o= Received: from CH2PR11CA0015.namprd11.prod.outlook.com (2603:10b6:610:54::25) by BY5PR12MB4163.namprd12.prod.outlook.com (2603:10b6:a03:202::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.24; Tue, 8 Jul 2025 07:51:46 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:610:54:cafe::1b) by CH2PR11CA0015.outlook.office365.com (2603:10b6:610:54::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.27 via Frontend Transport; Tue, 8 Jul 2025 07:51:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.20 via Frontend Transport; Tue, 8 Jul 2025 07:51:45 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 8 Jul 2025 02:51:44 -0500 Received: from hjbog-srdc-41.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 8 Jul 2025 02:51:39 -0500 From: Samuel Zhang To: , , , , , , , , , , , , , , CC: , , , , , , , , , , "Samuel Zhang" Subject: [PATCH v3 4/5] PM: hibernate: add new api pm_transition_event() Date: Tue, 8 Jul 2025 15:42:47 +0800 Message-ID: <20250708074248.1674924-5-guoqing.zhang@amd.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250708074248.1674924-1-guoqing.zhang@amd.com> References: <20250708074248.1674924-1-guoqing.zhang@amd.com> 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 Received-SPF: None (SATLEXMB04.amd.com: guoqing.zhang@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|BY5PR12MB4163:EE_ X-MS-Office365-Filtering-Correlation-Id: 75e8bc69-454b-4b2f-283e-08ddbdf4495e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3l79lFPZ2GZvQMuKFCrXroNydL5O94MTrl0ir3RpYBR7zuHylKaobASKJmX7?= =?us-ascii?Q?8jhO9CrPVJnwUWxgvyS+TTnXE+fR9ZfDMU0u3jHC4YYM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?gG0iNuThfBmmOLXgGuZcIMoBw/PjTKNFegIwtBUZUG0VbqA1Dnv7NH7I3enL?= =?us-ascii?Q?u1CYBfHtCGz1Tfpa3YmcJI3/nS+uJjlwBXci7w0KzOCbdZFS8VciNVXZrNnf?= =?us-ascii?Q?F5wRreoCur1EMNWBJDugamaXv23knOdh8iRPvUlTPYQuNDi7+O1JZbQAOdFG?= =?us-ascii?Q?4kiltLbCBAQwbSvELfNpnTXbdymAgNbcxCWKg2n09jDTu/Y9iKa6SrkzUMKa?= =?us-ascii?Q?6+SwLARaUBunErvVMnyj6B6luWRbEHlBYOftTAPZbSlJMv2q5TU1r1bzCz7Y?= =?us-ascii?Q?c30gXFQoDAfh2xJxrjtBgzScOc89ogt77Fg2bCJpXrQZmLNH/kEmL6gfajpq?= =?us-ascii?Q?+rzJH0YzNULhiIeoyuRGUoJGr23XFTQKSeTXB2/Kxv3cftyfoRvi0a7ll8RR?= =?us-ascii?Q?j9DlJEdgBDuFg724v0yI40TMac5i7kmZB1ZXSFergdlIZOJoo5vNbjpI3+2i?= =?us-ascii?Q?9jROOnfhPaap1sWlec6AeERVr9b/4WpUKINmAULm1kYvFYPtLezRFr+c44py?= =?us-ascii?Q?zw5QuIdM5MrhJzGEC/iRiV5KA0iX5bGcHLmJH04MfTQMA/4thVcU1IHV+g?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2025 07:51:45.6310 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75e8bc69-454b-4b2f-283e-08ddbdf4495e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4163 Content-Type: text/plain; charset="utf-8" dev_pm_ops.thaw() is called in following cases: * normal case: after hibernation image has been created. * error case 1: creation of a hibernation image has failed. * error case 2: restoration from a hibernation image has failed. For normal case, it is called mainly for resume storage devices for saving the hibernation image. Other devices that are not involved in the image saving do not need to resume the device. But since there's no api to know which case thaw() is called, device drivers can't conditionally resume device in thaw(). The new pm_transition_event() is such a api to query if thaw() is called in normal case. The returned value in thaw() is: * PM_EVENT_THAW: normal case, no need to resume non-storage devices. * PM_EVENT_RECOVER: error case, need to resume devices. Signed-off-by: Samuel Zhang --- drivers/base/power/main.c | 5 +++++ include/linux/pm.h | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 40e1d8d8a589..7e0982caa4d4 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -62,6 +62,11 @@ static LIST_HEAD(dpm_noirq_list); =20 static DEFINE_MUTEX(dpm_list_mtx); static pm_message_t pm_transition; +int pm_transition_event(void) +{ + return pm_transition.event; +} +EXPORT_SYMBOL_GPL(pm_transition_event); =20 static int async_error; =20 diff --git a/include/linux/pm.h b/include/linux/pm.h index 78855d794342..d1cb77ede1a2 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -657,6 +657,22 @@ struct pm_subsys_data { #define DPM_FLAG_SMART_SUSPEND BIT(2) #define DPM_FLAG_MAY_SKIP_RESUME BIT(3) =20 +/** + * pm_transition_event() - Query the current pm transition event value. + * + * Used to query the reason why thaw() is called. It will be one of 2 valu= es: + * + * PM_EVENT_THAW: normal case. + * hibernation image has been created. + * + * PM_EVENT_RECOVER: error case. + * creation of a hibernation image or restoration of the main memory + * contents from a hibernation image has failed. + * + * Return: PM_EVENT_ messages + */ +int pm_transition_event(void); + struct dev_pm_info { pm_message_t power_state; bool can_wakeup:1; --=20 2.43.5