|
@@ -45,7 +45,6 @@
|
|
#include <linux/file.h>
|
|
#include <linux/file.h>
|
|
#include <linux/mount.h>
|
|
#include <linux/mount.h>
|
|
#include <linux/cdev.h>
|
|
#include <linux/cdev.h>
|
|
-#include <linux/smp_lock.h>
|
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
@@ -611,23 +610,32 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
|
|
return file->device->ib_dev->mmap(file->ucontext, vma);
|
|
return file->device->ib_dev->mmap(file->ucontext, vma);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * ib_uverbs_open() does not need the BKL:
|
|
|
|
+ *
|
|
|
|
+ * - dev_table[] accesses are protected by map_lock, the
|
|
|
|
+ * ib_uverbs_device structures are properly reference counted, and
|
|
|
|
+ * everything else is purely local to the file being created, so
|
|
|
|
+ * races against other open calls are not a problem;
|
|
|
|
+ * - there is no ioctl method to race against;
|
|
|
|
+ * - the device is added to dev_table[] as the last part of module
|
|
|
|
+ * initialization, the open method will either immediately run
|
|
|
|
+ * -ENXIO, or all required initialization will be done.
|
|
|
|
+ */
|
|
static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
|
static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
|
{
|
|
{
|
|
struct ib_uverbs_device *dev;
|
|
struct ib_uverbs_device *dev;
|
|
struct ib_uverbs_file *file;
|
|
struct ib_uverbs_file *file;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
- lock_kernel();
|
|
|
|
spin_lock(&map_lock);
|
|
spin_lock(&map_lock);
|
|
dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
|
|
dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
|
|
if (dev)
|
|
if (dev)
|
|
kref_get(&dev->ref);
|
|
kref_get(&dev->ref);
|
|
spin_unlock(&map_lock);
|
|
spin_unlock(&map_lock);
|
|
|
|
|
|
- if (!dev) {
|
|
|
|
- unlock_kernel();
|
|
|
|
|
|
+ if (!dev)
|
|
return -ENXIO;
|
|
return -ENXIO;
|
|
- }
|
|
|
|
|
|
|
|
if (!try_module_get(dev->ib_dev->owner)) {
|
|
if (!try_module_get(dev->ib_dev->owner)) {
|
|
ret = -ENODEV;
|
|
ret = -ENODEV;
|
|
@@ -648,7 +656,6 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
|
|
|
|
|
filp->private_data = file;
|
|
filp->private_data = file;
|
|
|
|
|
|
- unlock_kernel();
|
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
err_module:
|
|
err_module:
|
|
@@ -656,7 +663,6 @@ err_module:
|
|
|
|
|
|
err:
|
|
err:
|
|
kref_put(&dev->ref, ib_uverbs_release_dev);
|
|
kref_put(&dev->ref, ib_uverbs_release_dev);
|
|
- unlock_kernel();
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|