From: Chris Bainbridge <chris.bainbridge@canonical.com>
To: linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, laurent.pinchart@ideasonboard.com,
hansg@kernel.org, mchehab@kernel.org
Subject: [PATCH 1/3] media: uvcvideo: Report the failing control when restoring controls fails
Date: Tue, 24 Nov 2026 10:06:21 +0000 [thread overview]
Message-ID: <20261124100623.2227323-2-chris.bainbridge@canonical.com> (raw)
In-Reply-To: <20261124100623.2227323-1-chris.bainbridge@canonical.com>
When uvc_ctrl_commit_entity() fails while restoring the controls after a
USB reset_resume, the only message visible at the default loglevel is
the generic "reset_resume error -5" from the USB core. The control that
caused the failure and the reason for it are only visible with the
uvcvideo trace parameter enabled (UVC_DBG_CONTROL), which makes the
problem almost impossible to diagnose in the field.
On a Logitech C270 (046d:0825, USB_QUIRK_RESET_RESUME), the processing
unit restore fails with UVC error code 7 (Invalid Request), mapped to
-EIO, and the user only sees "reset_resume error -5". The restore order
suggests that WHITE_BALANCE_TEMPERATURE is written while auto white
balance is enabled, which the device rejects.
Pass the err_ctrl out parameter of uvc_ctrl_commit_entity() and report
the name, the selector and the entity id of the failing control,
together with the error code, using a ratelimited warning. If the
failing control is not known, report the entity and the error code only.
Also extend the "Control error %u" debug message in uvc_query_ctrl()
with the name of the UVC error code, the name of the request, the
selector and the unit, so that the cause of the STALL is visible in the
trace log.
Signed-off-by: Chris Bainbridge <chris.bainbridge@canonical.com>
---
drivers/media/usb/uvc/uvc_ctrl.c | 36 +++++++++++++++++++++++++++++--
drivers/media/usb/uvc/uvc_video.c | 31 +++++++++++++++++++++++++-
2 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index d2f722bc3459..f70fa37800a4 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -3199,6 +3199,34 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
* Suspend/resume
*/
+/*
+ * Report a failure to restore the controls of an entity. @err_ctrl points to
+ * the control that failed, or is NULL if the failing control is not known.
+ */
+static void uvc_ctrl_restore_error(struct uvc_device *dev,
+ const struct uvc_entity *entity,
+ struct uvc_control *err_ctrl, int ret)
+{
+ const struct uvc_control_mapping *mapping;
+ const char *name = "Unknown Control";
+
+ if (!err_ctrl) {
+ dev_warn_ratelimited(&dev->intf->dev,
+ "Failed to restore controls on unit %u: %d\n",
+ entity->id, ret);
+ return;
+ }
+
+ mapping = list_first_entry_or_null(&err_ctrl->info.mappings,
+ struct uvc_control_mapping, list);
+ if (mapping)
+ name = uvc_map_get_name(mapping);
+
+ dev_warn_ratelimited(&dev->intf->dev,
+ "Failed to restore control %s (selector %u on unit %u): %d\n",
+ name, err_ctrl->info.selector, entity->id, ret);
+}
+
/*
* Restore control values after resume, skipping controls that haven't been
* changed.
@@ -3210,6 +3238,7 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
*/
int uvc_ctrl_restore_values(struct uvc_device *dev)
{
+ struct uvc_control *err_ctrl;
struct uvc_control *ctrl;
struct uvc_entity *entity;
unsigned int i;
@@ -3230,9 +3259,12 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
ctrl->dirty = 1;
}
- ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0, NULL);
- if (ret < 0)
+ err_ctrl = NULL;
+ ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0, &err_ctrl);
+ if (ret < 0) {
+ uvc_ctrl_restore_error(dev, entity, err_ctrl, ret);
return ret;
+ }
}
return 0;
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index a92a986ab714..b10064defaf4 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -68,6 +68,32 @@ static const char *uvc_query_name(u8 query)
}
}
+static const char *uvc_error_code_name(u8 error)
+{
+ switch (error) {
+ case 0:
+ return "No error";
+ case 1:
+ return "Not ready";
+ case 2:
+ return "Wrong state";
+ case 3:
+ return "Power";
+ case 4:
+ return "Out of range";
+ case 5:
+ return "Invalid unit";
+ case 6:
+ return "Invalid control";
+ case 7:
+ return "Invalid request";
+ case 8:
+ return "Invalid value within range";
+ default:
+ return "Unknown";
+ }
+}
+
int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
u8 intfnum, u8 cs, void *data, u16 size)
{
@@ -125,7 +151,10 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
return ret < 0 ? ret : -EPIPE;
}
- uvc_dbg(dev, CONTROL, "Control error %u\n", error);
+ uvc_dbg(dev, CONTROL,
+ "Control error %u (%s) for %s control %u on unit %u\n",
+ error, uvc_error_code_name(error), uvc_query_name(query), cs,
+ unit);
switch (error) {
case 0:
--
2.53.0
next prev parent reply other threads:[~2026-11-24 10:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 10:06 [PATCH 0/3] media: uvcvideo: fix control restore on reset_resume Chris Bainbridge
2026-11-24 10:06 ` Chris Bainbridge [this message]
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
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=20261124100623.2227323-2-chris.bainbridge@canonical.com \
--to=chris.bainbridge@canonical.com \
--cc=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/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
all inboxes | Powered by JetHome®