public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-media@vger.kernel.org,
	Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
	Daniel Drake <dsd@laptop.org>
Subject: Re: [PATCH] viafb camera controller driver
Date: Tue, 19 Oct 2010 13:42:52 -0200	[thread overview]
Message-ID: <4CBDBC7C.8010000@infradead.org> (raw)
In-Reply-To: <201010191652.56655.laurent.pinchart@ideasonboard.com>

Em 19-10-2010 12:52, Laurent Pinchart escreveu:
> Hi Mauro,
> 
> On Tuesday 19 October 2010 16:49:25 Mauro Carvalho Chehab wrote:
>> Em 19-10-2010 11:05, Laurent Pinchart escreveu:
>>>> It is not a "big lock": it doesn't stop other CPU's, doesn't affect
>>>> other hardware, not even another V4L device. Basically, what this new
>>>> lock does is to serialize access to the hardware and to the
>>>> hardware-mirrored data.
>>>
>>> The lock serializes all ioctls. That's much more than protecting access
>>> to data (both in system memory and in the hardware).
>>
>> It is not much more. What ioctl's doesn't access the hardware directly nor
>> access some struct that caches the hardware data? None, at the most
>> complex devices.
>>
>> For simpler devices, there are very few VIDIOC*ENUM stuff that may just
>> return a fixed set of values, but the userspace applications that call
>> them serializes the access anyway (as they are the enum ioctls, used
>> during the hardware detection phase of the userspace software).
>>
>> So, in practice, it makes no difference to serialize everything or to
>> remove the lock for the very few ioctls that just return a fixed set of
>> info.
> 
> That's not correct. There's a difference between taking a lock around 
> read/write operations and around the whole ioctl call stack.

Huh?

Even on simpler hardware, there are very few ioctls that don't access hardware.
Hardly, this would cause any performance impact.

What I said is that, if the userspace does:

open()
/* Serialized ioctls */
ioctl (...)
ioctl (...)
ioctl (...)
ioctl (...)
ioctl (...)
ioctl (...)
ioctl (...)
...

It doesn't matter if kernel is forcing serialization or not.

The difference only happens if userspace does things like:

fork()	/* Or some thread creation function */
...
/* proccess/thread 1 */
ioctl()
...
/* proccess/thread 2 */
ioctl()
...
/* proccess/thread 3 */
ioctl()
...

However, it doesn't make sense to do parallel access to *ENUM ioctls, so I don't know
any application doing that during the "hardware discover phase", whe.

The usage of different process/threads may make sense, from userspace POV, while streaming.
There are a few reasons for that, like:
	- users may want to adjust the bright/contrast (or other video/audio control)
	  while streaming;
	- if the dqbuf logic is complex (for example, it may have some software processing
	  logic - like de interlacing);
	- a separate process may be recording the video.

On all the above valid use-cases, the ioctl is really accessing the hardware and/or some
hardware-cached data. So, a lock is needed anyway.

Cheers,
Mauro

  reply	other threads:[~2010-10-19 15:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-10 22:23 [PATCH] viafb camera controller driver Jonathan Corbet
2010-10-11 12:09 ` Mauro Carvalho Chehab
2010-10-11 12:18 ` Laurent Pinchart
2010-10-11 15:30   ` Jonathan Corbet
2010-10-11 23:20     ` Laurent Pinchart
2010-10-16 13:44 ` Mauro Carvalho Chehab
2010-10-18 13:25   ` Jonathan Corbet
2010-10-19  3:20   ` Jonathan Corbet
2010-10-19  6:54     ` Hans Verkuil
2010-10-19  7:52       ` Laurent Pinchart
2010-10-19 10:46         ` Mauro Carvalho Chehab
2010-10-19 13:05           ` Laurent Pinchart
2010-10-19 14:04             ` Hans Verkuil
2010-10-19 14:21               ` Hans Verkuil
2010-10-19 14:49             ` Mauro Carvalho Chehab
2010-10-19 14:52               ` Laurent Pinchart
2010-10-19 15:42                 ` Mauro Carvalho Chehab [this message]
2010-10-20 19:23       ` ext_lock (was viafb camera controller driver) Jonathan Corbet
2010-10-21  2:57         ` Mauro Carvalho Chehab
2010-10-21  6:51         ` Hans Verkuil

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=4CBDBC7C.8010000@infradead.org \
    --to=mchehab@infradead.org \
    --cc=FlorianSchandinat@gmx.de \
    --cc=corbet@lwn.net \
    --cc=dsd@laptop.org \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --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