aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2010-03-02 02:52:31 -0500
committerRoland Dreier <rolandd@cisco.com>2010-03-02 02:52:31 -0500
commitfe8875e5a41a36ef26072cf05731df5493ade0e1 (patch)
tree786c31c1e86f5287177210fb469c8ecae0bdd146 /drivers/infiniband/core
parentf57721507ffeaf8785f7f17254651de4d8b45e09 (diff)
parenta265e5587f078618c1f17c3a83da65046f18746f (diff)
Merge branch 'misc' into for-next
Conflicts: drivers/infiniband/core/uverbs_main.c
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/ud_header.c14
-rw-r--r--drivers/infiniband/core/umem.c2
-rw-r--r--drivers/infiniband/core/uverbs_main.c61
3 files changed, 10 insertions, 67 deletions
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c
index 8ec7876bedc..650b501eb14 100644
--- a/drivers/infiniband/core/ud_header.c
+++ b/drivers/infiniband/core/ud_header.c
@@ -181,6 +181,7 @@ static const struct ib_field deth_table[] = {
181 * ib_ud_header_init - Initialize UD header structure 181 * ib_ud_header_init - Initialize UD header structure
182 * @payload_bytes:Length of packet payload 182 * @payload_bytes:Length of packet payload
183 * @grh_present:GRH flag (if non-zero, GRH will be included) 183 * @grh_present:GRH flag (if non-zero, GRH will be included)
184 * @immediate_present: specify if immediate data should be used
184 * @header:Structure to initialize 185 * @header:Structure to initialize
185 * 186 *
186 * ib_ud_header_init() initializes the lrh.link_version, lrh.link_next_header, 187 * ib_ud_header_init() initializes the lrh.link_version, lrh.link_next_header,
@@ -191,21 +192,13 @@ static const struct ib_field deth_table[] = {
191 */ 192 */
192void ib_ud_header_init(int payload_bytes, 193void ib_ud_header_init(int payload_bytes,
193 int grh_present, 194 int grh_present,
195 int immediate_present,
194 struct ib_ud_header *header) 196 struct ib_ud_header *header)
195{ 197{
196 int header_len;
197 u16 packet_length; 198 u16 packet_length;
198 199
199 memset(header, 0, sizeof *header); 200 memset(header, 0, sizeof *header);
200 201
201 header_len =
202 IB_LRH_BYTES +
203 IB_BTH_BYTES +
204 IB_DETH_BYTES;
205 if (grh_present) {
206 header_len += IB_GRH_BYTES;
207 }
208
209 header->lrh.link_version = 0; 202 header->lrh.link_version = 0;
210 header->lrh.link_next_header = 203 header->lrh.link_next_header =
211 grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL; 204 grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL;
@@ -231,7 +224,8 @@ void ib_ud_header_init(int payload_bytes,
231 224
232 header->lrh.packet_length = cpu_to_be16(packet_length); 225 header->lrh.packet_length = cpu_to_be16(packet_length);
233 226
234 if (header->immediate_present) 227 header->immediate_present = immediate_present;
228 if (immediate_present)
235 header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; 229 header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
236 else 230 else
237 header->bth.opcode = IB_OPCODE_UD_SEND_ONLY; 231 header->bth.opcode = IB_OPCODE_UD_SEND_ONLY;
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 6f7c096abf1..4f906f0614f 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -136,7 +136,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
136 down_write(&current->mm->mmap_sem); 136 down_write(&current->mm->mmap_sem);
137 137
138 locked = npages + current->mm->locked_vm; 138 locked = npages + current->mm->locked_vm;
139 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT; 139 lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
140 140
141 if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) { 141 if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
142 ret = -ENOMEM; 142 ret = -ENOMEM;
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index dbf04511cf0..ff59a795e84 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -42,7 +42,8 @@
42#include <linux/poll.h> 42#include <linux/poll.h>
43#include <linux/sched.h> 43#include <linux/sched.h>
44#include <linux/file.h> 44#include <linux/file.h>
45#include <linux/mount.h> 45#include <linux/cdev.h>
46#include <linux/anon_inodes.h>
46 47
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
@@ -52,8 +53,6 @@ MODULE_AUTHOR("Roland Dreier");
52MODULE_DESCRIPTION("InfiniBand userspace verbs access"); 53MODULE_DESCRIPTION("InfiniBand userspace verbs access");
53MODULE_LICENSE("Dual BSD/GPL"); 54MODULE_LICENSE("Dual BSD/GPL");
54 55
55#define INFINIBANDEVENTFS_MAGIC 0x49426576 /* "IBev" */
56
57enum { 56enum {
58 IB_UVERBS_MAJOR = 231, 57 IB_UVERBS_MAJOR = 231,
59 IB_UVERBS_BASE_MINOR = 192, 58 IB_UVERBS_BASE_MINOR = 192,
@@ -109,8 +108,6 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
109 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq, 108 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
110}; 109};
111 110
112static struct vfsmount *uverbs_event_mnt;
113
114static void ib_uverbs_add_one(struct ib_device *device); 111static void ib_uverbs_add_one(struct ib_device *device);
115static void ib_uverbs_remove_one(struct ib_device *device); 112static void ib_uverbs_remove_one(struct ib_device *device);
116 113
@@ -490,7 +487,6 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
490 int is_async, int *fd) 487 int is_async, int *fd)
491{ 488{
492 struct ib_uverbs_event_file *ev_file; 489 struct ib_uverbs_event_file *ev_file;
493 struct path path;
494 struct file *filp; 490 struct file *filp;
495 int ret; 491 int ret;
496 492
@@ -513,27 +509,16 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
513 goto err; 509 goto err;
514 } 510 }
515 511
516 /* 512 filp = anon_inode_getfile("[uverbs-event]", &uverbs_event_fops,
517 * fops_get() can't fail here, because we're coming from a 513 ev_file, O_RDONLY);
518 * system call on a uverbs file, which will already have a
519 * module reference.
520 */
521 path.mnt = uverbs_event_mnt;
522 path.dentry = uverbs_event_mnt->mnt_root;
523 path_get(&path);
524 filp = alloc_file(&path, FMODE_READ, fops_get(&uverbs_event_fops));
525 if (!filp) { 514 if (!filp) {
526 ret = -ENFILE; 515 ret = -ENFILE;
527 goto err_fd; 516 goto err_fd;
528 } 517 }
529 518
530 filp->private_data = ev_file;
531
532 return filp; 519 return filp;
533 520
534err_fd: 521err_fd:
535 fops_put(&uverbs_event_fops);
536 path_put(&path);
537 put_unused_fd(*fd); 522 put_unused_fd(*fd);
538 523
539err: 524err:
@@ -854,21 +839,6 @@ static void ib_uverbs_remove_one(struct ib_device *device)
854 kfree(uverbs_dev); 839 kfree(uverbs_dev);
855} 840}
856 841
857static int uverbs_event_get_sb(struct file_system_type *fs_type, int flags,
858 const char *dev_name, void *data,
859 struct vfsmount *mnt)
860{
861 return get_sb_pseudo(fs_type, "infinibandevent:", NULL,
862 INFINIBANDEVENTFS_MAGIC, mnt);
863}
864
865static struct file_system_type uverbs_event_fs = {
866 /* No owner field so module can be unloaded */
867 .name = "infinibandeventfs",
868 .get_sb = uverbs_event_get_sb,
869 .kill_sb = kill_litter_super
870};
871
872static int __init ib_uverbs_init(void) 842static int __init ib_uverbs_init(void)
873{ 843{
874 int ret; 844 int ret;
@@ -893,33 +863,14 @@ static int __init ib_uverbs_init(void)
893 goto out_class; 863 goto out_class;
894 } 864 }
895 865
896 ret = register_filesystem(&uverbs_event_fs);
897 if (ret) {
898 printk(KERN_ERR "user_verbs: couldn't register infinibandeventfs\n");
899 goto out_class;
900 }
901
902 uverbs_event_mnt = kern_mount(&uverbs_event_fs);
903 if (IS_ERR(uverbs_event_mnt)) {
904 ret = PTR_ERR(uverbs_event_mnt);
905 printk(KERN_ERR "user_verbs: couldn't mount infinibandeventfs\n");
906 goto out_fs;
907 }
908
909 ret = ib_register_client(&uverbs_client); 866 ret = ib_register_client(&uverbs_client);
910 if (ret) { 867 if (ret) {
911 printk(KERN_ERR "user_verbs: couldn't register client\n"); 868 printk(KERN_ERR "user_verbs: couldn't register client\n");
912 goto out_mnt; 869 goto out_class;
913 } 870 }
914 871
915 return 0; 872 return 0;
916 873
917out_mnt:
918 mntput(uverbs_event_mnt);
919
920out_fs:
921 unregister_filesystem(&uverbs_event_fs);
922
923out_class: 874out_class:
924 class_destroy(uverbs_class); 875 class_destroy(uverbs_class);
925 876
@@ -933,8 +884,6 @@ out:
933static void __exit ib_uverbs_cleanup(void) 884static void __exit ib_uverbs_cleanup(void)
934{ 885{
935 ib_unregister_client(&uverbs_client); 886 ib_unregister_client(&uverbs_client);
936 mntput(uverbs_event_mnt);
937 unregister_filesystem(&uverbs_event_fs);
938 class_destroy(uverbs_class); 887 class_destroy(uverbs_class);
939 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES); 888 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
940 if (overflow_maj) 889 if (overflow_maj)