Skip to content

Commit

Permalink
net/hns3: fix configure FEC when concurrent with reset
Browse files Browse the repository at this point in the history
[ upstream commit 6d36028 ]

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: 9bf2ea8 ("net/hns3: support FEC")

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
  • Loading branch information
Chengchang Tang authored and steevenlee committed May 8, 2021
1 parent 33c960a commit 41111ae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/net/hns3/hns3_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -6128,11 +6128,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;
}

Expand Down

0 comments on commit 41111ae

Please sign in to comment.