diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2014-10-01 07:02:00 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-10-09 03:06:06 -0400 |
commit | 96f15198c1457df29b51ed151b1e5b2a223d1346 (patch) | |
tree | 21ffd370da9a6d2f352cdb0f1cf1d6a6ce972586 /drivers/infiniband | |
parent | 6bb0279f95dc74082184d91b65743b295a2a11a6 (diff) |
IB/iser: Extend iser_free_ib_conn_res()
Put all connection IB related resources release in this routine. One
exception is the cm_id which cannot be destroyed as the routine is
protected by the state mutex. Also move its position to avoid forward
declaration. While at it fix qp NULL assignment.
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Ariel Nahum <arieln@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index e69aba8eabec..e4299743c459 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -496,27 +496,6 @@ out_err: | |||
496 | } | 496 | } |
497 | 497 | ||
498 | /** | 498 | /** |
499 | * releases the QP object | ||
500 | */ | ||
501 | static void iser_free_ib_conn_res(struct iser_conn *iser_conn) | ||
502 | { | ||
503 | struct ib_conn *ib_conn = &iser_conn->ib_conn; | ||
504 | |||
505 | iser_info("freeing conn %p cma_id %p qp %p\n", | ||
506 | ib_conn, ib_conn->cma_id, | ||
507 | ib_conn->qp); | ||
508 | |||
509 | /* qp is created only once both addr & route are resolved */ | ||
510 | |||
511 | if (ib_conn->qp != NULL) { | ||
512 | ib_conn->device->cq_active_qps[ib_conn->cq_index]--; | ||
513 | rdma_destroy_qp(ib_conn->cma_id); | ||
514 | } | ||
515 | |||
516 | ib_conn->qp = NULL; | ||
517 | } | ||
518 | |||
519 | /** | ||
520 | * based on the resolved device node GUID see if there already allocated | 499 | * based on the resolved device node GUID see if there already allocated |
521 | * device for this device. If there's no such, create one. | 500 | * device for this device. If there's no such, create one. |
522 | */ | 501 | */ |
@@ -608,12 +587,41 @@ void iser_release_work(struct work_struct *work) | |||
608 | } | 587 | } |
609 | 588 | ||
610 | /** | 589 | /** |
590 | * iser_free_ib_conn_res - release IB related resources | ||
591 | * @iser_conn: iser connection struct | ||
592 | * | ||
593 | * This routine is called with the iser state mutex held | ||
594 | * so the cm_id removal is out of here. It is Safe to | ||
595 | * be invoked multiple times. | ||
596 | */ | ||
597 | static void iser_free_ib_conn_res(struct iser_conn *iser_conn) | ||
598 | { | ||
599 | struct ib_conn *ib_conn = &iser_conn->ib_conn; | ||
600 | struct iser_device *device = ib_conn->device; | ||
601 | |||
602 | iser_info("freeing conn %p cma_id %p qp %p\n", | ||
603 | iser_conn, ib_conn->cma_id, ib_conn->qp); | ||
604 | |||
605 | iser_free_rx_descriptors(iser_conn); | ||
606 | |||
607 | if (ib_conn->qp != NULL) { | ||
608 | ib_conn->device->cq_active_qps[ib_conn->cq_index]--; | ||
609 | rdma_destroy_qp(ib_conn->cma_id); | ||
610 | ib_conn->qp = NULL; | ||
611 | } | ||
612 | |||
613 | if (device != NULL) { | ||
614 | iser_device_try_release(device); | ||
615 | ib_conn->device = NULL; | ||
616 | } | ||
617 | } | ||
618 | |||
619 | /** | ||
611 | * Frees all conn objects and deallocs conn descriptor | 620 | * Frees all conn objects and deallocs conn descriptor |
612 | */ | 621 | */ |
613 | void iser_conn_release(struct iser_conn *iser_conn) | 622 | void iser_conn_release(struct iser_conn *iser_conn) |
614 | { | 623 | { |
615 | struct ib_conn *ib_conn = &iser_conn->ib_conn; | 624 | struct ib_conn *ib_conn = &iser_conn->ib_conn; |
616 | struct iser_device *device = ib_conn->device; | ||
617 | 625 | ||
618 | mutex_lock(&ig.connlist_mutex); | 626 | mutex_lock(&ig.connlist_mutex); |
619 | list_del(&iser_conn->conn_list); | 627 | list_del(&iser_conn->conn_list); |
@@ -621,13 +629,7 @@ void iser_conn_release(struct iser_conn *iser_conn) | |||
621 | 629 | ||
622 | mutex_lock(&iser_conn->state_mutex); | 630 | mutex_lock(&iser_conn->state_mutex); |
623 | BUG_ON(iser_conn->state != ISER_CONN_DOWN); | 631 | BUG_ON(iser_conn->state != ISER_CONN_DOWN); |
624 | |||
625 | iser_free_rx_descriptors(iser_conn); | ||
626 | iser_free_ib_conn_res(iser_conn); | 632 | iser_free_ib_conn_res(iser_conn); |
627 | ib_conn->device = NULL; | ||
628 | /* on EVENT_ADDR_ERROR there's no device yet for this conn */ | ||
629 | if (device != NULL) | ||
630 | iser_device_try_release(device); | ||
631 | mutex_unlock(&iser_conn->state_mutex); | 633 | mutex_unlock(&iser_conn->state_mutex); |
632 | 634 | ||
633 | if (ib_conn->cma_id != NULL) { | 635 | if (ib_conn->cma_id != NULL) { |