Re: [PATCH v3 3/3] media: uvcvideo: skip streaming restart after hibernation snapshot

From: Laurent Pinchart

Date: Wed Jul 22 2026 - 16:06:42 EST


On Thu, Jun 18, 2026 at 09:31:33AM +0800, Haowen Tu wrote:
> 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.

Why is that desired (both the decision to only block the resume of the
video interface, and the decision to not block the next suspend) ?

> 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.

I don't think this sentence belongs to the commit message.

> 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;

--
Regards,

Laurent Pinchart