1419 c = qp->refcount;
1420 spin_unlock_irq(&dev->qp_table.lock);
1421
1422 return c;
1423}
1424
1425void mthca_free_qp(struct mthca_dev *dev,
1426 struct mthca_qp *qp)
1427{
1428 u8 status;
1429 struct mthca_cq *send_cq;
1430 struct mthca_cq *recv_cq;
1431
1432 send_cq = to_mcq(qp->ibqp.send_cq);
1433 recv_cq = to_mcq(qp->ibqp.recv_cq);
1434
1435
1436
1437
1438
1439 mthca_lock_cqs(send_cq, recv_cq);
1440
1441 spin_lock(&dev->qp_table.lock);
1442 mthca_array_clear(&dev->qp_table.qp,
1443 qp->qpn & (dev->limits.num_qps - 1));
1444 --qp->refcount;
1445 spin_unlock(&dev->qp_table.lock);
1446
1447 mthca_unlock_cqs(send_cq, recv_cq);
1448
1449 wait_event(qp->wait, !get_qp_refcount(dev, qp));
1450
1451 if (qp->state != IB_QPS_RESET)
1452 mthca_MODIFY_QP(dev, qp->state, IB_QPS_RESET, qp->qpn, 0,
1453 NULL, 0, &status);
1454
1455
1456
1457
1458
1459