diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-13 18:29:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-13 18:29:07 -0500 |
commit | fb7ffeb11bb7e9e75dc83ff67a4925c270e0fa3c (patch) | |
tree | 6344d7a8a8a828f346f8eceb99339f8ba2c63cc1 | |
parent | 69eebed240b32377b9034551f1b8c4ae2774ceb6 (diff) | |
parent | 95ed644fd12f53c6fc778f3f246974e5fe3a9468 (diff) |
Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
21 files changed, 287 insertions, 352 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 3a611fe5497e..c06b18102b6a 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -3163,22 +3163,6 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, | |||
3163 | } | 3163 | } |
3164 | EXPORT_SYMBOL(ib_cm_init_qp_attr); | 3164 | EXPORT_SYMBOL(ib_cm_init_qp_attr); |
3165 | 3165 | ||
3166 | static __be64 cm_get_ca_guid(struct ib_device *device) | ||
3167 | { | ||
3168 | struct ib_device_attr *device_attr; | ||
3169 | __be64 guid; | ||
3170 | int ret; | ||
3171 | |||
3172 | device_attr = kmalloc(sizeof *device_attr, GFP_KERNEL); | ||
3173 | if (!device_attr) | ||
3174 | return 0; | ||
3175 | |||
3176 | ret = ib_query_device(device, device_attr); | ||
3177 | guid = ret ? 0 : device_attr->node_guid; | ||
3178 | kfree(device_attr); | ||
3179 | return guid; | ||
3180 | } | ||
3181 | |||
3182 | static void cm_add_one(struct ib_device *device) | 3166 | static void cm_add_one(struct ib_device *device) |
3183 | { | 3167 | { |
3184 | struct cm_device *cm_dev; | 3168 | struct cm_device *cm_dev; |
@@ -3200,9 +3184,7 @@ static void cm_add_one(struct ib_device *device) | |||
3200 | return; | 3184 | return; |
3201 | 3185 | ||
3202 | cm_dev->device = device; | 3186 | cm_dev->device = device; |
3203 | cm_dev->ca_guid = cm_get_ca_guid(device); | 3187 | cm_dev->ca_guid = device->node_guid; |
3204 | if (!cm_dev->ca_guid) | ||
3205 | goto error1; | ||
3206 | 3188 | ||
3207 | set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); | 3189 | set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); |
3208 | for (i = 1; i <= device->phys_port_cnt; i++) { | 3190 | for (i = 1; i <= device->phys_port_cnt; i++) { |
@@ -3217,11 +3199,11 @@ static void cm_add_one(struct ib_device *device) | |||
3217 | cm_recv_handler, | 3199 | cm_recv_handler, |
3218 | port); | 3200 | port); |
3219 | if (IS_ERR(port->mad_agent)) | 3201 | if (IS_ERR(port->mad_agent)) |
3220 | goto error2; | 3202 | goto error1; |
3221 | 3203 | ||
3222 | ret = ib_modify_port(device, i, 0, &port_modify); | 3204 | ret = ib_modify_port(device, i, 0, &port_modify); |
3223 | if (ret) | 3205 | if (ret) |
3224 | goto error3; | 3206 | goto error2; |
3225 | } | 3207 | } |
3226 | ib_set_client_data(device, &cm_client, cm_dev); | 3208 | ib_set_client_data(device, &cm_client, cm_dev); |
3227 | 3209 | ||
@@ -3230,9 +3212,9 @@ static void cm_add_one(struct ib_device *device) | |||
3230 | write_unlock_irqrestore(&cm.device_lock, flags); | 3212 | write_unlock_irqrestore(&cm.device_lock, flags); |
3231 | return; | 3213 | return; |
3232 | 3214 | ||
3233 | error3: | ||
3234 | ib_unregister_mad_agent(port->mad_agent); | ||
3235 | error2: | 3215 | error2: |
3216 | ib_unregister_mad_agent(port->mad_agent); | ||
3217 | error1: | ||
3236 | port_modify.set_port_cap_mask = 0; | 3218 | port_modify.set_port_cap_mask = 0; |
3237 | port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; | 3219 | port_modify.clr_port_cap_mask = IB_PORT_CM_SUP; |
3238 | while (--i) { | 3220 | while (--i) { |
@@ -3240,7 +3222,6 @@ error2: | |||
3240 | ib_modify_port(device, port->port_num, 0, &port_modify); | 3222 | ib_modify_port(device, port->port_num, 0, &port_modify); |
3241 | ib_unregister_mad_agent(port->mad_agent); | 3223 | ib_unregister_mad_agent(port->mad_agent); |
3242 | } | 3224 | } |
3243 | error1: | ||
3244 | kfree(cm_dev); | 3225 | kfree(cm_dev); |
3245 | } | 3226 | } |
3246 | 3227 | ||
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index e169e798354b..b2f3cb91d9bc 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
@@ -38,8 +38,7 @@ | |||
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | 41 | #include <linux/mutex.h> | |
42 | #include <asm/semaphore.h> | ||
43 | 42 | ||
44 | #include "core_priv.h" | 43 | #include "core_priv.h" |
45 | 44 | ||
@@ -57,13 +56,13 @@ static LIST_HEAD(device_list); | |||
57 | static LIST_HEAD(client_list); | 56 | static LIST_HEAD(client_list); |
58 | 57 | ||
59 | /* | 58 | /* |
60 | * device_sem protects access to both device_list and client_list. | 59 | * device_mutex protects access to both device_list and client_list. |
61 | * There's no real point to using multiple locks or something fancier | 60 | * There's no real point to using multiple locks or something fancier |
62 | * like an rwsem: we always access both lists, and we're always | 61 | * like an rwsem: we always access both lists, and we're always |
63 | * modifying one list or the other list. In any case this is not a | 62 | * modifying one list or the other list. In any case this is not a |
64 | * hot path so there's no point in trying to optimize. | 63 | * hot path so there's no point in trying to optimize. |
65 | */ | 64 | */ |
66 | static DECLARE_MUTEX(device_sem); | 65 | static DEFINE_MUTEX(device_mutex); |
67 | 66 | ||
68 | static int ib_device_check_mandatory(struct ib_device *device) | 67 | static int ib_device_check_mandatory(struct ib_device *device) |
69 | { | 68 | { |
@@ -221,7 +220,7 @@ int ib_register_device(struct ib_device *device) | |||
221 | { | 220 | { |
222 | int ret; | 221 | int ret; |
223 | 222 | ||
224 | down(&device_sem); | 223 | mutex_lock(&device_mutex); |
225 | 224 | ||
226 | if (strchr(device->name, '%')) { | 225 | if (strchr(device->name, '%')) { |
227 | ret = alloc_name(device->name); | 226 | ret = alloc_name(device->name); |
@@ -259,7 +258,7 @@ int ib_register_device(struct ib_device *device) | |||
259 | } | 258 | } |
260 | 259 | ||
261 | out: | 260 | out: |
262 | up(&device_sem); | 261 | mutex_unlock(&device_mutex); |
263 | return ret; | 262 | return ret; |
264 | } | 263 | } |
265 | EXPORT_SYMBOL(ib_register_device); | 264 | EXPORT_SYMBOL(ib_register_device); |
@@ -276,7 +275,7 @@ void ib_unregister_device(struct ib_device *device) | |||
276 | struct ib_client_data *context, *tmp; | 275 | struct ib_client_data *context, *tmp; |
277 | unsigned long flags; | 276 | unsigned long flags; |
278 | 277 | ||
279 | down(&device_sem); | 278 | mutex_lock(&device_mutex); |
280 | 279 | ||
281 | list_for_each_entry_reverse(client, &client_list, list) | 280 | list_for_each_entry_reverse(client, &client_list, list) |
282 | if (client->remove) | 281 | if (client->remove) |
@@ -284,7 +283,7 @@ void ib_unregister_device(struct ib_device *device) | |||
284 | 283 | ||
285 | list_del(&device->core_list); | 284 | list_del(&device->core_list); |
286 | 285 | ||
287 | up(&device_sem); | 286 | mutex_unlock(&device_mutex); |
288 | 287 | ||
289 | spin_lock_irqsave(&device->client_data_lock, flags); | 288 | spin_lock_irqsave(&device->client_data_lock, flags); |
290 | list_for_each_entry_safe(context, tmp, &device->client_data_list, list) | 289 | list_for_each_entry_safe(context, tmp, &device->client_data_list, list) |
@@ -312,14 +311,14 @@ int ib_register_client(struct ib_client *client) | |||
312 | { | 311 | { |
313 | struct ib_device *device; | 312 | struct ib_device *device; |
314 | 313 | ||
315 | down(&device_sem); | 314 | mutex_lock(&device_mutex); |
316 | 315 | ||
317 | list_add_tail(&client->list, &client_list); | 316 | list_add_tail(&client->list, &client_list); |
318 | list_for_each_entry(device, &device_list, core_list) | 317 | list_for_each_entry(device, &device_list, core_list) |
319 | if (client->add && !add_client_context(device, client)) | 318 | if (client->add && !add_client_context(device, client)) |
320 | client->add(device); | 319 | client->add(device); |
321 | 320 | ||
322 | up(&device_sem); | 321 | mutex_unlock(&device_mutex); |
323 | 322 | ||
324 | return 0; | 323 | return 0; |
325 | } | 324 | } |
@@ -339,7 +338,7 @@ void ib_unregister_client(struct ib_client *client) | |||
339 | struct ib_device *device; | 338 | struct ib_device *device; |
340 | unsigned long flags; | 339 | unsigned long flags; |
341 | 340 | ||
342 | down(&device_sem); | 341 | mutex_lock(&device_mutex); |
343 | 342 | ||
344 | list_for_each_entry(device, &device_list, core_list) { | 343 | list_for_each_entry(device, &device_list, core_list) { |
345 | if (client->remove) | 344 | if (client->remove) |
@@ -355,7 +354,7 @@ void ib_unregister_client(struct ib_client *client) | |||
355 | } | 354 | } |
356 | list_del(&client->list); | 355 | list_del(&client->list); |
357 | 356 | ||
358 | up(&device_sem); | 357 | mutex_unlock(&device_mutex); |
359 | } | 358 | } |
360 | EXPORT_SYMBOL(ib_unregister_client); | 359 | EXPORT_SYMBOL(ib_unregister_client); |
361 | 360 | ||
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 1f1743c5c9a3..5982d687a000 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -445,13 +445,7 @@ static int ib_device_uevent(struct class_device *cdev, char **envp, | |||
445 | return -ENOMEM; | 445 | return -ENOMEM; |
446 | 446 | ||
447 | /* | 447 | /* |
448 | * It might be nice to pass the node GUID with the event, but | 448 | * It would be nice to pass the node GUID with the event... |
449 | * right now the only way to get it is to query the device | ||
450 | * provider, and this can crash during device removal because | ||
451 | * we are will be running after driver removal has started. | ||
452 | * We could add a node_guid field to struct ib_device, or we | ||
453 | * could just let userspace read the node GUID from sysfs when | ||
454 | * devices are added. | ||
455 | */ | 449 | */ |
456 | 450 | ||
457 | envp[i] = NULL; | 451 | envp[i] = NULL; |
@@ -623,21 +617,15 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) | |||
623 | static ssize_t show_node_guid(struct class_device *cdev, char *buf) | 617 | static ssize_t show_node_guid(struct class_device *cdev, char *buf) |
624 | { | 618 | { |
625 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); | 619 | struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); |
626 | struct ib_device_attr attr; | ||
627 | ssize_t ret; | ||
628 | 620 | ||
629 | if (!ibdev_is_alive(dev)) | 621 | if (!ibdev_is_alive(dev)) |
630 | return -ENODEV; | 622 | return -ENODEV; |
631 | 623 | ||
632 | ret = ib_query_device(dev, &attr); | ||
633 | if (ret) | ||
634 | return ret; | ||
635 | |||
636 | return sprintf(buf, "%04x:%04x:%04x:%04x\n", | 624 | return sprintf(buf, "%04x:%04x:%04x:%04x\n", |
637 | be16_to_cpu(((__be16 *) &attr.node_guid)[0]), | 625 | be16_to_cpu(((__be16 *) &dev->node_guid)[0]), |
638 | be16_to_cpu(((__be16 *) &attr.node_guid)[1]), | 626 | be16_to_cpu(((__be16 *) &dev->node_guid)[1]), |
639 | be16_to_cpu(((__be16 *) &attr.node_guid)[2]), | 627 | be16_to_cpu(((__be16 *) &dev->node_guid)[2]), |
640 | be16_to_cpu(((__be16 *) &attr.node_guid)[3])); | 628 | be16_to_cpu(((__be16 *) &dev->node_guid)[3])); |
641 | } | 629 | } |
642 | 630 | ||
643 | static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); | 631 | static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); |
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 6e15787d1de1..e95c4293a496 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/mount.h> | 42 | #include <linux/mount.h> |
43 | #include <linux/cdev.h> | 43 | #include <linux/cdev.h> |
44 | #include <linux/idr.h> | 44 | #include <linux/idr.h> |
45 | #include <linux/mutex.h> | ||
45 | 46 | ||
46 | #include <asm/uaccess.h> | 47 | #include <asm/uaccess.h> |
47 | 48 | ||
@@ -113,7 +114,7 @@ static struct ib_client ucm_client = { | |||
113 | .remove = ib_ucm_remove_one | 114 | .remove = ib_ucm_remove_one |
114 | }; | 115 | }; |
115 | 116 | ||
116 | static DECLARE_MUTEX(ctx_id_mutex); | 117 | static DEFINE_MUTEX(ctx_id_mutex); |
117 | static DEFINE_IDR(ctx_id_table); | 118 | static DEFINE_IDR(ctx_id_table); |
118 | static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES); | 119 | static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES); |
119 | 120 | ||
@@ -121,7 +122,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) | |||
121 | { | 122 | { |
122 | struct ib_ucm_context *ctx; | 123 | struct ib_ucm_context *ctx; |
123 | 124 | ||
124 | down(&ctx_id_mutex); | 125 | mutex_lock(&ctx_id_mutex); |
125 | ctx = idr_find(&ctx_id_table, id); | 126 | ctx = idr_find(&ctx_id_table, id); |
126 | if (!ctx) | 127 | if (!ctx) |
127 | ctx = ERR_PTR(-ENOENT); | 128 | ctx = ERR_PTR(-ENOENT); |
@@ -129,7 +130,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) | |||
129 | ctx = ERR_PTR(-EINVAL); | 130 | ctx = ERR_PTR(-EINVAL); |
130 | else | 131 | else |
131 | atomic_inc(&ctx->ref); | 132 | atomic_inc(&ctx->ref); |
132 | up(&ctx_id_mutex); | 133 | mutex_unlock(&ctx_id_mutex); |
133 | 134 | ||
134 | return ctx; | 135 | return ctx; |
135 | } | 136 | } |
@@ -186,9 +187,9 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) | |||
186 | if (!result) | 187 | if (!result) |
187 | goto error; | 188 | goto error; |
188 | 189 | ||
189 | down(&ctx_id_mutex); | 190 | mutex_lock(&ctx_id_mutex); |
190 | result = idr_get_new(&ctx_id_table, ctx, &ctx->id); | 191 | result = idr_get_new(&ctx_id_table, ctx, &ctx->id); |
191 | up(&ctx_id_mutex); | 192 | mutex_unlock(&ctx_id_mutex); |
192 | } while (result == -EAGAIN); | 193 | } while (result == -EAGAIN); |
193 | 194 | ||
194 | if (result) | 195 | if (result) |
@@ -550,9 +551,9 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, | |||
550 | err2: | 551 | err2: |
551 | ib_destroy_cm_id(ctx->cm_id); | 552 | ib_destroy_cm_id(ctx->cm_id); |
552 | err1: | 553 | err1: |
553 | down(&ctx_id_mutex); | 554 | mutex_lock(&ctx_id_mutex); |
554 | idr_remove(&ctx_id_table, ctx->id); | 555 | idr_remove(&ctx_id_table, ctx->id); |
555 | up(&ctx_id_mutex); | 556 | mutex_unlock(&ctx_id_mutex); |
556 | kfree(ctx); | 557 | kfree(ctx); |
557 | return result; | 558 | return result; |
558 | } | 559 | } |
@@ -572,7 +573,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, | |||
572 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) | 573 | if (copy_from_user(&cmd, inbuf, sizeof(cmd))) |
573 | return -EFAULT; | 574 | return -EFAULT; |
574 | 575 | ||
575 | down(&ctx_id_mutex); | 576 | mutex_lock(&ctx_id_mutex); |
576 | ctx = idr_find(&ctx_id_table, cmd.id); | 577 | ctx = idr_find(&ctx_id_table, cmd.id); |
577 | if (!ctx) | 578 | if (!ctx) |
578 | ctx = ERR_PTR(-ENOENT); | 579 | ctx = ERR_PTR(-ENOENT); |
@@ -580,7 +581,7 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, | |||
580 | ctx = ERR_PTR(-EINVAL); | 581 | ctx = ERR_PTR(-EINVAL); |
581 | else | 582 | else |
582 | idr_remove(&ctx_id_table, ctx->id); | 583 | idr_remove(&ctx_id_table, ctx->id); |
583 | up(&ctx_id_mutex); | 584 | mutex_unlock(&ctx_id_mutex); |
584 | 585 | ||
585 | if (IS_ERR(ctx)) | 586 | if (IS_ERR(ctx)) |
586 | return PTR_ERR(ctx); | 587 | return PTR_ERR(ctx); |
@@ -1280,9 +1281,9 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) | |||
1280 | struct ib_ucm_context, file_list); | 1281 | struct ib_ucm_context, file_list); |
1281 | up(&file->mutex); | 1282 | up(&file->mutex); |
1282 | 1283 | ||
1283 | down(&ctx_id_mutex); | 1284 | mutex_lock(&ctx_id_mutex); |
1284 | idr_remove(&ctx_id_table, ctx->id); | 1285 | idr_remove(&ctx_id_table, ctx->id); |
1285 | up(&ctx_id_mutex); | 1286 | mutex_unlock(&ctx_id_mutex); |
1286 | 1287 | ||
1287 | ib_destroy_cm_id(ctx->cm_id); | 1288 | ib_destroy_cm_id(ctx->cm_id); |
1288 | ib_ucm_cleanup_events(ctx); | 1289 | ib_ucm_cleanup_events(ctx); |
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 7114e3fbab00..f7eecbc6af6c 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -41,6 +41,7 @@ | |||
41 | 41 | ||
42 | #include <linux/kref.h> | 42 | #include <linux/kref.h> |
43 | #include <linux/idr.h> | 43 | #include <linux/idr.h> |
44 | #include <linux/mutex.h> | ||
44 | 45 | ||
45 | #include <rdma/ib_verbs.h> | 46 | #include <rdma/ib_verbs.h> |
46 | #include <rdma/ib_user_verbs.h> | 47 | #include <rdma/ib_user_verbs.h> |
@@ -88,7 +89,7 @@ struct ib_uverbs_event_file { | |||
88 | 89 | ||
89 | struct ib_uverbs_file { | 90 | struct ib_uverbs_file { |
90 | struct kref ref; | 91 | struct kref ref; |
91 | struct semaphore mutex; | 92 | struct mutex mutex; |
92 | struct ib_uverbs_device *device; | 93 | struct ib_uverbs_device *device; |
93 | struct ib_ucontext *ucontext; | 94 | struct ib_ucontext *ucontext; |
94 | struct ib_event_handler event_handler; | 95 | struct ib_event_handler event_handler; |
@@ -131,7 +132,7 @@ struct ib_ucq_object { | |||
131 | u32 async_events_reported; | 132 | u32 async_events_reported; |
132 | }; | 133 | }; |
133 | 134 | ||
134 | extern struct semaphore ib_uverbs_idr_mutex; | 135 | extern struct mutex ib_uverbs_idr_mutex; |
135 | extern struct idr ib_uverbs_pd_idr; | 136 | extern struct idr ib_uverbs_pd_idr; |
136 | extern struct idr ib_uverbs_mr_idr; | 137 | extern struct idr ib_uverbs_mr_idr; |
137 | extern struct idr ib_uverbs_mw_idr; | 138 | extern struct idr ib_uverbs_mw_idr; |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index a02c5a05c984..407b6284d7d5 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -67,7 +67,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
67 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 67 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
68 | return -EFAULT; | 68 | return -EFAULT; |
69 | 69 | ||
70 | down(&file->mutex); | 70 | mutex_lock(&file->mutex); |
71 | 71 | ||
72 | if (file->ucontext) { | 72 | if (file->ucontext) { |
73 | ret = -EINVAL; | 73 | ret = -EINVAL; |
@@ -119,7 +119,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
119 | 119 | ||
120 | fd_install(resp.async_fd, filp); | 120 | fd_install(resp.async_fd, filp); |
121 | 121 | ||
122 | up(&file->mutex); | 122 | mutex_unlock(&file->mutex); |
123 | 123 | ||
124 | return in_len; | 124 | return in_len; |
125 | 125 | ||
@@ -131,7 +131,7 @@ err_free: | |||
131 | ibdev->dealloc_ucontext(ucontext); | 131 | ibdev->dealloc_ucontext(ucontext); |
132 | 132 | ||
133 | err: | 133 | err: |
134 | up(&file->mutex); | 134 | mutex_unlock(&file->mutex); |
135 | return ret; | 135 | return ret; |
136 | } | 136 | } |
137 | 137 | ||
@@ -157,7 +157,7 @@ ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, | |||
157 | memset(&resp, 0, sizeof resp); | 157 | memset(&resp, 0, sizeof resp); |
158 | 158 | ||
159 | resp.fw_ver = attr.fw_ver; | 159 | resp.fw_ver = attr.fw_ver; |
160 | resp.node_guid = attr.node_guid; | 160 | resp.node_guid = file->device->ib_dev->node_guid; |
161 | resp.sys_image_guid = attr.sys_image_guid; | 161 | resp.sys_image_guid = attr.sys_image_guid; |
162 | resp.max_mr_size = attr.max_mr_size; | 162 | resp.max_mr_size = attr.max_mr_size; |
163 | resp.page_size_cap = attr.page_size_cap; | 163 | resp.page_size_cap = attr.page_size_cap; |
@@ -290,7 +290,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, | |||
290 | pd->uobject = uobj; | 290 | pd->uobject = uobj; |
291 | atomic_set(&pd->usecnt, 0); | 291 | atomic_set(&pd->usecnt, 0); |
292 | 292 | ||
293 | down(&ib_uverbs_idr_mutex); | 293 | mutex_lock(&ib_uverbs_idr_mutex); |
294 | 294 | ||
295 | retry: | 295 | retry: |
296 | if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) { | 296 | if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) { |
@@ -314,11 +314,11 @@ retry: | |||
314 | goto err_idr; | 314 | goto err_idr; |
315 | } | 315 | } |
316 | 316 | ||
317 | down(&file->mutex); | 317 | mutex_lock(&file->mutex); |
318 | list_add_tail(&uobj->list, &file->ucontext->pd_list); | 318 | list_add_tail(&uobj->list, &file->ucontext->pd_list); |
319 | up(&file->mutex); | 319 | mutex_unlock(&file->mutex); |
320 | 320 | ||
321 | up(&ib_uverbs_idr_mutex); | 321 | mutex_unlock(&ib_uverbs_idr_mutex); |
322 | 322 | ||
323 | return in_len; | 323 | return in_len; |
324 | 324 | ||
@@ -326,7 +326,7 @@ err_idr: | |||
326 | idr_remove(&ib_uverbs_pd_idr, uobj->id); | 326 | idr_remove(&ib_uverbs_pd_idr, uobj->id); |
327 | 327 | ||
328 | err_up: | 328 | err_up: |
329 | up(&ib_uverbs_idr_mutex); | 329 | mutex_unlock(&ib_uverbs_idr_mutex); |
330 | ib_dealloc_pd(pd); | 330 | ib_dealloc_pd(pd); |
331 | 331 | ||
332 | err: | 332 | err: |
@@ -346,7 +346,7 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file, | |||
346 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 346 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
347 | return -EFAULT; | 347 | return -EFAULT; |
348 | 348 | ||
349 | down(&ib_uverbs_idr_mutex); | 349 | mutex_lock(&ib_uverbs_idr_mutex); |
350 | 350 | ||
351 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 351 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
352 | if (!pd || pd->uobject->context != file->ucontext) | 352 | if (!pd || pd->uobject->context != file->ucontext) |
@@ -360,14 +360,14 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file, | |||
360 | 360 | ||
361 | idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); | 361 | idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); |
362 | 362 | ||
363 | down(&file->mutex); | 363 | mutex_lock(&file->mutex); |
364 | list_del(&uobj->list); | 364 | list_del(&uobj->list); |
365 | up(&file->mutex); | 365 | mutex_unlock(&file->mutex); |
366 | 366 | ||
367 | kfree(uobj); | 367 | kfree(uobj); |
368 | 368 | ||
369 | out: | 369 | out: |
370 | up(&ib_uverbs_idr_mutex); | 370 | mutex_unlock(&ib_uverbs_idr_mutex); |
371 | 371 | ||
372 | return ret ? ret : in_len; | 372 | return ret ? ret : in_len; |
373 | } | 373 | } |
@@ -426,7 +426,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, | |||
426 | 426 | ||
427 | obj->umem.virt_base = cmd.hca_va; | 427 | obj->umem.virt_base = cmd.hca_va; |
428 | 428 | ||
429 | down(&ib_uverbs_idr_mutex); | 429 | mutex_lock(&ib_uverbs_idr_mutex); |
430 | 430 | ||
431 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 431 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
432 | if (!pd || pd->uobject->context != file->ucontext) { | 432 | if (!pd || pd->uobject->context != file->ucontext) { |
@@ -476,11 +476,11 @@ retry: | |||
476 | goto err_idr; | 476 | goto err_idr; |
477 | } | 477 | } |
478 | 478 | ||
479 | down(&file->mutex); | 479 | mutex_lock(&file->mutex); |
480 | list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); | 480 | list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); |
481 | up(&file->mutex); | 481 | mutex_unlock(&file->mutex); |
482 | 482 | ||
483 | up(&ib_uverbs_idr_mutex); | 483 | mutex_unlock(&ib_uverbs_idr_mutex); |
484 | 484 | ||
485 | return in_len; | 485 | return in_len; |
486 | 486 | ||
@@ -492,7 +492,7 @@ err_unreg: | |||
492 | atomic_dec(&pd->usecnt); | 492 | atomic_dec(&pd->usecnt); |
493 | 493 | ||
494 | err_up: | 494 | err_up: |
495 | up(&ib_uverbs_idr_mutex); | 495 | mutex_unlock(&ib_uverbs_idr_mutex); |
496 | 496 | ||
497 | ib_umem_release(file->device->ib_dev, &obj->umem); | 497 | ib_umem_release(file->device->ib_dev, &obj->umem); |
498 | 498 | ||
@@ -513,7 +513,7 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file, | |||
513 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 513 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
514 | return -EFAULT; | 514 | return -EFAULT; |
515 | 515 | ||
516 | down(&ib_uverbs_idr_mutex); | 516 | mutex_lock(&ib_uverbs_idr_mutex); |
517 | 517 | ||
518 | mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle); | 518 | mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle); |
519 | if (!mr || mr->uobject->context != file->ucontext) | 519 | if (!mr || mr->uobject->context != file->ucontext) |
@@ -527,15 +527,15 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file, | |||
527 | 527 | ||
528 | idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); | 528 | idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); |
529 | 529 | ||
530 | down(&file->mutex); | 530 | mutex_lock(&file->mutex); |
531 | list_del(&memobj->uobject.list); | 531 | list_del(&memobj->uobject.list); |
532 | up(&file->mutex); | 532 | mutex_unlock(&file->mutex); |
533 | 533 | ||
534 | ib_umem_release(file->device->ib_dev, &memobj->umem); | 534 | ib_umem_release(file->device->ib_dev, &memobj->umem); |
535 | kfree(memobj); | 535 | kfree(memobj); |
536 | 536 | ||
537 | out: | 537 | out: |
538 | up(&ib_uverbs_idr_mutex); | 538 | mutex_unlock(&ib_uverbs_idr_mutex); |
539 | 539 | ||
540 | return ret ? ret : in_len; | 540 | return ret ? ret : in_len; |
541 | } | 541 | } |
@@ -628,7 +628,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, | |||
628 | cq->cq_context = ev_file; | 628 | cq->cq_context = ev_file; |
629 | atomic_set(&cq->usecnt, 0); | 629 | atomic_set(&cq->usecnt, 0); |
630 | 630 | ||
631 | down(&ib_uverbs_idr_mutex); | 631 | mutex_lock(&ib_uverbs_idr_mutex); |
632 | 632 | ||
633 | retry: | 633 | retry: |
634 | if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) { | 634 | if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) { |
@@ -653,11 +653,11 @@ retry: | |||
653 | goto err_idr; | 653 | goto err_idr; |
654 | } | 654 | } |
655 | 655 | ||
656 | down(&file->mutex); | 656 | mutex_lock(&file->mutex); |
657 | list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); | 657 | list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); |
658 | up(&file->mutex); | 658 | mutex_unlock(&file->mutex); |
659 | 659 | ||
660 | up(&ib_uverbs_idr_mutex); | 660 | mutex_unlock(&ib_uverbs_idr_mutex); |
661 | 661 | ||
662 | return in_len; | 662 | return in_len; |
663 | 663 | ||
@@ -665,7 +665,7 @@ err_idr: | |||
665 | idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); | 665 | idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); |
666 | 666 | ||
667 | err_up: | 667 | err_up: |
668 | up(&ib_uverbs_idr_mutex); | 668 | mutex_unlock(&ib_uverbs_idr_mutex); |
669 | ib_destroy_cq(cq); | 669 | ib_destroy_cq(cq); |
670 | 670 | ||
671 | err: | 671 | err: |
@@ -701,7 +701,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, | |||
701 | goto out_wc; | 701 | goto out_wc; |
702 | } | 702 | } |
703 | 703 | ||
704 | down(&ib_uverbs_idr_mutex); | 704 | mutex_lock(&ib_uverbs_idr_mutex); |
705 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | 705 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); |
706 | if (!cq || cq->uobject->context != file->ucontext) { | 706 | if (!cq || cq->uobject->context != file->ucontext) { |
707 | ret = -EINVAL; | 707 | ret = -EINVAL; |
@@ -731,7 +731,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, | |||
731 | ret = -EFAULT; | 731 | ret = -EFAULT; |
732 | 732 | ||
733 | out: | 733 | out: |
734 | up(&ib_uverbs_idr_mutex); | 734 | mutex_unlock(&ib_uverbs_idr_mutex); |
735 | kfree(resp); | 735 | kfree(resp); |
736 | 736 | ||
737 | out_wc: | 737 | out_wc: |
@@ -750,14 +750,14 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file, | |||
750 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 750 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
751 | return -EFAULT; | 751 | return -EFAULT; |
752 | 752 | ||
753 | down(&ib_uverbs_idr_mutex); | 753 | mutex_lock(&ib_uverbs_idr_mutex); |
754 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | 754 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); |
755 | if (cq && cq->uobject->context == file->ucontext) { | 755 | if (cq && cq->uobject->context == file->ucontext) { |
756 | ib_req_notify_cq(cq, cmd.solicited_only ? | 756 | ib_req_notify_cq(cq, cmd.solicited_only ? |
757 | IB_CQ_SOLICITED : IB_CQ_NEXT_COMP); | 757 | IB_CQ_SOLICITED : IB_CQ_NEXT_COMP); |
758 | ret = in_len; | 758 | ret = in_len; |
759 | } | 759 | } |
760 | up(&ib_uverbs_idr_mutex); | 760 | mutex_unlock(&ib_uverbs_idr_mutex); |
761 | 761 | ||
762 | return ret; | 762 | return ret; |
763 | } | 763 | } |
@@ -779,7 +779,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
779 | 779 | ||
780 | memset(&resp, 0, sizeof resp); | 780 | memset(&resp, 0, sizeof resp); |
781 | 781 | ||
782 | down(&ib_uverbs_idr_mutex); | 782 | mutex_lock(&ib_uverbs_idr_mutex); |
783 | 783 | ||
784 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); | 784 | cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); |
785 | if (!cq || cq->uobject->context != file->ucontext) | 785 | if (!cq || cq->uobject->context != file->ucontext) |
@@ -795,9 +795,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
795 | 795 | ||
796 | idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); | 796 | idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); |
797 | 797 | ||
798 | down(&file->mutex); | 798 | mutex_lock(&file->mutex); |
799 | list_del(&uobj->uobject.list); | 799 | list_del(&uobj->uobject.list); |
800 | up(&file->mutex); | 800 | mutex_unlock(&file->mutex); |
801 | 801 | ||
802 | ib_uverbs_release_ucq(file, ev_file, uobj); | 802 | ib_uverbs_release_ucq(file, ev_file, uobj); |
803 | 803 | ||
@@ -811,7 +811,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
811 | ret = -EFAULT; | 811 | ret = -EFAULT; |
812 | 812 | ||
813 | out: | 813 | out: |
814 | up(&ib_uverbs_idr_mutex); | 814 | mutex_unlock(&ib_uverbs_idr_mutex); |
815 | 815 | ||
816 | return ret ? ret : in_len; | 816 | return ret ? ret : in_len; |
817 | } | 817 | } |
@@ -845,7 +845,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, | |||
845 | if (!uobj) | 845 | if (!uobj) |
846 | return -ENOMEM; | 846 | return -ENOMEM; |
847 | 847 | ||
848 | down(&ib_uverbs_idr_mutex); | 848 | mutex_lock(&ib_uverbs_idr_mutex); |
849 | 849 | ||
850 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 850 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
851 | scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle); | 851 | scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle); |
@@ -930,11 +930,11 @@ retry: | |||
930 | goto err_idr; | 930 | goto err_idr; |
931 | } | 931 | } |
932 | 932 | ||
933 | down(&file->mutex); | 933 | mutex_lock(&file->mutex); |
934 | list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list); | 934 | list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list); |
935 | up(&file->mutex); | 935 | mutex_unlock(&file->mutex); |
936 | 936 | ||
937 | up(&ib_uverbs_idr_mutex); | 937 | mutex_unlock(&ib_uverbs_idr_mutex); |
938 | 938 | ||
939 | return in_len; | 939 | return in_len; |
940 | 940 | ||
@@ -950,7 +950,7 @@ err_destroy: | |||
950 | atomic_dec(&attr.srq->usecnt); | 950 | atomic_dec(&attr.srq->usecnt); |
951 | 951 | ||
952 | err_up: | 952 | err_up: |
953 | up(&ib_uverbs_idr_mutex); | 953 | mutex_unlock(&ib_uverbs_idr_mutex); |
954 | 954 | ||
955 | kfree(uobj); | 955 | kfree(uobj); |
956 | return ret; | 956 | return ret; |
@@ -972,7 +972,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, | |||
972 | if (!attr) | 972 | if (!attr) |
973 | return -ENOMEM; | 973 | return -ENOMEM; |
974 | 974 | ||
975 | down(&ib_uverbs_idr_mutex); | 975 | mutex_lock(&ib_uverbs_idr_mutex); |
976 | 976 | ||
977 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 977 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
978 | if (!qp || qp->uobject->context != file->ucontext) { | 978 | if (!qp || qp->uobject->context != file->ucontext) { |
@@ -1033,7 +1033,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, | |||
1033 | ret = in_len; | 1033 | ret = in_len; |
1034 | 1034 | ||
1035 | out: | 1035 | out: |
1036 | up(&ib_uverbs_idr_mutex); | 1036 | mutex_unlock(&ib_uverbs_idr_mutex); |
1037 | kfree(attr); | 1037 | kfree(attr); |
1038 | 1038 | ||
1039 | return ret; | 1039 | return ret; |
@@ -1054,7 +1054,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
1054 | 1054 | ||
1055 | memset(&resp, 0, sizeof resp); | 1055 | memset(&resp, 0, sizeof resp); |
1056 | 1056 | ||
1057 | down(&ib_uverbs_idr_mutex); | 1057 | mutex_lock(&ib_uverbs_idr_mutex); |
1058 | 1058 | ||
1059 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1059 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1060 | if (!qp || qp->uobject->context != file->ucontext) | 1060 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1073,9 +1073,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
1073 | 1073 | ||
1074 | idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); | 1074 | idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); |
1075 | 1075 | ||
1076 | down(&file->mutex); | 1076 | mutex_lock(&file->mutex); |
1077 | list_del(&uobj->uevent.uobject.list); | 1077 | list_del(&uobj->uevent.uobject.list); |
1078 | up(&file->mutex); | 1078 | mutex_unlock(&file->mutex); |
1079 | 1079 | ||
1080 | ib_uverbs_release_uevent(file, &uobj->uevent); | 1080 | ib_uverbs_release_uevent(file, &uobj->uevent); |
1081 | 1081 | ||
@@ -1088,7 +1088,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
1088 | ret = -EFAULT; | 1088 | ret = -EFAULT; |
1089 | 1089 | ||
1090 | out: | 1090 | out: |
1091 | up(&ib_uverbs_idr_mutex); | 1091 | mutex_unlock(&ib_uverbs_idr_mutex); |
1092 | 1092 | ||
1093 | return ret ? ret : in_len; | 1093 | return ret ? ret : in_len; |
1094 | } | 1094 | } |
@@ -1119,7 +1119,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, | |||
1119 | if (!user_wr) | 1119 | if (!user_wr) |
1120 | return -ENOMEM; | 1120 | return -ENOMEM; |
1121 | 1121 | ||
1122 | down(&ib_uverbs_idr_mutex); | 1122 | mutex_lock(&ib_uverbs_idr_mutex); |
1123 | 1123 | ||
1124 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1124 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1125 | if (!qp || qp->uobject->context != file->ucontext) | 1125 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1224,7 +1224,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, | |||
1224 | ret = -EFAULT; | 1224 | ret = -EFAULT; |
1225 | 1225 | ||
1226 | out: | 1226 | out: |
1227 | up(&ib_uverbs_idr_mutex); | 1227 | mutex_unlock(&ib_uverbs_idr_mutex); |
1228 | 1228 | ||
1229 | while (wr) { | 1229 | while (wr) { |
1230 | next = wr->next; | 1230 | next = wr->next; |
@@ -1341,7 +1341,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, | |||
1341 | if (IS_ERR(wr)) | 1341 | if (IS_ERR(wr)) |
1342 | return PTR_ERR(wr); | 1342 | return PTR_ERR(wr); |
1343 | 1343 | ||
1344 | down(&ib_uverbs_idr_mutex); | 1344 | mutex_lock(&ib_uverbs_idr_mutex); |
1345 | 1345 | ||
1346 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1346 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1347 | if (!qp || qp->uobject->context != file->ucontext) | 1347 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1362,7 +1362,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, | |||
1362 | ret = -EFAULT; | 1362 | ret = -EFAULT; |
1363 | 1363 | ||
1364 | out: | 1364 | out: |
1365 | up(&ib_uverbs_idr_mutex); | 1365 | mutex_unlock(&ib_uverbs_idr_mutex); |
1366 | 1366 | ||
1367 | while (wr) { | 1367 | while (wr) { |
1368 | next = wr->next; | 1368 | next = wr->next; |
@@ -1392,7 +1392,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, | |||
1392 | if (IS_ERR(wr)) | 1392 | if (IS_ERR(wr)) |
1393 | return PTR_ERR(wr); | 1393 | return PTR_ERR(wr); |
1394 | 1394 | ||
1395 | down(&ib_uverbs_idr_mutex); | 1395 | mutex_lock(&ib_uverbs_idr_mutex); |
1396 | 1396 | ||
1397 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); | 1397 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); |
1398 | if (!srq || srq->uobject->context != file->ucontext) | 1398 | if (!srq || srq->uobject->context != file->ucontext) |
@@ -1413,7 +1413,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, | |||
1413 | ret = -EFAULT; | 1413 | ret = -EFAULT; |
1414 | 1414 | ||
1415 | out: | 1415 | out: |
1416 | up(&ib_uverbs_idr_mutex); | 1416 | mutex_unlock(&ib_uverbs_idr_mutex); |
1417 | 1417 | ||
1418 | while (wr) { | 1418 | while (wr) { |
1419 | next = wr->next; | 1419 | next = wr->next; |
@@ -1446,7 +1446,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file, | |||
1446 | if (!uobj) | 1446 | if (!uobj) |
1447 | return -ENOMEM; | 1447 | return -ENOMEM; |
1448 | 1448 | ||
1449 | down(&ib_uverbs_idr_mutex); | 1449 | mutex_lock(&ib_uverbs_idr_mutex); |
1450 | 1450 | ||
1451 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 1451 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
1452 | if (!pd || pd->uobject->context != file->ucontext) { | 1452 | if (!pd || pd->uobject->context != file->ucontext) { |
@@ -1498,11 +1498,11 @@ retry: | |||
1498 | goto err_idr; | 1498 | goto err_idr; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | down(&file->mutex); | 1501 | mutex_lock(&file->mutex); |
1502 | list_add_tail(&uobj->list, &file->ucontext->ah_list); | 1502 | list_add_tail(&uobj->list, &file->ucontext->ah_list); |
1503 | up(&file->mutex); | 1503 | mutex_unlock(&file->mutex); |
1504 | 1504 | ||
1505 | up(&ib_uverbs_idr_mutex); | 1505 | mutex_unlock(&ib_uverbs_idr_mutex); |
1506 | 1506 | ||
1507 | return in_len; | 1507 | return in_len; |
1508 | 1508 | ||
@@ -1513,7 +1513,7 @@ err_destroy: | |||
1513 | ib_destroy_ah(ah); | 1513 | ib_destroy_ah(ah); |
1514 | 1514 | ||
1515 | err_up: | 1515 | err_up: |
1516 | up(&ib_uverbs_idr_mutex); | 1516 | mutex_unlock(&ib_uverbs_idr_mutex); |
1517 | 1517 | ||
1518 | kfree(uobj); | 1518 | kfree(uobj); |
1519 | return ret; | 1519 | return ret; |
@@ -1530,7 +1530,7 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file, | |||
1530 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1530 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1531 | return -EFAULT; | 1531 | return -EFAULT; |
1532 | 1532 | ||
1533 | down(&ib_uverbs_idr_mutex); | 1533 | mutex_lock(&ib_uverbs_idr_mutex); |
1534 | 1534 | ||
1535 | ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle); | 1535 | ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle); |
1536 | if (!ah || ah->uobject->context != file->ucontext) | 1536 | if (!ah || ah->uobject->context != file->ucontext) |
@@ -1544,14 +1544,14 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file, | |||
1544 | 1544 | ||
1545 | idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle); | 1545 | idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle); |
1546 | 1546 | ||
1547 | down(&file->mutex); | 1547 | mutex_lock(&file->mutex); |
1548 | list_del(&uobj->list); | 1548 | list_del(&uobj->list); |
1549 | up(&file->mutex); | 1549 | mutex_unlock(&file->mutex); |
1550 | 1550 | ||
1551 | kfree(uobj); | 1551 | kfree(uobj); |
1552 | 1552 | ||
1553 | out: | 1553 | out: |
1554 | up(&ib_uverbs_idr_mutex); | 1554 | mutex_unlock(&ib_uverbs_idr_mutex); |
1555 | 1555 | ||
1556 | return ret ? ret : in_len; | 1556 | return ret ? ret : in_len; |
1557 | } | 1557 | } |
@@ -1569,7 +1569,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, | |||
1569 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1569 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1570 | return -EFAULT; | 1570 | return -EFAULT; |
1571 | 1571 | ||
1572 | down(&ib_uverbs_idr_mutex); | 1572 | mutex_lock(&ib_uverbs_idr_mutex); |
1573 | 1573 | ||
1574 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1574 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1575 | if (!qp || qp->uobject->context != file->ucontext) | 1575 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1602,7 +1602,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, | |||
1602 | kfree(mcast); | 1602 | kfree(mcast); |
1603 | 1603 | ||
1604 | out: | 1604 | out: |
1605 | up(&ib_uverbs_idr_mutex); | 1605 | mutex_unlock(&ib_uverbs_idr_mutex); |
1606 | 1606 | ||
1607 | return ret ? ret : in_len; | 1607 | return ret ? ret : in_len; |
1608 | } | 1608 | } |
@@ -1620,7 +1620,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file, | |||
1620 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1620 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1621 | return -EFAULT; | 1621 | return -EFAULT; |
1622 | 1622 | ||
1623 | down(&ib_uverbs_idr_mutex); | 1623 | mutex_lock(&ib_uverbs_idr_mutex); |
1624 | 1624 | ||
1625 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); | 1625 | qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); |
1626 | if (!qp || qp->uobject->context != file->ucontext) | 1626 | if (!qp || qp->uobject->context != file->ucontext) |
@@ -1641,7 +1641,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file, | |||
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | out: | 1643 | out: |
1644 | up(&ib_uverbs_idr_mutex); | 1644 | mutex_unlock(&ib_uverbs_idr_mutex); |
1645 | 1645 | ||
1646 | return ret ? ret : in_len; | 1646 | return ret ? ret : in_len; |
1647 | } | 1647 | } |
@@ -1673,7 +1673,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, | |||
1673 | if (!uobj) | 1673 | if (!uobj) |
1674 | return -ENOMEM; | 1674 | return -ENOMEM; |
1675 | 1675 | ||
1676 | down(&ib_uverbs_idr_mutex); | 1676 | mutex_lock(&ib_uverbs_idr_mutex); |
1677 | 1677 | ||
1678 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); | 1678 | pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); |
1679 | 1679 | ||
@@ -1730,11 +1730,11 @@ retry: | |||
1730 | goto err_idr; | 1730 | goto err_idr; |
1731 | } | 1731 | } |
1732 | 1732 | ||
1733 | down(&file->mutex); | 1733 | mutex_lock(&file->mutex); |
1734 | list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); | 1734 | list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); |
1735 | up(&file->mutex); | 1735 | mutex_unlock(&file->mutex); |
1736 | 1736 | ||
1737 | up(&ib_uverbs_idr_mutex); | 1737 | mutex_unlock(&ib_uverbs_idr_mutex); |
1738 | 1738 | ||
1739 | return in_len; | 1739 | return in_len; |
1740 | 1740 | ||
@@ -1746,7 +1746,7 @@ err_destroy: | |||
1746 | atomic_dec(&pd->usecnt); | 1746 | atomic_dec(&pd->usecnt); |
1747 | 1747 | ||
1748 | err_up: | 1748 | err_up: |
1749 | up(&ib_uverbs_idr_mutex); | 1749 | mutex_unlock(&ib_uverbs_idr_mutex); |
1750 | 1750 | ||
1751 | kfree(uobj); | 1751 | kfree(uobj); |
1752 | return ret; | 1752 | return ret; |
@@ -1764,7 +1764,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file, | |||
1764 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1764 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1765 | return -EFAULT; | 1765 | return -EFAULT; |
1766 | 1766 | ||
1767 | down(&ib_uverbs_idr_mutex); | 1767 | mutex_lock(&ib_uverbs_idr_mutex); |
1768 | 1768 | ||
1769 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); | 1769 | srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); |
1770 | if (!srq || srq->uobject->context != file->ucontext) { | 1770 | if (!srq || srq->uobject->context != file->ucontext) { |
@@ -1778,7 +1778,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file, | |||
1778 | ret = ib_modify_srq(srq, &attr, cmd.attr_mask); | 1778 | ret = ib_modify_srq(srq, &attr, cmd.attr_mask); |
1779 | 1779 | ||
1780 | out: | 1780 | out: |
1781 | up(&ib_uverbs_idr_mutex); | 1781 | mutex_unlock(&ib_uverbs_idr_mutex); |
1782 | 1782 | ||
1783 | return ret ? ret : in_len; | 1783 | return ret ? ret : in_len; |
1784 | } | 1784 | } |
@@ -1796,7 +1796,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1796 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 1796 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
1797 | return -EFAULT; | 1797 | return -EFAULT; |
1798 | 1798 | ||
1799 | down(&ib_uverbs_idr_mutex); | 1799 | mutex_lock(&ib_uverbs_idr_mutex); |
1800 | 1800 | ||
1801 | memset(&resp, 0, sizeof resp); | 1801 | memset(&resp, 0, sizeof resp); |
1802 | 1802 | ||
@@ -1812,9 +1812,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1812 | 1812 | ||
1813 | idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); | 1813 | idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); |
1814 | 1814 | ||
1815 | down(&file->mutex); | 1815 | mutex_lock(&file->mutex); |
1816 | list_del(&uobj->uobject.list); | 1816 | list_del(&uobj->uobject.list); |
1817 | up(&file->mutex); | 1817 | mutex_unlock(&file->mutex); |
1818 | 1818 | ||
1819 | ib_uverbs_release_uevent(file, uobj); | 1819 | ib_uverbs_release_uevent(file, uobj); |
1820 | 1820 | ||
@@ -1827,7 +1827,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1827 | ret = -EFAULT; | 1827 | ret = -EFAULT; |
1828 | 1828 | ||
1829 | out: | 1829 | out: |
1830 | up(&ib_uverbs_idr_mutex); | 1830 | mutex_unlock(&ib_uverbs_idr_mutex); |
1831 | 1831 | ||
1832 | return ret ? ret : in_len; | 1832 | return ret ? ret : in_len; |
1833 | } | 1833 | } |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 81737bd6faea..96ea79b63df7 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -66,7 +66,7 @@ enum { | |||
66 | 66 | ||
67 | static struct class *uverbs_class; | 67 | static struct class *uverbs_class; |
68 | 68 | ||
69 | DECLARE_MUTEX(ib_uverbs_idr_mutex); | 69 | DEFINE_MUTEX(ib_uverbs_idr_mutex); |
70 | DEFINE_IDR(ib_uverbs_pd_idr); | 70 | DEFINE_IDR(ib_uverbs_pd_idr); |
71 | DEFINE_IDR(ib_uverbs_mr_idr); | 71 | DEFINE_IDR(ib_uverbs_mr_idr); |
72 | DEFINE_IDR(ib_uverbs_mw_idr); | 72 | DEFINE_IDR(ib_uverbs_mw_idr); |
@@ -180,7 +180,7 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file, | |||
180 | if (!context) | 180 | if (!context) |
181 | return 0; | 181 | return 0; |
182 | 182 | ||
183 | down(&ib_uverbs_idr_mutex); | 183 | mutex_lock(&ib_uverbs_idr_mutex); |
184 | 184 | ||
185 | list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) { | 185 | list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) { |
186 | struct ib_ah *ah = idr_find(&ib_uverbs_ah_idr, uobj->id); | 186 | struct ib_ah *ah = idr_find(&ib_uverbs_ah_idr, uobj->id); |
@@ -250,7 +250,7 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file, | |||
250 | kfree(uobj); | 250 | kfree(uobj); |
251 | } | 251 | } |
252 | 252 | ||
253 | up(&ib_uverbs_idr_mutex); | 253 | mutex_unlock(&ib_uverbs_idr_mutex); |
254 | 254 | ||
255 | return context->device->dealloc_ucontext(context); | 255 | return context->device->dealloc_ucontext(context); |
256 | } | 256 | } |
@@ -653,7 +653,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) | |||
653 | file->ucontext = NULL; | 653 | file->ucontext = NULL; |
654 | file->async_file = NULL; | 654 | file->async_file = NULL; |
655 | kref_init(&file->ref); | 655 | kref_init(&file->ref); |
656 | init_MUTEX(&file->mutex); | 656 | mutex_init(&file->mutex); |
657 | 657 | ||
658 | filp->private_data = file; | 658 | filp->private_data = file; |
659 | 659 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c index 22fdc446f25c..a14eed08a0fc 100644 --- a/drivers/infiniband/hw/mthca/mthca_av.c +++ b/drivers/infiniband/hw/mthca/mthca_av.c | |||
@@ -163,6 +163,11 @@ int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah) | |||
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | int mthca_ah_grh_present(struct mthca_ah *ah) | ||
167 | { | ||
168 | return !!(ah->av->g_slid & 0x80); | ||
169 | } | ||
170 | |||
166 | int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, | 171 | int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, |
167 | struct ib_ud_header *header) | 172 | struct ib_ud_header *header) |
168 | { | 173 | { |
@@ -172,8 +177,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, | |||
172 | header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28; | 177 | header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28; |
173 | header->lrh.destination_lid = ah->av->dlid; | 178 | header->lrh.destination_lid = ah->av->dlid; |
174 | header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f); | 179 | header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f); |
175 | if (ah->av->g_slid & 0x80) { | 180 | if (mthca_ah_grh_present(ah)) { |
176 | header->grh_present = 1; | ||
177 | header->grh.traffic_class = | 181 | header->grh.traffic_class = |
178 | (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff; | 182 | (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff; |
179 | header->grh.flow_label = | 183 | header->grh.flow_label = |
@@ -184,8 +188,6 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, | |||
184 | &header->grh.source_gid); | 188 | &header->grh.source_gid); |
185 | memcpy(header->grh.destination_gid.raw, | 189 | memcpy(header->grh.destination_gid.raw, |
186 | ah->av->dgid, 16); | 190 | ah->av->dgid, 16); |
187 | } else { | ||
188 | header->grh_present = 0; | ||
189 | } | 191 | } |
190 | 192 | ||
191 | return 0; | 193 | return 0; |
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index 22ac72bc20c3..be1791be627b 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
@@ -606,7 +606,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, | |||
606 | err = -EINVAL; | 606 | err = -EINVAL; |
607 | goto out; | 607 | goto out; |
608 | } | 608 | } |
609 | for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i) { | 609 | for (i = 0; i < mthca_icm_size(&iter) >> lg; ++i) { |
610 | if (virt != -1) { | 610 | if (virt != -1) { |
611 | pages[nent * 2] = cpu_to_be64(virt); | 611 | pages[nent * 2] = cpu_to_be64(virt); |
612 | virt += 1 << lg; | 612 | virt += 1 << lg; |
@@ -727,8 +727,8 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status) | |||
727 | * system pages needed. | 727 | * system pages needed. |
728 | */ | 728 | */ |
729 | dev->fw.arbel.fw_pages = | 729 | dev->fw.arbel.fw_pages = |
730 | (dev->fw.arbel.fw_pages + (1 << (PAGE_SHIFT - 12)) - 1) >> | 730 | ALIGN(dev->fw.arbel.fw_pages, PAGE_SIZE >> 12) >> |
731 | (PAGE_SHIFT - 12); | 731 | (PAGE_SHIFT - 12); |
732 | 732 | ||
733 | mthca_dbg(dev, "Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n", | 733 | mthca_dbg(dev, "Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n", |
734 | (unsigned long long) dev->fw.arbel.clr_int_base, | 734 | (unsigned long long) dev->fw.arbel.clr_int_base, |
@@ -1445,6 +1445,7 @@ int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages, | |||
1445 | * pages needed. | 1445 | * pages needed. |
1446 | */ | 1446 | */ |
1447 | *aux_pages = (*aux_pages + (1 << (PAGE_SHIFT - 12)) - 1) >> (PAGE_SHIFT - 12); | 1447 | *aux_pages = (*aux_pages + (1 << (PAGE_SHIFT - 12)) - 1) >> (PAGE_SHIFT - 12); |
1448 | *aux_pages = ALIGN(*aux_pages, PAGE_SIZE >> 12) >> (PAGE_SHIFT - 12); | ||
1448 | 1449 | ||
1449 | return 0; | 1450 | return 0; |
1450 | } | 1451 | } |
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index 795b379260bf..a104ab041ea3 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h | |||
@@ -520,6 +520,7 @@ int mthca_create_ah(struct mthca_dev *dev, | |||
520 | int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah); | 520 | int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah); |
521 | int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, | 521 | int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, |
522 | struct ib_ud_header *header); | 522 | struct ib_ud_header *header); |
523 | int mthca_ah_grh_present(struct mthca_ah *ah); | ||
523 | 524 | ||
524 | int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); | 525 | int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); |
525 | int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); | 526 | int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); |
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index e8a948f087c0..2eabb27804cd 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
@@ -45,6 +45,7 @@ | |||
45 | enum { | 45 | enum { |
46 | MTHCA_NUM_ASYNC_EQE = 0x80, | 46 | MTHCA_NUM_ASYNC_EQE = 0x80, |
47 | MTHCA_NUM_CMD_EQE = 0x80, | 47 | MTHCA_NUM_CMD_EQE = 0x80, |
48 | MTHCA_NUM_SPARE_EQE = 0x80, | ||
48 | MTHCA_EQ_ENTRY_SIZE = 0x20 | 49 | MTHCA_EQ_ENTRY_SIZE = 0x20 |
49 | }; | 50 | }; |
50 | 51 | ||
@@ -277,11 +278,10 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq) | |||
277 | { | 278 | { |
278 | struct mthca_eqe *eqe; | 279 | struct mthca_eqe *eqe; |
279 | int disarm_cqn; | 280 | int disarm_cqn; |
280 | int eqes_found = 0; | 281 | int eqes_found = 0; |
282 | int set_ci = 0; | ||
281 | 283 | ||
282 | while ((eqe = next_eqe_sw(eq))) { | 284 | while ((eqe = next_eqe_sw(eq))) { |
283 | int set_ci = 0; | ||
284 | |||
285 | /* | 285 | /* |
286 | * Make sure we read EQ entry contents after we've | 286 | * Make sure we read EQ entry contents after we've |
287 | * checked the ownership bit. | 287 | * checked the ownership bit. |
@@ -345,12 +345,6 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq) | |||
345 | be16_to_cpu(eqe->event.cmd.token), | 345 | be16_to_cpu(eqe->event.cmd.token), |
346 | eqe->event.cmd.status, | 346 | eqe->event.cmd.status, |
347 | be64_to_cpu(eqe->event.cmd.out_param)); | 347 | be64_to_cpu(eqe->event.cmd.out_param)); |
348 | /* | ||
349 | * cmd_event() may add more commands. | ||
350 | * The card will think the queue has overflowed if | ||
351 | * we don't tell it we've been processing events. | ||
352 | */ | ||
353 | set_ci = 1; | ||
354 | break; | 348 | break; |
355 | 349 | ||
356 | case MTHCA_EVENT_TYPE_PORT_CHANGE: | 350 | case MTHCA_EVENT_TYPE_PORT_CHANGE: |
@@ -385,8 +379,16 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq) | |||
385 | set_eqe_hw(eqe); | 379 | set_eqe_hw(eqe); |
386 | ++eq->cons_index; | 380 | ++eq->cons_index; |
387 | eqes_found = 1; | 381 | eqes_found = 1; |
382 | ++set_ci; | ||
388 | 383 | ||
389 | if (unlikely(set_ci)) { | 384 | /* |
385 | * The HCA will think the queue has overflowed if we | ||
386 | * don't tell it we've been processing events. We | ||
387 | * create our EQs with MTHCA_NUM_SPARE_EQE extra | ||
388 | * entries, so we must update our consumer index at | ||
389 | * least that often. | ||
390 | */ | ||
391 | if (unlikely(set_ci >= MTHCA_NUM_SPARE_EQE)) { | ||
390 | /* | 392 | /* |
391 | * Conditional on hca_type is OK here because | 393 | * Conditional on hca_type is OK here because |
392 | * this is a rare case, not the fast path. | 394 | * this is a rare case, not the fast path. |
@@ -862,19 +864,19 @@ int __devinit mthca_init_eq_table(struct mthca_dev *dev) | |||
862 | intr = (dev->mthca_flags & MTHCA_FLAG_MSI) ? | 864 | intr = (dev->mthca_flags & MTHCA_FLAG_MSI) ? |
863 | 128 : dev->eq_table.inta_pin; | 865 | 128 : dev->eq_table.inta_pin; |
864 | 866 | ||
865 | err = mthca_create_eq(dev, dev->limits.num_cqs, | 867 | err = mthca_create_eq(dev, dev->limits.num_cqs + MTHCA_NUM_SPARE_EQE, |
866 | (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 128 : intr, | 868 | (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 128 : intr, |
867 | &dev->eq_table.eq[MTHCA_EQ_COMP]); | 869 | &dev->eq_table.eq[MTHCA_EQ_COMP]); |
868 | if (err) | 870 | if (err) |
869 | goto err_out_unmap; | 871 | goto err_out_unmap; |
870 | 872 | ||
871 | err = mthca_create_eq(dev, MTHCA_NUM_ASYNC_EQE, | 873 | err = mthca_create_eq(dev, MTHCA_NUM_ASYNC_EQE + MTHCA_NUM_SPARE_EQE, |
872 | (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 129 : intr, | 874 | (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 129 : intr, |
873 | &dev->eq_table.eq[MTHCA_EQ_ASYNC]); | 875 | &dev->eq_table.eq[MTHCA_EQ_ASYNC]); |
874 | if (err) | 876 | if (err) |
875 | goto err_out_comp; | 877 | goto err_out_comp; |
876 | 878 | ||
877 | err = mthca_create_eq(dev, MTHCA_NUM_CMD_EQE, | 879 | err = mthca_create_eq(dev, MTHCA_NUM_CMD_EQE + MTHCA_NUM_SPARE_EQE, |
878 | (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 130 : intr, | 880 | (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 130 : intr, |
879 | &dev->eq_table.eq[MTHCA_EQ_CMD]); | 881 | &dev->eq_table.eq[MTHCA_EQ_CMD]); |
880 | if (err) | 882 | if (err) |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 4cc7e2846df1..484a7e6b7f8c 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -33,7 +33,7 @@ | |||
33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
34 | * SOFTWARE. | 34 | * SOFTWARE. |
35 | * | 35 | * |
36 | * $Id: mthca_provider.c 1397 2004-12-28 05:09:00Z roland $ | 36 | * $Id: mthca_provider.c 4859 2006-01-09 21:55:10Z roland $ |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <rdma/ib_smi.h> | 39 | #include <rdma/ib_smi.h> |
@@ -45,6 +45,14 @@ | |||
45 | #include "mthca_user.h" | 45 | #include "mthca_user.h" |
46 | #include "mthca_memfree.h" | 46 | #include "mthca_memfree.h" |
47 | 47 | ||
48 | static void init_query_mad(struct ib_smp *mad) | ||
49 | { | ||
50 | mad->base_version = 1; | ||
51 | mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | ||
52 | mad->class_version = 1; | ||
53 | mad->method = IB_MGMT_METHOD_GET; | ||
54 | } | ||
55 | |||
48 | static int mthca_query_device(struct ib_device *ibdev, | 56 | static int mthca_query_device(struct ib_device *ibdev, |
49 | struct ib_device_attr *props) | 57 | struct ib_device_attr *props) |
50 | { | 58 | { |
@@ -55,7 +63,7 @@ static int mthca_query_device(struct ib_device *ibdev, | |||
55 | 63 | ||
56 | u8 status; | 64 | u8 status; |
57 | 65 | ||
58 | in_mad = kmalloc(sizeof *in_mad, GFP_KERNEL); | 66 | in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); |
59 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); | 67 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); |
60 | if (!in_mad || !out_mad) | 68 | if (!in_mad || !out_mad) |
61 | goto out; | 69 | goto out; |
@@ -64,12 +72,8 @@ static int mthca_query_device(struct ib_device *ibdev, | |||
64 | 72 | ||
65 | props->fw_ver = mdev->fw_ver; | 73 | props->fw_ver = mdev->fw_ver; |
66 | 74 | ||
67 | memset(in_mad, 0, sizeof *in_mad); | 75 | init_query_mad(in_mad); |
68 | in_mad->base_version = 1; | 76 | in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; |
69 | in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | ||
70 | in_mad->class_version = 1; | ||
71 | in_mad->method = IB_MGMT_METHOD_GET; | ||
72 | in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; | ||
73 | 77 | ||
74 | err = mthca_MAD_IFC(mdev, 1, 1, | 78 | err = mthca_MAD_IFC(mdev, 1, 1, |
75 | 1, NULL, NULL, in_mad, out_mad, | 79 | 1, NULL, NULL, in_mad, out_mad, |
@@ -87,7 +91,6 @@ static int mthca_query_device(struct ib_device *ibdev, | |||
87 | props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); | 91 | props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); |
88 | props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32)); | 92 | props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32)); |
89 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); | 93 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); |
90 | memcpy(&props->node_guid, out_mad->data + 12, 8); | ||
91 | 94 | ||
92 | props->max_mr_size = ~0ull; | 95 | props->max_mr_size = ~0ull; |
93 | props->page_size_cap = mdev->limits.page_size_cap; | 96 | props->page_size_cap = mdev->limits.page_size_cap; |
@@ -128,20 +131,16 @@ static int mthca_query_port(struct ib_device *ibdev, | |||
128 | int err = -ENOMEM; | 131 | int err = -ENOMEM; |
129 | u8 status; | 132 | u8 status; |
130 | 133 | ||
131 | in_mad = kmalloc(sizeof *in_mad, GFP_KERNEL); | 134 | in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); |
132 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); | 135 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); |
133 | if (!in_mad || !out_mad) | 136 | if (!in_mad || !out_mad) |
134 | goto out; | 137 | goto out; |
135 | 138 | ||
136 | memset(props, 0, sizeof *props); | 139 | memset(props, 0, sizeof *props); |
137 | 140 | ||
138 | memset(in_mad, 0, sizeof *in_mad); | 141 | init_query_mad(in_mad); |
139 | in_mad->base_version = 1; | 142 | in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; |
140 | in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | 143 | in_mad->attr_mod = cpu_to_be32(port); |
141 | in_mad->class_version = 1; | ||
142 | in_mad->method = IB_MGMT_METHOD_GET; | ||
143 | in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; | ||
144 | in_mad->attr_mod = cpu_to_be32(port); | ||
145 | 144 | ||
146 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, | 145 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, |
147 | port, NULL, NULL, in_mad, out_mad, | 146 | port, NULL, NULL, in_mad, out_mad, |
@@ -220,18 +219,14 @@ static int mthca_query_pkey(struct ib_device *ibdev, | |||
220 | int err = -ENOMEM; | 219 | int err = -ENOMEM; |
221 | u8 status; | 220 | u8 status; |
222 | 221 | ||
223 | in_mad = kmalloc(sizeof *in_mad, GFP_KERNEL); | 222 | in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); |
224 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); | 223 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); |
225 | if (!in_mad || !out_mad) | 224 | if (!in_mad || !out_mad) |
226 | goto out; | 225 | goto out; |
227 | 226 | ||
228 | memset(in_mad, 0, sizeof *in_mad); | 227 | init_query_mad(in_mad); |
229 | in_mad->base_version = 1; | 228 | in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE; |
230 | in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | 229 | in_mad->attr_mod = cpu_to_be32(index / 32); |
231 | in_mad->class_version = 1; | ||
232 | in_mad->method = IB_MGMT_METHOD_GET; | ||
233 | in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE; | ||
234 | in_mad->attr_mod = cpu_to_be32(index / 32); | ||
235 | 230 | ||
236 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, | 231 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, |
237 | port, NULL, NULL, in_mad, out_mad, | 232 | port, NULL, NULL, in_mad, out_mad, |
@@ -259,18 +254,14 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, | |||
259 | int err = -ENOMEM; | 254 | int err = -ENOMEM; |
260 | u8 status; | 255 | u8 status; |
261 | 256 | ||
262 | in_mad = kmalloc(sizeof *in_mad, GFP_KERNEL); | 257 | in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); |
263 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); | 258 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); |
264 | if (!in_mad || !out_mad) | 259 | if (!in_mad || !out_mad) |
265 | goto out; | 260 | goto out; |
266 | 261 | ||
267 | memset(in_mad, 0, sizeof *in_mad); | 262 | init_query_mad(in_mad); |
268 | in_mad->base_version = 1; | 263 | in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; |
269 | in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | 264 | in_mad->attr_mod = cpu_to_be32(port); |
270 | in_mad->class_version = 1; | ||
271 | in_mad->method = IB_MGMT_METHOD_GET; | ||
272 | in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; | ||
273 | in_mad->attr_mod = cpu_to_be32(port); | ||
274 | 265 | ||
275 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, | 266 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, |
276 | port, NULL, NULL, in_mad, out_mad, | 267 | port, NULL, NULL, in_mad, out_mad, |
@@ -284,13 +275,9 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, | |||
284 | 275 | ||
285 | memcpy(gid->raw, out_mad->data + 8, 8); | 276 | memcpy(gid->raw, out_mad->data + 8, 8); |
286 | 277 | ||
287 | memset(in_mad, 0, sizeof *in_mad); | 278 | init_query_mad(in_mad); |
288 | in_mad->base_version = 1; | 279 | in_mad->attr_id = IB_SMP_ATTR_GUID_INFO; |
289 | in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | 280 | in_mad->attr_mod = cpu_to_be32(index / 8); |
290 | in_mad->class_version = 1; | ||
291 | in_mad->method = IB_MGMT_METHOD_GET; | ||
292 | in_mad->attr_id = IB_SMP_ATTR_GUID_INFO; | ||
293 | in_mad->attr_mod = cpu_to_be32(index / 8); | ||
294 | 281 | ||
295 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, | 282 | err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, |
296 | port, NULL, NULL, in_mad, out_mad, | 283 | port, NULL, NULL, in_mad, out_mad, |
@@ -458,8 +445,10 @@ static struct ib_srq *mthca_create_srq(struct ib_pd *pd, | |||
458 | if (pd->uobject) { | 445 | if (pd->uobject) { |
459 | context = to_mucontext(pd->uobject->context); | 446 | context = to_mucontext(pd->uobject->context); |
460 | 447 | ||
461 | if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) | 448 | if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { |
462 | return ERR_PTR(-EFAULT); | 449 | err = -EFAULT; |
450 | goto err_free; | ||
451 | } | ||
463 | 452 | ||
464 | err = mthca_map_user_db(to_mdev(pd->device), &context->uar, | 453 | err = mthca_map_user_db(to_mdev(pd->device), &context->uar, |
465 | context->db_tab, ucmd.db_index, | 454 | context->db_tab, ucmd.db_index, |
@@ -535,8 +524,10 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd, | |||
535 | if (pd->uobject) { | 524 | if (pd->uobject) { |
536 | context = to_mucontext(pd->uobject->context); | 525 | context = to_mucontext(pd->uobject->context); |
537 | 526 | ||
538 | if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) | 527 | if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { |
528 | kfree(qp); | ||
539 | return ERR_PTR(-EFAULT); | 529 | return ERR_PTR(-EFAULT); |
530 | } | ||
540 | 531 | ||
541 | err = mthca_map_user_db(to_mdev(pd->device), &context->uar, | 532 | err = mthca_map_user_db(to_mdev(pd->device), &context->uar, |
542 | context->db_tab, | 533 | context->db_tab, |
@@ -783,24 +774,20 @@ static struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd, | |||
783 | if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) | 774 | if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) |
784 | return ERR_PTR(-EINVAL); | 775 | return ERR_PTR(-EINVAL); |
785 | 776 | ||
786 | if (num_phys_buf > 1 && | ||
787 | ((buffer_list[0].addr + buffer_list[0].size) & ~PAGE_MASK)) | ||
788 | return ERR_PTR(-EINVAL); | ||
789 | |||
790 | mask = 0; | 777 | mask = 0; |
791 | total_size = 0; | 778 | total_size = 0; |
792 | for (i = 0; i < num_phys_buf; ++i) { | 779 | for (i = 0; i < num_phys_buf; ++i) { |
793 | if (i != 0 && buffer_list[i].addr & ~PAGE_MASK) | 780 | if (i != 0) |
794 | return ERR_PTR(-EINVAL); | 781 | mask |= buffer_list[i].addr; |
795 | if (i != 0 && i != num_phys_buf - 1 && | 782 | if (i != num_phys_buf - 1) |
796 | (buffer_list[i].size & ~PAGE_MASK)) | 783 | mask |= buffer_list[i].addr + buffer_list[i].size; |
797 | return ERR_PTR(-EINVAL); | ||
798 | 784 | ||
799 | total_size += buffer_list[i].size; | 785 | total_size += buffer_list[i].size; |
800 | if (i > 0) | ||
801 | mask |= buffer_list[i].addr; | ||
802 | } | 786 | } |
803 | 787 | ||
788 | if (mask & ~PAGE_MASK) | ||
789 | return ERR_PTR(-EINVAL); | ||
790 | |||
804 | /* Find largest page shift we can use to cover buffers */ | 791 | /* Find largest page shift we can use to cover buffers */ |
805 | for (shift = PAGE_SHIFT; shift < 31; ++shift) | 792 | for (shift = PAGE_SHIFT; shift < 31; ++shift) |
806 | if (num_phys_buf > 1) { | 793 | if (num_phys_buf > 1) { |
@@ -1070,11 +1057,48 @@ static struct class_device_attribute *mthca_class_attributes[] = { | |||
1070 | &class_device_attr_board_id | 1057 | &class_device_attr_board_id |
1071 | }; | 1058 | }; |
1072 | 1059 | ||
1060 | static int mthca_init_node_data(struct mthca_dev *dev) | ||
1061 | { | ||
1062 | struct ib_smp *in_mad = NULL; | ||
1063 | struct ib_smp *out_mad = NULL; | ||
1064 | int err = -ENOMEM; | ||
1065 | u8 status; | ||
1066 | |||
1067 | in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); | ||
1068 | out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); | ||
1069 | if (!in_mad || !out_mad) | ||
1070 | goto out; | ||
1071 | |||
1072 | init_query_mad(in_mad); | ||
1073 | in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; | ||
1074 | |||
1075 | err = mthca_MAD_IFC(dev, 1, 1, | ||
1076 | 1, NULL, NULL, in_mad, out_mad, | ||
1077 | &status); | ||
1078 | if (err) | ||
1079 | goto out; | ||
1080 | if (status) { | ||
1081 | err = -EINVAL; | ||
1082 | goto out; | ||
1083 | } | ||
1084 | |||
1085 | memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8); | ||
1086 | |||
1087 | out: | ||
1088 | kfree(in_mad); | ||
1089 | kfree(out_mad); | ||
1090 | return err; | ||
1091 | } | ||
1092 | |||
1073 | int mthca_register_device(struct mthca_dev *dev) | 1093 | int mthca_register_device(struct mthca_dev *dev) |
1074 | { | 1094 | { |
1075 | int ret; | 1095 | int ret; |
1076 | int i; | 1096 | int i; |
1077 | 1097 | ||
1098 | ret = mthca_init_node_data(dev); | ||
1099 | if (ret) | ||
1100 | return ret; | ||
1101 | |||
1078 | strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX); | 1102 | strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX); |
1079 | dev->ib_dev.owner = THIS_MODULE; | 1103 | dev->ib_dev.owner = THIS_MODULE; |
1080 | 1104 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 564b6d51c394..fba608ed7df2 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -1434,7 +1434,7 @@ static int build_mlx_header(struct mthca_dev *dev, struct mthca_sqp *sqp, | |||
1434 | u16 pkey; | 1434 | u16 pkey; |
1435 | 1435 | ||
1436 | ib_ud_header_init(256, /* assume a MAD */ | 1436 | ib_ud_header_init(256, /* assume a MAD */ |
1437 | sqp->ud_header.grh_present, | 1437 | mthca_ah_grh_present(to_mah(wr->wr.ud.ah)), |
1438 | &sqp->ud_header); | 1438 | &sqp->ud_header); |
1439 | 1439 | ||
1440 | err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header); | 1440 | err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index 9923a15a9996..e0a5412b7e68 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h | |||
@@ -45,11 +45,11 @@ | |||
45 | #include <linux/config.h> | 45 | #include <linux/config.h> |
46 | #include <linux/kref.h> | 46 | #include <linux/kref.h> |
47 | #include <linux/if_infiniband.h> | 47 | #include <linux/if_infiniband.h> |
48 | #include <linux/mutex.h> | ||
48 | 49 | ||
49 | #include <net/neighbour.h> | 50 | #include <net/neighbour.h> |
50 | 51 | ||
51 | #include <asm/atomic.h> | 52 | #include <asm/atomic.h> |
52 | #include <asm/semaphore.h> | ||
53 | 53 | ||
54 | #include <rdma/ib_verbs.h> | 54 | #include <rdma/ib_verbs.h> |
55 | #include <rdma/ib_pack.h> | 55 | #include <rdma/ib_pack.h> |
@@ -123,8 +123,8 @@ struct ipoib_dev_priv { | |||
123 | 123 | ||
124 | unsigned long flags; | 124 | unsigned long flags; |
125 | 125 | ||
126 | struct semaphore mcast_mutex; | 126 | struct mutex mcast_mutex; |
127 | struct semaphore vlan_mutex; | 127 | struct mutex vlan_mutex; |
128 | 128 | ||
129 | struct rb_root path_tree; | 129 | struct rb_root path_tree; |
130 | struct list_head path_list; | 130 | struct list_head path_list; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 23885801b6d2..86bcdd72a107 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(data_debug_level, | |||
52 | 52 | ||
53 | #define IPOIB_OP_RECV (1ul << 31) | 53 | #define IPOIB_OP_RECV (1ul << 31) |
54 | 54 | ||
55 | static DECLARE_MUTEX(pkey_sem); | 55 | static DEFINE_MUTEX(pkey_mutex); |
56 | 56 | ||
57 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, | 57 | struct ipoib_ah *ipoib_create_ah(struct net_device *dev, |
58 | struct ib_pd *pd, struct ib_ah_attr *attr) | 58 | struct ib_pd *pd, struct ib_ah_attr *attr) |
@@ -445,25 +445,16 @@ int ipoib_ib_dev_down(struct net_device *dev) | |||
445 | 445 | ||
446 | /* Shutdown the P_Key thread if still active */ | 446 | /* Shutdown the P_Key thread if still active */ |
447 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { | 447 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { |
448 | down(&pkey_sem); | 448 | mutex_lock(&pkey_mutex); |
449 | set_bit(IPOIB_PKEY_STOP, &priv->flags); | 449 | set_bit(IPOIB_PKEY_STOP, &priv->flags); |
450 | cancel_delayed_work(&priv->pkey_task); | 450 | cancel_delayed_work(&priv->pkey_task); |
451 | up(&pkey_sem); | 451 | mutex_unlock(&pkey_mutex); |
452 | flush_workqueue(ipoib_workqueue); | 452 | flush_workqueue(ipoib_workqueue); |
453 | } | 453 | } |
454 | 454 | ||
455 | ipoib_mcast_stop_thread(dev, 1); | 455 | ipoib_mcast_stop_thread(dev, 1); |
456 | |||
457 | /* | ||
458 | * Flush the multicast groups first so we stop any multicast joins. The | ||
459 | * completion thread may have already died and we may deadlock waiting | ||
460 | * for the completion thread to finish some multicast joins. | ||
461 | */ | ||
462 | ipoib_mcast_dev_flush(dev); | 456 | ipoib_mcast_dev_flush(dev); |
463 | 457 | ||
464 | /* Delete broadcast and local addresses since they will be recreated */ | ||
465 | ipoib_mcast_dev_down(dev); | ||
466 | |||
467 | ipoib_flush_paths(dev); | 458 | ipoib_flush_paths(dev); |
468 | 459 | ||
469 | return 0; | 460 | return 0; |
@@ -608,13 +599,13 @@ void ipoib_ib_dev_flush(void *_dev) | |||
608 | if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) | 599 | if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) |
609 | ipoib_ib_dev_up(dev); | 600 | ipoib_ib_dev_up(dev); |
610 | 601 | ||
611 | down(&priv->vlan_mutex); | 602 | mutex_lock(&priv->vlan_mutex); |
612 | 603 | ||
613 | /* Flush any child interfaces too */ | 604 | /* Flush any child interfaces too */ |
614 | list_for_each_entry(cpriv, &priv->child_intfs, list) | 605 | list_for_each_entry(cpriv, &priv->child_intfs, list) |
615 | ipoib_ib_dev_flush(&cpriv->dev); | 606 | ipoib_ib_dev_flush(&cpriv->dev); |
616 | 607 | ||
617 | up(&priv->vlan_mutex); | 608 | mutex_unlock(&priv->vlan_mutex); |
618 | } | 609 | } |
619 | 610 | ||
620 | void ipoib_ib_dev_cleanup(struct net_device *dev) | 611 | void ipoib_ib_dev_cleanup(struct net_device *dev) |
@@ -624,9 +615,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev) | |||
624 | ipoib_dbg(priv, "cleaning up ib_dev\n"); | 615 | ipoib_dbg(priv, "cleaning up ib_dev\n"); |
625 | 616 | ||
626 | ipoib_mcast_stop_thread(dev, 1); | 617 | ipoib_mcast_stop_thread(dev, 1); |
627 | 618 | ipoib_mcast_dev_flush(dev); | |
628 | /* Delete the broadcast address and the local address */ | ||
629 | ipoib_mcast_dev_down(dev); | ||
630 | 619 | ||
631 | ipoib_transport_dev_cleanup(dev); | 620 | ipoib_transport_dev_cleanup(dev); |
632 | } | 621 | } |
@@ -662,12 +651,12 @@ void ipoib_pkey_poll(void *dev_ptr) | |||
662 | if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) | 651 | if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) |
663 | ipoib_open(dev); | 652 | ipoib_open(dev); |
664 | else { | 653 | else { |
665 | down(&pkey_sem); | 654 | mutex_lock(&pkey_mutex); |
666 | if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) | 655 | if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) |
667 | queue_delayed_work(ipoib_workqueue, | 656 | queue_delayed_work(ipoib_workqueue, |
668 | &priv->pkey_task, | 657 | &priv->pkey_task, |
669 | HZ); | 658 | HZ); |
670 | up(&pkey_sem); | 659 | mutex_unlock(&pkey_mutex); |
671 | } | 660 | } |
672 | } | 661 | } |
673 | 662 | ||
@@ -681,12 +670,12 @@ int ipoib_pkey_dev_delay_open(struct net_device *dev) | |||
681 | 670 | ||
682 | /* P_Key value not assigned yet - start polling */ | 671 | /* P_Key value not assigned yet - start polling */ |
683 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { | 672 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { |
684 | down(&pkey_sem); | 673 | mutex_lock(&pkey_mutex); |
685 | clear_bit(IPOIB_PKEY_STOP, &priv->flags); | 674 | clear_bit(IPOIB_PKEY_STOP, &priv->flags); |
686 | queue_delayed_work(ipoib_workqueue, | 675 | queue_delayed_work(ipoib_workqueue, |
687 | &priv->pkey_task, | 676 | &priv->pkey_task, |
688 | HZ); | 677 | HZ); |
689 | up(&pkey_sem); | 678 | mutex_unlock(&pkey_mutex); |
690 | return 1; | 679 | return 1; |
691 | } | 680 | } |
692 | 681 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 780009c7eaa6..fd3f5c862a5d 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -105,7 +105,7 @@ int ipoib_open(struct net_device *dev) | |||
105 | struct ipoib_dev_priv *cpriv; | 105 | struct ipoib_dev_priv *cpriv; |
106 | 106 | ||
107 | /* Bring up any child interfaces too */ | 107 | /* Bring up any child interfaces too */ |
108 | down(&priv->vlan_mutex); | 108 | mutex_lock(&priv->vlan_mutex); |
109 | list_for_each_entry(cpriv, &priv->child_intfs, list) { | 109 | list_for_each_entry(cpriv, &priv->child_intfs, list) { |
110 | int flags; | 110 | int flags; |
111 | 111 | ||
@@ -115,7 +115,7 @@ int ipoib_open(struct net_device *dev) | |||
115 | 115 | ||
116 | dev_change_flags(cpriv->dev, flags | IFF_UP); | 116 | dev_change_flags(cpriv->dev, flags | IFF_UP); |
117 | } | 117 | } |
118 | up(&priv->vlan_mutex); | 118 | mutex_unlock(&priv->vlan_mutex); |
119 | } | 119 | } |
120 | 120 | ||
121 | netif_start_queue(dev); | 121 | netif_start_queue(dev); |
@@ -140,7 +140,7 @@ static int ipoib_stop(struct net_device *dev) | |||
140 | struct ipoib_dev_priv *cpriv; | 140 | struct ipoib_dev_priv *cpriv; |
141 | 141 | ||
142 | /* Bring down any child interfaces too */ | 142 | /* Bring down any child interfaces too */ |
143 | down(&priv->vlan_mutex); | 143 | mutex_lock(&priv->vlan_mutex); |
144 | list_for_each_entry(cpriv, &priv->child_intfs, list) { | 144 | list_for_each_entry(cpriv, &priv->child_intfs, list) { |
145 | int flags; | 145 | int flags; |
146 | 146 | ||
@@ -150,7 +150,7 @@ static int ipoib_stop(struct net_device *dev) | |||
150 | 150 | ||
151 | dev_change_flags(cpriv->dev, flags & ~IFF_UP); | 151 | dev_change_flags(cpriv->dev, flags & ~IFF_UP); |
152 | } | 152 | } |
153 | up(&priv->vlan_mutex); | 153 | mutex_unlock(&priv->vlan_mutex); |
154 | } | 154 | } |
155 | 155 | ||
156 | return 0; | 156 | return 0; |
@@ -892,8 +892,8 @@ static void ipoib_setup(struct net_device *dev) | |||
892 | spin_lock_init(&priv->lock); | 892 | spin_lock_init(&priv->lock); |
893 | spin_lock_init(&priv->tx_lock); | 893 | spin_lock_init(&priv->tx_lock); |
894 | 894 | ||
895 | init_MUTEX(&priv->mcast_mutex); | 895 | mutex_init(&priv->mcast_mutex); |
896 | init_MUTEX(&priv->vlan_mutex); | 896 | mutex_init(&priv->vlan_mutex); |
897 | 897 | ||
898 | INIT_LIST_HEAD(&priv->path_list); | 898 | INIT_LIST_HEAD(&priv->path_list); |
899 | INIT_LIST_HEAD(&priv->child_intfs); | 899 | INIT_LIST_HEAD(&priv->child_intfs); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index ed0c2ead8bc1..98039da0caf0 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c | |||
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(mcast_debug_level, | |||
55 | "Enable multicast debug tracing if > 0"); | 55 | "Enable multicast debug tracing if > 0"); |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | static DECLARE_MUTEX(mcast_mutex); | 58 | static DEFINE_MUTEX(mcast_mutex); |
59 | 59 | ||
60 | /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ | 60 | /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ |
61 | struct ipoib_mcast { | 61 | struct ipoib_mcast { |
@@ -97,8 +97,6 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) | |||
97 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 97 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
98 | struct ipoib_neigh *neigh, *tmp; | 98 | struct ipoib_neigh *neigh, *tmp; |
99 | unsigned long flags; | 99 | unsigned long flags; |
100 | LIST_HEAD(ah_list); | ||
101 | struct ipoib_ah *ah, *tah; | ||
102 | 100 | ||
103 | ipoib_dbg_mcast(netdev_priv(dev), | 101 | ipoib_dbg_mcast(netdev_priv(dev), |
104 | "deleting multicast group " IPOIB_GID_FMT "\n", | 102 | "deleting multicast group " IPOIB_GID_FMT "\n", |
@@ -107,8 +105,14 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) | |||
107 | spin_lock_irqsave(&priv->lock, flags); | 105 | spin_lock_irqsave(&priv->lock, flags); |
108 | 106 | ||
109 | list_for_each_entry_safe(neigh, tmp, &mcast->neigh_list, list) { | 107 | list_for_each_entry_safe(neigh, tmp, &mcast->neigh_list, list) { |
108 | /* | ||
109 | * It's safe to call ipoib_put_ah() inside priv->lock | ||
110 | * here, because we know that mcast->ah will always | ||
111 | * hold one more reference, so ipoib_put_ah() will | ||
112 | * never do more than decrement the ref count. | ||
113 | */ | ||
110 | if (neigh->ah) | 114 | if (neigh->ah) |
111 | list_add_tail(&neigh->ah->list, &ah_list); | 115 | ipoib_put_ah(neigh->ah); |
112 | *to_ipoib_neigh(neigh->neighbour) = NULL; | 116 | *to_ipoib_neigh(neigh->neighbour) = NULL; |
113 | neigh->neighbour->ops->destructor = NULL; | 117 | neigh->neighbour->ops->destructor = NULL; |
114 | kfree(neigh); | 118 | kfree(neigh); |
@@ -116,9 +120,6 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) | |||
116 | 120 | ||
117 | spin_unlock_irqrestore(&priv->lock, flags); | 121 | spin_unlock_irqrestore(&priv->lock, flags); |
118 | 122 | ||
119 | list_for_each_entry_safe(ah, tah, &ah_list, list) | ||
120 | ipoib_put_ah(ah); | ||
121 | |||
122 | if (mcast->ah) | 123 | if (mcast->ah) |
123 | ipoib_put_ah(mcast->ah); | 124 | ipoib_put_ah(mcast->ah); |
124 | 125 | ||
@@ -384,10 +385,10 @@ static void ipoib_mcast_join_complete(int status, | |||
384 | 385 | ||
385 | if (!status && !ipoib_mcast_join_finish(mcast, mcmember)) { | 386 | if (!status && !ipoib_mcast_join_finish(mcast, mcmember)) { |
386 | mcast->backoff = 1; | 387 | mcast->backoff = 1; |
387 | down(&mcast_mutex); | 388 | mutex_lock(&mcast_mutex); |
388 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) | 389 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) |
389 | queue_work(ipoib_workqueue, &priv->mcast_task); | 390 | queue_work(ipoib_workqueue, &priv->mcast_task); |
390 | up(&mcast_mutex); | 391 | mutex_unlock(&mcast_mutex); |
391 | complete(&mcast->done); | 392 | complete(&mcast->done); |
392 | return; | 393 | return; |
393 | } | 394 | } |
@@ -417,7 +418,7 @@ static void ipoib_mcast_join_complete(int status, | |||
417 | 418 | ||
418 | mcast->query = NULL; | 419 | mcast->query = NULL; |
419 | 420 | ||
420 | down(&mcast_mutex); | 421 | mutex_lock(&mcast_mutex); |
421 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) { | 422 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) { |
422 | if (status == -ETIMEDOUT) | 423 | if (status == -ETIMEDOUT) |
423 | queue_work(ipoib_workqueue, &priv->mcast_task); | 424 | queue_work(ipoib_workqueue, &priv->mcast_task); |
@@ -426,7 +427,7 @@ static void ipoib_mcast_join_complete(int status, | |||
426 | mcast->backoff * HZ); | 427 | mcast->backoff * HZ); |
427 | } else | 428 | } else |
428 | complete(&mcast->done); | 429 | complete(&mcast->done); |
429 | up(&mcast_mutex); | 430 | mutex_unlock(&mcast_mutex); |
430 | 431 | ||
431 | return; | 432 | return; |
432 | } | 433 | } |
@@ -481,12 +482,12 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast, | |||
481 | if (mcast->backoff > IPOIB_MAX_BACKOFF_SECONDS) | 482 | if (mcast->backoff > IPOIB_MAX_BACKOFF_SECONDS) |
482 | mcast->backoff = IPOIB_MAX_BACKOFF_SECONDS; | 483 | mcast->backoff = IPOIB_MAX_BACKOFF_SECONDS; |
483 | 484 | ||
484 | down(&mcast_mutex); | 485 | mutex_lock(&mcast_mutex); |
485 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) | 486 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) |
486 | queue_delayed_work(ipoib_workqueue, | 487 | queue_delayed_work(ipoib_workqueue, |
487 | &priv->mcast_task, | 488 | &priv->mcast_task, |
488 | mcast->backoff * HZ); | 489 | mcast->backoff * HZ); |
489 | up(&mcast_mutex); | 490 | mutex_unlock(&mcast_mutex); |
490 | } else | 491 | } else |
491 | mcast->query_id = ret; | 492 | mcast->query_id = ret; |
492 | } | 493 | } |
@@ -519,11 +520,11 @@ void ipoib_mcast_join_task(void *dev_ptr) | |||
519 | priv->broadcast = ipoib_mcast_alloc(dev, 1); | 520 | priv->broadcast = ipoib_mcast_alloc(dev, 1); |
520 | if (!priv->broadcast) { | 521 | if (!priv->broadcast) { |
521 | ipoib_warn(priv, "failed to allocate broadcast group\n"); | 522 | ipoib_warn(priv, "failed to allocate broadcast group\n"); |
522 | down(&mcast_mutex); | 523 | mutex_lock(&mcast_mutex); |
523 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) | 524 | if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) |
524 | queue_delayed_work(ipoib_workqueue, | 525 | queue_delayed_work(ipoib_workqueue, |
525 | &priv->mcast_task, HZ); | 526 | &priv->mcast_task, HZ); |
526 | up(&mcast_mutex); | 527 | mutex_unlock(&mcast_mutex); |
527 | return; | 528 | return; |
528 | } | 529 | } |
529 | 530 | ||
@@ -579,10 +580,10 @@ int ipoib_mcast_start_thread(struct net_device *dev) | |||
579 | 580 | ||
580 | ipoib_dbg_mcast(priv, "starting multicast thread\n"); | 581 | ipoib_dbg_mcast(priv, "starting multicast thread\n"); |
581 | 582 | ||
582 | down(&mcast_mutex); | 583 | mutex_lock(&mcast_mutex); |
583 | if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags)) | 584 | if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags)) |
584 | queue_work(ipoib_workqueue, &priv->mcast_task); | 585 | queue_work(ipoib_workqueue, &priv->mcast_task); |
585 | up(&mcast_mutex); | 586 | mutex_unlock(&mcast_mutex); |
586 | 587 | ||
587 | return 0; | 588 | return 0; |
588 | } | 589 | } |
@@ -594,10 +595,10 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush) | |||
594 | 595 | ||
595 | ipoib_dbg_mcast(priv, "stopping multicast thread\n"); | 596 | ipoib_dbg_mcast(priv, "stopping multicast thread\n"); |
596 | 597 | ||
597 | down(&mcast_mutex); | 598 | mutex_lock(&mcast_mutex); |
598 | clear_bit(IPOIB_MCAST_RUN, &priv->flags); | 599 | clear_bit(IPOIB_MCAST_RUN, &priv->flags); |
599 | cancel_delayed_work(&priv->mcast_task); | 600 | cancel_delayed_work(&priv->mcast_task); |
600 | up(&mcast_mutex); | 601 | mutex_unlock(&mcast_mutex); |
601 | 602 | ||
602 | if (flush) | 603 | if (flush) |
603 | flush_workqueue(ipoib_workqueue); | 604 | flush_workqueue(ipoib_workqueue); |
@@ -741,48 +742,23 @@ void ipoib_mcast_dev_flush(struct net_device *dev) | |||
741 | { | 742 | { |
742 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 743 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
743 | LIST_HEAD(remove_list); | 744 | LIST_HEAD(remove_list); |
744 | struct ipoib_mcast *mcast, *tmcast, *nmcast; | 745 | struct ipoib_mcast *mcast, *tmcast; |
745 | unsigned long flags; | 746 | unsigned long flags; |
746 | 747 | ||
747 | ipoib_dbg_mcast(priv, "flushing multicast list\n"); | 748 | ipoib_dbg_mcast(priv, "flushing multicast list\n"); |
748 | 749 | ||
749 | spin_lock_irqsave(&priv->lock, flags); | 750 | spin_lock_irqsave(&priv->lock, flags); |
750 | list_for_each_entry_safe(mcast, tmcast, &priv->multicast_list, list) { | ||
751 | nmcast = ipoib_mcast_alloc(dev, 0); | ||
752 | if (nmcast) { | ||
753 | nmcast->flags = | ||
754 | mcast->flags & (1 << IPOIB_MCAST_FLAG_SENDONLY); | ||
755 | 751 | ||
756 | nmcast->mcmember.mgid = mcast->mcmember.mgid; | 752 | list_for_each_entry_safe(mcast, tmcast, &priv->multicast_list, list) { |
757 | 753 | list_del(&mcast->list); | |
758 | /* Add the new group in before the to-be-destroyed group */ | 754 | rb_erase(&mcast->rb_node, &priv->multicast_tree); |
759 | list_add_tail(&nmcast->list, &mcast->list); | 755 | list_add_tail(&mcast->list, &remove_list); |
760 | list_del_init(&mcast->list); | ||
761 | |||
762 | rb_replace_node(&mcast->rb_node, &nmcast->rb_node, | ||
763 | &priv->multicast_tree); | ||
764 | |||
765 | list_add_tail(&mcast->list, &remove_list); | ||
766 | } else { | ||
767 | ipoib_warn(priv, "could not reallocate multicast group " | ||
768 | IPOIB_GID_FMT "\n", | ||
769 | IPOIB_GID_ARG(mcast->mcmember.mgid)); | ||
770 | } | ||
771 | } | 756 | } |
772 | 757 | ||
773 | if (priv->broadcast) { | 758 | if (priv->broadcast) { |
774 | nmcast = ipoib_mcast_alloc(dev, 0); | 759 | rb_erase(&priv->broadcast->rb_node, &priv->multicast_tree); |
775 | if (nmcast) { | 760 | list_add_tail(&priv->broadcast->list, &remove_list); |
776 | nmcast->mcmember.mgid = priv->broadcast->mcmember.mgid; | 761 | priv->broadcast = NULL; |
777 | |||
778 | rb_replace_node(&priv->broadcast->rb_node, | ||
779 | &nmcast->rb_node, | ||
780 | &priv->multicast_tree); | ||
781 | |||
782 | list_add_tail(&priv->broadcast->list, &remove_list); | ||
783 | } | ||
784 | |||
785 | priv->broadcast = nmcast; | ||
786 | } | 762 | } |
787 | 763 | ||
788 | spin_unlock_irqrestore(&priv->lock, flags); | 764 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -793,24 +769,6 @@ void ipoib_mcast_dev_flush(struct net_device *dev) | |||
793 | } | 769 | } |
794 | } | 770 | } |
795 | 771 | ||
796 | void ipoib_mcast_dev_down(struct net_device *dev) | ||
797 | { | ||
798 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
799 | unsigned long flags; | ||
800 | |||
801 | /* Delete broadcast since it will be recreated */ | ||
802 | if (priv->broadcast) { | ||
803 | ipoib_dbg_mcast(priv, "deleting broadcast group\n"); | ||
804 | |||
805 | spin_lock_irqsave(&priv->lock, flags); | ||
806 | rb_erase(&priv->broadcast->rb_node, &priv->multicast_tree); | ||
807 | spin_unlock_irqrestore(&priv->lock, flags); | ||
808 | ipoib_mcast_leave(dev, priv->broadcast); | ||
809 | ipoib_mcast_free(priv->broadcast); | ||
810 | priv->broadcast = NULL; | ||
811 | } | ||
812 | } | ||
813 | |||
814 | void ipoib_mcast_restart_task(void *dev_ptr) | 772 | void ipoib_mcast_restart_task(void *dev_ptr) |
815 | { | 773 | { |
816 | struct net_device *dev = dev_ptr; | 774 | struct net_device *dev = dev_ptr; |
@@ -824,7 +782,8 @@ void ipoib_mcast_restart_task(void *dev_ptr) | |||
824 | 782 | ||
825 | ipoib_mcast_stop_thread(dev, 0); | 783 | ipoib_mcast_stop_thread(dev, 0); |
826 | 784 | ||
827 | spin_lock_irqsave(&priv->lock, flags); | 785 | spin_lock_irqsave(&dev->xmit_lock, flags); |
786 | spin_lock(&priv->lock); | ||
828 | 787 | ||
829 | /* | 788 | /* |
830 | * Unfortunately, the networking core only gives us a list of all of | 789 | * Unfortunately, the networking core only gives us a list of all of |
@@ -896,7 +855,9 @@ void ipoib_mcast_restart_task(void *dev_ptr) | |||
896 | list_add_tail(&mcast->list, &remove_list); | 855 | list_add_tail(&mcast->list, &remove_list); |
897 | } | 856 | } |
898 | } | 857 | } |
899 | spin_unlock_irqrestore(&priv->lock, flags); | 858 | |
859 | spin_unlock(&priv->lock); | ||
860 | spin_unlock_irqrestore(&dev->xmit_lock, flags); | ||
900 | 861 | ||
901 | /* We have to cancel outside of the spinlock */ | 862 | /* We have to cancel outside of the spinlock */ |
902 | list_for_each_entry_safe(mcast, tmcast, &remove_list, list) { | 863 | list_for_each_entry_safe(mcast, tmcast, &remove_list, list) { |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index e829e10400e3..faaf10e5fc7b 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c | |||
@@ -65,9 +65,9 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) | |||
65 | } | 65 | } |
66 | 66 | ||
67 | /* attach QP to multicast group */ | 67 | /* attach QP to multicast group */ |
68 | down(&priv->mcast_mutex); | 68 | mutex_lock(&priv->mcast_mutex); |
69 | ret = ib_attach_mcast(priv->qp, mgid, mlid); | 69 | ret = ib_attach_mcast(priv->qp, mgid, mlid); |
70 | up(&priv->mcast_mutex); | 70 | mutex_unlock(&priv->mcast_mutex); |
71 | if (ret) | 71 | if (ret) |
72 | ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret); | 72 | ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret); |
73 | 73 | ||
@@ -81,9 +81,9 @@ int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid) | |||
81 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 81 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
82 | int ret; | 82 | int ret; |
83 | 83 | ||
84 | down(&priv->mcast_mutex); | 84 | mutex_lock(&priv->mcast_mutex); |
85 | ret = ib_detach_mcast(priv->qp, mgid, mlid); | 85 | ret = ib_detach_mcast(priv->qp, mgid, mlid); |
86 | up(&priv->mcast_mutex); | 86 | mutex_unlock(&priv->mcast_mutex); |
87 | if (ret) | 87 | if (ret) |
88 | ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret); | 88 | ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret); |
89 | 89 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c index d280b341a37f..4ca175553f9f 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c | |||
@@ -63,7 +63,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) | |||
63 | 63 | ||
64 | ppriv = netdev_priv(pdev); | 64 | ppriv = netdev_priv(pdev); |
65 | 65 | ||
66 | down(&ppriv->vlan_mutex); | 66 | mutex_lock(&ppriv->vlan_mutex); |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * First ensure this isn't a duplicate. We check the parent device and | 69 | * First ensure this isn't a duplicate. We check the parent device and |
@@ -124,7 +124,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) | |||
124 | 124 | ||
125 | list_add_tail(&priv->list, &ppriv->child_intfs); | 125 | list_add_tail(&priv->list, &ppriv->child_intfs); |
126 | 126 | ||
127 | up(&ppriv->vlan_mutex); | 127 | mutex_unlock(&ppriv->vlan_mutex); |
128 | 128 | ||
129 | return 0; | 129 | return 0; |
130 | 130 | ||
@@ -139,7 +139,7 @@ device_init_failed: | |||
139 | free_netdev(priv->dev); | 139 | free_netdev(priv->dev); |
140 | 140 | ||
141 | err: | 141 | err: |
142 | up(&ppriv->vlan_mutex); | 142 | mutex_unlock(&ppriv->vlan_mutex); |
143 | return result; | 143 | return result; |
144 | } | 144 | } |
145 | 145 | ||
@@ -153,7 +153,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey) | |||
153 | 153 | ||
154 | ppriv = netdev_priv(pdev); | 154 | ppriv = netdev_priv(pdev); |
155 | 155 | ||
156 | down(&ppriv->vlan_mutex); | 156 | mutex_lock(&ppriv->vlan_mutex); |
157 | list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) { | 157 | list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) { |
158 | if (priv->pkey == pkey) { | 158 | if (priv->pkey == pkey) { |
159 | unregister_netdev(priv->dev); | 159 | unregister_netdev(priv->dev); |
@@ -167,7 +167,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey) | |||
167 | break; | 167 | break; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | up(&ppriv->vlan_mutex); | 170 | mutex_unlock(&ppriv->vlan_mutex); |
171 | 171 | ||
172 | return ret; | 172 | return ret; |
173 | } | 173 | } |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index dd488d3cffa9..31207e664148 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -1516,8 +1516,7 @@ static ssize_t show_port(struct class_device *class_dev, char *buf) | |||
1516 | 1516 | ||
1517 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 1517 | static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
1518 | 1518 | ||
1519 | static struct srp_host *srp_add_port(struct ib_device *device, | 1519 | static struct srp_host *srp_add_port(struct ib_device *device, u8 port) |
1520 | __be64 node_guid, u8 port) | ||
1521 | { | 1520 | { |
1522 | struct srp_host *host; | 1521 | struct srp_host *host; |
1523 | 1522 | ||
@@ -1532,7 +1531,7 @@ static struct srp_host *srp_add_port(struct ib_device *device, | |||
1532 | host->port = port; | 1531 | host->port = port; |
1533 | 1532 | ||
1534 | host->initiator_port_id[7] = port; | 1533 | host->initiator_port_id[7] = port; |
1535 | memcpy(host->initiator_port_id + 8, &node_guid, 8); | 1534 | memcpy(host->initiator_port_id + 8, &device->node_guid, 8); |
1536 | 1535 | ||
1537 | host->pd = ib_alloc_pd(device); | 1536 | host->pd = ib_alloc_pd(device); |
1538 | if (IS_ERR(host->pd)) | 1537 | if (IS_ERR(host->pd)) |
@@ -1580,22 +1579,11 @@ static void srp_add_one(struct ib_device *device) | |||
1580 | { | 1579 | { |
1581 | struct list_head *dev_list; | 1580 | struct list_head *dev_list; |
1582 | struct srp_host *host; | 1581 | struct srp_host *host; |
1583 | struct ib_device_attr *dev_attr; | ||
1584 | int s, e, p; | 1582 | int s, e, p; |
1585 | 1583 | ||
1586 | dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL); | ||
1587 | if (!dev_attr) | ||
1588 | return; | ||
1589 | |||
1590 | if (ib_query_device(device, dev_attr)) { | ||
1591 | printk(KERN_WARNING PFX "Couldn't query node GUID for %s.\n", | ||
1592 | device->name); | ||
1593 | goto out; | ||
1594 | } | ||
1595 | |||
1596 | dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); | 1584 | dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); |
1597 | if (!dev_list) | 1585 | if (!dev_list) |
1598 | goto out; | 1586 | return; |
1599 | 1587 | ||
1600 | INIT_LIST_HEAD(dev_list); | 1588 | INIT_LIST_HEAD(dev_list); |
1601 | 1589 | ||
@@ -1608,15 +1596,12 @@ static void srp_add_one(struct ib_device *device) | |||
1608 | } | 1596 | } |
1609 | 1597 | ||
1610 | for (p = s; p <= e; ++p) { | 1598 | for (p = s; p <= e; ++p) { |
1611 | host = srp_add_port(device, dev_attr->node_guid, p); | 1599 | host = srp_add_port(device, p); |
1612 | if (host) | 1600 | if (host) |
1613 | list_add_tail(&host->list, dev_list); | 1601 | list_add_tail(&host->list, dev_list); |
1614 | } | 1602 | } |
1615 | 1603 | ||
1616 | ib_set_client_data(device, &srp_client, dev_list); | 1604 | ib_set_client_data(device, &srp_client, dev_list); |
1617 | |||
1618 | out: | ||
1619 | kfree(dev_attr); | ||
1620 | } | 1605 | } |
1621 | 1606 | ||
1622 | static void srp_remove_one(struct ib_device *device) | 1607 | static void srp_remove_one(struct ib_device *device) |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a7f4c355a91f..22fc886b9695 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -88,7 +88,6 @@ enum ib_atomic_cap { | |||
88 | 88 | ||
89 | struct ib_device_attr { | 89 | struct ib_device_attr { |
90 | u64 fw_ver; | 90 | u64 fw_ver; |
91 | __be64 node_guid; | ||
92 | __be64 sys_image_guid; | 91 | __be64 sys_image_guid; |
93 | u64 max_mr_size; | 92 | u64 max_mr_size; |
94 | u64 page_size_cap; | 93 | u64 page_size_cap; |
@@ -951,6 +950,7 @@ struct ib_device { | |||
951 | u64 uverbs_cmd_mask; | 950 | u64 uverbs_cmd_mask; |
952 | int uverbs_abi_ver; | 951 | int uverbs_abi_ver; |
953 | 952 | ||
953 | __be64 node_guid; | ||
954 | u8 node_type; | 954 | u8 node_type; |
955 | u8 phys_port_cnt; | 955 | u8 phys_port_cnt; |
956 | }; | 956 | }; |