Commit f07a54f8 authored by Jie Wang's avatar Jie Wang Committed by Hao Chen
Browse files

net: hns3: fix wrong use of semaphore up

maillist inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAQ6G2
CVE: NA

Reference: https://patchwork.kernel.org/project/netdevbpf/patch/20240813141024.1707252-2-shaojijie@huawei.com/



----------------------------------------------------------------------

Currently, if hns3 PF or VF FLR reset failed after five times retry,
the reset done process will directly release the semaphore
which has already released in hclge_reset_prepare_general.
This will cause down operation fail.

So this patch fixes it by adding reset state judgement. The up operation is
only called after successful PF FLR reset.

Fixes: 8627bded ("net: hns3: refactor the precedure of PF FLR")
Fixes: f28368bb ("net: hns3: refactor the procedure of VF FLR")
Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
parent 49cb18ca
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -12295,7 +12295,7 @@ static void hclge_reset_done(struct hnae3_ae_dev *ae_dev)
		dev_err(&hdev->pdev->dev, "fail to rebuild, ret=%d\n", ret);

	hdev->reset_type = HNAE3_NONE_RESET;
	clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state);
	if (test_and_clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
		up(&hdev->reset_sem);
}

+2 −2
Original line number Diff line number Diff line
@@ -1910,7 +1910,7 @@ static void hclgevf_reset_done(struct hnae3_ae_dev *ae_dev)
			 ret);

	hdev->reset_type = HNAE3_NONE_RESET;
	clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state);
	if (test_and_clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state))
		up(&hdev->reset_sem);
}