diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 884cded22..5970db606 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2055,6 +2055,7 @@ static void srpt_completion(struct ib_cq *cq, void *ctx) { struct srpt_rdma_ch *ch = ctx; + atomic_inc(&ch->processing_compl); switch (thread) { case MODE_IB_COMPLETION_IN_THREAD: wake_up_interruptible(&ch->wait_queue); @@ -2066,6 +2067,7 @@ static void srpt_completion(struct ib_cq *cq, void *ctx) srpt_process_completion(cq, ch, SCST_CONTEXT_TASKLET); break; } + atomic_dec(&ch->processing_compl); } static int srpt_compl_thread(void *arg) @@ -2211,6 +2213,9 @@ static void srpt_unregister_channel(struct srpt_rdma_ch *ch) PRINT_ERROR("Setting queue pair in error state failed: %d", ret); + while (atomic_read(&ch->processing_compl)) + ; + /* * At this point it is guaranteed that no new commands will be sent to * the SCST core for channel ch, which is a requirement for @@ -2519,6 +2524,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, ch->sport = &sdev->port[param->port - 1]; ch->cm_id = cm_id; ch->rq_size = max(SRPT_RQ_SIZE, scst_get_max_lun_commands(NULL, 0)); + atomic_set(&ch->processing_compl, 0); atomic_set(&ch->state, RDMA_CHANNEL_CONNECTING); INIT_LIST_HEAD(&ch->cmd_wait_list); diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 36369310f..252646446 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -285,6 +285,7 @@ struct srpt_rdma_ch { struct ib_cm_id *cm_id; struct ib_qp *qp; int rq_size; + atomic_t processing_compl; struct ib_cq *cq; atomic_t sq_wr_avail; struct srpt_port *sport;