aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/user_mad.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/core/user_mad.c')
-rw-r--r--drivers/infiniband/core/user_mad.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 11af1c61c135..928cdd20e2d1 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -506,13 +506,15 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
506 506
507 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data; 507 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
508 hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class); 508 hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
509 if (!ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)) { 509
510 copy_offset = IB_MGMT_MAD_HDR; 510 if (ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
511 rmpp_active = 0; 511 && ib_mad_kernel_rmpp_agent(agent)) {
512 } else {
513 copy_offset = IB_MGMT_RMPP_HDR; 512 copy_offset = IB_MGMT_RMPP_HDR;
514 rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & 513 rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
515 IB_MGMT_RMPP_FLAG_ACTIVE; 514 IB_MGMT_RMPP_FLAG_ACTIVE;
515 } else {
516 copy_offset = IB_MGMT_MAD_HDR;
517 rmpp_active = 0;
516 } 518 }
517 519
518 data_len = count - hdr_size(file) - hdr_len; 520 data_len = count - hdr_size(file) - hdr_len;
@@ -558,14 +560,22 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
558 rmpp_mad->mad_hdr.tid = *tid; 560 rmpp_mad->mad_hdr.tid = *tid;
559 } 561 }
560 562
561 spin_lock_irq(&file->send_lock); 563 if (!ib_mad_kernel_rmpp_agent(agent)
562 ret = is_duplicate(file, packet); 564 && ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
563 if (!ret) 565 && (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
566 spin_lock_irq(&file->send_lock);
564 list_add_tail(&packet->list, &file->send_list); 567 list_add_tail(&packet->list, &file->send_list);
565 spin_unlock_irq(&file->send_lock); 568 spin_unlock_irq(&file->send_lock);
566 if (ret) { 569 } else {
567 ret = -EINVAL; 570 spin_lock_irq(&file->send_lock);
568 goto err_msg; 571 ret = is_duplicate(file, packet);
572 if (!ret)
573 list_add_tail(&packet->list, &file->send_list);
574 spin_unlock_irq(&file->send_lock);
575 if (ret) {
576 ret = -EINVAL;
577 goto err_msg;
578 }
569 } 579 }
570 580
571 ret = ib_post_send_mad(packet->msg, NULL); 581 ret = ib_post_send_mad(packet->msg, NULL);