public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Pecio <michal.pecio@gmail.com>
To: Jeffrey Hein <jp@jphein.com>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>,
	Ricardo Ribalda <ribalda@chromium.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans de Goede <hansg@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-media@vger.kernel.org, linux-usb@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v5 2/3] media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile firmware
Date: Mon, 27 Apr 2026 08:35:53 +0200	[thread overview]
Message-ID: <20260427083553.36ff4731.michal.pecio@gmail.com> (raw)
In-Reply-To: <20260413100545.71796c66.michal.pecio@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]

On Mon, 13 Apr 2026 10:05:45 +0200, Michal Pecio wrote:
> Question: can you kill it by starting some video application to set
> the camera up, closing it and then running this loop?
> 
> while :; do v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=1; done

Hi again,

Any chance you could try it? And also the attached test program:

cc -lusb-1.0 hammerint.c -o hammerint
sudo ./hammerint 1532 0e05 0 85

Initial arguments are VID:PID of the device, next is the number of
an interface containing some interrupt endpoint and then the endpoint
address (including 8_ if IN).

I tried with a variety of SuperSpeed devices (UVC, NICs, hubs) and this
reliably breaks ASMedia HCs within seconds. If the same is the case on
Intel then it's a bigger problem than just UVC.

The video streaming loop breaks even more controllers. I have some
general idea how the streaming case could be dealt with, but not so
much the interrupt one. Maybe rate limiting. I found that avoiding
Set TR Dequeue to Link TRBs reduces failure rate, but not to zero.

Long ago I also looked at the issued command sequences and I haven't
noticed obvious errors or spec violations. Looks like a HW bug.

Regards,
Michal

[-- Attachment #2: hammerint.c --]
[-- Type: text/x-c++src, Size: 1425 bytes --]

#include <stdio.h>
#include <stdlib.h>

#include <libusb-1.0/libusb.h>

void comp(struct libusb_transfer *t) {
	char c = t->status == LIBUSB_TRANSFER_CANCELLED ? '.' :
		t->status == LIBUSB_TRANSFER_COMPLETED ? ',' : '-';
	fputc(c, stdout);
	fflush(stdout);
}

int hammer(int vid, int pid, int ifc, int ep) {
	struct libusb_device_handle *d;
	struct libusb_transfer *t;
	char bufi[1024] = {0};
	char bufc[2];
	int r;

	r = libusb_init(NULL);
	t = libusb_alloc_transfer(0);
	if (r || !t)
		return 1;

	d = libusb_open_device_with_vid_pid(NULL, vid, pid);
	if (!d)
		return 2;

	libusb_detach_kernel_driver(d, ifc);
	r = libusb_claim_interface(d, ifc);
	if (r)
		return 3;

	libusb_fill_interrupt_transfer(t, d, ep, bufi, sizeof(bufi), comp, NULL, 0);

	for (;;) {
		/* GET_STATUS(DEVICE) */
		r = libusb_control_transfer(d, 0x80, 0, 0, 0, bufc, sizeof(bufc), 100);
		if (r != sizeof(bufc))
			return 4;

		r = libusb_submit_transfer(t);
		if (r)
			return 5;
		r = libusb_cancel_transfer(t);
		if (r)
			return 6;
		r = libusb_handle_events(NULL);
		if (r)
			return 7;
	}
}

int main (int argc, char **argv) {
	int vid, pid, ifc, ep;
	int r;

	if (argc != 5) {
		fprintf(stderr, "USAGE: %s vid pid ifc ep\n", argv[0]);
		return 1;
	}

	vid = strtol(argv[1], NULL, 16);
	pid = strtol(argv[2], NULL, 16);
	ifc = strtol(argv[3], NULL, 16);
	ep = strtol(argv[4], NULL, 16);

	r = hammer(vid, pid, ifc, ep);
	printf("%d\n", r);
}

  reply	other threads:[~2026-04-27  6:36 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31  0:38 [PATCH v5 0/3] USB/UVC: Add quirks to prevent Razer Kiyo Pro xHCI cascade failure JP Hein
2026-03-31  0:38 ` [PATCH v5 1/3] USB: core: add NO_LPM quirk for Razer Kiyo Pro webcam JP Hein
2026-03-31  0:38 ` [PATCH v5 2/3] media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile firmware JP Hein
2026-04-09  6:45   ` Ricardo Ribalda
     [not found]     ` <CAD5VvzAu8+Qz7hEEBzuKvO11X=YD-wrtX3_Tk77g2Cq5rZZD0Q@mail.gmail.com>
2026-04-09  7:51       ` Jeffrey Hein
2026-04-09  8:02     ` Michal Pecio
2026-04-09  8:15       ` Jeffrey Hein
2026-04-09 20:17       ` Michal Pecio
2026-04-10  0:01         ` Jeffrey Hein
2026-04-10  0:24           ` Jeffrey Hein
2026-04-10  4:47             ` Michal Pecio
2026-04-10 21:48         ` Mathias Nyman
2026-04-10 23:06           ` Jeffrey Hein
2026-04-13  8:05             ` Michal Pecio
2026-04-27  6:35               ` Michal Pecio [this message]
2026-04-13 20:24             ` Michal Pecio
2026-04-11 13:39           ` Michal Pecio
2026-03-31  0:38 ` [PATCH v5 3/3] media: uvcvideo: add quirks for Razer Kiyo Pro webcam JP Hein
2026-04-09  6:49   ` Ricardo Ribalda
2026-04-09  7:38     ` Jeffrey Hein
2026-04-09  7:42 ` [PATCH v6 0/2] media: uvcvideo: Add quirks to prevent Razer Kiyo Pro xHCI cascade failure JP Hein
2026-04-09  7:42   ` [PATCH v6 1/2] media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile USB firmware JP Hein
2026-04-09  7:57     ` Ricardo Ribalda
2026-04-09  8:12       ` Jeffrey Hein
2026-04-09  7:42   ` [PATCH v6 2/2] media: uvcvideo: add Razer Kiyo Pro to device info table JP Hein
2026-04-09  7:57     ` Ricardo Ribalda
2026-04-09  8:13       ` Jeffrey Hein
2026-04-10  0:28 ` [PATCH v7 0/2] media: uvcvideo: Add quirks to prevent Razer Kiyo Pro xHCI cascade failure JP Hein
2026-04-10  0:28   ` [PATCH v7 1/2] media: uvcvideo: add UVC_QUIRK_CTRL_THROTTLE for fragile USB firmware JP Hein
2026-04-10  0:28   ` [PATCH v7 2/2] media: uvcvideo: add Razer Kiyo Pro to device info table JP Hein
2026-04-13 20:40   ` [PATCH v7 0/2] media: uvcvideo: Add quirks to prevent Razer Kiyo Pro xHCI cascade failure Michal Pecio
2026-04-18 17:26     ` Jeffrey Hein

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=20260427083553.36ff4731.michal.pecio@gmail.com \
    --to=michal.pecio@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hansg@kernel.org \
    --cc=jp@jphein.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=ribalda@chromium.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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