From: Haowen Tu <tuhaowen@uniontech.com>
To: rafael@kernel.org
Cc: lenb@kernel.org, pavel@kernel.org, linux-pm@vger.kernel.org,
laurent.pinchart@ideasonboard.com, hansg@kernel.org,
mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, Haowen Tu <tuhaowen@uniontech.com>
Subject: [PATCH 2/2] media: uvcvideo: skip resume when writing hibernation image
Date: Tue, 28 Apr 2026 16:05:13 +0800 [thread overview]
Message-ID: <20260428080513.1833515-3-tuhaowen@uniontech.com> (raw)
In-Reply-To: <20260428080513.1833515-1-tuhaowen@uniontech.com>
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@uniontech.com>
---
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
next prev parent reply other threads:[~2026-04-28 8:06 UTC|newest]
Thread overview: 8+ 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-04-28 8:05 ` Haowen Tu [this message]
2026-04-28 8:36 ` [PATCH 2/2] media: uvcvideo: skip resume when writing hibernation image 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
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=20260428080513.1833515-3-tuhaowen@uniontech.com \
--to=tuhaowen@uniontech.com \
--cc=hansg@kernel.org \
--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=mchehab@kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
/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