Re: [RFC PATCH 00/26] Remove the V4L2_FL_LOCK_ALL_FOPS flag

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

 



Hi Hans,

On 06/24/2012 01:25 PM, Hans Verkuil wrote:
Hi all,

In the 3.5 kernel a change was made regarding core locking (i.e. how locking
is done if the 'lock' field is set in struct video_device). Before kernel 3.5
all file operations would be locked in that case. But this turned out to be
problematic, adding unnecessary latencies in some cases (poll) and potentially
introducing a deadlock in mmap: the kernel takes the mm semaphore before calling
the driver's file operation, where the core lock is taken, whereas other file
ops take the core lock first, and in case of a page fault the mm semaphore
will be taken. This scenario is very unlikely, but the lockdep checker will
complain about it.

So in kernel 3.5 we decided not to take the core lock anymore for file
operations other than unlocked_ioctl. Instead the driver will have to do
the locking. As a temporary measure the flag V4L2_FL_LOCK_ALL_FOPS was
introduced that, if set, would force the core to take the lock anyway for
all file operations. In other words, drivers that were not converted yet
to do their own locking for non-unlocked_ioctl file operations would just
set this flag and keep the old behavior.

This patch series goes through all those drivers and pushed the locking
down into the driver and removes this legacy flag.

These patches just push the locking down and do not do anything smart (except
for some additional dead code removal in saa7146, or if I was 100% certain no
locking was needed for a particular file operation). In particular for mmap
it will still take the core lock, it just does it in the driver now, making it
easier to change in a future patch.

I have already tested ivtv, saa7146, cpia2, usbvision, em28xx, tm6000,
mem2mem_testdev and cx231xx. I hope to test vpif_capture/display tomorrow.

The others need to be tested and/or reviewed by others (i.e. you!).

I'd really want to get rid of this flag as soon as possible as it makes the
v4l2 core lock handling unnecessarily complex, and it also complicates the
core and vb2 enhancements patch series I am working on:

http://www.spinics.net/lists/linux-media/msg49299.html

So please take a look, test if you can, and let me know if it is OK.

I prepared patches removing the V4L2_FL_LOCK_ALL_FOPS flag in s5p-fimc
driver a few weeks ago (and also for fimc-lite), just didn't post it
yet. I'm going to do it in coming week, when I'm back in the office.
Please feel free to drop patches for s5p-fimc in this series and mark
off this driver on your list.

--
Kind regards,
Sylwester
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux