media: uvcvideo: fix control restore on reset_resume
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | media: uvcvideo: Report the failing control when restoring controls failsdrivers/ drivers/ | +64 | 1 reply | |
| 2/3 | media: uvcvideo: Restore auto controls first and skip inactive slavesdrivers/ | +126 | 1 reply | |
| 3/3 | media: uvcvideo: Do not abort resume when restoring controls failsdrivers/ drivers/ | +64 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] media: uvcvideo: fix control restore on reset_resume
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
Signature · 1 line
2.53.0