From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org
Subject: Re: [RFC] Serialization flag example
Date: Thu, 01 Apr 2010 18:32:33 -0300 [thread overview]
Message-ID: <4BB510F1.7090504@redhat.com> (raw)
In-Reply-To: <201004012257.08684.hverkuil@xs4all.nl>
Hans Verkuil wrote:
>> Maybe a better alternative would be to pass to the V4L2 core, optionally, some lock,
>> used internally on the driver. This approach will still be pedantic, as all ioctls will
>> keep being serialized, but at least the driver will need to explicitly handle the lock,
>> and the same lock can be used on other parts of the driver.
>
> Well, I guess you could add a 'struct mutex *serialize;' field to v4l2_device
> that drivers can set. But I don't see much of a difference in practice.
It makes easier to implement more complex approaches, where you may need to use more
locks. Also, It makes no sense to make a DVB code or an alsa code dependent on a V4L
header, just because it needs to see a mutex.
Also, a mutex at the driver need to be initialized inside the driver. It is not just one
flag that someone writing a new driver will clone without really understanding what
it is doing.
> Regarding the 'pedantic approach': we can easily move the locking to video_ioctl2:
>
> struct video_device *vdev = video_devdata(file);
> int serialize = must_serialize_ioctl(vdev, cmd);
>
> if (serialize)
> mutex_lock(&vdev->v4l2_dev->serialize_lock);
> /* Handles IOCTL */
> err = __video_do_ioctl(file, cmd, parg);
> if (serialize)
> mutex_unlock(&vdev->v4l2_dev->serialize_lock);
>
>
> And must_serialize_ioctl() looks like this:
>
> static int must_serialize_ioctl(struct video_device *vdev, int cmd)
> {
> if (!vdev->v4l2_dev || !vdev->v4l2_dev->fl_serialize)
> return 0;
> switch (cmd) {
> case VIDIOC_QUERYCAP:
> case VIDIOC_ENUM_FMT:
> ...
> return 0;
> }
> return 1;
> }
>
> Basically the CAP (capability) ioctls and all ENUM ioctls do not have to be
> serialized. I am not sure whether the streaming ioctls should also be included
> here. I can't really grasp the consequences of whatever choice we make. If we
> want to be compatible with what happens today with ioctl and the BKL, then we
> need to lock and have videobuf unlock whenever it has to wait for an event.
I suspect that the list of "must have" is driver-dependent.
--
Cheers,
Mauro
next prev parent reply other threads:[~2010-04-01 21:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-01 17:37 [RFC] Serialization flag example Hans Verkuil
2010-04-01 18:24 ` Mauro Carvalho Chehab
2010-04-01 20:57 ` Hans Verkuil
2010-04-01 21:32 ` Mauro Carvalho Chehab [this message]
2010-04-02 8:57 ` Hans Verkuil
2010-04-02 16:06 ` Mauro Carvalho Chehab
2010-04-03 0:30 ` Andy Walls
2010-04-02 17:43 ` Manu Abraham
2010-04-02 17:53 ` Devin Heitmueller
2010-04-02 18:24 ` Manu Abraham
2010-04-02 18:34 ` Devin Heitmueller
2010-04-02 21:15 ` Mauro Carvalho Chehab
2010-04-03 0:47 ` Andy Walls
-- strict thread matches above, loose matches on Subject: below --
2010-04-03 11:55 Aw: " hermann-pitton
2010-04-04 3:14 ` David Ellingsworth
2010-04-05 22:46 ` Laurent Pinchart
2010-04-05 22:58 ` Hans Verkuil
2010-04-06 6:30 ` Hans Verkuil
2010-04-06 12:59 ` Mauro Carvalho Chehab
2010-04-06 13:54 ` Hans Verkuil
2010-04-06 14:42 ` Mauro Carvalho Chehab
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=4BB510F1.7090504@redhat.com \
--to=mchehab@redhat.com \
--cc=hverkuil@xs4all.nl \
--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 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.