[7/7] net/hns3: fix configure FEC when concurrent with reset

Message ID 1617963365-41299-8-git-send-email-humin29@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series Bugfix for hns3 PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

humin (Q) April 9, 2021, 10:16 a.m. UTC
  From: Chengchang Tang <tangchengchang@huawei.com>

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 <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index edace55..c359efc 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6411,11 +6411,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;
 }