From 99d4f5c064a42e99eedd1b7133d30f594de7ff91 Mon Sep 17 00:00:00 2001 From: Ian Ziemba Date: Wed, 10 Jan 2024 13:03:46 -0600 Subject: [PATCH] prov/cxi: Move msg otx_reqs inc to after ring Making this change is required for messaging to use the TXC emit functions. The TXC emit functions already handle otx_reqs. Signed-off-by: Ian Ziemba --- prov/cxi/src/cxip_msg.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/prov/cxi/src/cxip_msg.c b/prov/cxi/src/cxip_msg.c index 5812ed20fb1..5d96b8d4c21 100644 --- a/prov/cxi/src/cxip_msg.c +++ b/prov/cxi/src/cxip_msg.c @@ -4768,7 +4768,7 @@ static ssize_t _cxip_send_rdzv_put(struct cxip_req *req) } cxip_txq_ring(cmdq, !!(req->send.flags & FI_MORE), - ofi_atomic_get32(&req->send.txc->otx_reqs) - 1); + ofi_atomic_get32(&req->send.txc->otx_reqs)); ofi_genlock_unlock(&txc->domain->trig_cmdq_lock); } else { @@ -4781,9 +4781,11 @@ static ssize_t _cxip_send_rdzv_put(struct cxip_req *req) goto err_enqueue; cxip_txq_ring(cmdq, !!(req->send.flags & FI_MORE), - ofi_atomic_get32(&req->send.txc->otx_reqs) - 1); + ofi_atomic_get32(&req->send.txc->otx_reqs)); } + ofi_atomic_inc32(&req->send.txc->otx_reqs); + return FI_SUCCESS; err_enqueue: @@ -4984,7 +4986,9 @@ static ssize_t _cxip_send_eager_idc(struct cxip_req *req) } cxip_txq_ring(cmdq, !!(req->send.flags & FI_MORE), - ofi_atomic_get32(&req->send.txc->otx_reqs) - 1); + ofi_atomic_get32(&req->send.txc->otx_reqs)); + + ofi_atomic_inc32(&req->send.txc->otx_reqs); return FI_SUCCESS; @@ -5075,7 +5079,7 @@ static ssize_t _cxip_send_eager(struct cxip_req *req) goto err_enqueue; } cxip_txq_ring(cmdq, !!(req->send.flags & FI_MORE), - ofi_atomic_get32(&req->send.txc->otx_reqs) - 1); + ofi_atomic_get32(&req->send.txc->otx_reqs)); ofi_genlock_unlock(&txc->domain->trig_cmdq_lock); } else { @@ -5088,9 +5092,11 @@ static ssize_t _cxip_send_eager(struct cxip_req *req) goto err_enqueue; cxip_txq_ring(cmdq, !!(req->send.flags & FI_MORE), - ofi_atomic_get32(&req->send.txc->otx_reqs) - 1); + ofi_atomic_get32(&req->send.txc->otx_reqs)); } + ofi_atomic_inc32(&req->send.txc->otx_reqs); + return FI_SUCCESS; err_enqueue: @@ -5332,6 +5338,13 @@ int cxip_fc_resume(struct cxip_ep_obj *ep_obj, uint32_t nic_addr, uint32_t pid) dlist_foreach_container_safe(&peer->msg_queue, struct cxip_req, req, send.txc_entry, tmp) { + + /* Since messaging does not have events disabled, need to return + * a TXC credit for replay. _cxip_send_req() will take the + * credit again. + */ + ofi_atomic_dec32(&txc->otx_reqs); + /* -FI_EAGAIN can be return if the command queue is full. Loop * until this goes through. */ @@ -5583,7 +5596,7 @@ ssize_t cxip_send_common(struct cxip_txc *txc, uint32_t tclass, const void *buf, } /* Restrict outstanding success event requests to queue size */ - if (ofi_atomic_inc32(&txc->otx_reqs) > txc->attr.size) { + if (ofi_atomic_get32(&txc->otx_reqs) >= txc->attr.size) { ret = -FI_EAGAIN; goto err_req_free; } @@ -5664,7 +5677,6 @@ ssize_t cxip_send_common(struct cxip_txc *txc, uint32_t tclass, const void *buf, err_req_buf_fini: cxip_send_buf_fini(req); err_req_free: - ofi_atomic_dec32(&txc->otx_reqs); cxip_evtq_req_free(req); unlock: ofi_genlock_unlock(&txc->ep_obj->lock);