mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens.net>
To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Daniel Axtens <dja@axtens.net>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: [PATCH 2/2] [media] uvcvideo: Kill video URBs on disconnect
Date: Mon, 17 Apr 2017 18:52:40 +1000	[thread overview]
Message-ID: <20170417085240.12930-2-dja@axtens.net> (raw)
In-Reply-To: <20170417085240.12930-1-dja@axtens.net>

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 <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>

---

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);
-- 
2.9.3

  reply	other threads:[~2017-04-17  8:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17  8:52 [PATCH 1/2] [media] uvcvideo: Refactor teardown of uvc on USB disconnect Daniel Axtens
2017-04-17  8:52 ` Daniel Axtens [this message]
2017-04-17 12:49   ` [PATCH 2/2] [media] uvcvideo: Kill video URBs on disconnect Laurent Pinchart
2017-04-23  0:40     ` Daniel Axtens
2017-04-17 12:23 ` [PATCH 1/2] [media] uvcvideo: Refactor teardown of uvc on USB disconnect Laurent Pinchart
2017-04-23  0:57   ` Daniel Axtens
2017-04-30 16:18   ` Greg KH

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=20170417085240.12930-2-dja@axtens.net \
    --to=dja@axtens.net \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.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

Powered by JetHome