From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795094404; b=KfW2ZpA1jLvox+hcTzMCbjqJ3SylcJ2zvZWQwfUpTpNojj8iqf0ZYZKQuM9V/LEx1ta7 ivp1IrV6rm/LzElo+Z3qH7vE6p24W5KO6if4L8CJlSbimpczPIsaoJJUUe4aQc+ewdo2h Uem9ZuJ7SVE6AeXQLylUNcbU/cyjkRPKQReeICRfO1oKTmXIGqFzKu68uhteECAFWRtt3 g2RhDqRJOybcReu7IZW1RAP14ivmAZ8MmWz9h6WXXYr4Tb7AGmMWP2vRytjjRuy8wAQ3s k6KntcUHEyI4Tf+3noNdxSd481ab8Lf69q1YUgSoDH4JTqs6/MScfIIbKKzdgEu59uQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795094404; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=uny0r6hCq3qe4nIhgg26vhi2MvVOok40ekvov7+HjGs=; b=S9/UWyajhyPlgA5BtbbIoufg7+rgbrf8iP/+iidS2+lkBFJMFDpslqDHKrPZSyj7Zlb1 52wqk/XEji86UO0lj97e6ZKDhTp4grk1lPBdShi63LRTO6idODySbYUymF1q4xbNs/n1r QLPDz6AsqvCMU1KRfeLxykc9a0ADQUW1q8iXl1MPisehOCRVZOOS88rejkkr8WwWbBLsC nyhJ0zypPqe46sBYY1+ccaFdgULNU4TDFK2weaP7k3hDm/zazwjbKF14eGNUAnG55zPl+ ESGSlAMq5A+MEEx1VbtrSjHgQB1MdDhdl7oak5Ky7hJXvVil0qpUJFfX9XN+zXcH/kg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=zby4UAdz; arc=none smtp.remote-ip=209.85.221.46 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 510C660A2600 for ; Thu, 19 Nov 2026 13:20:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 510C660A2600 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=zby4UAdz Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-491971ac844so2215813f8f.2 for ; Thu, 19 Nov 2026 05:20:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795094402; x=1795699202; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=uny0r6hCq3qe4nIhgg26vhi2MvVOok40ekvov7+HjGs=; b=zby4UAdzmhxZdr/bAyuWfJ2SNu+0nJp3ZNIS6OucsRacuO3m8N3xB1EyaHq9Bm44CK p5EVPmTizagQhAuYKcotrE2QplLp0vSRFdiA2IQZZjzIfKtUKYHNJS/wocV9B6xEXAbg trfDvOGEWGiqq9oyw6LGayd1+YFUflfvjLiYKdWlh6fOALXyoIP4tuC/ghgEiVBTl3wd X/SeYhK6v4fnKJBN/CAg5oDb102sX1rEibd4z6ZopuJD4fFPvyCIRgcI/Deo9iy91hJ5 mzPj40hW7xkbbQ5WOVJTzwx2XQ0i8hC/cBlAZnaiSh3ONicC7uNQLFRB5s6KHWHNaiD1 +1Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795094402; x=1795699202; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=uny0r6hCq3qe4nIhgg26vhi2MvVOok40ekvov7+HjGs=; b=szteg49FXGZ71r9TSA97TGKUHH8WbTa18kbfyZQqRJuaV26KS+Vk7gEUy384LoHriW jEDn6ajjLetXXi0rjtnRUZQyP+mRdqsJr4QD0yJRyOieCGedo0oghx1aSOD40fn4FcFG SYfQd2xAV5ivHZFdpBQyGbXBLMJrsg4vxvlWP8pMi5sH4Sgu4xzLI5jmXJiqkVNini9d JxjD5R6vxoNlR/0xO74RV/gJfF1aiVcAmchDgiN9GnWGJ0MiXKXkyZ/WMKlBDEsFQW6Q v8SvEgVWs/av0Hig2mwWScj787ot+HC2cS57+0oLjLZlWKL/OoBCFUVGRFfdIEYYGln8 gjfw== X-Forwarded-Encrypted: i=1; AL+hErGmi4k9qNYsdxpRsElmW6dVwdK2yFnpvpXAT1QU2tcS9oC9lFenZtr9IxJCoMUUGpU3THje2fqVY5chLg==@vger.kernel.org X-Gm-Message-State: APuU4Z9HNRnGSAqVWKBTd9U0HUze6IKRYJz1sYQKEU25zGFz2cSTev/j N63CgbQ7/yTJk9KD7XMbsxW7FU/b/jR7Q39f4qJ0UBXFTASfN1M3paLa X-Gm-Gg: AZFdTZdXkD9Pzz1dCim5ZRohZZ5l2fVZ0X2USFOt2FO/mlqEfOPN9VPWHKTKpoSK2W/ IMWZvUth+P96POetpPjfgxcwpxf9WPN/vmu2Uy761zYckjhy/KvMkLNdLi4p8UTX0uIqKc3pHTX Dr8QNkPqw2lj/zWlEMnJd0YFEgkm4OaObUcWUCfYDoxie6mCYIg2ajP9ubjCueClBaiLXRADfF6 XpRjDzYfZXL4TZicrFkuHkkef6zaCOcVXnxzSeq6CPPpslF1LdiH9dgRCyE5aRgZ3WbLlPVua5C tdP18qQxpS/1wo+FSRgG0zT+3Utxeq8CL+Drep4bpWoSiusqmtFkmPH8Mk/njMLSceFbz/8bYwG obz0c9wpN91qbAyZslFtDrSlYv1OqCMhLseMx6ZdKUObU888Ck9WX7dLxg/zaFb+lTL+Oqm95nC x7awMq+7v/DNfQtkKZXJsoJuwXhuAkuffIFb+mJ2z85NYcfkWrEzOTZ8kGH95NYHV96MqXNDJ0Z uQ6xlJjETYMih8xwRFRMreaPk2LQVuRFUJ8b87IZdFB2qpdPtYA7r3UANjEunuoGbW1+vfR1Z9o gOzTdEt0/vIvtrerhxn4A85ufcNs9z+GodsGx8M= X-Received: by 2002:a05:6000:4b17:b0:4a7:f82a:7f6d with SMTP id ffacd0b85a97d-4a7f82a8286mr9060323f8f.6.1795094402014; Thu, 19 Nov 2026 05:20:02 -0800 (PST) Received: from foxbook (bgu85.neoplus.adsl.tpnet.pl. [83.28.84.85]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a65609391bsm10793007f8f.36.2026.11.19.05.20.00 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 19 Nov 2026 05:20:01 -0800 (PST) Date: Thu, 19 Nov 2026 14:19:56 +0100 From: Michal Pecio To: Ricardo Ribalda Cc: hi@yasunobu.dev, linux-media@vger.kernel.org, Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Mathias Nyman , linux-usb@vger.kernel.org Subject: Re: [PATCH] media: uvcvideo: Batch StreamCam unlinks on ASUS ASM2142 Message-ID: <20261119141956.2f320b1e.michal.pecio@gmail.com> In-Reply-To: References: <20261119-streamcam-batched-unlink-v1-1-076bc02866c1@yasunobu.dev> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 19 Nov 2026 13:06:50 +0100, Ricardo Ribalda wrote: > On Thu, 19 Nov 2026 at 12:47, Yasunobu Sakashita via B4 Relay > wrote: > > > > From: Yasunobu Sakashita > > > > Stopping a SuperSpeed StreamCam can halt xHCI on the ASUS PRIME > > Z270-A. The fifth Stop Endpoint command timed out after an invalid > > type 15 event. > > > > For the affected StreamCam and ASM2142, block URB resubmission. > > Queue all unlinks before waiting so xHCI can coalesce them. Hi Yasunobu, I'm curious what's your general experience with SuperSpeed isochronous cameras on ASM2142 (or ASM3142 - same IDs, not sure what difference). Does it work, including in high resolution uncompressed video modes? In my experience with one no-name USB3 camera, ASMedia contrellers worked poorly in general, which is why I haven't bothered upstreaming this compatibility hack. Could you post "lsusb -v" of this camera? Preferably with usbutils v019 or newer. > > > > The stock driver reproduced the halt on Ubuntu 6.8.0-149-generic. > > Three FFmpeg 720p MJPEG and audio capture cycles passed with the > > patch. > > > > I used Codex to help analyze traces and draft the patch and > > changelog. > > > > Signed-off-by: Yasunobu Sakashita > > --- > > Built uvc_video.o on media-committers/next with and without CONFIG_PCI. > > --- > > drivers/media/usb/uvc/uvc_video.c | 43 ++++++++++++++++++++++++++++++++++----- > > 1 file changed, 38 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > > index a92a986ab..0ee5a7d17 100644 > > --- a/drivers/media/usb/uvc/uvc_video.c > > +++ b/drivers/media/usb/uvc/uvc_video.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -1885,6 +1886,26 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, > > return 0; > > } > > > > +static bool uvc_streamcam_batch_unlink(const struct uvc_streaming *stream) > > +{ > > + const struct usb_device *udev = stream->dev->udev; > > + struct device *controller = udev->bus->controller; > > + const struct pci_dev *pdev; > > + > > + if (stream->frozen || udev->state != USB_STATE_CONFIGURED || > > + udev->speed != USB_SPEED_SUPER || > > + le16_to_cpu(udev->descriptor.idVendor) != 0x046d || > > + le16_to_cpu(udev->descriptor.idProduct) != 0x0893 || > > + !controller || !dev_is_pci(controller)) > > + return false; > > + > > + pdev = to_pci_dev(controller); > > + return pdev->vendor == PCI_VENDOR_ID_ASMEDIA && > > + pdev->device == 0x2142 && > > + pdev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK && > > + pdev->subsystem_device == 0x8732 && pdev->revision == 0; > > +} > > + This shouldn't be unnecessary, the alternative unlinking logic is unlikely to cause compatibility issues with any hardware. > > /* > > * Uninitialize isochronous/bulk URBs and free transfer buffers. > > */ > > @@ -1896,12 +1917,24 @@ static void uvc_video_stop_transfer(struct uvc_streaming *stream, > > uvc_video_stats_stop(stream); > > > > /* > > - * We must poison the URBs rather than kill them to ensure that even > > - * after the completion handler returns, any asynchronous workqueues > > - * will be prevented from resubmitting the URBs. > > + * URBs must stay blocked until the workqueue has been flushed. > > + * A completion handler can leave work that tries to resubmit an URB. > > */ > > - for_each_uvc_urb(uvc_urb, stream) > > - usb_poison_urb(uvc_urb->urb); > > + if (uvc_streamcam_batch_unlink(stream)) { > > + /* > > + * usb_block_urb() keeps URBs blocked after usb_kill_urb(). > > + * Queue unlinks together so xHCI can coalesce them. > > + */ > > + for_each_uvc_urb(uvc_urb, stream) > > + usb_block_urb(uvc_urb->urb); > > + for_each_uvc_urb(uvc_urb, stream) > > + usb_unlink_urb(uvc_urb->urb); > > + for_each_uvc_urb(uvc_urb, stream) > > + usb_kill_urb(uvc_urb->urb); For the record, the objective of this ugly code was to hopefully preserve the same guarantees to the UVC driver as the original, while avoiding repeatedly stopping and restarting the xHCI endpoint, which occurs because usb_poison_urb() forces unlink of urb N to complete before unlink of urb N+1 can begin. I don't claim that this is the best or the only solution. > > + } else { > > + for_each_uvc_urb(uvc_urb, stream) > > + usb_poison_urb(uvc_urb->urb); > > + } > > > > Michal proposed something very similar not so long ago: > > https://lore.kernel.org/linux-media/20261115110132.2b0bda47.michal.pecio@gmail.com/ Yes, LLMs got pretty good at stealing test patches from maling lists. > He also mentioned that those crashes were solved in 7.3. Could you > check if your device works fine on 7.3, or if it still crashes? > (Note that even if a workaround is still needed, we probably wouldn't > want to match host-controller PCI IDs inside uvcvideo.) To be exact, 7.3 solved interrupt endpoint crashes on ASMedia and isochronous endpoint crashes on VIA. I haven't tested isochronous on ASMedia, but now I will, subject to the limitation that my camera barely works with those controllers at all. > Michal, would you recommend applying something like what you proposed > in your email, or would you rather fix this at the USB level? Other than bloat, the UVC change should be harmless and it makes unlinking multiple URBs somewhat wore efficient and faster. But it does make the code longer and weirder. If there is a need, perhaps USB core could provide a new usb_nuke_endpoint() call. I'm also curious to hear whether the 7.3 changes or this patch affect the Intel+Razer case (linked above). Regards, Michal