Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l2-core: remove the old .ioctl BKL replacement

To keep V4L2 drivers that did not yet convert to unlocked_ioctl happy,
the v4l2 core had a .ioctl file operation that took a V4L2 lock.

The last drivers are now converted to unlocked_ioctl, so all this
old code can now be removed.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
5cf6f7f3 06e5cc3d

-32
-28
drivers/media/v4l2-core/v4l2-dev.c
··· 357 357 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); 358 358 if (lock) 359 359 mutex_unlock(lock); 360 - } else if (vdev->fops->ioctl) { 361 - /* This code path is a replacement for the BKL. It is a major 362 - * hack but it will have to do for those drivers that are not 363 - * yet converted to use unlocked_ioctl. 364 - * 365 - * All drivers implement struct v4l2_device, so we use the 366 - * lock defined there to serialize the ioctls. 367 - * 368 - * However, if the driver sleeps, then it blocks all ioctls 369 - * since the lock is still held. This is very common for 370 - * VIDIOC_DQBUF since that normally waits for a frame to arrive. 371 - * As a result any other ioctl calls will proceed very, very 372 - * slowly since each call will have to wait for the VIDIOC_QBUF 373 - * to finish. Things that should take 0.01s may now take 10-20 374 - * seconds. 375 - * 376 - * The workaround is to *not* take the lock for VIDIOC_DQBUF. 377 - * This actually works OK for videobuf-based drivers, since 378 - * videobuf will take its own internal lock. 379 - */ 380 - struct mutex *m = &vdev->v4l2_dev->ioctl_lock; 381 - 382 - if (cmd != VIDIOC_DQBUF && mutex_lock_interruptible(m)) 383 - return -ERESTARTSYS; 384 - if (video_is_registered(vdev)) 385 - ret = vdev->fops->ioctl(filp, cmd, arg); 386 - if (cmd != VIDIOC_DQBUF) 387 - mutex_unlock(m); 388 360 } else 389 361 ret = -ENOTTY; 390 362
-1
drivers/media/v4l2-core/v4l2-device.c
··· 37 37 38 38 INIT_LIST_HEAD(&v4l2_dev->subdevs); 39 39 spin_lock_init(&v4l2_dev->lock); 40 - mutex_init(&v4l2_dev->ioctl_lock); 41 40 v4l2_prio_init(&v4l2_dev->prio); 42 41 kref_init(&v4l2_dev->ref); 43 42 get_device(dev);
-1
include/media/v4l2-dev.h
··· 65 65 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 66 66 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 67 67 unsigned int (*poll) (struct file *, struct poll_table_struct *); 68 - long (*ioctl) (struct file *, unsigned int, unsigned long); 69 68 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 70 69 #ifdef CONFIG_COMPAT 71 70 long (*compat_ioctl32) (struct file *, unsigned int, unsigned long);
-2
include/media/v4l2-device.h
··· 58 58 struct v4l2_ctrl_handler *ctrl_handler; 59 59 /* Device's priority state */ 60 60 struct v4l2_prio_state prio; 61 - /* BKL replacement mutex. Temporary solution only. */ 62 - struct mutex ioctl_lock; 63 61 /* Keep track of the references to this struct. */ 64 62 struct kref ref; 65 63 /* Release function that is called when the ref count goes to 0. */