All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/6] v4l2 core: push ioctl lock down to ioctl handler
@ 2018-05-14 11:55 Hans Verkuil
  2018-05-14 11:55 ` [RFC PATCH 1/6] pvrusb2: replace pvr2_v4l2_ioctl by video_ioctl2 Hans Verkuil
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-05-14 11:55 UTC (permalink / raw)
  To: linux-media; +Cc: Mike Isely, Ezequiel Garcia

From: Hans Verkuil <hans.verkuil@cisco.com>

While working on the DMA fence API and the Request API it became
clear that the core ioctl scheme was done at a too-high level.

Being able to actually look at the struct passed as the ioctl
argument would help a lot in decide what lock(s) to take.

This patch series pushes the lock down into v4l2-ioctl.c, after
video_usercopy() was called.

The first patch is for the only driver that does not set
unlocked_ioctl to video_ioctl2: pvrusb2. It actually does
call it in its own unlocked_ioctl function.

Mike, can you test this patch? I tried to test it but my pvrusb2
fails in a USB transfer (unrelated to this patch). I'll mail you
separately with the details, since I've no idea what is going on.

The second patch pushes the lock down.

The third patch adds support for mem2mem devices by selecting
the correct queue lock (capture vs output): this was never
possible before.

Note: in practice it appears that all m2m devices use the same
lock for both capture and output queues. Perhaps this should
be standardized?

The final three patches require that queue->lock is always
set. There are some drivers that do not set this (and Ezequiel
will look at that and provide patches that will have to go
in between patch 3 and 4 of this RFC series), but without that
you will have performance issues with a blocking DQBUF (it
will never release the core ioctl serialization lock while
waiting for a new frame).

I have added a test for this to v4l2-compliance. We never tested
this before.

Another note: the gspca vb2 conversion series I posted yesterday
also remove the v4l2_disable_ioctl_locking() function, so that
cleans up another little locking-related dark corner in the core.

Regards,

	Hans

Hans Verkuil (6):
  pvrusb2: replace pvr2_v4l2_ioctl by video_ioctl2
  v4l2-core: push taking ioctl mutex down to ioctl handler.
  v4l2-ioctl.c: use correct vb2_queue lock for m2m devices
  videobuf2-core: require q->lock
  videobuf2: assume q->lock is always set
  v4l2-ioctl.c: assume queue->lock is always set

 .../media/common/videobuf2/videobuf2-core.c   | 22 ++---
 .../media/common/videobuf2/videobuf2-v4l2.c   | 27 ++----
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c      | 83 +++++++------------
 drivers/media/v4l2-core/v4l2-dev.c            |  6 --
 drivers/media/v4l2-core/v4l2-ioctl.c          | 75 +++++++++++++++--
 drivers/media/v4l2-core/v4l2-subdev.c         | 17 +++-
 include/media/v4l2-dev.h                      |  9 --
 include/media/v4l2-ioctl.h                    | 12 ---
 include/media/videobuf2-core.h                |  2 -
 9 files changed, 133 insertions(+), 120 deletions(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-05-14 21:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 11:55 [RFC PATCH 0/6] v4l2 core: push ioctl lock down to ioctl handler Hans Verkuil
2018-05-14 11:55 ` [RFC PATCH 1/6] pvrusb2: replace pvr2_v4l2_ioctl by video_ioctl2 Hans Verkuil
2018-05-14 12:11   ` Hans Verkuil
2018-05-14 11:55 ` [RFC PATCH 2/6] v4l2-core: push taking ioctl mutex down to ioctl handler Hans Verkuil
2018-05-14 21:02   ` Ezequiel Garcia
2018-05-14 11:55 ` [RFC PATCH 3/6] v4l2-ioctl.c: use correct vb2_queue lock for m2m devices Hans Verkuil
2018-05-14 11:56 ` [RFC PATCH 4/6] videobuf2-core: require q->lock Hans Verkuil
2018-05-14 11:56 ` [RFC PATCH 5/6] videobuf2: assume q->lock is always set Hans Verkuil
2018-05-14 11:56 ` [RFC PATCH 6/6] v4l2-ioctl.c: assume queue->lock " Hans Verkuil
2018-05-14 12:09 ` [RFC PATCH 0/6] v4l2 core: push ioctl lock down to ioctl handler Hans Verkuil

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.