From 40b798efe3460797a4ac928ee2e038774e2758eb Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 15:35:43 +0000 Subject: [PATCH 01/16] drivers: Remove BKL from misc_open misc_open() is already serialized with misc_mtx. Remove the BKL locking which got there via the BKL pushdown. Signed-off-by: Thomas Gleixner Cc: Greg Kroah-Hartman LKML-Reference: <20091010153349.237173041@linutronix.de> --- drivers/char/misc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 07fa612a58d..96f1cd086dd 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -49,7 +49,6 @@ #include #include #include -#include /* * Head entry for the doubly linked miscdevice list @@ -118,8 +117,7 @@ static int misc_open(struct inode * inode, struct file * file) struct miscdevice *c; int err = -ENODEV; const struct file_operations *old_fops, *new_fops = NULL; - - lock_kernel(); + mutex_lock(&misc_mtx); list_for_each_entry(c, &misc_list, list) { @@ -157,7 +155,6 @@ static int misc_open(struct inode * inode, struct file * file) fops_put(old_fops); fail: mutex_unlock(&misc_mtx); - unlock_kernel(); return err; } From a7e63bb5f08378620d913824ab42e49027f22194 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 15:35:48 +0000 Subject: [PATCH 02/16] drivers: Remove BKL from cs5535_gpio The big BKL pushdown added cycle_kernel_lock(). There is nothing to wait for in this driver. Remove it. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153349.277882707@linutronix.de> --- drivers/char/cs5535_gpio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c index 04ba906b488..4d830dc482e 100644 --- a/drivers/char/cs5535_gpio.c +++ b/drivers/char/cs5535_gpio.c @@ -17,7 +17,7 @@ #include #include #include -#include + #include #include @@ -158,7 +158,6 @@ static int cs5535_gpio_open(struct inode *inode, struct file *file) { u32 m = iminor(inode); - cycle_kernel_lock(); /* the mask says which pins are usable by this driver */ if ((mask & (1 << m)) == 0) return -EINVAL; From 4c2aedc2543248c3fdc8c06c662b589d36c93bbb Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 15:35:52 +0000 Subject: [PATCH 03/16] spi: Remove BKL from spidev_open The BKL was added there with the big pushdown. Remove it as the code is serialized already. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153349.318535932@linutronix.de> Cc: David Brownell --- drivers/spi/spidev.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 5d23983f02f..815a65012cb 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -477,7 +476,6 @@ static int spidev_open(struct inode *inode, struct file *filp) struct spidev_data *spidev; int status = -ENXIO; - lock_kernel(); mutex_lock(&device_list_lock); list_for_each_entry(spidev, &device_list, device_entry) { @@ -503,7 +501,6 @@ static int spidev_open(struct inode *inode, struct file *filp) pr_debug("spidev: nothing for minor %d\n", iminor(inode)); mutex_unlock(&device_list_lock); - unlock_kernel(); return status; } From 205153aa40b7fb36dc7fe76c1798584ace55b288 Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Fri, 9 Oct 2009 20:31:02 +0200 Subject: [PATCH 04/16] mem_class: Drop the bkl from memory_open() The generic open callback for the mem class devices is "protected" by the bkl. Let's look at the datas manipulated inside memory_open: - inode and file: safe - the devlist: safe because it is constant - the memdev classes inside this array are safe too (constant) After we find out which memdev file operation we need to use, we call its open callback. Depending on the targeted memdev, we call either open_port() that doesn't manipulate any racy data (just a capable() check), or we call nothing. So it's safe to remove the big kernel lock there. Signed-off-by: Frederic Weisbecker LKML-Reference: <1255113062-5835-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Thomas Gleixner --- drivers/char/mem.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/char/mem.c b/drivers/char/mem.c index a074fceb67d..ad82ec92ebd 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -892,29 +891,23 @@ static int memory_open(struct inode *inode, struct file *filp) { int minor; const struct memdev *dev; - int ret = -ENXIO; - - lock_kernel(); minor = iminor(inode); if (minor >= ARRAY_SIZE(devlist)) - goto out; + return -ENXIO; dev = &devlist[minor]; if (!dev->fops) - goto out; + return -ENXIO; filp->f_op = dev->fops; if (dev->dev_info) filp->f_mapping->backing_dev_info = dev->dev_info; if (dev->fops->open) - ret = dev->fops->open(inode, filp); - else - ret = 0; -out: - unlock_kernel(); - return ret; + return dev->fops->open(inode, filp); + + return 0; } static const struct file_operations memory_fops = { From 6783b9cd7104470a3afab51c205c5aea53a2858f Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Fri, 9 Oct 2009 21:20:30 +0200 Subject: [PATCH 05/16] nvram: Drop the bkl from nvram_llseek() There is nothing to protect inside nvram_llseek(), the file offset doesn't need to be protected and nvram_len is only initialized from an __init path. It's safe to remove the big kernel lock there. Signed-off-by: Frederic Weisbecker LKML-Reference: <1255116030-6929-1-git-send-email-fweisbec@gmail.com> Cc: Greg KH Signed-off-by: Thomas Gleixner --- drivers/char/generic_nvram.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c index ef31738c2cb..fda4181b5e6 100644 --- a/drivers/char/generic_nvram.c +++ b/drivers/char/generic_nvram.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #ifdef CONFIG_PPC_PMAC @@ -32,7 +31,6 @@ static ssize_t nvram_len; static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) { - lock_kernel(); switch (origin) { case 1: offset += file->f_pos; @@ -41,12 +39,11 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) offset += nvram_len; break; } - if (offset < 0) { - unlock_kernel(); + if (offset < 0) return -EINVAL; - } + file->f_pos = offset; - unlock_kernel(); + return file->f_pos; } From 9e8ab74ddaa591575f599248080a1f0d917a56ee Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Fri, 9 Oct 2009 21:27:06 +0200 Subject: [PATCH 06/16] nvram: Drop the bkl from non-generic nvram_llseek() Drop the bkl from nvram_llseek() as it obviously protects nothing. The file offset is safe in essence. Signed-off-by: Frederic Weisbecker LKML-Reference: <1255116426-7270-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Thomas Gleixner --- drivers/char/nvram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 88cee4099be..2100a8f7bd8 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c @@ -38,7 +38,6 @@ #define NVRAM_VERSION "1.3" #include -#include #include #define PC 1 @@ -214,7 +213,6 @@ void nvram_set_checksum(void) static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) { - lock_kernel(); switch (origin) { case 0: /* nothing to do */ @@ -226,7 +224,7 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) offset += NVRAM_BYTES; break; } - unlock_kernel(); + return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; } From 95fdac73725c15072d068ac7f131958cf5c324e4 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 13:38:57 +0200 Subject: [PATCH 07/16] macintosh: Remove BKL from ans-lcd The ans-lcd driver got the cycle_kernel_lock() in anslcd_open() from the BKL pushdown and it still uses the locked ioctl. The BKL serialization in this driver is more than obscure and definitely does not cover all possible corner cases. Protect the access to the hardware with a local mutex and get rid of BKL and locked ioctl. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153349.966159859@linutronix.de> Acked-by: Benjamin Herrenschmidt --- drivers/macintosh/ans-lcd.c | 45 +++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c index 6a822189325..a3d25da2f27 100644 --- a/drivers/macintosh/ans-lcd.c +++ b/drivers/macintosh/ans-lcd.c @@ -3,7 +3,6 @@ */ #include -#include #include #include #include @@ -26,6 +25,7 @@ static unsigned long anslcd_short_delay = 80; static unsigned long anslcd_long_delay = 3280; static volatile unsigned char __iomem *anslcd_ptr; +static DEFINE_MUTEX(anslcd_mutex); #undef DEBUG @@ -65,26 +65,31 @@ anslcd_write( struct file * file, const char __user * buf, if (!access_ok(VERIFY_READ, buf, count)) return -EFAULT; + + mutex_lock(&anslcd_mutex); for ( i = *ppos; count > 0; ++i, ++p, --count ) { char c; __get_user(c, p); anslcd_write_byte_data( c ); } + mutex_unlock(&anslcd_mutex); *ppos = i; return p - buf; } -static int -anslcd_ioctl( struct inode * inode, struct file * file, - unsigned int cmd, unsigned long arg ) +static long +anslcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { char ch, __user *temp; + long ret = 0; #ifdef DEBUG printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg); #endif + mutex_lock(&anslcd_mutex); + switch ( cmd ) { case ANSLCD_CLEAR: @@ -93,7 +98,7 @@ anslcd_ioctl( struct inode * inode, struct file * file, anslcd_write_byte_ctrl ( 0x06 ); anslcd_write_byte_ctrl ( 0x01 ); anslcd_write_byte_ctrl ( 0x02 ); - return 0; + break; case ANSLCD_SENDCTRL: temp = (char __user *) arg; __get_user(ch, temp); @@ -101,33 +106,37 @@ anslcd_ioctl( struct inode * inode, struct file * file, anslcd_write_byte_ctrl ( ch ); __get_user(ch, temp); } - return 0; + break; case ANSLCD_SETSHORTDELAY: if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - anslcd_short_delay=arg; - return 0; + ret =-EACCES; + else + anslcd_short_delay=arg; + break; case ANSLCD_SETLONGDELAY: if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - anslcd_long_delay=arg; - return 0; + ret = -EACCES; + else + anslcd_long_delay=arg; + break; default: - return -EINVAL; + ret = -EINVAL; } + + mutex_unlock(&anslcd_mutex); + return ret; } static int anslcd_open( struct inode * inode, struct file * file ) { - cycle_kernel_lock(); return 0; } const struct file_operations anslcd_fops = { - .write = anslcd_write, - .ioctl = anslcd_ioctl, - .open = anslcd_open, + .write = anslcd_write, + .unlocked_ioctl = anslcd_ioctl, + .open = anslcd_open, }; static struct miscdevice anslcd_dev = { @@ -168,6 +177,7 @@ anslcd_init(void) printk(KERN_DEBUG "LCD: init\n"); #endif + mutex_lock(&anslcd_mutex); anslcd_write_byte_ctrl ( 0x38 ); anslcd_write_byte_ctrl ( 0x0c ); anslcd_write_byte_ctrl ( 0x06 ); @@ -176,6 +186,7 @@ anslcd_init(void) for(a=0;a<80;a++) { anslcd_write_byte_data(anslcd_logo[a]); } + mutex_unlock(&anslcd_mutex); return 0; } From a09ba31a54dbc9a548c4ff90619e4c7128a4282e Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 12:36:32 +0200 Subject: [PATCH 08/16] hw_random: Remove BKL from core hw_random core is completely serialized with rng_mutex. No need for the cycle_kernel_lock() magic. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153349.844488872@linutronix.de> Cc: Herbert Xu --- drivers/char/hw_random/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 1573aebd54b..75fb859a50b 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -87,7 +87,6 @@ static int rng_dev_open(struct inode *inode, struct file *filp) return -EINVAL; if (filp->f_mode & FMODE_WRITE) return -EINVAL; - cycle_kernel_lock(); return 0; } From d2d23559857e5f34762c61487f8ffb2fa4d7442d Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 12:41:43 +0200 Subject: [PATCH 09/16] input: Remove BKL from hp_sdc_rtc cycle_kernel_lock() was added during the big BKL pushdown. It should ensure the serializiation against driver init code. In this case there is nothing to serialize. Remove it. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153349.884891604@linutronix.de> Cc: Geert Uytterhoeven Cc: Dmitry Torokhov --- drivers/input/misc/hp_sdc_rtc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 216a559f55e..4d1aa9a2c33 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -409,7 +408,6 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait) static int hp_sdc_rtc_open(struct inode *inode, struct file *file) { - cycle_kernel_lock(); return 0; } From a5ee6dc9ebe8fc2640ee3fbf2c340bd853e2fd36 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 15:14:03 +0200 Subject: [PATCH 10/16] rtc: Remove BKL from efirtc BKL locking came to efirtc via the big BKL push down, but the access to the efi functions is protected by efi_rtc_lock already. Remove it. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153350.046644063@linutronix.de> --- drivers/char/efirtc.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index 34d15d54823..26a47dc88f6 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c @@ -27,8 +27,6 @@ * - Add module support */ - -#include #include #include #include @@ -174,13 +172,12 @@ static long efi_rtc_ioctl(struct file *file, unsigned int cmd, return -EINVAL; case RTC_RD_TIME: - lock_kernel(); spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.get_time(&eft, &cap); spin_unlock_irqrestore(&efi_rtc_lock,flags); - unlock_kernel(); + if (status != EFI_SUCCESS) { /* should never happen */ printk(KERN_ERR "efitime: can't read time\n"); @@ -202,13 +199,11 @@ static long efi_rtc_ioctl(struct file *file, unsigned int cmd, convert_to_efi_time(&wtime, &eft); - lock_kernel(); spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.set_time(&eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); - unlock_kernel(); return status == EFI_SUCCESS ? 0 : -EINVAL; @@ -224,7 +219,6 @@ static long efi_rtc_ioctl(struct file *file, unsigned int cmd, convert_to_efi_time(&wtime, &eft); - lock_kernel(); spin_lock_irqsave(&efi_rtc_lock, flags); /* * XXX Fixme: @@ -235,19 +229,16 @@ static long efi_rtc_ioctl(struct file *file, unsigned int cmd, status = efi.set_wakeup_time((efi_bool_t)enabled, &eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); - unlock_kernel(); return status == EFI_SUCCESS ? 0 : -EINVAL; case RTC_WKALM_RD: - lock_kernel(); spin_lock_irqsave(&efi_rtc_lock, flags); status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft); spin_unlock_irqrestore(&efi_rtc_lock,flags); - unlock_kernel(); if (status != EFI_SUCCESS) return -EINVAL; @@ -277,7 +268,6 @@ static int efi_rtc_open(struct inode *inode, struct file *file) * We do accept multiple open files at the same time as we * synchronize on the per call operation. */ - cycle_kernel_lock(); return 0; } From eb29b758a8b0b2dbffd8dc898490237d3ee783e4 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 15:33:17 +0200 Subject: [PATCH 11/16] parisc: Remove BKL from eisa_eeprom Remove the empty ioctl and the cycle_kernel_lock() in eisa_eeprom_open() which got there with the big BKL push down. There is nothing to wait for and sychronize with after the misc device has been registered. Remove the empty ioctl as well. The generic code handles the -ENOTTY if no ioctl function is provided. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153350.086917493@linutronix.de> Cc: Kyle McMartin --- drivers/parisc/eisa_eeprom.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c index 8c0b26e9b98..cce00ed81f3 100644 --- a/drivers/parisc/eisa_eeprom.c +++ b/drivers/parisc/eisa_eeprom.c @@ -75,17 +75,8 @@ static ssize_t eisa_eeprom_read(struct file * file, return ret; } -static int eisa_eeprom_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, - unsigned long arg) -{ - return -ENOTTY; -} - static int eisa_eeprom_open(struct inode *inode, struct file *file) { - cycle_kernel_lock(); - if (file->f_mode & FMODE_WRITE) return -EINVAL; @@ -104,7 +95,6 @@ static const struct file_operations eisa_eeprom_fops = { .owner = THIS_MODULE, .llseek = eisa_eeprom_llseek, .read = eisa_eeprom_read, - .ioctl = eisa_eeprom_ioctl, .open = eisa_eeprom_open, .release = eisa_eeprom_release, }; From 71d69bc2c0202f438669073d849999d2f6b6ca31 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 15:56:00 +0200 Subject: [PATCH 12/16] drivers: Remove BKL from pc8736x_gpio cycle_kernel_lock() was added during the big BKL pushdown. It should ensure the serializiation against driver init code. In this case there is nothing to serialize. Remove it. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153350.127093710@linutronix.de> Acked-by: Jim Cromie --- drivers/char/pc8736x_gpio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index 3f7da8cf3a8..8ecbcc174c1 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #define DEVNAME "pc8736x_gpio" @@ -223,7 +222,6 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file) unsigned m = iminor(inode); file->private_data = &pc8736x_gpio_ops; - cycle_kernel_lock(); dev_dbg(&pdev->dev, "open %d\n", m); if (m >= PC8736X_GPIO_CT) From 3a8183a2061ba54c4c2b3cd31c3add6fd717e853 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 16:02:53 +0200 Subject: [PATCH 13/16] drivers: Remove BKL from scx200_gpio cycle_kernel_lock() was added during the big BKL pushdown. It should ensure the serializiation against driver init code. In this case there is nothing to serialize. Remove it. Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153350.167321547@linutronix.de> Acked-by: Jim Cromie --- drivers/char/scx200_gpio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 1d9100561c8..99e5272e3c5 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -52,7 +51,6 @@ static int scx200_gpio_open(struct inode *inode, struct file *file) unsigned m = iminor(inode); file->private_data = &scx200_gpio_ops; - cycle_kernel_lock(); if (m >= MAX_PINS) return -EINVAL; return nonseekable_open(inode, file); From d2a7be0be1099c2554f4705d2c1c5081f8f96efc Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sat, 10 Oct 2009 16:07:03 +0200 Subject: [PATCH 14/16] mips: Remove BKL from tb0219 cycle_kernel_lock() was added during the big BKL pushdown. It should ensure the serializiation against driver init code. tb0219_base is initialized before the character device is registered, but the spinlock is not initialized. Initialize the spinlock statically and remove cycle_kernel_lock(). Signed-off-by: Thomas Gleixner LKML-Reference: <20091010153350.222654356@linutronix.de> Cc: Yoichi Yuasa Cc: Ralf Baechle --- drivers/char/tb0219.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c index b3ec9b10e29..cad4eb65f13 100644 --- a/drivers/char/tb0219.c +++ b/drivers/char/tb0219.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -38,7 +37,7 @@ MODULE_PARM_DESC(major, "Major device number"); static void (*old_machine_restart)(char *command); static void __iomem *tb0219_base; -static spinlock_t tb0219_lock; +static DEFINE_SPINLOCK(tb0219_lock); #define tb0219_read(offset) readw(tb0219_base + (offset)) #define tb0219_write(offset, value) writew((value), tb0219_base + (offset)) @@ -237,7 +236,6 @@ static int tanbac_tb0219_open(struct inode *inode, struct file *file) { unsigned int minor; - cycle_kernel_lock(); minor = iminor(inode); switch (minor) { case 0: @@ -306,8 +304,6 @@ static int __devinit tb0219_probe(struct platform_device *dev) return retval; } - spin_lock_init(&tb0219_lock); - old_machine_restart = _machine_restart; _machine_restart = tb0219_restart; From f96d3015e9f7f7fff4cab7ed1d467664cc980061 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 14 Oct 2009 16:36:26 +0200 Subject: [PATCH 15/16] inifiband: Remove BKL from ipath_open() cycle_kernel_lock() got pushed down to ipath_open(). I tried hard to understand what it might protect, but finally gave up. Roland noted that qlogic seems to have abandoned the ipath driver and came to the following wise conclusion: "So I guess if the BKL stuff is blocking you in any way, we can just drop it from ipath and leave it as yet another race condition in a rotting old driver." Signed-off-by: Thomas Gleixner LKML-Reference: Cc: Roland Dreier --- drivers/infiniband/hw/ipath/ipath_file_ops.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 40dbe54056c..73933a41ce8 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c @@ -1821,7 +1821,6 @@ done: static int ipath_open(struct inode *in, struct file *fp) { /* The real work is performed later in ipath_assign_port() */ - cycle_kernel_lock(); fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL); return fp->private_data ? 0 : -ENOMEM; } From 55e858c8483af427144f33b42b818b30612b82b0 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Sun, 11 Oct 2009 22:24:25 +0200 Subject: [PATCH 16/16] agp: Remove the BKL from agp_open - Remove the BKL from agp_open - Perform a few clean-ups. Analysis: --------- int minor is local to the function. The following are protected by agp_fe.agp_mutex struct agp_file_private *priv; struct agp_client *client; Call-outs: kzalloc should be safe to call under the mutex_lock agp_find_client_by_pid: - agp_mmap calls that under agp_fe.agp_mutex which we hold in agp_open - agpioc_reserve_wrap calls it without any locking what-so-ever. - Is that an error? Or is that okay because it has pid that is a unique handle? agp_insert_file_private: - This function only manipulates struct agp_file_private, once again while agp_fe.agp_mutex is held Signed-off-by: John Kacur Acked-by: David Airlie LKML-Reference: Signed-off-by: Thomas Gleixner --- drivers/char/agp/frontend.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index a96f3197e60..43412c03969 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c @@ -676,25 +676,25 @@ static int agp_open(struct inode *inode, struct file *file) int minor = iminor(inode); struct agp_file_private *priv; struct agp_client *client; - int rc = -ENXIO; - - lock_kernel(); - mutex_lock(&(agp_fe.agp_mutex)); if (minor != AGPGART_MINOR) - goto err_out; + return -ENXIO; + + mutex_lock(&(agp_fe.agp_mutex)); priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL); - if (priv == NULL) - goto err_out_nomem; + if (priv == NULL) { + mutex_unlock(&(agp_fe.agp_mutex)); + return -ENOMEM; + } set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags); priv->my_pid = current->pid; - if (capable(CAP_SYS_RAWIO)) { + if (capable(CAP_SYS_RAWIO)) /* Root priv, can be controller */ set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags); - } + client = agp_find_client_by_pid(current->pid); if (client != NULL) { @@ -704,16 +704,10 @@ static int agp_open(struct inode *inode, struct file *file) file->private_data = (void *) priv; agp_insert_file_private(priv); DBG("private=%p, client=%p", priv, client); - mutex_unlock(&(agp_fe.agp_mutex)); - unlock_kernel(); - return 0; -err_out_nomem: - rc = -ENOMEM; -err_out: mutex_unlock(&(agp_fe.agp_mutex)); - unlock_kernel(); - return rc; + + return 0; }