From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) (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 A91622D3ECF for ; Thu, 18 Jun 2026 01:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.254.200.128 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781746375; cv=none; b=gkuSjqT5+r0cg2O6Lvpa0gX4DAaM1G6ECK2XFv+jOl1aem4a8zCFa/CrJ9Le+38QFkzyJZd79ud4wNzZuTE0KMOilM2pQ6Z7WpcKkBg+lwCFpjTcxD95oK43wSBuUCIW76MQZAjYULzn5jd9rOmlsl+8j1hVdpZGYrnhq7OOxl0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781746375; c=relaxed/simple; bh=2gr6RnPWlqfowu2APd9UT+JaBUmNi2S9q1Qj8h8PPWs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=asiV7yeBf4EiF4I2dyt+SarzRXiAGcJs/Opp/6g9PPK9w53fQHahTu0ikp+63j7vXbMk/qeYFiCrv0gJp8i00+ypB+eyYXBNqrRXtDzGkVcdnHyNhH1HaR3HflUYsGb1q1KIvUtfd36dST8TsD8c9bGtb8uKoAP64AYwv5b+gVU= 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=Mto3hzKp; arc=none smtp.client-ip=54.254.200.128 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="Mto3hzKp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1781746333; bh=IJJqRoaJn1UGNs+9V5J1PVXcLQf6UF9/UcB48PE0U4M=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Mto3hzKpfyoR9peu+q762THMkEA02XxIuKfXvtghIP+f68v0Grulj7AVFtpKnGLdu WUQLLzyoRTacb84qHccxNBqBNZr0YYBR0eNqFS3gU0KWILmrCgg45iPDw3A7pvbdUp dVATq4qF92NDJULqiuVtb+30ESUOuJK04rLd7wqk= X-QQ-mid: esmtpsz10t1781746320tc3798f72 X-QQ-Originating-IP: lrrYilJAl45jPMuEjtLcMdeb/zzIeyM440DdwcO7wec= Received: from localhost.localdomain ( [113.57.152.160]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Jun 2026 09:31:56 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 1632563843144384507 EX-QQ-RecipientCnt: 15 From: Haowen Tu To: rafael@kernel.org Cc: tuhaowen@uniontech.com, gregkh@linuxfoundation.org, hansg@kernel.org, kernel@uniontech.com, laurent.pinchart@ideasonboard.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, stern@rowland.harvard.edu Subject: [PATCH v3 3/3] media: uvcvideo: skip streaming restart after hibernation snapshot Date: Thu, 18 Jun 2026 09:31:33 +0800 Message-Id: <20260618013133.1047270-4-tuhaowen@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20260618013133.1047270-1-tuhaowen@uniontech.com> References: <20260602032413.1540166-1-tuhaowen@uniontech.com> <20260618013133.1047270-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: esmtpsz:uniontech.com:qybglogicsvrsz:qybglogicsvrsz3b-0 X-QQ-XMAILINFO: MYcyYH/A/+tCxc5h8rptSGR5zk19Hnezk2EjqNxGH2kCSqbWqXz1gogl ZCIm7OZJRi17BOYoV/d5QqqMIfxlu/QXm6U+W3SeNQ2/y4nyP/znbgAZ9yzwGQ10DWh2GQx pL2amlc5iLI5XLbWVuXpzGVDsg+R3jYeny3jbZHeUvRKTETSJqzCLE8gWL7Y23/TvUqgLJu NGv3J2mjAe3mWWwihJi3f27fNiEnNJTfNDcTrfGsFq6cD5L1LHHWGynE9QEK1PNzGQjn1ht KuA/0WdftpyBkPYq8/pIi1T68XwrZuZoGAITrJAckf8hO+zovrQA4aNkAub0ei0Ew9LmCaH 9FL1TmdhVPrr0oCLenJT8tEtd8v5TkPda7+LiuREmIfrQJtCUuAQnpMouZEYxgqV0Azc/Sl i2S+o/ooQPJJtB+JFEE9ZIBkucGIDI2//K39yUfJecdnTZqQkzhgCSI7qWp+mBI192Hp1+s QfJmV1kgW2vkgLj1QA35/DwtxonVutbpJTsSmxaxwk4vBbEkdNPsuOpPbcRhy/5CASCjvhs mHVSNc/jc3f3gXsKLI/uaeQddm/tUgsYm3dpqYorHCVPKHlBuss6WOzs5OrKhl4LtPe7szs JJ59ZAz0Y5jMa2+jp8j6tVwhQtTcI9a7e6ouIdhWJqM6hQ4ZTBi2y33JzCd2EGTvc9bU44H peOnjpk6UpWwewjfMKpeNhRIjKUxCpiVBth95+Lo/2pHCmNbCvPrQ3fprmKL4tMd0efkH57 C2vlKcJET/0y+l3hqWFR8HEQPNsFmYACUyeiv9cxhBJzNBCCNfrTvKuQ7ZWCyzHrHe0zRq4 tIiOadSwyEb/852cylZAP2vZm2UpzLwNkjlneeoE51HDcGVMF8y9SNBVcYTZxDJ6vB98DM/ vXpwrPkB/wCkvaXy3ZoOj71EUs6P/eSveFGvZkjF8Myr9Hi9BH1ZZj89gpNBqVHs3nrxcEG QNOzsmPlq4cLFwsobkrbsuYM251Zo4qu1gJmSx0WU/NkuMQf3c+u5DkA6/OCisOsdM1djAt Am96rurecEx0AbY8EiEYtO1LUpvjLvPveKFa8J04Hn9C4TcxvnuFa+HjjxpW0= X-QQ-XMRINFO: NS+P29fieYNwqS3WCnRCOn9D1NpZuCnCRA== X-QQ-RECHKSPAM: 0 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. 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. 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 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 #include #include +#include #include #include #include @@ -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; -- 2.20.1