From 80eb4a6f89bbf8e8318e108701bad11451efb2df Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 18:10:10 +0200 Subject: alpha: kill big kernel lock All uses of the BKL on alpha are totally bogus, nothing is really protected by this. Remove the remaining users so we don't have to mark alpha as 'depends on BKL'. Signed-off-by: Arnd Bergmann Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-alpha@vger.kernel.org --- arch/alpha/kernel/osf_sys.c | 5 ----- arch/alpha/kernel/traps.c | 3 --- 2 files changed, 8 deletions(-) (limited to 'arch') diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 5d1e6d6ce68..49225ddb9d7 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -69,7 +68,6 @@ SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start, { struct mm_struct *mm; - lock_kernel(); mm = current->mm; mm->end_code = bss_start + bss_len; mm->start_brk = bss_start + bss_len; @@ -78,7 +76,6 @@ SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start, printk("set_program_attributes(%lx %lx %lx %lx)\n", text_start, text_len, bss_start, bss_len); #endif - unlock_kernel(); return 0; } @@ -517,7 +514,6 @@ SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code, long error; int __user *min_buf_size_ptr; - lock_kernel(); switch (code) { case PL_SET: if (get_user(error, &args->set.nbytes)) @@ -547,7 +543,6 @@ SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code, error = -EOPNOTSUPP; break; }; - unlock_kernel(); return error; } diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index b14f015008a..0414e021a91 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -623,7 +622,6 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg, return; } - lock_kernel(); printk("Bad unaligned kernel access at %016lx: %p %lx %lu\n", pc, va, opcode, reg); do_exit(SIGSEGV); @@ -646,7 +644,6 @@ got_exception: * Yikes! No one to forward the exception to. * Since the registers are in a weird format, dump them ourselves. */ - lock_kernel(); printk("%s(%d): unhandled unaligned exception\n", current->comm, task_pid_nr(current)); -- cgit v1.2.3 From 0890b5880df6a4989336add11f3a22122b26d9e1 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 18:18:22 +0200 Subject: cris: autoconvert trivial BKL users All uses of the big kernel lock in the cris architecture are for ioctl and open functions of character device drivers, which can be trivially converted to a per-driver mutex. Most of these are probably unnecessary, so it may make sense to audit them and eventually remove the extra mutex introduced by this patch. Signed-off-by: Arnd Bergmann Cc: Mikael Starvik Cc: Jesper Nilsson Cc: linux-cris-kernel@axis.com --- arch/cris/arch-v10/drivers/ds1302.c | 7 ++++--- arch/cris/arch-v10/drivers/pcf8563.c | 6 +++--- arch/cris/arch-v10/drivers/sync_serial.c | 11 ++++++----- arch/cris/arch-v32/drivers/cryptocop.c | 4 ++-- arch/cris/arch-v32/drivers/mach-a3/gpio.c | 11 ++++++----- arch/cris/arch-v32/drivers/mach-fs/gpio.c | 11 ++++++----- arch/cris/arch-v32/drivers/pcf8563.c | 6 +++--- arch/cris/arch-v32/drivers/sync_serial.c | 11 ++++++----- 8 files changed, 36 insertions(+), 31 deletions(-) (limited to 'arch') diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c index 884275629ef..4b92ad08b0f 100644 --- a/arch/cris/arch-v10/drivers/ds1302.c +++ b/arch/cris/arch-v10/drivers/ds1302.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -34,6 +34,7 @@ #define RTC_MAJOR_NR 121 /* local major, change later */ +static DEFINE_MUTEX(ds1302_mutex); static const char ds1302_name[] = "ds1302"; /* The DS1302 might be connected to different bits on different products. @@ -357,9 +358,9 @@ static long rtc_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned lon { int ret; - lock_kernel(); + mutex_lock(&ds1302_mutex); ret = rtc_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&ds1302_mutex); return ret; } diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c index 7dcb1f85f42..2f1ddedca2b 100644 --- a/arch/cris/arch-v10/drivers/pcf8563.c +++ b/arch/cris/arch-v10/drivers/pcf8563.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -49,6 +48,7 @@ #define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) #define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) +static DEFINE_MUTEX(pcf8563_mutex); static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ static const unsigned char days_in_month[] = @@ -343,9 +343,9 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned { int ret; - lock_kernel(); + mutex_lock(&pcf8563_mutex); return pcf8563_ioctl(filp, cmd, arg); - unlock_kernel(); + mutex_unlock(&pcf8563_mutex); return ret; } diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c index ee2dd4323da..3d9fa074a94 100644 --- a/arch/cris/arch-v10/drivers/sync_serial.c +++ b/arch/cris/arch-v10/drivers/sync_serial.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -149,6 +149,7 @@ struct sync_port { }; +static DEFINE_MUTEX(sync_serial_mutex); static int etrax_sync_serial_init(void); static void initialize_port(int portnbr); static inline int sync_data_avail(struct sync_port *port); @@ -445,7 +446,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) int mode; int err = -EBUSY; - lock_kernel(); + mutex_lock(&sync_serial_mutex); DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { @@ -626,7 +627,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) ret = 0; out: - unlock_kernel(); + mutex_unlock(&sync_serial_mutex); return ret; } @@ -961,9 +962,9 @@ static long sync_serial_ioctl(struct file *file, { long ret; - lock_kernel(); + mutex_lock(&sync_serial_mutex); ret = sync_serial_ioctl_unlocked(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&sync_serial_mutex); return ret; } diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c index b07646a3050..0973d5a2780 100644 --- a/arch/cris/arch-v32/drivers/cryptocop.c +++ b/arch/cris/arch-v32/drivers/cryptocop.c @@ -3139,9 +3139,9 @@ cryptocop_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct inode *inode = file->f_path.dentry->d_inode; long ret; - lock_kernel(); + mutex_lock(&cryptocop_mutex); ret = cryptocop_ioctl_unlocked(inode, filp, cmd, arg); - unlock_kernel(); + mutex_unlock(&cryptocop_mutex); return ret; } diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c index 2dcd27adbad..50d1885c479 100644 --- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c +++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -66,6 +66,7 @@ static int dp_cnt; #define DP(x) #endif +static DEFINE_MUTEX(gpio_mutex); static char gpio_name[] = "etrax gpio"; #ifdef CONFIG_ETRAX_VIRTUAL_GPIO @@ -391,7 +392,7 @@ static int gpio_open(struct inode *inode, struct file *filp) if (!priv) return -ENOMEM; - lock_kernel(); + mutex_lock(&gpio_mutex); memset(priv, 0, sizeof(*priv)); priv->minor = p; @@ -414,7 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp) spin_unlock_irq(&gpio_lock); } - unlock_kernel(); + mutex_unlock(&gpio_mutex); return 0; } @@ -667,9 +668,9 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&gpio_mutex); ret = gpio_ioctl_unlocked(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&gpio_mutex); return ret; } diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c index 5ec8a7d4e7d..de8dca0550f 100644 --- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c +++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -64,6 +64,7 @@ static int dp_cnt; #define DP(x) #endif +static DEFINE_MUTEX(gpio_mutex); static char gpio_name[] = "etrax gpio"; #if 0 @@ -429,7 +430,7 @@ gpio_open(struct inode *inode, struct file *filp) if (!priv) return -ENOMEM; - lock_kernel(); + mutex_lock(&gpio_mutex); memset(priv, 0, sizeof(*priv)); priv->minor = p; @@ -450,7 +451,7 @@ gpio_open(struct inode *inode, struct file *filp) alarmlist = priv; spin_unlock_irq(&alarm_lock); - unlock_kernel(); + mutex_unlock(&gpio_mutex); return 0; } @@ -708,9 +709,9 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&gpio_mutex); ret = gpio_ioctl_unlocked(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&gpio_mutex); return ret; } diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c index bef6eb53b15..bdcac9dec5c 100644 --- a/arch/cris/arch-v32/drivers/pcf8563.c +++ b/arch/cris/arch-v32/drivers/pcf8563.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) #define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) +static DEFINE_MUTEX(pcf8563_mutex); static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ static const unsigned char days_in_month[] = @@ -339,9 +339,9 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned { int ret; - lock_kernel(); + mutex_lock(&pcf8563_mutex); return pcf8563_ioctl(filp, cmd, arg); - unlock_kernel(); + mutex_unlock(&pcf8563_mutex); return ret; } diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c index ca248f3adb8..a01ae9f3b81 100644 --- a/arch/cris/arch-v32/drivers/sync_serial.c +++ b/arch/cris/arch-v32/drivers/sync_serial.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -145,6 +145,7 @@ typedef struct sync_port spinlock_t lock; } sync_port; +static DEFINE_MUTEX(sync_serial_mutex); static int etrax_sync_serial_init(void); static void initialize_port(int portnbr); static inline int sync_data_avail(struct sync_port *port); @@ -434,7 +435,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; - lock_kernel(); + mutex_lock(&sync_serial_mutex); DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) @@ -583,7 +584,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) port->busy++; ret = 0; out: - unlock_kernel(); + mutex_unlock(&sync_serial_mutex); return ret; } @@ -966,9 +967,9 @@ static long sync_serial_ioctl(struct file *file, { long ret; - lock_kernel(); + mutex_lock(&sync_serial_mutex); ret = sync_serial_ioctl_unlocked(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&sync_serial_mutex); return ret; } -- cgit v1.2.3 From fa0d4c26be9f989816b30626f6c67d9e7ef867f8 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 18:24:46 +0200 Subject: parisc: remove big kernel lock The parisc version of the perf code is sufficiently protected by its own spinlock, no need to use the BKL. Signed-off-by: Arnd Bergmann Cc: Kyle McMartin Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: linux-parisc@vger.kernel.org --- arch/parisc/kernel/perf.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'arch') diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c index f9f6783e4bd..ba0c053e25a 100644 --- a/arch/parisc/kernel/perf.c +++ b/arch/parisc/kernel/perf.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -261,16 +260,13 @@ printk("Preparing to start counters\n"); */ static int perf_open(struct inode *inode, struct file *file) { - lock_kernel(); spin_lock(&perf_lock); if (perf_enabled) { spin_unlock(&perf_lock); - unlock_kernel(); return -EBUSY; } perf_enabled = 1; spin_unlock(&perf_lock); - unlock_kernel(); return 0; } -- cgit v1.2.3 From 9a181c58617134822ae596339dbea076ef9b5cf7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 11 Sep 2010 18:38:03 +0200 Subject: uml: kill big kernel lock Three uml device drivers still use the big kernel lock, but all of them can be safely converted to using a per-driver mutex instead. Most likely this is not even necessary, so after further review these can and should be removed as well. The exec system call no longer requires the BKL either, so remove it from there, too. Signed-off-by: Arnd Bergmann Cc: Jeff Dike Cc: user-mode-linux-devel@lists.sourceforge.net --- arch/um/drivers/harddog_kern.c | 13 +++++++------ arch/um/drivers/hostaudio_kern.c | 12 +++++++----- arch/um/drivers/ubd_kern.c | 11 ++++++----- arch/um/kernel/exec.c | 2 -- 4 files changed, 20 insertions(+), 18 deletions(-) (limited to 'arch') diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c index cfcac1ff4cf..86036276020 100644 --- a/arch/um/drivers/harddog_kern.c +++ b/arch/um/drivers/harddog_kern.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,6 +50,7 @@ MODULE_LICENSE("GPL"); +static DEFINE_MUTEX(harddog_mutex); static DEFINE_SPINLOCK(lock); static int timer_alive; static int harddog_in_fd = -1; @@ -66,7 +67,7 @@ static int harddog_open(struct inode *inode, struct file *file) int err = -EBUSY; char *sock = NULL; - lock_kernel(); + mutex_lock(&harddog_mutex); spin_lock(&lock); if(timer_alive) goto err; @@ -83,11 +84,11 @@ static int harddog_open(struct inode *inode, struct file *file) timer_alive = 1; spin_unlock(&lock); - unlock_kernel(); + mutex_unlock(&harddog_mutex); return nonseekable_open(inode, file); err: spin_unlock(&lock); - unlock_kernel(); + mutex_unlock(&harddog_mutex); return err; } @@ -153,9 +154,9 @@ static long harddog_ioctl(struct file *file, { long ret; - lock_kernel(); + mutex_lock(&harddog_mutex); ret = harddog_ioctl_unlocked(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&harddog_mutex); return ret; } diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c index 0c46e398cd8..d92ff6d6029 100644 --- a/arch/um/drivers/hostaudio_kern.c +++ b/arch/um/drivers/hostaudio_kern.c @@ -8,7 +8,7 @@ #include "linux/slab.h" #include "linux/sound.h" #include "linux/soundcard.h" -#include "linux/smp_lock.h" +#include "linux/mutex.h" #include "asm/uaccess.h" #include "init.h" #include "os.h" @@ -67,6 +67,8 @@ MODULE_PARM_DESC(mixer, MIXER_HELP); #endif +static DEFINE_MUTEX(hostaudio_mutex); + /* /dev/dsp file operations */ static ssize_t hostaudio_read(struct file *file, char __user *buffer, @@ -202,9 +204,9 @@ static int hostaudio_open(struct inode *inode, struct file *file) w = 1; kparam_block_sysfs_write(dsp); - lock_kernel(); + mutex_lock(&hostaudio_mutex); ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); - unlock_kernel(); + mutex_unlock(&hostaudio_mutex); kparam_unblock_sysfs_write(dsp); if (ret < 0) { @@ -263,9 +265,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file) w = 1; kparam_block_sysfs_write(mixer); - lock_kernel(); + mutex_lock(&hostaudio_mutex); ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); - unlock_kernel(); + mutex_unlock(&hostaudio_mutex); kparam_unblock_sysfs_write(mixer); if (ret < 0) { diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 1bcd208c459..0c053607ce9 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -33,7 +33,7 @@ #include "linux/mm.h" #include "linux/slab.h" #include "linux/vmalloc.h" -#include "linux/smp_lock.h" +#include "linux/mutex.h" #include "linux/blkpg.h" #include "linux/genhd.h" #include "linux/spinlock.h" @@ -100,6 +100,7 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data) #define DRIVER_NAME "uml-blkdev" static DEFINE_MUTEX(ubd_lock); +static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */ static int ubd_open(struct block_device *bdev, fmode_t mode); static int ubd_release(struct gendisk *disk, fmode_t mode); @@ -1099,7 +1100,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode) struct ubd *ubd_dev = disk->private_data; int err = 0; - lock_kernel(); + mutex_lock(&ubd_mutex); if(ubd_dev->count == 0){ err = ubd_open_dev(ubd_dev); if(err){ @@ -1118,7 +1119,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode) err = -EROFS; }*/ out: - unlock_kernel(); + mutex_unlock(&ubd_mutex); return err; } @@ -1126,10 +1127,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode) { struct ubd *ubd_dev = disk->private_data; - lock_kernel(); + mutex_lock(&ubd_mutex); if(--ubd_dev->count == 0) ubd_close_dev(ubd_dev); - unlock_kernel(); + mutex_unlock(&ubd_mutex); return 0; } diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c index cd145eda357..460ce86f401 100644 --- a/arch/um/kernel/exec.c +++ b/arch/um/kernel/exec.c @@ -78,13 +78,11 @@ long sys_execve(const char __user *file, char __user *__user *argv, long error; char *filename; - lock_kernel(); filename = getname(file); error = PTR_ERR(filename); if (IS_ERR(filename)) goto out; error = execve1(filename, argv, env); putname(filename); out: - unlock_kernel(); return error; } -- cgit v1.2.3