From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) (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 86BBE296BD3 for ; Thu, 18 Jun 2026 01:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.207.22.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781746368; cv=none; b=h/IdpPuowZ97vzxBoczpuVfo/IzsuDV9wSewOdOTvWHYLuVQR9j7dYAkzVvpUKL4R0tsTOboTC5++4FfnaglZqUPzZrU3JxxkzzVH5VfHFvwPboR03cvPdd8KPvne30JHhRQYcqgurExorbBroWK7EOuUjApilL1F2uqL62lQhs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781746368; c=relaxed/simple; bh=3cdZrQ+gMzRsEoUHwz0XvvxIhexenokN/Q0zcOGJlvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y/ibT2snsLCGIlz3mUvrISJaz8sBtSBmWebKkwfs/MjLEFTNJFW05ChSH7+EGeVT07BtytZWE8iIuXy5TvWVofDj4ycguesJxo2FCD3WMTT1zm4LbaGCEAjk0OvaBj1tsJa7KGyNdsusx1eYbKF5K6m5TyIIe5ZLjnOkgCQAalQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=jFRUei6A; arc=none smtp.client-ip=54.207.22.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="jFRUei6A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1781746326; bh=Ra1g4MXA5D0NhDjT7hmvSp+cfr8vAcLzgs85SXpwPE0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=jFRUei6AigW8e+nqguxlLjbNa6SI7OOP2ltAyjjv6wjKPAZJ1tn98Bm7HtlDsJbLG +qQlDc8/S/3W9iV4G4H9sMWQKXTmRZVT6xHi8b/7bPwhwswu322wflhXx7b7O2KDn4 9KqBiNJomgR6smWCYuIBpQwV80hFMVeQH3KvrpmM= X-QQ-mid: esmtpsz10t1781746314tf9685e16 X-QQ-Originating-IP: JHNYKEAbmnN9fprXduYE5hvJDTnHVbSiaOyiDAyODMU= Received: from localhost.localdomain ( [113.57.152.160]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Jun 2026 09:31:51 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 3410012867176178788 EX-QQ-RecipientCnt: 15 From: Haowen Tu To: rafael@kernel.org Cc: tuhaowen@uniontech.com, gregkh@linuxfoundation.org, hansg@kernel.org, kernel@uniontech.com, laurent.pinchart@ideasonboard.com, lenb@kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, mchehab@kernel.org, oneukum@suse.com, pavel@kernel.org, stern@rowland.harvard.edu Subject: [PATCH v3 2/3] PM: hibernate: add pm_hibernation_snapshot_done() helper Date: Thu, 18 Jun 2026 09:31:32 +0800 Message-Id: <20260618013133.1047270-3-tuhaowen@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260618013133.1047270-1-tuhaowen@uniontech.com> References: <20260602032413.1540166-1-tuhaowen@uniontech.com> <20260618013133.1047270-1-tuhaowen@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: esmtpsz:uniontech.com:qybglogicsvrsz:qybglogicsvrsz3b-0 X-QQ-XMAILINFO: MSstRF5C1p/jzRp3en0jaXVmohUQQ9IdST2YKhdNI3Sde9fyL3LThhX4 hj9DMxdPhEwW9qh7D5VIc0suO90+m7nooy8+PkPfw6UFuN8V/oMCMnvxNmbXsDrShtEgoXp CXItigae42ZgkEaV5oGipgPP+X3Lyhw8Sq6II3wuYCKN6KFxDka5EtIePmuTp5qjIwAsvm9 bgDmHmcluhaaoDTC2Liw7IKJNRF/7QNTMhh0SXiaFFti9kiAONgwr3bdff9jCfxEyPXKAiR gCOQ0iofanTzPC3nq3p7R5Fw9+OBe/9zk6NGUGJzwAUi54TY697u8+D6QyfszgpvSWQ7o+p f2EhEuBczSLXCRcCNQeOt5lyFJpljwgHo58rmAOjTKxrlFxYk0u+1Cw1jSPqOBD4SwmJ5eZ UxReXU47m72FD9n42grL/Wm9SYdbbGSNMQyRubJ5j75aSwOdJzvhVimcu+U/jiZPIUdygCM pyD+h4alnkhjGgi4u3F/frjXo12RciRl5BShP8PRRZQUzmW4lwYwHlyuXzwmc0VS1uW54Sx bYSCLq3hSxDyFTYEe9p91ItSzdEuqf6mouHRWi7GE69Uh5l0qBghFQFKsHRaprEglDrN6nc RbF0KN+5+hd+YhO8hfDpSDRWmHgDClPmKeIjR8xcWXi4fdf+SoTzw9hN/FJ0/3N5YLS149G 6JhXMi3eW3c2nUTKoJSPJBwqBcCjRuhkf3E8bNJ7cwB2S07LxuPkZqyDsl0uap6eC+prLTg R+Io/57XlKdVx26ctiQgZnoWgK93H+RygyTslspxW9xwuZ92bRjUskvUjLKaNDEJLnRb/jJ Hh9L1W2jd5p/tMnIJ4sKYzgoFTjcN1uaeZzNzXhoY1I/VtBNvGOzjOnX6GReTGck+jW51iI O74NmDFf5Ifn4Y77g1D2O/jRQjGcMUnEnCQrGGIx6amZBU5ZUzalFEp/JFeaeuUeHvJIm0w TDve6w7x+YJKA4hJLmSwaAqlyKAR3cSPpaImGSrspWGCVh+8NM7YmDBiTsStgofMsi7kz8I Xtku5HZpDvvIhm2+4Cpz69wMXZgHPZuX/sl7eCCRm5NmYQPXEIxbxRn4Gjz+zU3zVguAcyL vxSOY5wpRvSUKp/2tQGINg= X-QQ-XMRINFO: MSVp+SPm3vtSI1QTLgDHQqIV1w2oNKDqfg== X-QQ-RECHKSPAM: 0 Some subsystem resume callbacks do not receive the PM event and therefore cannot distinguish the PMSG_THAW phase after snapshot creation from the PMSG_RESTORE phase. Export pm_hibernation_snapshot_done() so a driver can query whether the hibernation snapshot has been created and is still available. The helper only exposes the PM state; callers remain responsible for ensuring that any device-specific behavior is safe, including subsequent poweroff or shutdown handling. The helper returns !!in_suspend. This variable is set before swsusp_arch_suspend(), cleared before the snapshot memory is released, and marked __nosavedata, so it remains clear on the restore path. Signed-off-by: Haowen Tu --- Changes in v3: - Split the in_suspend cleanup into a preceding patch. - Clarify that callers must account for poweroff/shutdown handling. - Drop extern from the new prototype. Changes in v2: - Rename pm_hibernation_storing_image() to pm_hibernation_snapshot_done(). include/linux/suspend.h | 2 ++ kernel/power/hibernate.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index b02876f1ae38..2cebbec3e2f7 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -393,6 +393,7 @@ extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); extern int hibernate(void); extern bool system_entering_hibernation(void); extern bool hibernation_available(void); +bool pm_hibernation_snapshot_done(void); asmlinkage int swsusp_save(void); extern struct pbe *restore_pblist; int pfn_is_nosave(unsigned long pfn); @@ -412,6 +413,7 @@ static inline void hibernation_set_ops(const struct platform_hibernation_ops *op static inline int hibernate(void) { return -ENOSYS; } static inline bool system_entering_hibernation(void) { return false; } static inline bool hibernation_available(void) { return false; } +static inline bool pm_hibernation_snapshot_done(void) { return false; } static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) { return -ENOTSUPP; diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 6d3e637c5a02..045d29f55011 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -113,6 +113,18 @@ bool hibernation_available(void) !secretmem_active() && !cxl_mem_active(); } +/** + * pm_hibernation_snapshot_done - check if a hibernation snapshot is available + * + * Return: %true if a hibernation snapshot has been taken and has not been + * released yet. + */ +bool pm_hibernation_snapshot_done(void) +{ + return !!in_suspend; +} +EXPORT_SYMBOL_GPL(pm_hibernation_snapshot_done); + /** * hibernation_set_ops - Set the global hibernate operations. * @ops: Hibernation operations to use in subsequent hibernation transitions. -- 2.20.1