From patchwork Mon Apr 17 08:52:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 9683665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A0A460375 for ; Mon, 17 Apr 2017 08:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69E9627EED for ; Mon, 17 Apr 2017 08:53:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EE1A27F2B; Mon, 17 Apr 2017 08:53:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC00B27EED for ; Mon, 17 Apr 2017 08:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754472AbdDQIx2 (ORCPT ); Mon, 17 Apr 2017 04:53:28 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36262 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754202AbdDQIxZ (ORCPT ); Mon, 17 Apr 2017 04:53:25 -0400 Received: by mail-pf0-f194.google.com with SMTP id i5so23482037pfc.3 for ; Mon, 17 Apr 2017 01:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2cKGQ1GXOV79F/CtiDwdGdAwaY1l1bqlBNuIqZa0rGg=; b=JwXSebBCNHwgw5Rl0MzqYx1vHH853997fXwE117fhYKAPQ0QqAxR9vfbUfCQT+uyFF kRcRVYAbLm3NHuhUzto8lp3rsVXdQhGIfQKsWdOgqtH1n8EAoy2fCpMjV0nu5Cm9QDA8 X2w5sRFwUJEepmbKPi69hy4EI89Amyxv2o1+E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2cKGQ1GXOV79F/CtiDwdGdAwaY1l1bqlBNuIqZa0rGg=; b=eDhaPz9pF1IymQyF4w/SebZozz5OzIeFo3C4qFC7iyPmo6Jh9iGFUy7iVWWap222gW UZ6MyfiNR4iaCghKF7fB7gE3tKE0qJbKxtiAXzPeGLdLbq69AyfrwYFaVAVFNvY7x0DV UbrF8p6w0zaZmzaJ+NEnQim3WszyrsKYCF5V+KJUFz6ojzYa2iTyWF0UKX0ytxTEW8QF zgfAtcYCSjXf9TShdSUaXWA8LTGJIqrzvGE79kQKc0XcSw+yulRFxxngcy3L4BhStczu OzAiKkB4olkDH0mtWzmmyYjmr4Zqc3inmEbI7koC88DXWCvaAp1JNng4UsyBnPoKvatC WERw== X-Gm-Message-State: AN3rC/6A8sY8jURudt1uh8oG+uSl/MzJFHi6k9FP6xcTt2XJECYTwF8q iPQr6VRx70AMeg== X-Received: by 10.99.54.72 with SMTP id d69mr10782606pga.24.1492419204435; Mon, 17 Apr 2017 01:53:24 -0700 (PDT) Received: from localhost.localdomain (124-171-208-74.dyn.iinet.net.au. [124.171.208.74]) by smtp.gmail.com with ESMTPSA id 128sm16497119pgi.49.2017.04.17.01.53.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Apr 2017 01:53:24 -0700 (PDT) From: Daniel Axtens To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Axtens , Laurent Pinchart Subject: [PATCH 2/2] [media] uvcvideo: Kill video URBs on disconnect Date: Mon, 17 Apr 2017 18:52:40 +1000 Message-Id: <20170417085240.12930-2-dja@axtens.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170417085240.12930-1-dja@axtens.net> References: <20170417085240.12930-1-dja@axtens.net> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When an in-use webcam is disconnected, I noticed the following messages: uvcvideo: Failed to resubmit video URB (-19). -19 is -ENODEV, which does make sense given that the device has disappeared. We could put a case for -ENODEV like we have with -ENOENT, -ECONNRESET and -ESHUTDOWN, but the usb_unlink_urb() API documentation says that 'The disconnect function should synchronize with a driver's I/O routines to insure that all URB-related activity has completed before it returns.' So we should make an effort to proactively kill URBs in the disconnect path instead. Call uvc_enable_video() (specifying 0 to disable) in the disconnect path, which kills and frees URBs. Cc: Laurent Pinchart Signed-off-by: Daniel Axtens --- Before this patch, yavta -c hangs when a camera is disconnected, but with this patch it exits immediately after the camera is disconnected. I'm not sure if this is acceptable - Laurent? --- drivers/media/usb/uvc/uvc_driver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 2390592f78e0..647e3d8a1256 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1877,6 +1877,8 @@ static void uvc_unregister_video(struct uvc_device *dev) if (!video_is_registered(&stream->vdev)) continue; + uvc_video_enable(stream, 0); + video_unregister_device(&stream->vdev); uvc_debugfs_cleanup_stream(stream);