From adfedd216d9f0bc3f5bfa8aab42932301d4edc31 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 19:53:25 +0200 Subject: dvb/bt8xx: kill the big kernel lock The bt8xx driver only uses the big kernel lock in its dst_ca_ioctl function and never to serialize against other code, so we can trivially replace it with a private mutex. Signed-off-by: Arnd Bergmann Cc: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab --- drivers/media/dvb/bt8xx/dst_ca.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/media') diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index cf87051..d75788b 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include "dvbdev.h" @@ -52,6 +52,7 @@ } while(0) +static DEFINE_MUTEX(dst_ca_mutex); static unsigned int verbose = 5; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); @@ -564,7 +565,7 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct void __user *arg = (void __user *)ioctl_arg; int result = 0; - lock_kernel(); + mutex_lock(&dst_ca_mutex); dvbdev = file->private_data; state = (struct dst_state *)dvbdev->priv; p_ca_message = kmalloc(sizeof (struct ca_msg), GFP_KERNEL); @@ -652,7 +653,7 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct kfree (p_ca_slot_info); kfree (p_ca_caps); - unlock_kernel(); + mutex_unlock(&dst_ca_mutex); return result; } -- cgit v1.1 From 72024f1ec5164a70d84dd8cf4458fe4064a6b692 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 19:56:45 +0200 Subject: dvb-core: kill the big kernel lock The dvb core only uses the big kernel lock in the open and ioctl functions, which means it can be replaced with a dvb specific mutex. Fortunately, all the ioctl functions go through dvb_usercopy, so we can move the serialization in there. Signed-off-by: Arnd Bergmann Cc: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org --- drivers/media/dvb/dvb-core/dmxdev.c | 17 ++--------------- drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 8 +------- drivers/media/dvb/dvb-core/dvb_net.c | 9 +-------- drivers/media/dvb/dvb-core/dvbdev.c | 17 +++++++---------- 4 files changed, 11 insertions(+), 40 deletions(-) (limited to 'drivers/media') diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 0042306..2de13b0 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -1088,13 +1087,7 @@ static int dvb_demux_do_ioctl(struct file *file, static long dvb_demux_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - int ret; - - lock_kernel(); - ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl); - unlock_kernel(); - - return ret; + return dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl); } static unsigned int dvb_demux_poll(struct file *file, poll_table *wait) @@ -1186,13 +1179,7 @@ static int dvb_dvr_do_ioctl(struct file *file, static long dvb_dvr_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - int ret; - - lock_kernel(); - ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl); - unlock_kernel(); - - return ret; + return dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl); } static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait) diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index cb97e6b..1723a98 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -1259,13 +1259,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file, static long dvb_ca_en50221_io_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - int ret; - - lock_kernel(); - ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl); - unlock_kernel(); - - return ret; + return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl); } diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 6c3a8a0..a080322 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -1445,13 +1444,7 @@ static int dvb_net_do_ioctl(struct file *file, static long dvb_net_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - int ret; - - lock_kernel(); - ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl); - unlock_kernel(); - - return ret; + return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl); } static int dvb_net_close(struct inode *inode, struct file *file) diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index b915c39..28f486e 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c @@ -32,9 +32,9 @@ #include #include #include -#include #include "dvbdev.h" +static DEFINE_MUTEX(dvbdev_mutex); static int dvbdev_debug; module_param(dvbdev_debug, int, 0644); @@ -68,7 +68,7 @@ static int dvb_device_open(struct inode *inode, struct file *file) { struct dvb_device *dvbdev; - lock_kernel(); + mutex_lock(&dvbdev_mutex); down_read(&minor_rwsem); dvbdev = dvb_minors[iminor(inode)]; @@ -91,12 +91,12 @@ static int dvb_device_open(struct inode *inode, struct file *file) } fops_put(old_fops); up_read(&minor_rwsem); - unlock_kernel(); + mutex_unlock(&dvbdev_mutex); return err; } fail: up_read(&minor_rwsem); - unlock_kernel(); + mutex_unlock(&dvbdev_mutex); return -ENODEV; } @@ -158,7 +158,6 @@ long dvb_generic_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct dvb_device *dvbdev = file->private_data; - int ret; if (!dvbdev) return -ENODEV; @@ -166,11 +165,7 @@ long dvb_generic_ioctl(struct file *file, if (!dvbdev->kernel_ioctl) return -EINVAL; - lock_kernel(); - ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl); - unlock_kernel(); - - return ret; + return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl); } EXPORT_SYMBOL(dvb_generic_ioctl); @@ -421,8 +416,10 @@ int dvb_usercopy(struct file *file, } /* call driver */ + mutex_lock(&dvbdev_mutex); if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD) err = -EINVAL; + mutex_unlock(&dvbdev_mutex); if (err < 0) goto out; -- cgit v1.1 From 7ff52efdca367d4bfe2449bd3d4a1f8172c5953a Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 4 Oct 2010 21:24:14 +0200 Subject: dabusb: remove the BKL The dabusb device driver is sufficiently serialized using its own mutex, no need for the big kernel lock here in addition. Signed-off-by: Arnd Bergmann Cc: Mauro Carvalho Chehab --- drivers/media/video/dabusb.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'drivers/media') diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index 5b176bd..f3e25e9 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -621,7 +620,6 @@ static int dabusb_open (struct inode *inode, struct file *file) if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB)) return -EIO; - lock_kernel(); s = &dabusb[devnum - DABUSB_MINOR]; dbg("dabusb_open"); @@ -630,21 +628,17 @@ static int dabusb_open (struct inode *inode, struct file *file) while (!s->usbdev || s->opened) { mutex_unlock(&s->mutex); - if (file->f_flags & O_NONBLOCK) { + if (file->f_flags & O_NONBLOCK) return -EBUSY; - } msleep_interruptible(500); - if (signal_pending (current)) { - unlock_kernel(); + if (signal_pending (current)) return -EAGAIN; - } mutex_lock(&s->mutex); } if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { mutex_unlock(&s->mutex); dev_err(&s->usbdev->dev, "set_interface failed\n"); - unlock_kernel(); return -EINVAL; } s->opened = 1; @@ -654,7 +648,6 @@ static int dabusb_open (struct inode *inode, struct file *file) file->private_data = s; r = nonseekable_open(inode, file); - unlock_kernel(); return r; } @@ -689,17 +682,13 @@ static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg dbg("dabusb_ioctl"); - lock_kernel(); - if (s->remove_pending) { - unlock_kernel(); + if (s->remove_pending) return -EIO; - } mutex_lock(&s->mutex); if (!s->usbdev) { mutex_unlock(&s->mutex); - unlock_kernel(); return -EIO; } @@ -735,7 +724,6 @@ static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg break; } mutex_unlock(&s->mutex); - unlock_kernel(); return ret; } -- cgit v1.1 From 6de5bd128d381ad88ac6d419a5e597048eb468cf Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 18:00:57 +0200 Subject: BKL: introduce CONFIG_BKL. With all the patches we have queued in the BKL removal tree, only a few dozen modules are left that actually rely on the BKL, and even there are lots of low-hanging fruit. We need to decide what to do about them, this patch illustrates one of the options: Every user of the BKL is marked as 'depends on BKL' in Kconfig, and the CONFIG_BKL becomes a user-visible option. If it gets disabled, no BKL using module can be built any more and the BKL code itself is compiled out. The one exception is file locking, which is practically always enabled and does a 'select BKL' instead. This effectively forces CONFIG_BKL to be enabled until we have solved the fs/lockd mess and can apply the patch that removes the BKL from fs/locks.c. Signed-off-by: Arnd Bergmann --- drivers/media/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/media') diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index a28541b..bad2ced 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig @@ -19,6 +19,7 @@ comment "Multimedia core support" config VIDEO_DEV tristate "Video For Linux" + depends on BKL # used in many drivers for ioctl handling, need to kill ---help--- V4L core support for video capture and overlay devices, webcams and AM/FM radio cards. -- cgit v1.1