All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@redhat.com>
To: Laurent Pinchart <laurent.pinchart@skynet.be>
Cc: Alan Cox <alan@redhat.com>,
	video4linux-list@redhat.com, linux-uvc-devel@lists.berlios.de
Subject: Re: [Linux-uvc-devel] Thread safety of ioctls
Date: Tue, 24 Jun 2008 18:23:34 -0400	[thread overview]
Message-ID: <20080624222334.GB2268@devserv.devel.redhat.com> (raw)
In-Reply-To: <200806242334.44102.laurent.pinchart@skynet.be>

On Tue, Jun 24, 2008 at 11:34:43PM +0200, Laurent Pinchart wrote:
> Buffer dequeuing can sleep for a longer time than most other operations, as it 
> waits for a video buffer to be ready. However, no other operation from the 
> above list should be performed while a VIDIOC_DQBUF is in progress.

Another thread can do so - or want for example to poll(). The case where
you sleep waiting for an event that may take a fair bit of time is perhaps
the one you need to drop the lock for.
> 
> Getting locking right is very difficult. I spent a lot of time checking corner 
> cases when developing the driver, and I'm pretty sure a few race conditions 
> still exist, especially when then ioctl code will not be covered by the BKL 
> anymore. I would greatly appreciate anyone reviewing the patch I will post 
> soon to get the UVC driver included in the mainline kernel for race 
> conditions and locking issues.

Agreed - one construct you will see in some drivers is basically

try_again: /* For the odd case we are beaten to a buffer etc */
	if (conditions) {
		drop_lock
		wait
		take lock
		if (!conditions)
			goto try_again;
	}

Some of this can get quite tricky when you have hardware state to manage


Alan

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  reply	other threads:[~2008-06-24 22:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-23 10:26 Thread safety of ioctls Gregor Jasny
2008-06-23 13:29 ` Alan Cox
2008-06-23 22:33 ` [Linux-uvc-devel] " Laurent Pinchart
2008-06-24 13:39   ` Alan Cox
2008-06-24 21:34     ` Laurent Pinchart
2008-06-24 22:23       ` Alan Cox [this message]
2008-06-24 21:36   ` Mauro Carvalho Chehab
2008-06-24 22:04     ` Laurent Pinchart
2008-06-26 19:48   ` Driver hangs at DQBUF ioctl Gregor Jasny
2008-06-30 15:39     ` [Linux-uvc-devel] " Laurent Pinchart

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=20080624222334.GB2268@devserv.devel.redhat.com \
    --to=alan@redhat.com \
    --cc=laurent.pinchart@skynet.be \
    --cc=linux-uvc-devel@lists.berlios.de \
    --cc=video4linux-list@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.