Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5386219rwl; Wed, 28 Dec 2022 18:29:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXvznuRCyB6/3CXuMZtljY8KU1PIH3joq0fdvTKjPmtZ9V/XXXSANynVVGKs+Y5injjaxCBG X-Received: by 2002:a05:6a21:1584:b0:b3:32fa:1d91 with SMTP id nr4-20020a056a21158400b000b332fa1d91mr15529288pzb.50.1672280966040; Wed, 28 Dec 2022 18:29:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672280966; cv=none; d=google.com; s=arc-20160816; b=vcre5tkD/hwiGyAldc8tvKlKZtTfLRopkgUVnTFEmwTt49F8u6O4PgzVYC3GXpWBqL s7H6o24boakcWUwDtC2d7Vwc4SGNbovzEk0x9tZUvHJ/cVy4uMBCrzB8jsrTRW8a+HfY q8CxzoO8eEEmQGh5ElZLJAT7nIegLsCA73jFtFT/ABc3rtocQOsPZ+v0yIkmhzMLrv3K 8LcT/h4YykS6ZnO6J8Wd2fk3mHTQBMB3Hh3LteAMgqulgsE0+xBff6Cvz43/UZILisJy xrHNdMi3qoKQKVcOIuDoAtzQAD64ypX52ItFMgHOtC7Hl99d32FVqmIWEikv4lUtL1cx EDlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LrDz9z/tCot3yn2YnjO3gHUB8+klzgdHJNuZCei8RKU=; b=s86Gr7ZW2is2Di1vg4W5C8avbT6001AnGn4uCVwlNhySbA6nOfBUOvm6Y/y0u29xUa 46P8Ddwt9llUKj/971zMhg0RIZ499f+ZtZB9Hyu09u/uhcTP86YlvYdXzkGMRC0JGGgv 3JJicGU6NxTJ3q9soZFLu07rQpww0v/Halbil+LQNOooquT1pdp+D5Y5Tny9puibXimM 1tyxD3FH1X32uuX60RUO2Qf3B3dUi7rxl00xX/cddDlAQ7BjuftWXY1tI95wM5eG3SRt G/WofuT5dXFWfV1Zli7d84zBfgVlSjlKW4hZPFEeAirq6dPhsi989WCCpZ4LRZhUGxvr RM1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=db2jTVpF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a056a001a4200b0057c4543b15esi17746078pfv.281.2022.12.28.18.29.16; Wed, 28 Dec 2022 18:29:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=db2jTVpF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbiL2CQL (ORCPT + 63 others); Wed, 28 Dec 2022 21:16:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbiL2CQI (ORCPT ); Wed, 28 Dec 2022 21:16:08 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D40C7F; Wed, 28 Dec 2022 18:16:06 -0800 (PST) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C4FA109; Thu, 29 Dec 2022 03:16:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1672280165; bh=WwQBvzpgnzReaGkHUuiGxWOEOKrQl4LCceXe70mDN5s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=db2jTVpFWVtUT9APhhGLZPnKGK5eI3/AadbyMWqMAX1ATXfDqpgB3LlbgDV7BWdBA 8hMERqtgaKwH0qjtbjZgdB2hI8vPHww95XrEXr77a9h3i4vvMBEa6szxI3wnMliLv3 4eKiQMboQpUwj+2Yn9DNmc+/PRdR3v2eYcdnybfc= Date: Thu, 29 Dec 2022 04:16:01 +0200 From: Laurent Pinchart To: Ricardo Ribalda Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sergey Senozhatsky , linux-kernel@vger.kernel.org, Yunke Cao Subject: Re: [PATCH v4] media: uvcvideo: Recover stalled ElGato devices Message-ID: References: <20220920-resend-elgato-v4-0-f9555e13e458@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220920-resend-elgato-v4-0-f9555e13e458@chromium.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ricardo, On Tue, Dec 06, 2022 at 12:15:04AM +0100, Ricardo Ribalda wrote: > Elgato Cam Link 4k can be in a stalled state if the resolution of > the external source has changed while the firmware initializes. > Once in this state, the device is useless until it receives a > USB reset. It has even been observed that the stalled state will > continue even after unplugging the device. > > lsusb -v > > Bus 002 Device 002: ID 0fd9:0066 Elgato Systems GmbH Cam Link 4K > Device Descriptor: > bLength 18 > bDescriptorType 1 > bcdUSB 3.00 > bDeviceClass 239 Miscellaneous Device > bDeviceSubClass 2 > bDeviceProtocol 1 Interface Association > bMaxPacketSize0 9 > idVendor 0x0fd9 Elgato Systems GmbH > idProduct 0x0066 > bcdDevice 0.00 > iManufacturer 1 Elgato > iProduct 2 Cam Link 4K > iSerial 4 0005AC52FE000 > bNumConfigurations 1 > > Reviewed-by: Sergey Senozhatsky > Reviewed-by: Laurent Pinchart > Signed-off-by: Ricardo Ribalda > --- > Recover stalled ElGato devices > > Just a resend of this hw fix. Taken in my tree, thanks. > To: Laurent Pinchart > To: Mauro Carvalho Chehab > Cc: linux-media@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: Sergey Senozhatsky > Cc: Yunke Cao > --- > Changes in v4: > - Add Reviewed-by: Laurent > - Update error messages (Thanks Laurent!) > - Swap checks on if (Thanks Laurent) > - Link to v3: https://lore.kernel.org/r/20220920-resend-elgato-v3-0-57668054127f@chromium.org > > Changes in v3: > - Add Reviewed-by: Sergey > - Improve identation (Thanks Sergey!) > - Link to v2: https://lore.kernel.org/r/20220920-resend-elgato-v2-0-06b48b3b486a@chromium.org > > Changes in v2: > - Remove info from lsusb > - Link to v1: https://lore.kernel.org/r/20220920-resend-elgato-v1-0-8672a2380e3d@chromium.org > --- > drivers/media/usb/uvc/uvc_video.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > index 170a008f4006..ba7c159cb2a6 100644 > --- a/drivers/media/usb/uvc/uvc_video.c > +++ b/drivers/media/usb/uvc/uvc_video.c > @@ -129,12 +129,13 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit, > return -EPIPE; > } > > +static const struct usb_device_id elgato_cam_link_4k = { > + USB_DEVICE(0x0fd9, 0x0066) > +}; > + > static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, > struct uvc_streaming_control *ctrl) > { > - static const struct usb_device_id elgato_cam_link_4k = { > - USB_DEVICE(0x0fd9, 0x0066) > - }; > struct uvc_format *format = NULL; > struct uvc_frame *frame = NULL; > unsigned int i; > @@ -297,7 +298,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream, > dev_err(&stream->intf->dev, > "Failed to query (%u) UVC %s control : %d (exp. %u).\n", > query, probe ? "probe" : "commit", ret, size); > - ret = -EIO; > + ret = (ret == -EPROTO) ? -EPROTO : -EIO; > goto out; > } > > @@ -2121,6 +2122,21 @@ int uvc_video_init(struct uvc_streaming *stream) > * request on the probe control, as required by the UVC specification. > */ > ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR); > + > + /* > + * Elgato Cam Link 4k can be in a stalled state if the resolution of > + * the external source has changed while the firmware initializes. > + * Once in this state, the device is useless until it receives a > + * USB reset. It has even been observed that the stalled state will > + * continue even after unplugging the device. > + */ > + if (ret == -EPROTO && > + usb_match_one_id(stream->dev->intf, &elgato_cam_link_4k)) { > + dev_err(&stream->intf->dev, "Elgato Cam Link 4K firmware crash detected\n"); > + dev_err(&stream->intf->dev, "Resetting the device, unplug and replug to recover\n"); > + usb_reset_device(stream->dev->udev); > + } > + > if (ret < 0) > return ret; > > > --- > base-commit: 521a547ced6477c54b4b0cc206000406c221b4d6 > change-id: 20220920-resend-elgato-a845482bdd02 -- Regards, Laurent Pinchart