From nobody Tue Oct 7 13:28:37 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) (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 675A528AAEA; Thu, 10 Jul 2025 06:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752128636; cv=fail; b=TlBAkLpzKHf5hI6XRAJvGYmdlKMs+1KHP16b6mlX3A8vk+OM7+KULbS3s3ny5eerfaUWwh9iqN+5aKUfoc3dcPpg9PUDd96fGWvSdpEXebB/pjVAH3WPDe9sb22ihRN3/G4gNPJ06dPlb/V39t7sglYNsICZKgaqXMRkBPMjTno= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752128636; c=relaxed/simple; bh=EWnPHiNym8CswCixcZZ8L4CzNJoWiLM4yHPswEw6STs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uqhgbGTR+QmNW3W0KV6DOjXLv8tTFPI8DOvNvBGLnmQfM3emprZ5VOgFymzv06Ru34MrXscEdQ9zxxlztipqRPHffzfmbVpbN2koN7GMyjZHJOeSykFQFFLFj84IogHwah4MLy+APW8XH6cZ8wsABmsOXfba+7x6rrHOQ4vBiTI= 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=LQ9BLMrR; arc=fail smtp.client-ip=40.107.223.74 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="LQ9BLMrR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vJdH1D4w0BW78hWGFFro8poGhhro5Q1WTJe1tDDAFFBFFpfGXFv5J6BuKOof65c7ueGJ81pod2kRcXbES0y+rI5kakgq9RgD95Mcf673dB0BgUrSX2fW5wUw3bQjPgjaddfph8nPrV2G3oyx6k83JoBgvGvbAinOWGcUFlGgwH8J4KpGuZNrGwqnihqHS8RAz9Y49+x39qVFZ9vFr3QDO9IJQlpPFiUSMyNmdiL9zO2kznVAn5HuruOsLkY0QSqK1/bNcmuSchZBjNydr0uHsEenXjULNEcZkuOD3HDsFms9D69TpjMkGPpYtAzyDCQmr06ttHKre8wUX0jjziH+jw== 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=mhip2z1PdyAhIJEjRwtH8QTK2sEk2zYioa65zld3x5Q=; b=yK1r3z58P+Y+b7h3KeZmgwjfE3OvD53QmnjgyxZGdxWRNZ3Iu/3ht/nxZ2fv+sWS8yPpSQndesoLBmyEpsvUl3E9qZa1ma8oXC+/QT0mr6tqJutLBerP0vleFE+fC/B0/wgCnPK+ILQJl1SHJ9XdpGmaUht0a/+38OG4dz0DtssAEFom4OqkfLv8EgnwoDFYFTU6QCX++AgpB1ECaPT9T8wKWenZwNpKUUgrWlbibW1Sk9VL4pSrc3/ulqt9pfx5AUEYxppyJF4gw/AblJoyMvq5REjtO6ucdM/8AH3hxrNXSyEIK+x5tS0tuUbt0AhI5Gh4sGN7metoK21Zy/ioow== 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=mhip2z1PdyAhIJEjRwtH8QTK2sEk2zYioa65zld3x5Q=; b=LQ9BLMrRgqYCP8HfMzDh/FTxFjGTulIeZx4JlNEzyFbfxDjfYxev/5uDsoE34vG+mwTutpqy4Ut9MjStn93TwdXc7+AG2iGmJ5ZQkvNYcdUBOPx1GWGr1XZCvCn6+4Dxfdhh9YiIt9otu10NAytoB2P5dZUjsh8k/tOPSf/dgh0= Received: from PH2PEPF00003859.namprd17.prod.outlook.com (2603:10b6:518:1::7b) by DS2PR12MB9688.namprd12.prod.outlook.com (2603:10b6:8:27d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.25; Thu, 10 Jul 2025 06:23:52 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2a01:111:f403:f910::1) by PH2PEPF00003859.outlook.office365.com (2603:1036:903:48::3) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.21 via Frontend Transport; Thu, 10 Jul 2025 06:23:51 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 06:23:51 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Jul 2025 01:23:50 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Jul 2025 01:23:50 -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; Thu, 10 Jul 2025 01:23:45 -0500 From: Samuel Zhang To: , , , , , , , , , , , , , , CC: , , , , , , , , , , "Samuel Zhang" Subject: [PATCH v6 4/5] PM: hibernate: add new api pm_hibernate_is_recovering() Date: Thu, 10 Jul 2025 14:23:12 +0800 Message-ID: <20250710062313.3226149-5-guoqing.zhang@amd.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250710062313.3226149-1-guoqing.zhang@amd.com> References: <20250710062313.3226149-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 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|DS2PR12MB9688:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f0404d6-16d8-4283-cb23-08ddbf7a566c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9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N5oNCR5/DVrKTdXZeroxEDD?= =?us-ascii?Q?Z5hYKL26/o9R2zrhqcUknxcrnEYVuOfYd9WkI3n6x95Yxw5Jw4BPq8LRlmYE?= =?us-ascii?Q?z0ivwkVPuPqCsMyDHelkrlMqCt5LRtNiYqGQH/3VpMXKGhk1YKpVGrUEmGTW?= =?us-ascii?Q?l/dc3fEVLLhUDeb/6KZGxmQRfm4qh20ozzP3UtlrFeMIlllEeTUWrlpI+GCi?= =?us-ascii?Q?rfMFpbybxf+w9yhB4TTFMFrN7Wd7dstqAtQDUAcC8Ahjwx5JYOhwhiG+O2YE?= =?us-ascii?Q?AAGlXkKu4/YMKLhDi08HSb1BnHWK+/6Tla0h7C+3JlB1ypDzvCx01IMJ1HFQ?= =?us-ascii?Q?YD0MnHBPX16toPdSbk4YD2rnEf0w8YEqhezg2PgJOv+nBK4K4dZhGXwc8SaE?= =?us-ascii?Q?GcgwsihKh5OHeD34DUY0q4irRYA7UDo3OXjpSKlL/Y0YI89yXWKIokhh9z6H?= =?us-ascii?Q?XZG9LV4Ocg2yG6ZLKx6Rebc8mGQqasT60pBAWyz3LULQRtV+4igISN/Po7++?= =?us-ascii?Q?looMGlqRnwoggVfmH7HcoYWzIaBEKzpJ2a8i5A1OezmyvWFDONRfvORbAh3K?= =?us-ascii?Q?xYewBtXouEuC4knScOdnJwjuEu/jlXIv4Ys/B4M/J17f+HgegG4JuPN6ybyC?= =?us-ascii?Q?uQuRhW9qvB6SpYAhI3eKsi3XR06nnhrWO2ggrYiwppsmZqyNZvNhM5nlYA?= =?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:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 06:23:51.2520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f0404d6-16d8-4283-cb23-08ddbf7a566c 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9688 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_hibernate_is_recovering() is such a api to query if thaw() is called in normal case. Signed-off-by: Samuel Zhang Acked-by: Rafael J. Wysocki --- drivers/base/power/main.c | 14 ++++++++++++++ include/linux/suspend.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 24ebe7a635a7..c4817b379230 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -66,6 +66,20 @@ static pm_message_t pm_transition; static DEFINE_MUTEX(async_wip_mtx); static int async_error; =20 +/** + * pm_hibernate_is_recovering - if recovering from hibernate due to error. + * + * Used to query if dev_pm_ops.thaw() is called for normal hibernation cas= e or + * recovering from some error. + * + * Return: true for error case, false for normal case. + */ +bool pm_hibernate_is_recovering(void) +{ + return pm_transition.event =3D=3D PM_EVENT_RECOVER; +} +EXPORT_SYMBOL_GPL(pm_hibernate_is_recovering); + static const char *pm_verb(int event) { switch (event) { diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 6a3f92098872..d11a124b7a91 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -426,6 +426,8 @@ int is_hibernate_resume_dev(dev_t dev); static inline int is_hibernate_resume_dev(dev_t dev) { return 0; } #endif =20 +bool pm_hibernate_is_recovering(void); + /* Hibernation and suspend events */ #define PM_HIBERNATION_PREPARE 0x0001 /* Going to hibernate */ #define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */ --=20 2.43.5