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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
IB/ehca: Discard double CQE for one WR
IB/ehca: Check idr_find() return value
IB/ehca: Repoll CQ on invalid opcode
IB/ehca: Rename goto label in ehca_poll_cq_one()
IB/ehca: Update qp_state on cached modify_qp()
IPoIB/cm: Use vmalloc() to allocate rx_rings

+104 -31
+9
drivers/infiniband/hw/ehca/ehca_classes.h
··· 156 156 157 157 #define EHCA_MOD_QP_PARM_MAX 4 158 158 159 + #define QMAP_IDX_MASK 0xFFFFULL 160 + 161 + /* struct for tracking if cqes have been reported to the application */ 162 + struct ehca_qmap_entry { 163 + u16 app_wr_id; 164 + u16 reported; 165 + }; 166 + 159 167 struct ehca_qp { 160 168 union { 161 169 struct ib_qp ib_qp; ··· 173 165 enum ehca_ext_qp_type ext_type; 174 166 enum ib_qp_state state; 175 167 struct ipz_queue ipz_squeue; 168 + struct ehca_qmap_entry *sq_map; 176 169 struct ipz_queue ipz_rqueue; 177 170 struct h_galpas galpas; 178 171 u32 qkey;
+1
drivers/infiniband/hw/ehca/ehca_qes.h
··· 213 213 #define WC_STATUS_ERROR_BIT 0x80000000 214 214 #define WC_STATUS_REMOTE_ERROR_FLAGS 0x0000F800 215 215 #define WC_STATUS_PURGE_BIT 0x10 216 + #define WC_SEND_RECEIVE_BIT 0x80 216 217 217 218 struct ehca_cqe { 218 219 u64 work_request_id;
+35 -13
drivers/infiniband/hw/ehca/ehca_qp.c
··· 412 412 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca, 413 413 ib_device); 414 414 struct ib_ucontext *context = NULL; 415 + u32 nr_qes; 415 416 u64 h_ret; 416 417 int is_llqp = 0, has_srq = 0; 417 418 int qp_type, max_send_sge, max_recv_sge, ret; ··· 716 715 "and pages ret=%i", ret); 717 716 goto create_qp_exit2; 718 717 } 718 + nr_qes = my_qp->ipz_squeue.queue_length / 719 + my_qp->ipz_squeue.qe_size; 720 + my_qp->sq_map = vmalloc(nr_qes * 721 + sizeof(struct ehca_qmap_entry)); 722 + if (!my_qp->sq_map) { 723 + ehca_err(pd->device, "Couldn't allocate squeue " 724 + "map ret=%i", ret); 725 + goto create_qp_exit3; 726 + } 719 727 } 720 728 721 729 if (HAS_RQ(my_qp)) { ··· 734 724 if (ret) { 735 725 ehca_err(pd->device, "Couldn't initialize rqueue " 736 726 "and pages ret=%i", ret); 737 - goto create_qp_exit3; 727 + goto create_qp_exit4; 738 728 } 739 729 } 740 730 ··· 780 770 if (!my_qp->mod_qp_parm) { 781 771 ehca_err(pd->device, 782 772 "Could not alloc mod_qp_parm"); 783 - goto create_qp_exit4; 773 + goto create_qp_exit5; 784 774 } 785 775 } 786 776 } ··· 790 780 h_ret = ehca_define_sqp(shca, my_qp, init_attr); 791 781 if (h_ret != H_SUCCESS) { 792 782 ret = ehca2ib_return_code(h_ret); 793 - goto create_qp_exit5; 783 + goto create_qp_exit6; 794 784 } 795 785 } 796 786 ··· 799 789 if (ret) { 800 790 ehca_err(pd->device, 801 791 "Couldn't assign qp to send_cq ret=%i", ret); 802 - goto create_qp_exit5; 792 + goto create_qp_exit6; 803 793 } 804 794 } 805 795 ··· 825 815 if (ib_copy_to_udata(udata, &resp, sizeof resp)) { 826 816 ehca_err(pd->device, "Copy to udata failed"); 827 817 ret = -EINVAL; 828 - goto create_qp_exit6; 818 + goto create_qp_exit7; 829 819 } 830 820 } 831 821 832 822 return my_qp; 833 823 834 - create_qp_exit6: 824 + create_qp_exit7: 835 825 ehca_cq_unassign_qp(my_qp->send_cq, my_qp->real_qp_num); 836 826 837 - create_qp_exit5: 827 + create_qp_exit6: 838 828 kfree(my_qp->mod_qp_parm); 839 829 840 - create_qp_exit4: 830 + create_qp_exit5: 841 831 if (HAS_RQ(my_qp)) 842 832 ipz_queue_dtor(my_pd, &my_qp->ipz_rqueue); 833 + 834 + create_qp_exit4: 835 + if (HAS_SQ(my_qp)) 836 + vfree(my_qp->sq_map); 843 837 844 838 create_qp_exit3: 845 839 if (HAS_SQ(my_qp)) ··· 1548 1534 if (attr_mask & IB_QP_QKEY) 1549 1535 my_qp->qkey = attr->qkey; 1550 1536 1551 - my_qp->state = qp_new_state; 1552 - 1553 1537 modify_qp_exit2: 1554 1538 if (squeue_locked) { /* this means: sqe -> rts */ 1555 1539 spin_unlock_irqrestore(&my_qp->spinlock_s, flags); ··· 1563 1551 int ehca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, 1564 1552 struct ib_udata *udata) 1565 1553 { 1554 + int ret = 0; 1555 + 1566 1556 struct ehca_shca *shca = container_of(ibqp->device, struct ehca_shca, 1567 1557 ib_device); 1568 1558 struct ehca_qp *my_qp = container_of(ibqp, struct ehca_qp, ib_qp); ··· 1611 1597 attr->qp_state, my_qp->init_attr.port_num, 1612 1598 ibqp->qp_type); 1613 1599 spin_unlock_irqrestore(&sport->mod_sqp_lock, flags); 1614 - return 0; 1600 + goto out; 1615 1601 } 1616 1602 spin_unlock_irqrestore(&sport->mod_sqp_lock, flags); 1617 1603 } 1618 1604 1619 - return internal_modify_qp(ibqp, attr, attr_mask, 0); 1605 + ret = internal_modify_qp(ibqp, attr, attr_mask, 0); 1606 + 1607 + out: 1608 + if ((ret == 0) && (attr_mask & IB_QP_STATE)) 1609 + my_qp->state = attr->qp_state; 1610 + 1611 + return ret; 1620 1612 } 1621 1613 1622 1614 void ehca_recover_sqp(struct ib_qp *sqp) ··· 1993 1973 1994 1974 if (HAS_RQ(my_qp)) 1995 1975 ipz_queue_dtor(my_pd, &my_qp->ipz_rqueue); 1996 - if (HAS_SQ(my_qp)) 1976 + if (HAS_SQ(my_qp)) { 1997 1977 ipz_queue_dtor(my_pd, &my_qp->ipz_squeue); 1978 + vfree(my_qp->sq_map); 1979 + } 1998 1980 kmem_cache_free(qp_cache, my_qp); 1999 1981 atomic_dec(&shca->num_qps); 2000 1982 return 0;
+47 -13
drivers/infiniband/hw/ehca/ehca_reqs.c
··· 139 139 static inline int ehca_write_swqe(struct ehca_qp *qp, 140 140 struct ehca_wqe *wqe_p, 141 141 const struct ib_send_wr *send_wr, 142 + u32 sq_map_idx, 142 143 int hidden) 143 144 { 144 145 u32 idx; ··· 158 157 /* clear wqe header until sglist */ 159 158 memset(wqe_p, 0, offsetof(struct ehca_wqe, u.ud_av.sg_list)); 160 159 161 - wqe_p->work_request_id = send_wr->wr_id; 160 + wqe_p->work_request_id = send_wr->wr_id & ~QMAP_IDX_MASK; 161 + wqe_p->work_request_id |= sq_map_idx & QMAP_IDX_MASK; 162 + 163 + qp->sq_map[sq_map_idx].app_wr_id = send_wr->wr_id & QMAP_IDX_MASK; 164 + qp->sq_map[sq_map_idx].reported = 0; 162 165 163 166 switch (send_wr->opcode) { 164 167 case IB_WR_SEND: ··· 386 381 { 387 382 struct ehca_wqe *wqe_p; 388 383 int ret; 384 + u32 sq_map_idx; 389 385 u64 start_offset = my_qp->ipz_squeue.current_q_offset; 390 386 391 387 /* get pointer next to free WQE */ ··· 399 393 "qp_num=%x", my_qp->ib_qp.qp_num); 400 394 return -ENOMEM; 401 395 } 396 + 397 + /* 398 + * Get the index of the WQE in the send queue. The same index is used 399 + * for writing into the sq_map. 400 + */ 401 + sq_map_idx = start_offset / my_qp->ipz_squeue.qe_size; 402 + 402 403 /* write a SEND WQE into the QUEUE */ 403 - ret = ehca_write_swqe(my_qp, wqe_p, cur_send_wr, hidden); 404 + ret = ehca_write_swqe(my_qp, wqe_p, cur_send_wr, sq_map_idx, hidden); 404 405 /* 405 406 * if something failed, 406 407 * reset the free entry pointer to the start value ··· 602 589 struct ehca_qp *my_qp; 603 590 int cqe_count = 0, is_error; 604 591 605 - poll_cq_one_read_cqe: 592 + repoll: 606 593 cqe = (struct ehca_cqe *) 607 594 ipz_qeit_get_inc_valid(&my_cq->ipz_queue); 608 595 if (!cqe) { ··· 630 617 ehca_dmp(cqe, 64, "cq_num=%x qp_num=%x", 631 618 my_cq->cq_number, cqe->local_qp_number); 632 619 /* ignore this purged cqe */ 633 - goto poll_cq_one_read_cqe; 620 + goto repoll; 634 621 } 635 622 spin_lock_irqsave(&qp->spinlock_s, flags); 636 623 purgeflag = qp->sqerr_purgeflag; ··· 649 636 * that caused sqe and turn off purge flag 650 637 */ 651 638 qp->sqerr_purgeflag = 0; 652 - goto poll_cq_one_read_cqe; 639 + goto repoll; 653 640 } 654 641 } 655 642 ··· 667 654 my_cq, my_cq->cq_number); 668 655 } 669 656 670 - /* we got a completion! */ 671 - wc->wr_id = cqe->work_request_id; 657 + read_lock(&ehca_qp_idr_lock); 658 + my_qp = idr_find(&ehca_qp_idr, cqe->qp_token); 659 + read_unlock(&ehca_qp_idr_lock); 660 + if (!my_qp) 661 + goto repoll; 662 + wc->qp = &my_qp->ib_qp; 663 + 664 + if (!(cqe->w_completion_flags & WC_SEND_RECEIVE_BIT)) { 665 + struct ehca_qmap_entry *qmap_entry; 666 + /* 667 + * We got a send completion and need to restore the original 668 + * wr_id. 669 + */ 670 + qmap_entry = &my_qp->sq_map[cqe->work_request_id & 671 + QMAP_IDX_MASK]; 672 + 673 + if (qmap_entry->reported) { 674 + ehca_warn(cq->device, "Double cqe on qp_num=%#x", 675 + my_qp->real_qp_num); 676 + /* found a double cqe, discard it and read next one */ 677 + goto repoll; 678 + } 679 + wc->wr_id = cqe->work_request_id & ~QMAP_IDX_MASK; 680 + wc->wr_id |= qmap_entry->app_wr_id; 681 + qmap_entry->reported = 1; 682 + } else 683 + /* We got a receive completion. */ 684 + wc->wr_id = cqe->work_request_id; 672 685 673 686 /* eval ib_wc_opcode */ 674 687 wc->opcode = ib_wc_opcode[cqe->optype]-1; ··· 706 667 ehca_dmp(cqe, 64, "ehca_cq=%p cq_num=%x", 707 668 my_cq, my_cq->cq_number); 708 669 /* update also queue adder to throw away this entry!!! */ 709 - goto poll_cq_one_exit0; 670 + goto repoll; 710 671 } 711 672 712 673 /* eval ib_wc_status */ ··· 716 677 wc->vendor_err = wc->status; 717 678 } else 718 679 wc->status = IB_WC_SUCCESS; 719 - 720 - read_lock(&ehca_qp_idr_lock); 721 - my_qp = idr_find(&ehca_qp_idr, cqe->qp_token); 722 - wc->qp = &my_qp->ib_qp; 723 - read_unlock(&ehca_qp_idr_lock); 724 680 725 681 wc->byte_len = cqe->nr_bytes_transferred; 726 682 wc->pkey_index = cqe->pkey_index;
+12 -5
drivers/infiniband/ulp/ipoib/ipoib_cm.c
··· 202 202 dev_kfree_skb_any(rx_ring[i].skb); 203 203 } 204 204 205 - kfree(rx_ring); 205 + vfree(rx_ring); 206 206 } 207 207 208 208 static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv) ··· 352 352 int ret; 353 353 int i; 354 354 355 - rx->rx_ring = kcalloc(ipoib_recvq_size, sizeof *rx->rx_ring, GFP_KERNEL); 356 - if (!rx->rx_ring) 355 + rx->rx_ring = vmalloc(ipoib_recvq_size * sizeof *rx->rx_ring); 356 + if (!rx->rx_ring) { 357 + printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n", 358 + priv->ca->name, ipoib_recvq_size); 357 359 return -ENOMEM; 360 + } 361 + 362 + memset(rx->rx_ring, 0, ipoib_recvq_size * sizeof *rx->rx_ring); 358 363 359 364 t = kmalloc(sizeof *t, GFP_KERNEL); 360 365 if (!t) { ··· 1499 1494 return; 1500 1495 } 1501 1496 1502 - priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring, 1503 - GFP_KERNEL); 1497 + priv->cm.srq_ring = vmalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring); 1504 1498 if (!priv->cm.srq_ring) { 1505 1499 printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n", 1506 1500 priv->ca->name, ipoib_recvq_size); 1507 1501 ib_destroy_srq(priv->cm.srq); 1508 1502 priv->cm.srq = NULL; 1503 + return; 1509 1504 } 1505 + 1506 + memset(priv->cm.srq_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring); 1510 1507 } 1511 1508 1512 1509 int ipoib_cm_dev_init(struct net_device *dev)