diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 7a337d0c3..6613bd6b9 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -308,9 +308,6 @@ mlx5_mr_get(struct rte_eth_dev *dev, struct rte_mempool *mp)
 	LIST_FOREACH(mr, &priv->mr, next) {
 		if (mr->mp == mp) {
 			rte_atomic32_inc(&mr->refcnt);
-			DRV_LOG(DEBUG, "port %u memory region %p refcnt: %d",
-				dev->data->port_id, (void *)mr,
-				rte_atomic32_read(&mr->refcnt));
 			return mr;
 		}
 	}
@@ -330,9 +327,9 @@ int
 mlx5_mr_release(struct mlx5_mr *mr)
 {
 	assert(mr);
-	DRV_LOG(DEBUG, "memory region %p refcnt: %d", (void *)mr,
-		rte_atomic32_read(&mr->refcnt));
 	if (rte_atomic32_dec_and_test(&mr->refcnt)) {
+		DRV_LOG(DEBUG, "memory region %p refcnt: %d", (void *)mr,
+			rte_atomic32_read(&mr->refcnt));
 		claim_zero(mlx5_glue->dereg_mr(mr->mr));
 		LIST_REMOVE(mr, next);
 		rte_free(mr);
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index a85b628fe..d993e3846 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -868,9 +868,6 @@ mlx5_rxq_ibv_get(struct rte_eth_dev *dev, uint16_t idx)
 	if (rxq_ctrl->ibv) {
 		mlx5_mr_get(dev, rxq_data->mp);
 		rte_atomic32_inc(&rxq_ctrl->ibv->refcnt);
-		DRV_LOG(DEBUG, "port %u Verbs Rx queue %u: refcnt %d",
-			dev->data->port_id, rxq_ctrl->idx,
-			rte_atomic32_read(&rxq_ctrl->ibv->refcnt));
 	}
 	return rxq_ctrl->ibv;
 }
@@ -896,10 +893,11 @@ mlx5_rxq_ibv_release(struct mlx5_rxq_ibv *rxq_ibv)
 	ret = mlx5_mr_release(rxq_ibv->mr);
 	if (!ret)
 		rxq_ibv->mr = NULL;
-	DRV_LOG(DEBUG, "port %u Verbs Rx queue %u: refcnt %d",
-		port_id(rxq_ibv->rxq_ctrl->priv),
-		rxq_ibv->rxq_ctrl->idx, rte_atomic32_read(&rxq_ibv->refcnt));
 	if (rte_atomic32_dec_and_test(&rxq_ibv->refcnt)) {
+		DRV_LOG(DEBUG, "port %u Verbs Rx queue %u: refcnt %d",
+			port_id(rxq_ibv->rxq_ctrl->priv),
+			rxq_ibv->rxq_ctrl->idx,
+			rte_atomic32_read(&rxq_ibv->refcnt));
 		rxq_free_elts(rxq_ibv->rxq_ctrl);
 		claim_zero(mlx5_glue->destroy_wq(rxq_ibv->wq));
 		claim_zero(mlx5_glue->destroy_cq(rxq_ibv->cq));
@@ -1111,9 +1109,6 @@ mlx5_rxq_get(struct rte_eth_dev *dev, uint16_t idx)
 					rxq);
 		mlx5_rxq_ibv_get(dev, idx);
 		rte_atomic32_inc(&rxq_ctrl->refcnt);
-		DRV_LOG(DEBUG, "port %u Rx queue %u: refcnt %d",
-			dev->data->port_id, rxq_ctrl->idx,
-			rte_atomic32_read(&rxq_ctrl->refcnt));
 	}
 	return rxq_ctrl;
 }
@@ -1141,9 +1136,10 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx)
 	assert(rxq_ctrl->priv);
 	if (rxq_ctrl->ibv && !mlx5_rxq_ibv_release(rxq_ctrl->ibv))
 		rxq_ctrl->ibv = NULL;
-	DRV_LOG(DEBUG, "port %u Rx queue %u: refcnt %d", dev->data->port_id,
-		rxq_ctrl->idx, rte_atomic32_read(&rxq_ctrl->refcnt));
 	if (rte_atomic32_dec_and_test(&rxq_ctrl->refcnt)) {
+		DRV_LOG(DEBUG, "port %u Rx queue %u: refcnt %d",
+			dev->data->port_id, rxq_ctrl->idx,
+			rte_atomic32_read(&rxq_ctrl->refcnt));
 		LIST_REMOVE(rxq_ctrl, next);
 		rte_free(rxq_ctrl);
 		(*priv->rxqs)[idx] = NULL;
@@ -1301,9 +1297,6 @@ mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, const uint16_t *queues,
 		unsigned int i;
 
 		rte_atomic32_inc(&ind_tbl->refcnt);
-		DRV_LOG(DEBUG, "port %u indirection table %p: refcnt %d",
-			dev->data->port_id, (void *)ind_tbl,
-			rte_atomic32_read(&ind_tbl->refcnt));
 		for (i = 0; i != ind_tbl->queues_n; ++i)
 			mlx5_rxq_get(dev, ind_tbl->queues[i]);
 	}
@@ -1327,9 +1320,6 @@ mlx5_ind_table_ibv_release(struct rte_eth_dev *dev,
 {
 	unsigned int i;
 
-	DRV_LOG(DEBUG, "port %u indirection table %p: refcnt %d",
-		((struct priv *)dev->data->dev_private)->port,
-		(void *)ind_tbl, rte_atomic32_read(&ind_tbl->refcnt));
 	if (rte_atomic32_dec_and_test(&ind_tbl->refcnt)) {
 		claim_zero(mlx5_glue->destroy_rwq_ind_table
 			   (ind_tbl->ind_table));
@@ -1339,6 +1329,9 @@ mlx5_ind_table_ibv_release(struct rte_eth_dev *dev,
 	for (i = 0; i != ind_tbl->queues_n; ++i)
 		claim_nonzero(mlx5_rxq_release(dev, ind_tbl->queues[i]));
 	if (!rte_atomic32_read(&ind_tbl->refcnt)) {
+		DRV_LOG(DEBUG, "port %u indirection table %p: refcnt %d",
+			((struct priv *)dev->data->dev_private)->port,
+			(void *)ind_tbl, rte_atomic32_read(&ind_tbl->refcnt));
 		LIST_REMOVE(ind_tbl, next);
 		rte_free(ind_tbl);
 		return 0;
@@ -1566,9 +1559,6 @@ mlx5_hrxq_get(struct rte_eth_dev *dev,
 			continue;
 		}
 		rte_atomic32_inc(&hrxq->refcnt);
-		DRV_LOG(DEBUG, "port %u hash Rx queue %p: refcnt %d",
-			dev->data->port_id, (void *)hrxq,
-			rte_atomic32_read(&hrxq->refcnt));
 		return hrxq;
 	}
 	return NULL;
@@ -1588,10 +1578,10 @@ mlx5_hrxq_get(struct rte_eth_dev *dev,
 int
 mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq)
 {
-	DRV_LOG(DEBUG, "port %u hash Rx queue %p: refcnt %d",
-		((struct priv *)dev->data->dev_private)->port,
-		(void *)hrxq, rte_atomic32_read(&hrxq->refcnt));
 	if (rte_atomic32_dec_and_test(&hrxq->refcnt)) {
+		DRV_LOG(DEBUG, "port %u hash Rx queue %p: refcnt %d",
+			((struct priv *)dev->data->dev_private)->port,
+			(void *)hrxq, rte_atomic32_read(&hrxq->refcnt));
 		claim_zero(mlx5_glue->destroy_qp(hrxq->qp));
 		DEBUG("port %u delete QP %p: hash: 0x%" PRIx64 ", tunnel:"
 		      " 0x%x, level: %u",
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 29959b4c7..3f4b5fea5 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -595,12 +595,8 @@ mlx5_txq_ibv_get(struct rte_eth_dev *dev, uint16_t idx)
 	if (!(*priv->txqs)[idx])
 		return NULL;
 	txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
-	if (txq_ctrl->ibv) {
+	if (txq_ctrl->ibv)
 		rte_atomic32_inc(&txq_ctrl->ibv->refcnt);
-		DRV_LOG(DEBUG, "port %u Verbs Tx queue %u: refcnt %d",
-			dev->data->port_id, txq_ctrl->idx,
-		      rte_atomic32_read(&txq_ctrl->ibv->refcnt));
-	}
 	return txq_ctrl->ibv;
 }
 
@@ -617,10 +613,11 @@ int
 mlx5_txq_ibv_release(struct mlx5_txq_ibv *txq_ibv)
 {
 	assert(txq_ibv);
-	DRV_LOG(DEBUG, "port %u Verbs Tx queue %u: refcnt %d",
-		port_id(txq_ibv->txq_ctrl->priv),
-		txq_ibv->txq_ctrl->idx, rte_atomic32_read(&txq_ibv->refcnt));
 	if (rte_atomic32_dec_and_test(&txq_ibv->refcnt)) {
+		DRV_LOG(DEBUG, "port %u Verbs Tx queue %u: refcnt %d",
+			port_id(txq_ibv->txq_ctrl->priv),
+			txq_ibv->txq_ctrl->idx,
+			rte_atomic32_read(&txq_ibv->refcnt));
 		claim_zero(mlx5_glue->destroy_qp(txq_ibv->qp));
 		claim_zero(mlx5_glue->destroy_cq(txq_ibv->cq));
 		LIST_REMOVE(txq_ibv, next);
@@ -860,9 +857,6 @@ mlx5_txq_get(struct rte_eth_dev *dev, uint16_t idx)
 						     ctrl->txq.mp2mr[i]->mp));
 		}
 		rte_atomic32_inc(&ctrl->refcnt);
-		DRV_LOG(DEBUG, "port %u Tx queue %u refcnt %d",
-			dev->data->port_id,
-			ctrl->idx, rte_atomic32_read(&ctrl->refcnt));
 	}
 	return ctrl;
 }
@@ -889,8 +883,6 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx)
 	if (!(*priv->txqs)[idx])
 		return 0;
 	txq = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
-	DRV_LOG(DEBUG, "port %u Tx queue %u: refcnt %d", dev->data->port_id,
-		txq->idx, rte_atomic32_read(&txq->refcnt));
 	if (txq->ibv && !mlx5_txq_ibv_release(txq->ibv))
 		txq->ibv = NULL;
 	for (i = 0; i != MLX5_PMD_TX_MP_CACHE; ++i) {
@@ -903,6 +895,9 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx)
 		munmap((void *)RTE_ALIGN_FLOOR((uintptr_t)txq->txq.bf_reg,
 		       page_size), page_size);
 	if (rte_atomic32_dec_and_test(&txq->refcnt)) {
+		DRV_LOG(DEBUG, "port %u Tx queue %u: refcnt %d",
+			dev->data->port_id, txq->idx,
+			rte_atomic32_read(&txq->refcnt));
 		txq_free_elts(txq);
 		LIST_REMOVE(txq, next);
 		rte_free(txq);
