From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D2BCDA0C45; Mon, 13 Sep 2021 21:17:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9242F40151; Mon, 13 Sep 2021 21:17:29 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by mails.dpdk.org (Postfix) with ESMTP id A65454014F; Mon, 13 Sep 2021 21:17:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zxim0zmF236aMwweNbP9pDxOz//ZzkwxIpCsoOqWo7qgg2Jc0fIRmLtvpeMx9k6Vi/D/IKMLxMhxrPw553tQccMcMggtD9mgppsYW/hdZjZyEfX0FAjN6vXjjJ8V7v0dsnZyQ9fE8Pj81D1wf6W3zQOnjks/C+qYozzxcXFHlP9SU8QXEv0fhEC8Cn+R+DiCzfserZPxIJSFE76ZA9RLWIYUfSgL1G0ecfT3k6JY8CSf5h4kBHS9GoFmFX+xEXdKprojx8X2x30NAVv7dai5wfk4Jf+LKIP97J2kg1IlcP/verNTjLk38QgRht3yv5NNQ87H4pbzuaOW6/piFG8ytA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=olBCmkCEMiPS2THn4/Zqvn3xW8T6FoBws+pJfQMiiVE=; b=hI5QhDUtU1PDX7ppm9RddlnwiSWvilaDsUXFwlT+bN/iLBf8tYUNH4+FcjxSbRkoO79m0/ULxMZydCrAHevnf5kTIvaouMejcwI5EDsNKbkZI0QxOT5hlVtQ3w4OF9AaaJQdab0or4ci+IN2zz/d0L2t6JZrS5IJQOHuxdDOnrgmLsVVtxVp7XTuUyzCo4UhsaUJn+sd/qlw3rTOaTNFn18tenfqHXzVq339FZMzgaX381NZH67VIF/zdck51xrZGYi5O6SGkRDJKLjDphjdYUtGEmLM41jVHR/GHK+ooqmKVQP2ST9Sz+sykTqvYVPJEQ4irsCXaOfOOiIl/lndzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=olBCmkCEMiPS2THn4/Zqvn3xW8T6FoBws+pJfQMiiVE=; b=mSZZb1bAM0GnCqD52wCOkiMN85iIVLCWzK0yVG3TNC2Ik0XBhjkTuG5tGDICO1g/t48pfEv8fPGfV5KZ/10w8hSlaErJ+QSJUnlJ5Raw+E8uNOf1pMBMka5ioATPu/mVG7l/8144fZrkiSS1ESzyqAzHu7DEweY/eAou5PmEzA8rLtcySC+wg2h0USRuId4vwsw+EiJXy6Y2H23nB704RqXRdcgx7sGVKyeQ+qe2/3kfFFKCjHWe2X+dfiDZqOkaTs60zGkBbO06iQk3ZBQiv5c0bCXaCcIdOeNVNYc7TN/LIzOYB9q9vB2el3+9DN7W1Pyo4/J8hYs3khTKiOA8ug== Received: from MWHPR19CA0016.namprd19.prod.outlook.com (2603:10b6:300:d4::26) by BY5PR12MB4082.namprd12.prod.outlook.com (2603:10b6:a03:212::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Mon, 13 Sep 2021 19:17:26 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:300:d4:cafe::2d) by MWHPR19CA0016.outlook.office365.com (2603:10b6:300:d4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 19:17:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 19:17:25 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 13 Sep 2021 19:17:25 +0000 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 13 Sep 2021 19:17:24 +0000 From: Michael Baum To: CC: Matan Azrad , Date: Mon, 13 Sep 2021 22:16:46 +0300 Message-ID: <20210913191646.612617-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 98c052fe-5e3b-414e-72b7-08d976eb1f10 X-MS-TrafficTypeDiagnostic: BY5PR12MB4082: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5CjBDSg/v1EVIw6hhYLnpZf+n2d3vPzvKr8TDhlybqUvC/UyFtOnG47MBKPCVV+iqh8GqZy47woec1QUwcu5m1o7oIqYIxTtJHc0jlaoWOxk0wygvhnlPI1d2cujPKQAgddS9vpHkHZRISXShqawO2XXl5mumBgahlC6TscSDO3DJRjKRgJnUs9knC8R05SS6NHBk053tErQ6Cn67/1J7InHafKWcOdZW/wpgrJKQZfh9VCRPEMBNYf+naFlMUDbg96W8CUnXfgtTNpNzOcgE2p3g7WXmqqSaemCoCND0B5HSJWgsMDXXITSSag6cf6eEtW9+fPbOjSyjgqxo/XHQbfCZL0KNgFs/XXDZo8kfv5Wo9mQOVXeMFFtQrOS3iD65SmCpgqbmFVCdgt1XBebR6KXND8sFWUBENQWzmmc8RsmsT7fpe20DRXFwMvVzE0u0muNje4krAILTWPiW0TyiFKBGOnykHg9ZNppAqR8+7CVY0e0Zuwg+Gu+cAxT7ET2aSHa03MlPWSgJC+LLa9I2dLBeHYsZmopse+IKBLIDK6G6IVhCX6DeOwbn5nFzr0kz11zo7Gr5gRW9BbTPbTUXs+OD+KPkWOsYGtuHoHoX8tBuB/1qIHRox3+NdmOdZ7P4hFRmMOa1OBShXb0rowkhJuuM8EuSmVbbvj/8jTwSxd9PyqqEQB1RyV53wvXObaMHIHmVHGwYZwMdrudG5IKLg== X-Forefront-Antispam-Report: CIP:216.228.112.35; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid02.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(46966006)(36840700001)(5660300002)(478600001)(82310400003)(70586007)(8936002)(7636003)(47076005)(356005)(16526019)(6666004)(186003)(2616005)(70206006)(336012)(2906002)(36860700001)(426003)(54906003)(4326008)(8676002)(6286002)(7696005)(83380400001)(86362001)(36906005)(1076003)(55016002)(26005)(6916009)(36756003)(450100002)(82740400003)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 19:17:25.9090 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98c052fe-5e3b-414e-72b7-08d976eb1f10 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.35]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4082 Subject: [dpdk-dev] [PATCH] crypto/mlx5: fix indirect mkey cleaning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Matan Azrad --- 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