* [PATCH net 1/5] net: hns3: fix wrong use of semaphore up
2024-08-13 14:10 [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver Jijie Shao
@ 2024-08-13 14:10 ` Jijie Shao
2024-08-13 14:10 ` [PATCH net 2/5] net: hns3: use the user's cfg after reset Jijie Shao
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Jijie Shao @ 2024-08-13 14:10 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, horms
Cc: shenjian15, wangjie125, liuyonglong, wangpeiyang1, shaojijie,
jonathan.cameron, shameerali.kolothum.thodi, netdev,
linux-kernel
From: Jie Wang <wangjie125@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: 8627bdedc435 ("net: hns3: refactor the precedure of PF FLR")
Fixes: f28368bb4542 ("net: hns3: refactor the procedure of VF FLR")
Signed-off-by: Jie Wang <wangjie125@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ++--
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 82574ce0194f..125e04434611 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -11516,8 +11516,8 @@ 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);
- up(&hdev->reset_sem);
+ if (test_and_clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
+ up(&hdev->reset_sem);
}
static void hclge_clear_resetting_state(struct hclge_dev *hdev)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 3735d2fed11f..094a7c7b5592 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1747,8 +1747,8 @@ 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);
- up(&hdev->reset_sem);
+ if (test_and_clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state))
+ up(&hdev->reset_sem);
}
static u32 hclgevf_get_fw_version(struct hnae3_handle *handle)
--
2.33.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net 2/5] net: hns3: use the user's cfg after reset
2024-08-13 14:10 [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2024-08-13 14:10 ` [PATCH net 1/5] net: hns3: fix wrong use of semaphore up Jijie Shao
@ 2024-08-13 14:10 ` Jijie Shao
2024-08-13 14:10 ` [PATCH net 3/5] net: hns3: fix a deadlock problem when config TC during resetting Jijie Shao
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Jijie Shao @ 2024-08-13 14:10 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, horms
Cc: shenjian15, wangjie125, liuyonglong, wangpeiyang1, shaojijie,
jonathan.cameron, shameerali.kolothum.thodi, netdev,
linux-kernel
From: Peiyang Wang <wangpeiyang1@huawei.com>
Consider the followed case that the user change speed and reset the net
interface. Before the hw change speed successfully, the driver get old
old speed from hw by timer task. After reset, the previous speed is config
to hw. As a result, the new speed is configed successfully but lost after
PF reset. The followed pictured shows more dirrectly.
+------+ +----+ +----+
| USER | | PF | | HW |
+---+--+ +-+--+ +-+--+
| ethtool -s 100G | |
+------------------>| set speed 100G |
| +--------------------->|
| | set successfully |
| |<---------------------+---+
| |query cfg (timer task)| |
| +--------------------->| | handle speed
| | return 200G | | changing event
| ethtool --reset |<---------------------+ | (100G)
+------------------>| cfg previous speed |<--+
| | after reset (200G) |
| +--------------------->|
| | +---+
| |query cfg (timer task)| |
| +--------------------->| | handle speed
| | return 100G | | changing event
| |<---------------------+ | (200G)
| | |<--+
| |query cfg (timer task)|
| +--------------------->|
| | return 200G |
| |<---------------------+
| | |
v v v
This patch save new speed if hw change speed successfully, which will be
used after reset successfully.
Fixes: 2d03eacc0b7e ("net: hns3: Only update mac configuation when necessary")
Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
.../hisilicon/hns3/hns3pf/hclge_main.c | 24 ++++++++++++++-----
.../hisilicon/hns3/hns3pf/hclge_mdio.c | 3 +++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 125e04434611..465f0d582283 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2653,8 +2653,17 @@ static int hclge_cfg_mac_speed_dup_h(struct hnae3_handle *handle, int speed,
{
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
+ int ret;
+
+ ret = hclge_cfg_mac_speed_dup(hdev, speed, duplex, lane_num);
- return hclge_cfg_mac_speed_dup(hdev, speed, duplex, lane_num);
+ if (ret)
+ return ret;
+
+ hdev->hw.mac.req_speed = speed;
+ hdev->hw.mac.req_duplex = duplex;
+
+ return 0;
}
static int hclge_set_autoneg_en(struct hclge_dev *hdev, bool enable)
@@ -2956,17 +2965,20 @@ static int hclge_mac_init(struct hclge_dev *hdev)
if (!test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))
hdev->hw.mac.duplex = HCLGE_MAC_FULL;
- ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.speed,
- hdev->hw.mac.duplex, hdev->hw.mac.lane_num);
- if (ret)
- return ret;
-
if (hdev->hw.mac.support_autoneg) {
ret = hclge_set_autoneg_en(hdev, hdev->hw.mac.autoneg);
if (ret)
return ret;
}
+ if (!hdev->hw.mac.autoneg) {
+ ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.req_speed,
+ hdev->hw.mac.req_duplex,
+ hdev->hw.mac.lane_num);
+ if (ret)
+ return ret;
+ }
+
mac->link = 0;
if (mac->user_fec_mode & BIT(HNAE3_FEC_USER_DEF)) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index 85fb11de43a1..80079657afeb 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -191,6 +191,9 @@ static void hclge_mac_adjust_link(struct net_device *netdev)
if (ret)
netdev_err(netdev, "failed to adjust link.\n");
+ hdev->hw.mac.req_speed = (u32)speed;
+ hdev->hw.mac.req_duplex = (u8)duplex;
+
ret = hclge_cfg_flowctrl(hdev);
if (ret)
netdev_err(netdev, "failed to configure flow control.\n");
--
2.33.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net 3/5] net: hns3: fix a deadlock problem when config TC during resetting
2024-08-13 14:10 [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2024-08-13 14:10 ` [PATCH net 1/5] net: hns3: fix wrong use of semaphore up Jijie Shao
2024-08-13 14:10 ` [PATCH net 2/5] net: hns3: use the user's cfg after reset Jijie Shao
@ 2024-08-13 14:10 ` Jijie Shao
2024-08-13 14:10 ` [PATCH net 4/5] net: hns3: void array out of bound when loop tnl_num Jijie Shao
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Jijie Shao @ 2024-08-13 14:10 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, horms
Cc: shenjian15, wangjie125, liuyonglong, wangpeiyang1, shaojijie,
jonathan.cameron, shameerali.kolothum.thodi, netdev,
linux-kernel
From: Jie Wang <wangjie125@huawei.com>
When config TC during the reset process, may cause a deadlock, the flow is
as below:
pf reset start
│
▼
......
setup tc │
│ ▼
▼ DOWN: napi_disable()
napi_disable()(skip) │
│ │
▼ ▼
...... ......
│ │
▼ │
napi_enable() │
▼
UINIT: netif_napi_del()
│
▼
......
│
▼
INIT: netif_napi_add()
│
▼
...... global reset start
│ │
▼ ▼
UP: napi_enable()(skip) ......
│ │
▼ ▼
...... napi_disable()
In reset process, the driver will DOWN the port and then UINIT, in this
case, the setup tc process will UP the port before UINIT, so cause the
problem. Adds a DOWN process in UINIT to fix it.
Fixes: bb6b94a896d4 ("net: hns3: Add reset interface implementation in client")
Signed-off-by: Jie Wang <wangjie125@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index a5fc0209d628..4cbc4d069a1f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -5724,6 +5724,9 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
struct net_device *netdev = handle->kinfo.netdev;
struct hns3_nic_priv *priv = netdev_priv(netdev);
+ if (!test_bit(HNS3_NIC_STATE_DOWN, &priv->state))
+ hns3_nic_net_stop(netdev);
+
if (!test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
netdev_warn(netdev, "already uninitialized\n");
return 0;
--
2.33.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net 4/5] net: hns3: void array out of bound when loop tnl_num
2024-08-13 14:10 [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (2 preceding siblings ...)
2024-08-13 14:10 ` [PATCH net 3/5] net: hns3: fix a deadlock problem when config TC during resetting Jijie Shao
@ 2024-08-13 14:10 ` Jijie Shao
2024-08-13 14:10 ` [PATCH net 5/5] net: hns3: use correct release function during uninitialization Jijie Shao
2024-08-15 11:20 ` [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver patchwork-bot+netdevbpf
5 siblings, 0 replies; 8+ messages in thread
From: Jijie Shao @ 2024-08-13 14:10 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, horms
Cc: shenjian15, wangjie125, liuyonglong, wangpeiyang1, shaojijie,
jonathan.cameron, shameerali.kolothum.thodi, netdev,
linux-kernel
From: Peiyang Wang <wangpeiyang1@huawei.com>
When query reg inf of SSU, it loops tnl_num times. However, tnl_num comes
from hardware and the length of array is a fixed value. To void array out
of bound, make sure the loop time is not greater than the length of array
Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
index e132c2f09560..cc7f46c0b35f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
@@ -1598,8 +1598,7 @@ static void hclge_query_reg_info_of_ssu(struct hclge_dev *hdev)
{
u32 loop_para[HCLGE_MOD_MSG_PARA_ARRAY_MAX_SIZE] = {0};
struct hclge_mod_reg_common_msg msg;
- u8 i, j, num;
- u32 loop_time;
+ u8 i, j, num, loop_time;
num = ARRAY_SIZE(hclge_ssu_reg_common_msg);
for (i = 0; i < num; i++) {
@@ -1609,7 +1608,8 @@ static void hclge_query_reg_info_of_ssu(struct hclge_dev *hdev)
loop_time = 1;
loop_para[0] = 0;
if (msg.need_para) {
- loop_time = hdev->ae_dev->dev_specs.tnl_num;
+ loop_time = min(hdev->ae_dev->dev_specs.tnl_num,
+ HCLGE_MOD_MSG_PARA_ARRAY_MAX_SIZE);
for (j = 0; j < loop_time; j++)
loop_para[j] = j + 1;
}
--
2.33.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net 5/5] net: hns3: use correct release function during uninitialization
2024-08-13 14:10 [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (3 preceding siblings ...)
2024-08-13 14:10 ` [PATCH net 4/5] net: hns3: void array out of bound when loop tnl_num Jijie Shao
@ 2024-08-13 14:10 ` Jijie Shao
2024-08-15 11:20 ` [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver patchwork-bot+netdevbpf
5 siblings, 0 replies; 8+ messages in thread
From: Jijie Shao @ 2024-08-13 14:10 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, horms
Cc: shenjian15, wangjie125, liuyonglong, wangpeiyang1, shaojijie,
jonathan.cameron, shameerali.kolothum.thodi, netdev,
linux-kernel
From: Peiyang Wang <wangpeiyang1@huawei.com>
pci_request_regions is called to apply for PCI I/O and memory resources
when the driver is initialized, Therefore, when the driver is uninstalled,
pci_release_regions should be used to release PCI I/O and memory resources
instead of pci_release_mem_regions is used to release memory reasouces
only.
Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 465f0d582283..6c33195a1168 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -11456,7 +11456,7 @@ static void hclge_pci_uninit(struct hclge_dev *hdev)
pcim_iounmap(pdev, hdev->hw.hw.io_base);
pci_free_irq_vectors(pdev);
- pci_release_mem_regions(pdev);
+ pci_release_regions(pdev);
pci_disable_device(pdev);
}
--
2.33.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver
2024-08-13 14:10 [PATCH net 0/5] There are some bugfix for the HNS3 ethernet driver Jijie Shao
` (4 preceding siblings ...)
2024-08-13 14:10 ` [PATCH net 5/5] net: hns3: use correct release function during uninitialization Jijie Shao
@ 2024-08-15 11:20 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-15 11:20 UTC (permalink / raw)
To: Jijie Shao
Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, horms,
shenjian15, wangjie125, liuyonglong, wangpeiyang1,
jonathan.cameron, shameerali.kolothum.thodi, netdev,
linux-kernel
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 13 Aug 2024 22:10:19 +0800 you wrote:
> There are some bugfix for the HNS3 ethernet driver
>
> Jie Wang (2):
> net: hns3: fix a deadlock problem when config TC during resetting
> net: hns3: fix wrong use of semaphore up
>
> Peiyang Wang (3):
> net: hns3: use the user's cfg after reset
> net: hns3: void array out of bound when loop tnl_num
> net: hns3: use correct release function during uninitialization
>
> [...]
Here is the summary with links:
- [net,1/5] net: hns3: fix wrong use of semaphore up
https://git.kernel.org/netdev/net/c/8445d9d3c031
- [net,2/5] net: hns3: use the user's cfg after reset
https://git.kernel.org/netdev/net/c/30545e17eac1
- [net,3/5] net: hns3: fix a deadlock problem when config TC during resetting
https://git.kernel.org/netdev/net/c/be5e816d00a5
- [net,4/5] net: hns3: void array out of bound when loop tnl_num
https://git.kernel.org/netdev/net/c/86db7bfb0670
- [net,5/5] net: hns3: use correct release function during uninitialization
https://git.kernel.org/netdev/net/c/7660833d2175
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread