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 <arnd@arndb.de> Cc: Mauro Carvalho Chehab <mchehab@infradead.org> Cc: linux-media@vger.kernel.org
This commit is contained in:
@@ -25,7 +25,6 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/smp_lock.h>
|
|
||||||
#include <linux/poll.h>
|
#include <linux/poll.h>
|
||||||
#include <linux/ioctl.h>
|
#include <linux/ioctl.h>
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
@@ -1088,13 +1087,7 @@ static int dvb_demux_do_ioctl(struct file *file,
|
|||||||
static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
|
static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
int ret;
|
return dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
|
||||||
|
|
||||||
lock_kernel();
|
|
||||||
ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
|
|
||||||
unlock_kernel();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
|
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,
|
static long dvb_dvr_ioctl(struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int ret;
|
return dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
|
||||||
|
|
||||||
lock_kernel();
|
|
||||||
ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
|
|
||||||
unlock_kernel();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
|
static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
|
||||||
|
@@ -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,
|
static long dvb_ca_en50221_io_ioctl(struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int ret;
|
return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
|
||||||
|
|
||||||
lock_kernel();
|
|
||||||
ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
|
|
||||||
unlock_kernel();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -59,7 +59,6 @@
|
|||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/etherdevice.h>
|
#include <linux/etherdevice.h>
|
||||||
#include <linux/dvb/net.h>
|
#include <linux/dvb/net.h>
|
||||||
#include <linux/smp_lock.h>
|
|
||||||
#include <linux/uio.h>
|
#include <linux/uio.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
@@ -1445,13 +1444,7 @@ static int dvb_net_do_ioctl(struct file *file,
|
|||||||
static long dvb_net_ioctl(struct file *file,
|
static long dvb_net_ioctl(struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int ret;
|
return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
|
||||||
|
|
||||||
lock_kernel();
|
|
||||||
ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
|
|
||||||
unlock_kernel();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dvb_net_close(struct inode *inode, struct file *file)
|
static int dvb_net_close(struct inode *inode, struct file *file)
|
||||||
|
@@ -32,9 +32,9 @@
|
|||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/cdev.h>
|
#include <linux/cdev.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/smp_lock.h>
|
|
||||||
#include "dvbdev.h"
|
#include "dvbdev.h"
|
||||||
|
|
||||||
|
static DEFINE_MUTEX(dvbdev_mutex);
|
||||||
static int dvbdev_debug;
|
static int dvbdev_debug;
|
||||||
|
|
||||||
module_param(dvbdev_debug, int, 0644);
|
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;
|
struct dvb_device *dvbdev;
|
||||||
|
|
||||||
lock_kernel();
|
mutex_lock(&dvbdev_mutex);
|
||||||
down_read(&minor_rwsem);
|
down_read(&minor_rwsem);
|
||||||
dvbdev = dvb_minors[iminor(inode)];
|
dvbdev = dvb_minors[iminor(inode)];
|
||||||
|
|
||||||
@@ -91,12 +91,12 @@ static int dvb_device_open(struct inode *inode, struct file *file)
|
|||||||
}
|
}
|
||||||
fops_put(old_fops);
|
fops_put(old_fops);
|
||||||
up_read(&minor_rwsem);
|
up_read(&minor_rwsem);
|
||||||
unlock_kernel();
|
mutex_unlock(&dvbdev_mutex);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
fail:
|
fail:
|
||||||
up_read(&minor_rwsem);
|
up_read(&minor_rwsem);
|
||||||
unlock_kernel();
|
mutex_unlock(&dvbdev_mutex);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,6 @@ long dvb_generic_ioctl(struct file *file,
|
|||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct dvb_device *dvbdev = file->private_data;
|
struct dvb_device *dvbdev = file->private_data;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!dvbdev)
|
if (!dvbdev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@@ -166,11 +165,7 @@ long dvb_generic_ioctl(struct file *file,
|
|||||||
if (!dvbdev->kernel_ioctl)
|
if (!dvbdev->kernel_ioctl)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
lock_kernel();
|
return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
|
||||||
ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
|
|
||||||
unlock_kernel();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(dvb_generic_ioctl);
|
EXPORT_SYMBOL(dvb_generic_ioctl);
|
||||||
|
|
||||||
@@ -421,8 +416,10 @@ int dvb_usercopy(struct file *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* call driver */
|
/* call driver */
|
||||||
|
mutex_lock(&dvbdev_mutex);
|
||||||
if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
|
if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
|
mutex_unlock(&dvbdev_mutex);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
Reference in New Issue
Block a user