[PATCH v4 0/4] PM: hibernate: defer UVC streaming restart after snapshot

From: Haowen Tu

Date: Wed Jul 29 2026 - 03:30:21 EST


During hibernation, after the memory snapshot has been created, the
kernel resumes devices with PMSG_THAW to write the hibernation image.
USB interface resume callbacks do not receive the PM message, so UVC
cannot distinguish that intermediate THAW resume from the later RESTORE
resume by using its local callback arguments.

This series keeps in_suspend consistent with the lifetime of snapshot
memory, exports pm_hibernation_snapshot_done(), adds a hibernation image
write failure notification, and uses both in uvcvideo to defer restarting
streaming during the THAW phase after snapshot creation.

Unlike v3, the UVC patch now handles the image write failure path. The
driver records streams whose streaming restart was deferred. If image
writeout fails, PM sends PM_HIBERNATION_IMAGE_WRITE_FAILED after
swsusp_write() returns and before userspace is thawed, and uvcvideo
restarts those deferred streams. If the recovery restart fails, the
driver falls back to its existing streamoff error path so userspace is
not left waiting indefinitely.

Changes in v4:
- Add PM_HIBERNATION_IMAGE_WRITE_FAILED before userspace thaw on image
write failure.
- Update uvcvideo to defer streaming restart instead of just skipping it.
- Recover deferred UVC streams on image write failure.
- Carry Rafael's Acked-by tags on the two PM patches from v3.

Haowen Tu (4):
PM: hibernate: clear in_suspend before freeing the snapshot
PM: hibernate: add pm_hibernation_snapshot_done() helper
PM: hibernate: notify on image write failure
media: uvcvideo: defer streaming restart after hibernation snapshot

drivers/media/usb/uvc/uvc_driver.c | 56 +++++++++++++++++++++++++++++-
drivers/media/usb/uvc/uvc_video.c | 19 +++++++++-
drivers/media/usb/uvc/uvcvideo.h | 2 ++
include/linux/suspend.h | 3 ++
kernel/power/hibernate.c | 27 +++++++++++---
5 files changed, 101 insertions(+), 6 deletions(-)

--
2.20.1