patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] crypto/mlx5: fix indirect mkey cleaning
@ 2021-09-13 19:16 Michael Baum
  2021-09-24 17:50 ` [dpdk-stable] [EXT] [dpdk-dev] " Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Baum @ 2021-09-13 19:16 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, stable

The driver creates an indirect mkey per entry in the queue to manage the
crypto operation using the BSF fields.

The indirect mkeys were never released neither while error occurs in the
creation phase nor when the queue is released.

Clean the indirect mkeys in the above cases.

Fixes: c2a42d19d967 ("crypto/mlx5: add WQE set initialization")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/crypto/mlx5/mlx5_crypto.c | 39 ++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c
index b3d5200ca3..1cc6720e44 100644
--- a/drivers/crypto/mlx5/mlx5_crypto.c
+++ b/drivers/crypto/mlx5/mlx5_crypto.c
@@ -252,11 +252,21 @@ mlx5_crypto_sym_session_clear(struct rte_cryptodev *dev,
 	DRV_LOG(DEBUG, "Session %p was cleared.", spriv);
 }
 
-static int
-mlx5_crypto_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id)
+static void
+mlx5_crypto_indirect_mkeys_release(struct mlx5_crypto_qp *qp, uint16_t n)
 {
-	struct mlx5_crypto_qp *qp = dev->data->queue_pairs[qp_id];
+	uint16_t i;
+
+	for (i = 0; i < n; i++)
+		if (qp->mkey[i])
+			claim_zero(mlx5_devx_cmd_destroy(qp->mkey[i]));
+}
 
+static void
+mlx5_crypto_qp_release(struct mlx5_crypto_qp *qp)
+{
+	if (qp == NULL)
+		return;
 	if (qp->qp_obj != NULL)
 		claim_zero(mlx5_devx_cmd_destroy(qp->qp_obj));
 	if (qp->umem_obj != NULL)
@@ -266,6 +276,15 @@ mlx5_crypto_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id)
 	mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
 	mlx5_devx_cq_destroy(&qp->cq_obj);
 	rte_free(qp);
+}
+
+static int
+mlx5_crypto_queue_pair_release(struct rte_cryptodev *dev, uint16_t qp_id)
+{
+	struct mlx5_crypto_qp *qp = dev->data->queue_pairs[qp_id];
+
+	mlx5_crypto_indirect_mkeys_release(qp, qp->entries_n);
+	mlx5_crypto_qp_release(qp);
 	dev->data->queue_pairs[qp_id] = NULL;
 	return 0;
 }
@@ -632,12 +651,14 @@ mlx5_crypto_indirect_mkeys_prepare(struct mlx5_crypto_priv *priv,
 	   i < qp->entries_n; i++, umr = RTE_PTR_ADD(umr, priv->wqe_set_size)) {
 		attr.klm_array = (struct mlx5_klm *)&umr->kseg[0];
 		qp->mkey[i] = mlx5_devx_cmd_mkey_create(priv->ctx, &attr);
-		if (!qp->mkey[i]) {
-			DRV_LOG(ERR, "Failed to allocate indirect mkey.");
-			return -1;
-		}
+		if (!qp->mkey[i])
+			goto error;
 	}
 	return 0;
+error:
+	DRV_LOG(ERR, "Failed to allocate indirect mkey.");
+	mlx5_crypto_indirect_mkeys_release(qp, i);
+	return -1;
 }
 
 static int
@@ -701,7 +722,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	attr.uar_index = mlx5_os_get_devx_uar_page_id(priv->uar);
 	attr.cqn = qp->cq_obj.cq->id;
 	attr.log_page_size = rte_log2_u32(sysconf(_SC_PAGESIZE));
-	attr.rq_size =  0;
+	attr.rq_size = 0;
 	attr.sq_size = RTE_BIT32(log_nb_desc);
 	attr.dbr_umem_valid = 1;
 	attr.wq_umem_id = qp->umem_obj->umem_id;
@@ -730,7 +751,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	dev->data->queue_pairs[qp_id] = qp;
 	return 0;
 error:
-	mlx5_crypto_queue_pair_release(dev, qp_id);
+	mlx5_crypto_qp_release(qp);
 	return -1;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [EXT] [dpdk-dev] [PATCH] crypto/mlx5: fix indirect mkey cleaning
  2021-09-13 19:16 [dpdk-stable] [PATCH] crypto/mlx5: fix indirect mkey cleaning Michael Baum
@ 2021-09-24 17:50 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2021-09-24 17:50 UTC (permalink / raw)
  To: Michael Baum, dev; +Cc: Matan Azrad, stable

> The driver creates an indirect mkey per entry in the queue to manage the
> crypto operation using the BSF fields.
> 
> The indirect mkeys were never released neither while error occurs in the
> creation phase nor when the queue is released.
> 
> Clean the indirect mkeys in the above cases.
> 
> Fixes: c2a42d19d967 ("crypto/mlx5: add WQE set initialization")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
Applied to dpdk-next-crypto


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-24 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 19:16 [dpdk-stable] [PATCH] crypto/mlx5: fix indirect mkey cleaning Michael Baum
2021-09-24 17:50 ` [dpdk-stable] [EXT] [dpdk-dev] " Akhil Goyal

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git