Locking & the videobuf2 API
Locking & the videobuf2 API
Posted Jun 16, 2011 6:52 UTC (Thu) by hverkuil (subscriber, #41056)Parent article: The videobuf2 API
But in a nutshell: you either set the 'lock' field in struct video_device to a mutex and then the framework will take care of serialization of file operations (mostly ioctls) for you, or you leave it at NULL and you have to do your own locking.
I tend to advocate using the framework serialization rather than doing it yourself since the chances of actually getting the locking right in a complex driver if you do it yourself are pretty close to zero, especially after the driver has undergone a few years of maintenance.
Posted Jun 16, 2011 16:03 UTC (Thu)
by corbet (editor, #1)
[Link] (2 responses)
Posted Jun 16, 2011 16:28 UTC (Thu)
by hverkuil (subscriber, #41056)
[Link] (1 responses)
Another reason for doing this was the BKL removal were we needed something reasonably simple to convert old (usually unmaintained) drivers without having to do extensive code reviews.
Posted Jun 16, 2011 16:34 UTC (Thu)
by corbet (editor, #1)
[Link]
As you know, some of us are not entirely in agreement there. I don't think you can do a complex driver without being aware of locking; trying to hide it looks to me like an attempt to return to the good old days of uniprocessor systems. I don't know of any other kernel subsystem which tries to hide locking in the midlayers in this way - though there almost certainly is one somewhere.
Locking & the videobuf2 API
Locking & the videobuf2 API
Understood, that all makes sense, sorry if I sounded critical. You've put in a lot of work and, as a result, V4L2 has gotten a lot better in the time I've been paying attention to it.
Locking & the videobuf2 API