[PATCH v3 3/3] media: uvcvideo: skip streaming restart after hibernation snapshot
From: Haowen Tu
Date: Wed Jun 17 2026 - 21:33:07 EST
After the hibernation snapshot is created, devices are resumed with
PMSG_THAW before the image is written and the system is powered off.
Restarting an active UVC stream during this phase reinitializes the
camera and visibly turns its indicator LED back on.
Skip only the UVC streaming hardware restart while the snapshot is
available. The driver's frozen state and clock are still updated before
the check, and a subsequent UVC suspend can stop the stream and select
alternate setting 0 as usual. uvcvideo does not provide a shutdown
callback that requires the streaming hardware to be restarted first.
This is a device-specific use of pm_hibernation_snapshot_done(). The
helper does not cause other drivers or USB core to skip THAW resume.
Tested with hibernation image written to local storage and resumed from
disk on a system with a USB UVC camera attached; the camera LED remains
off during image writing and the video stream resumes correctly after
restore.
Signed-off-by: Haowen Tu <tuhaowen@xxxxxxxxxxxxx>
---
Changes in v3:
- Clarify that only the UVC streaming hardware restart is skipped.
- Explain the subsequent UVC suspend and shutdown handling.
Changes in v2:
- Use pm_hibernation_snapshot_done() after the PM helper was renamed.
- Move the check after clearing the frozen state and resetting the clock.
drivers/media/usb/uvc/uvc_video.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index f6c8e3223796..1744298f4b1f 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -12,6 +12,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/suspend.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/videodev2.h>
@@ -2151,6 +2152,13 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset)
if (!uvc_queue_streaming(&stream->queue))
return 0;
+ /*
+ * Avoid restarting the streaming hardware during the transient THAW
+ * phase after a hibernation snapshot has been created.
+ */
+ if (pm_hibernation_snapshot_done())
+ return 0;
+
ret = uvc_commit_video(stream, &stream->ctrl);
if (ret < 0)
return ret;
--
2.20.1