From 755d92e8a3c3327632dc9e6f74fb7f07b4073a3e Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Sat, 10 Apr 2021 09:11:20 +0800 Subject: [PATCH 096/189] net/hns3: fix configure FEC when concurrent with reset Currently, after the reset is complete, the PMD restores the FEC according to the FEC configuration reserved in the driver. If there is a concurrency between the FEC setup operation and the restore operation after a reset, the FEC status of the last hardware may be unknown. This patch adds the step of obtaining the lock when setting the FEC to avoid concurrency between restore operation and setting operation. Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index c67486c..85e54ae 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -6433,11 +6433,16 @@ hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode) return -EINVAL; } + rte_spinlock_lock(&hw->lock); ret = hns3_set_fec_hw(hw, mode); - if (ret) + if (ret) { + rte_spinlock_unlock(&hw->lock); return ret; + } pf->fec_mode = mode; + rte_spinlock_unlock(&hw->lock); + return 0; } -- 2.7.4