From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpbgsg1.qq.com (smtpbgsg1.qq.com [54.254.200.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D94FF378830 for ; Thu, 28 May 2026 08:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.254.200.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779956401; cv=none; b=pngbvF9uDXS2xh9cUs22cfwdffdqMJtuoTdV/Wl5hldwA39qEQ/8kpy7DlziaUv/thih+KL+VGXWrlZYzFiuCrlhtUvkwMAdrJ68v8WhUwHwIy/3VMZ+xfNCiE1U0mvyUik2nmvWzxo0AvgLVuT2c88CO4KVZ/1h5JCCr24pWZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779956401; c=relaxed/simple; bh=MLatFh+ITEgavEN5ELhODVOrrueAp2v6chz36/OYIfQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H4aGBlNAztLtsaUd5VrdPpRDL/xk7MghX9k9TbOax6ufA5rvsaWFoP73VN7F8XkOHMIiTFtWph7kZZou8oa7m4jQScLo9gPNvIFH+jJM0A7dux/nG3TNKxHvsz0omC105YER5z2YkM4tHpGWmafj7TPShRcYSJgezRqCj77gzKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=X8QAun7X; arc=none smtp.client-ip=54.254.200.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="X8QAun7X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1779956367; bh=oeURz6oicc+pZP9AWLhlYv7MHtn2iU5Ne4XKIeL0nIc=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=X8QAun7X0dwo5JUXzGYQwEi1S+GME49fm9evWcx414Va3Q2cMqu2yQz36zHQ1UkXg 48ns6cKPcT5lYKCUd9s11+cDUwj/Dgv7KQA6CFJnQrKLHyfqIGJYaTcb661IMK3M1F +9kAY1DB1693aO+fhx2iEgwLb+W4qoEToh0pVrZo= X-QQ-mid: zesmtpgz3t1779956349t15de0229 X-QQ-Originating-IP: SYALA+0AfiCbbM+XpXJbIjiqmJcJglSmxfVd4eUuncE= Received: from localhost.localdomain ( [113.57.152.160]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 28 May 2026 16:19:06 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 10008302796186427878 EX-QQ-RecipientCnt: 15 From: Haowen Tu 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, gregkh@linuxfoundation.org, stern@rowland.harvard.edu, oneukum@suse.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@uniontech.com, Haowen Tu Subject: [PATCH v2 2/2] media: uvcvideo: skip resume after hibernation snapshot Date: Thu, 28 May 2026 16:18:40 +0800 Message-Id: <20260528081840.3528089-3-tuhaowen@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260528081840.3528089-1-tuhaowen@uniontech.com> References: <20260428080513.1833515-1-tuhaowen@uniontech.com> <20260528081840.3528089-1-tuhaowen@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: zesmtpgz:uniontech.com:qybglogicsvrsz:qybglogicsvrsz3b-0 X-QQ-XMAILINFO: NpT1fuJyWPv/+BwCdrMBm3WVXtPNZ7A1brXWiYFJ7JOUJ7GAkT4YlaXc RPQikeRPYgNGPt9ms6hXGGfjiKe/zp+K9glSg+539kqTBPZ7caK1WSNtEIG4yqqrnQyQZWQ yEprgIYUym0kLyB9tuGOjKKC7TqsEQa2maCrOIfb4Pg0vBLk04xUQNZdR7XDkDu7xL3t09D mXeP5SzBNUcpWqit4eOi8Yt/WJl6oecZKwzsXhEIFnSpCan7/5po9J4ynN0e7OizFuE4kNs DXbctlxjRCFtDSkaIXM8jpgvstUnmWrt8/0mhL+34F+SJk+KeoK38v5Z8mRhyqmcH0meWVd jA/tZ0X6A/vQGX7KD/GW4h/bag7PZ365EPJ153yvvQWTG154h4L92lIH9QYsuvIu//LWNAt QWF8eN/6hF0LFGvVzXkO6db0N9UptcLgVZp8NgkUBNbXA8VjWVfDif9XKklwsrffiRRQVTl ja6bcuQ8jBtK3R1Vcr6X/USpYVFCDnqDPVhniDPV86XGtrvkC5I1jC7qN3spFHAY/ypbduY asNxA6CDc+8VoKU7WXnriDekkJv8M7lNmyD+PDTgkbn+SmwHWFTc9+i9wcmaMQbjx1GbmDI 8UAVA3Ge42nU/W97IpIVHFscaPS6ugLJbSp4dVf63mWYWo01dB4FmVYJ3FXEL4bmRF5kYVz MGs0i3AxiWtoFEWmEZxxKpHVO2BbKxo0PL7YliYvV7MBYN61tp19hI46Rz73CwRlGX20u5Q dpLHRr7gFmcZddBkKuuwWJi8rtYkTuUU+hqoo14NF5lVYV/hY324na9g2ePV5hygtIH46X+ L5gQ2QIguabEGoCZnMy78ekG3XFUulv69WKf1wIjhl++EpCMmj6+h/Qb3rDpBRPNUvjNmc7 BQa/ip5aUNkvbil/fhnMHgdQ0iIMeaWi+lawQTNr2qlgS9x7h30/KvoOHLrAPvr8xkLoqoZ doVGaOBYOljIaou7oiVXJAJi15EAB0Ci5zOHNQ7NHTxjgHa3sCixK3RYCo1w+xSqg/g6MYS uGGjrIfvhs/IjD9QdByGOyhm1CyP7/gRCCyGhU9UIKcDR4kNVs0QS0NDSBTsib3rVush3LJ kgXnwhJ3uau X-QQ-XMRINFO: NS+P29fieYNwqS3WCnRCOn9D1NpZuCnCRA== X-QQ-RECHKSPAM: 0 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. This is intentionally handled in uvcvideo rather than in USB core. USB core cannot skip all interface resume callbacks during hibernation THAW, because some USB interfaces may be part of the image writeout path or otherwise be required by dependencies. uvcvideo has a concrete user-visible side effect from reinitializing hardware in this transient phase, and it is not involved in image writeout. The check is placed after stream->frozen is cleared and the clock is reset, so that driver state remains consistent if the image write fails and the system resumes normally instead of powering off. In that case userspace will need to restart the stream, but the driver will not be left with stale frozen state. 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 --- Changes in v2: - Use pm_hibernation_snapshot_done() after the PM helper was renamed. drivers/media/usb/uvc/uvc_video.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index f6c8e3223796..9fa649fd47e0 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -2151,6 +2152,17 @@ int uvc_video_resume(struct uvc_streaming *stream, int reset) if (!uvc_queue_streaming(&stream->queue)) return 0; + /* + * During hibernation image writing (PMSG_THAW), the kernel briefly + * resumes devices after the snapshot has been created. Skip hardware + * reinitialization to avoid USB traffic and the spurious camera LED + * activation. stream->frozen has already been cleared, so if the + * image write fails and the system resumes normally, driver state + * remains consistent; userspace will need to restart the stream. + */ + if (pm_hibernation_snapshot_done()) + return 0; + ret = uvc_commit_video(stream, &stream->ctrl); if (ret < 0) return ret; -- 2.20.1