Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branches 'cxgb4' and 'mlx5' into k.o/for-4.8

+83 -76
+17 -37
drivers/infiniband/core/iwcm.c
··· 183 183 184 184 /* 185 185 * Release a reference on cm_id. If the last reference is being 186 - * released, enable the waiting thread (in iw_destroy_cm_id) to 187 - * get woken up, and return 1 if a thread is already waiting. 186 + * released, free the cm_id and return 1. 188 187 */ 189 188 static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv) 190 189 { 191 190 BUG_ON(atomic_read(&cm_id_priv->refcount)==0); 192 191 if (atomic_dec_and_test(&cm_id_priv->refcount)) { 193 192 BUG_ON(!list_empty(&cm_id_priv->work_list)); 194 - complete(&cm_id_priv->destroy_comp); 193 + free_cm_id(cm_id_priv); 195 194 return 1; 196 195 } 197 196 ··· 207 208 static void rem_ref(struct iw_cm_id *cm_id) 208 209 { 209 210 struct iwcm_id_private *cm_id_priv; 210 - int cb_destroy; 211 211 212 212 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 213 213 214 - /* 215 - * Test bit before deref in case the cm_id gets freed on another 216 - * thread. 217 - */ 218 - cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); 219 - if (iwcm_deref_id(cm_id_priv) && cb_destroy) { 220 - BUG_ON(!list_empty(&cm_id_priv->work_list)); 221 - free_cm_id(cm_id_priv); 222 - } 214 + (void)iwcm_deref_id(cm_id_priv); 223 215 } 224 216 225 217 static int cm_event_handler(struct iw_cm_id *cm_id, struct iw_cm_event *event); ··· 360 370 wait_event(cm_id_priv->connect_wait, 361 371 !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags)); 362 372 373 + /* 374 + * Since we're deleting the cm_id, drop any events that 375 + * might arrive before the last dereference. 376 + */ 377 + set_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags); 378 + 363 379 spin_lock_irqsave(&cm_id_priv->lock, flags); 364 380 switch (cm_id_priv->state) { 365 381 case IW_CM_STATE_LISTEN: ··· 429 433 struct iwcm_id_private *cm_id_priv; 430 434 431 435 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 432 - BUG_ON(test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)); 433 - 434 436 destroy_cm_id(cm_id); 435 - 436 - wait_for_completion(&cm_id_priv->destroy_comp); 437 - 438 - free_cm_id(cm_id_priv); 439 437 } 440 438 EXPORT_SYMBOL(iw_destroy_cm_id); 441 439 ··· 799 809 ret = cm_id->cm_handler(cm_id, iw_event); 800 810 if (ret) { 801 811 iw_cm_reject(cm_id, NULL, 0); 802 - set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); 803 - destroy_cm_id(cm_id); 804 - if (atomic_read(&cm_id_priv->refcount)==0) 805 - free_cm_id(cm_id_priv); 812 + iw_destroy_cm_id(cm_id); 806 813 } 807 814 808 815 out: ··· 987 1000 unsigned long flags; 988 1001 int empty; 989 1002 int ret = 0; 990 - int destroy_id; 991 1003 992 1004 spin_lock_irqsave(&cm_id_priv->lock, flags); 993 1005 empty = list_empty(&cm_id_priv->work_list); ··· 999 1013 put_work(work); 1000 1014 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1001 1015 1002 - ret = process_event(cm_id_priv, &levent); 1003 - if (ret) { 1004 - set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); 1005 - destroy_cm_id(&cm_id_priv->id); 1006 - } 1007 - BUG_ON(atomic_read(&cm_id_priv->refcount)==0); 1008 - destroy_id = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); 1009 - if (iwcm_deref_id(cm_id_priv)) { 1010 - if (destroy_id) { 1011 - BUG_ON(!list_empty(&cm_id_priv->work_list)); 1012 - free_cm_id(cm_id_priv); 1013 - } 1016 + if (!test_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags)) { 1017 + ret = process_event(cm_id_priv, &levent); 1018 + if (ret) 1019 + destroy_cm_id(&cm_id_priv->id); 1020 + } else 1021 + pr_debug("dropping event %d\n", levent.event); 1022 + if (iwcm_deref_id(cm_id_priv)) 1014 1023 return; 1015 - } 1016 1024 if (empty) 1017 1025 return; 1018 1026 spin_lock_irqsave(&cm_id_priv->lock, flags);
+1 -1
drivers/infiniband/core/iwcm.h
··· 56 56 struct list_head work_free_list; 57 57 }; 58 58 59 - #define IWCM_F_CALLBACK_DESTROY 1 59 + #define IWCM_F_DROP_EVENTS 1 60 60 #define IWCM_F_CONNECT_WAIT 2 61 61 62 62 #endif /* IWCM_H */
+5 -1
drivers/infiniband/core/netlink.c
··· 229 229 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh, 230 230 __u32 pid) 231 231 { 232 - return nlmsg_unicast(nls, skb, pid); 232 + int err; 233 + 234 + err = netlink_unicast(nls, skb, pid, 0); 235 + return (err < 0) ? err : 0; 233 236 } 234 237 EXPORT_SYMBOL(ibnl_unicast); 235 238 ··· 255 252 return -ENOMEM; 256 253 } 257 254 255 + nls->sk_sndtimeo = 10 * HZ; 258 256 return 0; 259 257 } 260 258
+2 -2
drivers/infiniband/hw/cxgb3/iwch_cm.c
··· 1396 1396 state_set(&child_ep->com, CONNECTING); 1397 1397 child_ep->com.tdev = tdev; 1398 1398 child_ep->com.cm_id = NULL; 1399 - child_ep->com.local_addr.sin_family = PF_INET; 1399 + child_ep->com.local_addr.sin_family = AF_INET; 1400 1400 child_ep->com.local_addr.sin_port = req->local_port; 1401 1401 child_ep->com.local_addr.sin_addr.s_addr = req->local_ip; 1402 - child_ep->com.remote_addr.sin_family = PF_INET; 1402 + child_ep->com.remote_addr.sin_family = AF_INET; 1403 1403 child_ep->com.remote_addr.sin_port = req->peer_port; 1404 1404 child_ep->com.remote_addr.sin_addr.s_addr = req->peer_ip; 1405 1405 get_ep(&parent_ep->com);
+11 -1
drivers/infiniband/hw/cxgb4/cm.c
··· 3068 3068 PDBG("%s last streaming msg ack ep %p tid %u state %u " 3069 3069 "initiator %u freeing skb\n", __func__, ep, ep->hwtid, 3070 3070 state_read(&ep->com), ep->mpa_attr.initiator ? 1 : 0); 3071 + mutex_lock(&ep->com.mutex); 3071 3072 kfree_skb(ep->mpa_skb); 3072 3073 ep->mpa_skb = NULL; 3073 - mutex_lock(&ep->com.mutex); 3074 3074 if (test_bit(STOP_MPA_TIMER, &ep->com.flags)) 3075 3075 stop_ep_timer(ep); 3076 3076 mutex_unlock(&ep->com.mutex); ··· 3647 3647 ep->com.state = ABORTING; 3648 3648 else { 3649 3649 ep->com.state = CLOSING; 3650 + 3651 + /* 3652 + * if we close before we see the fw4_ack() then we fix 3653 + * up the timer state since we're reusing it. 3654 + */ 3655 + if (ep->mpa_skb && 3656 + test_bit(STOP_MPA_TIMER, &ep->com.flags)) { 3657 + clear_bit(STOP_MPA_TIMER, &ep->com.flags); 3658 + stop_ep_timer(ep); 3659 + } 3650 3660 start_ep_timer(ep); 3651 3661 } 3652 3662 set_bit(CLOSE_SENT, &ep->com.flags);
+1 -1
drivers/infiniband/hw/cxgb4/iw_cxgb4.h
··· 475 475 struct t4_wq wq; 476 476 spinlock_t lock; 477 477 struct mutex mutex; 478 - atomic_t refcnt; 478 + struct kref kref; 479 479 wait_queue_head_t wait; 480 480 struct timer_list timer; 481 481 int sq_sig_all;
+15 -11
drivers/infiniband/hw/cxgb4/mem.c
··· 603 603 604 604 mhp->dereg_skb = alloc_skb(SGE_MAX_WR_LEN, GFP_KERNEL); 605 605 if (!mhp->dereg_skb) { 606 - kfree(mhp); 607 - return ERR_PTR(-ENOMEM); 606 + ret = -ENOMEM; 607 + goto free_mhp; 608 608 } 609 609 610 610 ret = allocate_window(&rhp->rdev, &stag, php->pdid); 611 - if (ret) { 612 - kfree(mhp->dereg_skb); 613 - kfree(mhp); 614 - return ERR_PTR(ret); 615 - } 611 + if (ret) 612 + goto free_skb; 616 613 mhp->rhp = rhp; 617 614 mhp->attr.pdid = php->pdid; 618 615 mhp->attr.type = FW_RI_STAG_MW; ··· 617 620 mmid = (stag) >> 8; 618 621 mhp->ibmw.rkey = stag; 619 622 if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) { 620 - deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb); 621 - kfree(mhp->dereg_skb); 622 - kfree(mhp); 623 - return ERR_PTR(-ENOMEM); 623 + ret = -ENOMEM; 624 + goto dealloc_win; 624 625 } 625 626 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); 626 627 return &(mhp->ibmw); 628 + 629 + dealloc_win: 630 + deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb); 631 + free_skb: 632 + kfree_skb(mhp->dereg_skb); 633 + free_mhp: 634 + kfree(mhp); 635 + return ERR_PTR(ret); 627 636 } 628 637 629 638 int c4iw_dealloc_mw(struct ib_mw *mw) ··· 643 640 mmid = (mw->rkey) >> 8; 644 641 remove_handle(rhp, &rhp->mmidr, mmid); 645 642 deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb); 643 + kfree_skb(mhp->dereg_skb); 646 644 kfree(mhp); 647 645 PDBG("%s ib_mw %p mmid 0x%x ptr %p\n", __func__, mw, mmid, mhp); 648 646 return 0;
+23 -7
drivers/infiniband/hw/cxgb4/qp.c
··· 683 683 return 0; 684 684 } 685 685 686 + void _free_qp(struct kref *kref) 687 + { 688 + struct c4iw_qp *qhp; 689 + 690 + qhp = container_of(kref, struct c4iw_qp, kref); 691 + PDBG("%s qhp %p\n", __func__, qhp); 692 + kfree(qhp); 693 + } 694 + 686 695 void c4iw_qp_add_ref(struct ib_qp *qp) 687 696 { 688 697 PDBG("%s ib_qp %p\n", __func__, qp); 689 - atomic_inc(&(to_c4iw_qp(qp)->refcnt)); 698 + kref_get(&to_c4iw_qp(qp)->kref); 690 699 } 691 700 692 701 void c4iw_qp_rem_ref(struct ib_qp *qp) 693 702 { 694 703 PDBG("%s ib_qp %p\n", __func__, qp); 695 - if (atomic_dec_and_test(&(to_c4iw_qp(qp)->refcnt))) 696 - wake_up(&(to_c4iw_qp(qp)->wait)); 704 + kref_put(&to_c4iw_qp(qp)->kref, _free_qp); 697 705 } 698 706 699 707 static void add_to_fc_list(struct list_head *head, struct list_head *entry) ··· 1602 1594 wait_event(qhp->wait, !qhp->ep); 1603 1595 1604 1596 remove_handle(rhp, &rhp->qpidr, qhp->wq.sq.qid); 1605 - atomic_dec(&qhp->refcnt); 1606 - wait_event(qhp->wait, !atomic_read(&qhp->refcnt)); 1607 1597 1608 1598 spin_lock_irq(&rhp->lock); 1609 1599 if (!list_empty(&qhp->db_fc_entry)) ··· 1614 1608 destroy_qp(&rhp->rdev, &qhp->wq, 1615 1609 ucontext ? &ucontext->uctx : &rhp->rdev.uctx); 1616 1610 1611 + c4iw_qp_rem_ref(ib_qp); 1612 + 1617 1613 PDBG("%s ib_qp %p qpid 0x%0x\n", __func__, ib_qp, qhp->wq.sq.qid); 1618 - kfree(qhp); 1619 1614 return 0; 1620 1615 } 1621 1616 ··· 1713 1706 init_completion(&qhp->rq_drained); 1714 1707 mutex_init(&qhp->mutex); 1715 1708 init_waitqueue_head(&qhp->wait); 1716 - atomic_set(&qhp->refcnt, 1); 1709 + kref_init(&qhp->kref); 1717 1710 1718 1711 ret = insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.sq.qid); 1719 1712 if (ret) ··· 1905 1898 return 0; 1906 1899 } 1907 1900 1901 + static void move_qp_to_err(struct c4iw_qp *qp) 1902 + { 1903 + struct c4iw_qp_attributes attrs = { .next_state = C4IW_QP_STATE_ERROR }; 1904 + 1905 + (void)c4iw_modify_qp(qp->rhp, qp, C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); 1906 + } 1907 + 1908 1908 void c4iw_drain_sq(struct ib_qp *ibqp) 1909 1909 { 1910 1910 struct c4iw_qp *qp = to_c4iw_qp(ibqp); 1911 1911 unsigned long flag; 1912 1912 bool need_to_wait; 1913 1913 1914 + move_qp_to_err(qp); 1914 1915 spin_lock_irqsave(&qp->lock, flag); 1915 1916 need_to_wait = !t4_sq_empty(&qp->wq); 1916 1917 spin_unlock_irqrestore(&qp->lock, flag); ··· 1933 1918 unsigned long flag; 1934 1919 bool need_to_wait; 1935 1920 1921 + move_qp_to_err(qp); 1936 1922 spin_lock_irqsave(&qp->lock, flag); 1937 1923 need_to_wait = !t4_rq_empty(&qp->wq); 1938 1924 spin_unlock_irqrestore(&qp->lock, flag);
+6 -13
drivers/infiniband/hw/mlx5/gsi.c
··· 69 69 return MLX5_CAP_GEN(dev->mdev, set_deth_sqpn); 70 70 } 71 71 72 - static u32 next_outstanding(struct mlx5_ib_gsi_qp *gsi, u32 index) 73 - { 74 - return ++index % gsi->cap.max_send_wr; 75 - } 76 - 77 - #define for_each_outstanding_wr(gsi, index) \ 78 - for (index = gsi->outstanding_ci; index != gsi->outstanding_pi; \ 79 - index = next_outstanding(gsi, index)) 80 - 81 72 /* Call with gsi->lock locked */ 82 73 static void generate_completions(struct mlx5_ib_gsi_qp *gsi) 83 74 { ··· 76 85 struct mlx5_ib_gsi_wr *wr; 77 86 u32 index; 78 87 79 - for_each_outstanding_wr(gsi, index) { 80 - wr = &gsi->outstanding_wrs[index]; 88 + for (index = gsi->outstanding_ci; index != gsi->outstanding_pi; 89 + index++) { 90 + wr = &gsi->outstanding_wrs[index % gsi->cap.max_send_wr]; 81 91 82 92 if (!wr->completed) 83 93 break; ··· 422 430 return -ENOMEM; 423 431 } 424 432 425 - gsi_wr = &gsi->outstanding_wrs[gsi->outstanding_pi]; 426 - gsi->outstanding_pi = next_outstanding(gsi, gsi->outstanding_pi); 433 + gsi_wr = &gsi->outstanding_wrs[gsi->outstanding_pi % 434 + gsi->cap.max_send_wr]; 435 + gsi->outstanding_pi++; 427 436 428 437 if (!wc) { 429 438 memset(&gsi_wr->wc, 0, sizeof(gsi_wr->wc));
+1 -1
drivers/infiniband/hw/mlx5/main.c
··· 2574 2574 return ret; 2575 2575 } 2576 2576 2577 - static const char const *names[] = { 2577 + static const char * const names[] = { 2578 2578 "rx_write_requests", 2579 2579 "rx_read_requests", 2580 2580 "rx_atomic_requests",
+1 -1
drivers/infiniband/hw/mlx5/qp.c
··· 2657 2657 struct mlx5_ib_port *mibport = &dev->port[port_num]; 2658 2658 2659 2659 context->qp_counter_set_usr_page |= 2660 - cpu_to_be32(mibport->q_cnt_id << 16); 2660 + cpu_to_be32((u32)(mibport->q_cnt_id) << 24); 2661 2661 } 2662 2662 2663 2663 if (!ibqp->uobject && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT)