Skip to content

Commit

Permalink
net/bnxt: fix lock init and destroy
Browse files Browse the repository at this point in the history
[ upstream commit c9ffd6f ]

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: 1cb3d39 ("net/bnxt: synchronize between flow related functions")

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
  • Loading branch information
skotur-brcm authored and bluca committed Feb 2, 2021
1 parent 920206b commit 56c042f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions drivers/net/bnxt/bnxt_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,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;
Expand All @@ -1459,6 +1471,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;
Expand Down Expand Up @@ -4804,10 +4817,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;
}

Expand Down Expand Up @@ -5294,6 +5303,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;
Expand Down Expand Up @@ -5385,18 +5398,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)
{
Expand All @@ -5418,7 +5419,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);
Expand Down

0 comments on commit 56c042f

Please sign in to comment.