From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Haowen Tu <tuhaowen@uniontech.com>,
hansg@kernel.org, gregkh@linuxfoundation.org,
kernel@uniontech.com, lenb@kernel.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-pm@vger.kernel.org, linux-usb@vger.kernel.org,
mchehab@kernel.org, oneukum@suse.com, pavel@kernel.org,
rafael@kernel.org
Subject: Re: [PATCH v4 4/4] media: uvcvideo: defer streaming restart after hibernation snapshot
Date: Thu, 30 Jul 2026 18:38:17 +0300 [thread overview]
Message-ID: <20260730153817.GA1555869@killaraus.ideasonboard.com> (raw)
In-Reply-To: <a1f8d865-531c-4f30-85c1-735254940763@rowland.harvard.edu>
On Thu, Jul 30, 2026 at 10:29:34AM -0400, Alan Stern wrote:
> On Thu, Jul 30, 2026 at 04:16:28PM +0300, Laurent Pinchart wrote:
> > On Wed, Jul 29, 2026 at 10:08:51AM -0400, Alan Stern wrote:
> > > On Wed, Jul 29, 2026 at 03:56:55PM +0800, Haowen Tu wrote:
> > > > On Wed, Jul 29, 2026 at 09:29:03AM +0200, Hans de Goede wrote:
> > > > > Right, so the purpose here is to avoid the LED turning back on and
> > > > > to speedup the hibernate?
> > > > >
> > > > > IOW except for the LED turning back on and things taking slightly
> > > > > longer everything works correctly with the current code, right ?
> > > >
> > > > Yes, the current code is functionally correct in the sense that the
> > > > hibernation flow can complete and the camera can be restored afterwards.
> > > >
> > > > The issue was reported as a user-visible privacy concern. When an active
> > > > UVC camera enters hibernation, the camera LED turns off during the freeze
> > > > phase but turns back on after the snapshot has been created, while the
> > > > system is writing the hibernation image. From the user's point of view,
> > > > this looks like the camera has been activated again during the
> > > > hibernation transition.
> > > >
> > > > I am not claiming that this causes image data to be exposed. The problem
> > > > is the unnecessary hardware reactivation and the resulting unexpected
> > > > privacy-indicator behavior during a system power transition.
> > > >
> > > > Avoiding the restart also avoids unnecessary device work in this window,
> > > > but I do not intend to make performance the main argument here. The
> > > > primary goal is to avoid the unexpected camera reactivation.
> > > >
> > > > > I'm wondering if it would not be better to solve this in userspace
> > > > > and have userspace stop the streaming before hibernation ?
> > > >
> > > > That would help when all userspace camera users cooperate, but I don't
> > > > think it is equivalent to handling this in the driver.
> > > >
> > > > UVC is a generic driver and the kernel PM transition can happen while an
> > > > application is actively streaming. Relying on every userspace camera
> > > > consumer to stop streaming before hibernation would make the behavior
> > > > depend on userspace policy and application support. The driver already
> > > > knows whether streaming was active at freeze time, and it is also the
> > > > component that restarts the hardware during resume, so it can avoid this
> > > > specific unnecessary hardware restart more reliably.
> > > >
> > > > > Hmm, the way you word this sound like this is a problem at the USB
> > > > > layer. But I think this is more of a short-coming in the generic
> > > > > device model.
> > > > >
> > > > > To clarify AFAIK the actual USB device to which the interfaces belong
> > > > > also does not get a specific PM message here, right ?
> > > > >
> > > > > The reason I'm asking is because the way this is worded in the commit
> > > > > message makes it sounds like this might be something which could
> > > > > be solved in the USB subsystem which I do not think is the case ?
> > > >
> > > > Yes, that is my understanding as well. The USB device resume path does
> > > > not expose the specific PM transition type to the UVC interface driver's
> > > > resume callback.
> > > >
> > > > The problem was observed in UVC, and the immediate reason there is that
> > > > the UVC resume path is reached through usb_driver.resume(), which does
> > > > not receive the PM event. But I agree that this should not be worded as
> > > > a USB subsystem bug.
> > > >
> > > > My earlier thought was to expose the THAW/RESTORE distinction through
> > > > USB, but that would still need coordination with the PM core, and it
> > > > would only cover USB drivers. If other non-USB drivers have similar
> > > > device-specific reasons to avoid work during the post-snapshot THAW
> > > > phase, they would need their own handling too.
> > > >
> > > > So I can reword the commit message to avoid implying that this is a USB
> > > > core issue. Something like:
> > > >
> > > > Some resume callback paths, including the UVC path through
> > > > usb_driver.resume(), do not receive the PM event and therefore cannot
> > > > distinguish the transient post-snapshot THAW phase from the later
> > > > RESTORE phase using their local callback arguments.
> > > >
> > > > The helper is intended to expose only the hibernation snapshot state.
> > > > Whether it is safe or useful to defer any work remains a driver-specific
> > > > decision.
> > >
> > > You're missing an important fact: If something goes wrong during the
> > > hibernation transition (for example, if the kernel's memory image can't
> > > be stored to disk) then there will be no RESTORE phase. Following the
> > > THAW phase, the system will return to normal operation.
> > >
> > > For this reason, during THAW drivers must not assume that the system is
> > > about to power down.
> >
> > All of this seems fairly complicated to me for devices that have no role
> > to play whatsoever in the hibernation image write, and that's probably
> > the majority of devices.
> >
> > Is there a reason a driver couldn't set a flag at probe time to tell the
> > device doesn't care about hibernation, and have the PM core skip the
> > resume in the THAW phase, instead resuming only when THAW fails ?
>
> You mean adding an extra THAW phase to the hibernation transition, which
> gets triggered only when writing the memory image fails, and which
> affects only drivers having this new flag set? And as a result, when
> hibernation succeeds these drivers would see a FREEZE callback followed
> directly by a POWEROFF callback (unless the flag causes POWEROFF to be
> skipped as well)?
Something like that. I'm very biased as I mostly work on multimedia
devices, but it feels to me that for many drivers the current
hibernation procedure is too complex. Those drivers don't need to
differentiate suspend and hibernation, they only need to be instructed
to suspend at some point, and resume later. Resuming could occur when
the system is woken up, or when hibernation fails in the THAW phase, and
those drivers wouldn't care to differentiate between the two. Seeing an
extra resume + suspend cycle due to the hibernation machinery needing to
write the image to disk, and having to handle that cycle manually as in
this series, is additional complexity that (unless I'm missing
something) could be handled by the PM core.
> Another thing to be aware of is what happens while waking up from
> hibernation, if the memory image can't be restored. In that case the
> restore kernel would send THAW callbacks to all drivers before
> continuing, and presumably you wouldn't want this callback to be
> skipped.
I wasn't even aware this was a thing, which only strengthen my
conviction that we're making it too difficult for many drivers :-)
> That seems like it could be feasible, but the decision is up to Rafael.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-07-30 15:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260428080513.1833515-1-tuhaowen@uniontech.com>
2026-05-28 8:18 ` [PATCH v2 0/2] PM: hibernate: skip UVC resume after snapshot Haowen Tu
2026-05-28 8:18 ` [PATCH v2 1/2] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-06-01 18:22 ` Rafael J. Wysocki
2026-06-02 3:24 ` Haowen Tu
2026-06-18 1:31 ` [PATCH v3 0/3] PM: hibernate: skip UVC streaming restart after snapshot Haowen Tu
2026-06-18 1:31 ` [PATCH v3 1/3] PM: hibernate: clear in_suspend before freeing the snapshot Haowen Tu
2026-07-22 15:37 ` Rafael J. Wysocki (Intel)
2026-06-18 1:31 ` [PATCH v3 2/3] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-07-22 15:40 ` Rafael J. Wysocki (Intel)
2026-06-18 1:31 ` [PATCH v3 3/3] media: uvcvideo: skip streaming restart after hibernation snapshot Haowen Tu
2026-07-22 20:06 ` Laurent Pinchart
2026-07-23 1:39 ` Haowen Tu
2026-07-23 8:46 ` Laurent Pinchart
2026-07-29 7:11 ` [PATCH v4 0/4] PM: hibernate: defer UVC streaming restart after snapshot Haowen Tu
2026-07-29 7:11 ` [PATCH v4 1/4] PM: hibernate: clear in_suspend before freeing the snapshot Haowen Tu
2026-07-29 7:11 ` [PATCH v4 2/4] PM: hibernate: add pm_hibernation_snapshot_done() helper Haowen Tu
2026-07-29 7:11 ` [PATCH v4 3/4] PM: hibernate: notify on image write failure Haowen Tu
2026-07-29 7:11 ` [PATCH v4 4/4] media: uvcvideo: defer streaming restart after hibernation snapshot Haowen Tu
2026-07-29 7:29 ` Hans de Goede
2026-07-29 7:56 ` Haowen Tu
2026-07-29 14:08 ` Alan Stern
2026-07-29 14:43 ` Oliver Neukum
2026-07-29 14:54 ` Alan Stern
2026-07-30 13:16 ` Laurent Pinchart
2026-07-30 14:29 ` Alan Stern
2026-07-30 15:38 ` Laurent Pinchart [this message]
2026-05-28 8:18 ` [PATCH v2 2/2] media: uvcvideo: skip resume " 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=20260730153817.GA1555869@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=kernel@uniontech.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=oneukum@suse.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tuhaowen@uniontech.com \
/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