From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 90FA6A09FF; Thu, 24 Dec 2020 10:44:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8324BCA28; Thu, 24 Dec 2020 10:44:41 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (lpdvacalvio01.broadcom.com [192.19.229.182]) by dpdk.org (Postfix) with ESMTP id 452A2CA16 for ; Thu, 24 Dec 2020 10:44:39 +0100 (CET) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 786723D90D; Thu, 24 Dec 2020 01:44:36 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 786723D90D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1608803077; bh=yQhKSBJ3iAKW+9xao5MLnCR7hoEM/sD1CfUOGXgd+Kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJDett0T5XK35ZsRu63tr95DgXYbg0IQsdtNglGXqTVHbF6HN19lAAwG9plnZ4QpR 6JAYXzTR7W0UkKDr/UKvIBnFFV9euVGB4qzWHoTBZz3ShpNeDw2TIfdlVXv7bN6LqG PGl+nIQV5dV/oXnPOvkRsQ8/szKkhehtekwV2yQk= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Somnath Kotur Date: Thu, 24 Dec 2020 15:05:39 +0530 Message-Id: <20201224093541.13873-2-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.28.0.450.g3a238e5 In-Reply-To: <20201224093541.13873-1-somnath.kotur@broadcom.com> References: <20201224093541.13873-1-somnath.kotur@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/3] net/bnxt: fix to init/destroy locks only once X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Invoking init/uninit locks in init_resources and uninit_resources would end up initializing and destroying locks on every port start stop which is not desired. Move the 2 routines to dev_init and dev_close respectively as locks need to be initialized and destroyed only once during the lifetime of the driver. Fixes: 1cb3d39a48f7 ("net/bnxt: synchronize between flow related functions") Signed-off-by: Somnath Kotur --- drivers/net/bnxt/bnxt_ethdev.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 0788d263d8..6c38155da6 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1419,6 +1419,18 @@ static int bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) return 0; } +static void +bnxt_uninit_locks(struct bnxt *bp) +{ + pthread_mutex_destroy(&bp->flow_lock); + pthread_mutex_destroy(&bp->def_cp_lock); + pthread_mutex_destroy(&bp->health_check_lock); + if (bp->rep_info) { + pthread_mutex_destroy(&bp->rep_info->vfr_lock); + pthread_mutex_destroy(&bp->rep_info->vfr_start_lock); + } +} + static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) { struct bnxt *bp = eth_dev->data->dev_private; @@ -1444,6 +1456,7 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) bnxt_free_link_info(bp); bnxt_free_pf_info(bp); bnxt_free_parent_info(bp); + bnxt_uninit_locks(bp); rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone); bp->tx_mem_zone = NULL; @@ -4790,10 +4803,6 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) return rc; } - rc = bnxt_init_locks(bp); - if (rc) - return rc; - return 0; } @@ -5280,6 +5289,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) if (rc) goto error_free; + rc = bnxt_init_locks(bp); + if (rc) + goto error_free; + rc = bnxt_init_resources(bp, false); if (rc) goto error_free; @@ -5371,18 +5384,6 @@ bnxt_free_error_recovery_info(struct bnxt *bp) bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; } -static void -bnxt_uninit_locks(struct bnxt *bp) -{ - pthread_mutex_destroy(&bp->flow_lock); - pthread_mutex_destroy(&bp->def_cp_lock); - pthread_mutex_destroy(&bp->health_check_lock); - if (bp->rep_info) { - pthread_mutex_destroy(&bp->rep_info->vfr_lock); - pthread_mutex_destroy(&bp->rep_info->vfr_start_lock); - } -} - static int bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) { @@ -5404,7 +5405,6 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) bnxt_uninit_ctx_mem(bp); - bnxt_uninit_locks(bp); bnxt_free_flow_stats_info(bp); bnxt_free_rep_info(bp); rte_free(bp->ptp_cfg); -- 2.28.0.497.g54e85e7