From: Haowen Tu <tuhaowen@uniontech.com>
To: rafael@kernel.org
Cc: 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,
tuhaowen@uniontech.com
Subject: Re: [PATCH v2 1/2] PM: hibernate: add pm_hibernation_snapshot_done() helper
Date: Tue, 2 Jun 2026 11:24:13 +0800 [thread overview]
Message-ID: <20260602032413.1540166-1-tuhaowen@uniontech.com> (raw)
In-Reply-To: <CAJZ5v0gvcsowJL0oqKqaG-VFinpb9Rj06KNOkG9XaQ+6wp0Ygg@mail.gmail.com>
Hi Rafael,
On Mon, Jun 01, 2026 at 08:22:00PM +0200, Rafael J. Wysocki wrote:
> On Thu, May 28, 2026 at 10:19 AM Haowen Tu <tuhaowen@uniontech.com> wrote:
> >
> > During hibernation, after create_image() saves the memory snapshot, the
> > kernel resumes devices with PMSG_THAW solely to write the hibernation
> > image to storage, then powers off. Drivers for hardware not involved in
> > storage I/O have no reason to reinitialize during this transient phase.
>
> They do have a reason for doing it.
>
> Their poweroff (or shutdown) callbacks will be called while preparing
> to power off the system subsequently and they need to be ready for
> that. The most straightforward way to achieve this is to resume so
> they can "suspend" again.
Thanks for pointing this out.
My understanding is that the hibernation image contains the state from
the snapshot point, that is before the subsequent THAW and image-write
phase. Therefore, on the later restore path, the kernel resumes from the
state captured at the snapshot point and still goes through the normal
PMSG_RESTORE resume path. The THAW activity after the snapshot is not
part of the restored image state.
That said, I agree that some devices may need to be resumed before the
final poweroff/shutdown callbacks run, so the wording in the changelog is
too broad. I did not mean to suggest that all non-storage devices can or
should skip THAW resume.
The helper is meant to expose this PM state, not to prescribe that
drivers should skip THAW resume. Whether a driver uses it would remain a
driver-specific decision, based on whether skipping the hardware
reinitialization is safe for that device, including its subsequent
poweroff/shutdown handling. Drivers that need the normal THAW resume
before poweroff/shutdown would simply not use it.
In this series the user is uvcvideo. For USB devices, and specifically
for UVC cameras, the device is hotpluggable and the driver already needs
to tolerate device removal and disconnect-like conditions. The UVC
driver also does not need the camera streaming engine to be restarted in
order to write the hibernation image, while restarting it has a visible
side effect by turning the camera LED back on. The check is placed after
the driver's frozen state is cleared, so if image writeout fails, the
driver is not left in the frozen state.
I will reword the changelog in the next version to avoid implying that
non-storage devices generally have no reason to resume during THAW.
> > Clear in_suspend before releasing snapshot memory on hibernation failure
> > paths and after swsusp_write() returns, so the helper does not report a
> > stale snapshot after the snapshot pages have been released.
>
> This last piece needs to be split off into a separate patch.
Sure, I will split the in_suspend cleanup into a separate patch in the
next version.
I will wait for your feedback before sending the next version.
Thanks,
Haowen
next prev parent reply other threads:[~2026-06-02 3:25 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 8:05 [PATCH 0/2] PM: hibernate: add helper to detect image-write phase Haowen Tu
2026-04-28 8:05 ` [PATCH 1/2] PM: hibernate: add pm_hibernation_storing_image() helper Haowen Tu
2026-05-26 13:43 ` Rafael J. Wysocki
2026-04-28 8:05 ` [PATCH 2/2] media: uvcvideo: skip resume when writing hibernation image Haowen Tu
2026-04-28 8:36 ` Oliver Neukum
2026-04-28 8:58 ` Haowen Tu
2026-04-28 9:13 ` Laurent Pinchart
2026-04-29 1:15 ` Haowen Tu
2026-04-29 1:16 ` Haowen Tu
2026-05-28 8:18 ` [PATCH v2 0/2] PM: hibernate: skip UVC resume after snapshot Haowen Tu
2026-05-28 8:18 ` [PATCH v2 1/2] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-06-01 18:22 ` Rafael J. Wysocki
2026-06-02 3:24 ` Haowen Tu [this message]
2026-06-18 1:31 ` [PATCH v3 0/3] PM: hibernate: skip UVC streaming restart after snapshot Haowen Tu
2026-06-18 1:31 ` [PATCH v3 1/3] PM: hibernate: clear in_suspend before freeing the snapshot Haowen Tu
2026-07-22 15:37 ` Rafael J. Wysocki (Intel)
2026-06-18 1:31 ` [PATCH v3 2/3] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-07-22 15:40 ` Rafael J. Wysocki (Intel)
2026-06-18 1:31 ` [PATCH v3 3/3] media: uvcvideo: skip streaming restart after hibernation snapshot Haowen Tu
2026-07-22 20:06 ` Laurent Pinchart
2026-07-23 1:39 ` Haowen Tu
2026-07-23 8:46 ` Laurent Pinchart
2026-07-29 7:11 ` [PATCH v4 0/4] PM: hibernate: defer UVC streaming restart after snapshot Haowen Tu
2026-07-29 7:11 ` [PATCH v4 1/4] PM: hibernate: clear in_suspend before freeing the snapshot Haowen Tu
2026-07-29 7:11 ` [PATCH v4 2/4] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-07-29 7:11 ` [PATCH v4 3/4] PM: hibernate: notify on image write failure Haowen Tu
2026-07-29 7:11 ` [PATCH v4 4/4] media: uvcvideo: defer streaming restart after hibernation snapshot Haowen Tu
2026-07-29 7:29 ` Hans de Goede
2026-07-29 7:56 ` Haowen Tu
2026-07-29 14:08 ` Alan Stern
2026-07-29 14:43 ` Oliver Neukum
2026-07-29 14:54 ` Alan Stern
2026-07-30 13:16 ` Laurent Pinchart
2026-07-30 14:29 ` Alan Stern
2026-07-30 15:38 ` Laurent Pinchart
2026-07-31 1:30 ` Haowen Tu
2026-09-03 2:14 ` [PATCH v5 0/4] PM: hibernate: skip unnecessary THAW resume Haowen Tu
2026-09-03 2:14 ` [PATCH v5 1/4] PM: hibernate: clear in_suspend before freeing the snapshot Haowen Tu
2026-09-03 2:14 ` [PATCH v5 2/4] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-09-03 2:14 ` [PATCH v5 3/4] PM: hibernate: allow devices to skip post-snapshot THAW Haowen Tu
2026-09-03 2:14 ` [PATCH v5 4/4] media: uvcvideo: skip post-snapshot hibernation THAW Haowen Tu
2026-05-28 8:18 ` [PATCH v2 2/2] media: uvcvideo: skip resume after hibernation snapshot Haowen Tu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260602032413.1540166-1-tuhaowen@uniontech.com \
--to=tuhaowen@uniontech.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=kernel@uniontech.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=oneukum@suse.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®