mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] media: uvcvideo: fix control restore on reset_resume
@ 2026-11-24 10:06 Chris Bainbridge
  2026-11-24 10:06 ` [PATCH 1/3] media: uvcvideo: Report the failing control when restoring controls fails Chris Bainbridge
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Bainbridge @ 2026-11-24 10:06 UTC (permalink / raw)
  To: linux-media; +Cc: linux-kernel, laurent.pinchart, hansg, mchehab

uvc_ctrl_restore_values() restores each entity's modified controls in
index order via the transactional commit machinery
(uvc_ctrl_commit_entity()). On devices where SET_CUR on a manual control
STALLs while its master auto control is enabled, the commit switches to
rollback on the first failure: the remaining controls of the entity are
skipped, later entities are not restored, and the rollback copies
UVC_CTRL_DATA_BACKUP over UVC_CTRL_DATA_CURRENT for every dirty control
in the entity - but BACKUP is never populated on the restore path, so
the cached values are corrupted with stale data. __uvc_resume() then
returns early and uvc_status_resume() never runs, leaving the status
(interrupt) endpoint dead after resume. Observed on a Logitech C270
(046d:0825, USB_QUIRK_RESET_RESUME): SET_CUR on WHITE_BALANCE_TEMPERATURE
(selector 10 on unit 2) gets UVC error code 7 (Invalid Request) while
auto WB is enabled. The only userspace-visible effect is
"reset_resume error -5"; on such devices, every resume of a camera whose
controls have been written fails the restore. Kernel log:

  restoring control 00000000-...-000000000101/6/10
  restoring control 00000000-...-000000000101/12/11
  Control error 7 (Invalid request) for (SET_CUR) control 10 on unit 2
  UVC non compliance: Error -5 restoring control White Balance Temperature
  (selector 10 on unit 2)
  reset_resume error -5

patch 1/3 reports the failing control (V4L2 name, entity id, selector,
errno) when the restore fails; diagnostics only, and independently
useful.
patch 2/3 restores the auto (master) controls first and skips inactive
manual controls, so SET_CUR is not sent for a slave while its master is
on. Because the restore does not populate the cache, a master whose
state is unknown (not restored in the first pass and not cached) is
queried with GET_CUR rather than assumed; slaves skipped as inactive
have their cached state invalidated.
patch 3/3 stops using the transactional commit machinery for the
restore: each control is restored individually, failures are recorded
and the remaining controls and entities are still restored, the cached
state is not corrupted by rollback, and __uvc_resume() returns the first
restore error while always resuming the status endpoint - a status URB
submission failure takes priority over the already-logged best-effort
restore error.

Verified on the C270: with auto WB on, the WB temperature restore is
skipped as inactive and no error occurs; with manual WB active, WB auto
is restored first and then WB temperature; PLF and gain are restored
correctly. A 120-trial census across repeated
suspend/reset_resume/capture cycles (three control sequences x two
formats x 20 trials, camera autosuspended before every open so every
open runs the full reset_resume restore) completed with 0 wedged images,
0 restore errors and 0 recovery interventions. Returning the error is
safe: the USB core treats a reset_resume error as informational
(usb_resume_interface()).

Unrelated: the same camera also has a firmware-level race around AWB
mode writes near stream start (userspace-visible; in our testing it
fires only when stream start does not follow a reset_resume). May be
addressed by a quirk series later.

Chris
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-24 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 10:06 [PATCH 0/3] media: uvcvideo: fix control restore on reset_resume Chris Bainbridge
2026-11-24 10:06 ` [PATCH 1/3] media: uvcvideo: Report the failing control when restoring controls fails Chris Bainbridge
2026-11-24 10:06 ` [PATCH 2/3] media: uvcvideo: Restore auto controls first and skip inactive slaves Chris Bainbridge
2026-11-24 10:06 ` [PATCH 3/3] media: uvcvideo: Do not abort resume when restoring controls fails Chris Bainbridge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®