Re: RFC: allow usb drivers to disallow USBDEVFS_DISCONNECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Dienstag, 12. Januar 2010 22:08:22 schrieb Hans de Goede:
> Well libgphoto2 politely asks the kernel, can you please release usb device
> foo for userspace use ? I'm asking for drivers to have the possibility to
> say: No sorry, the device is in use.
> 
> This does not seem something strange to me. This can be hacked around
> in libgphoto by:
> 
> 1) Adding code to match the usb device to a /dev/video
> 2) If it matches a /dev/video, open that (this will work multiple opens
>     are allowed)
> 3) Try to start a stream (yes because we really want libgphoto2 to
>     have to start the webcam)
> 4) If 3) fails with ebusy, an other app is already streaming, don't ask
>     the kernel to release the device.
> 5) If 3) does not fail, close the device and continue

If you do it that way, you'll create a race. You have to kick yourself
off the device.

> That would be a gross hack, but that would be the way to "fix" libgphoto2 .

This works only if we can reliably locate all affected device nodes.
Hans, does libgphoto2 need to kick off all drivers or just the driver
for the video interface?
 
> Or we could have the please release the device call return -EBUSY, which
> almost every other single syscall in the kernel will do when a single use
> device is already in use by another application.

If we do this unconditionally blocking disconnect is a bad idea. We'd
better introduce a new ioctl, like USBDEVFS_RELEASE_IDLE_INTERFACE,
to lave user space the option to kick a driver off a busy device.

	Regards
		Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux