[PATCH 2/2] media: uvcvideo: skip resume when writing hibernation image

From: Haowen Tu

Date: Tue Apr 28 2026 - 04:08:15 EST


When a UVC camera is in active use and the system enters S4 hibernation,
the camera is suspended as part of the normal device freeze sequence.
However, after create_image() saves the memory snapshot, the kernel
briefly resumes all devices with PMSG_THAW to write the hibernation image
to storage. This causes uvc_video_resume() to run and reinitialize the
camera hardware, which visibly turns on the camera indicator LED during
this intermediate phase -- even though the system is about to power off.

The UVC device is not needed during the image-write window, where the
system only needs devices required for writing the hibernation image.
USB .resume callbacks do not receive pm_message_t (unlike .suspend),
so use the PM-layer helper to detect this phase and return early from
uvc_video_resume(), preventing the unnecessary hardware reinitialization
and the spurious LED activation.

Skipping the THAW resume is safe: stream->frozen remains 1 (set during
the earlier FREEZE suspend), the device is powered off immediately after
swsusp_write() with no intervening suspend, and the subsequent
PMSG_RESTORE resume on the restored kernel calls uvc_video_resume()
with pm_hibernation_storing_image() returning false, performing the full
reinitialization as normal.

Signed-off-by: Haowen Tu <tuhaowen@xxxxxxxxxxxxx>
---
drivers/media/usb/uvc/uvc_video.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index f6c8e3223796..16a911b684d5 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>
@@ -2135,6 +2136,15 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset)
{
int ret;

+ /*
+ * After taking the hibernation memory snapshot, the kernel briefly resumes
+ * devices with PMSG_THAW to write the image to storage before powerdown.
+ * The UVC device is not involved in storage I/O, so skip reinitializing
+ * it to avoid unnecessary USB traffic during this transient phase.
+ */
+ if (pm_hibernation_storing_image())
+ return 0;
+
/*
* If the bus has been reset on resume, set the alternate setting to 0.
* This should be the default value, but some devices crash or otherwise
--
2.20.1