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

[PATCH] IB: really reset QPs

When we modify a QP to the RESET state, completely clean up the QP
so that it is really and truly reset.

Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Roland Dreier and committed by
Roland Dreier
c9fe2b32 0b2b35f6

+32 -12
+32 -12
drivers/infiniband/hw/mthca/mthca_qp.c
··· 220 220 (PAGE_SIZE - 1)); 221 221 } 222 222 223 + static void mthca_wq_init(struct mthca_wq *wq) 224 + { 225 + spin_lock_init(&wq->lock); 226 + wq->next_ind = 0; 227 + wq->last_comp = wq->max - 1; 228 + wq->head = 0; 229 + wq->tail = 0; 230 + wq->last = NULL; 231 + } 232 + 223 233 void mthca_qp_event(struct mthca_dev *dev, u32 qpn, 224 234 enum ib_event_type event_type) 225 235 { ··· 843 833 store_attrs(to_msqp(qp), attr, attr_mask); 844 834 845 835 /* 846 - * If we are moving QP0 to RTR, bring the IB link up; if we 847 - * are moving QP0 to RESET or ERROR, bring the link back down. 836 + * If we moved QP0 to RTR, bring the IB link up; if we moved 837 + * QP0 to RESET or ERROR, bring the link back down. 848 838 */ 849 839 if (is_qp0(dev, qp)) { 850 840 if (cur_state != IB_QPS_RTR && ··· 856 846 (new_state == IB_QPS_RESET || 857 847 new_state == IB_QPS_ERR)) 858 848 mthca_CLOSE_IB(dev, to_msqp(qp)->port, &status); 849 + } 850 + 851 + /* 852 + * If we moved a kernel QP to RESET, clean up all old CQ 853 + * entries and reinitialize the QP. 854 + */ 855 + if (!err && new_state == IB_QPS_RESET && !qp->ibqp.uobject) { 856 + mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, 857 + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); 858 + if (qp->ibqp.send_cq != qp->ibqp.recv_cq) 859 + mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn, 860 + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); 861 + 862 + mthca_wq_init(&qp->sq); 863 + mthca_wq_init(&qp->rq); 864 + 865 + if (mthca_is_memfree(dev)) { 866 + *qp->sq.db = 0; 867 + *qp->rq.db = 0; 868 + } 859 869 } 860 870 861 871 return err; ··· 1031 1001 mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index); 1032 1002 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index); 1033 1003 } 1034 - } 1035 - 1036 - static void mthca_wq_init(struct mthca_wq* wq) 1037 - { 1038 - spin_lock_init(&wq->lock); 1039 - wq->next_ind = 0; 1040 - wq->last_comp = wq->max - 1; 1041 - wq->head = 0; 1042 - wq->tail = 0; 1043 - wq->last = NULL; 1044 1004 } 1045 1005 1046 1006 static int mthca_alloc_qp_common(struct mthca_dev *dev,