Skip to content

Commit a6f7bfd

Browse files
IronShendavem330
authored andcommitted
net: hns3: add reset check for VF updating port based VLAN
Currently hclgevf_update_port_base_vlan_info() may be called when VF is resetting, which may cause hns3_nic_net_open() being called twice unexpectedly. So fix it by adding a reset check for it, and extend critical region for rntl_lock in hclgevf_update_port_base_vlan_info(). Fixes: 92f11ea ("net: hns3: fix set port based VLAN issue for VF") Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a7e90ee commit a6f7bfd

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,23 +3439,35 @@ void hclgevf_update_port_base_vlan_info(struct hclgevf_dev *hdev, u16 state,
34393439
{
34403440
struct hnae3_handle *nic = &hdev->nic;
34413441
struct hclge_vf_to_pf_msg send_msg;
3442+
int ret;
34423443

34433444
rtnl_lock();
3444-
hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
3445-
rtnl_unlock();
3445+
3446+
if (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) {
3447+
dev_warn(&hdev->pdev->dev,
3448+
"is resetting when updating port based vlan info\n");
3449+
rtnl_unlock();
3450+
return;
3451+
}
3452+
3453+
ret = hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
3454+
if (ret) {
3455+
rtnl_unlock();
3456+
return;
3457+
}
34463458

34473459
/* send msg to PF and wait update port based vlan info */
34483460
hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
34493461
HCLGE_MBX_PORT_BASE_VLAN_CFG);
34503462
memcpy(send_msg.data, port_base_vlan_info, data_size);
3451-
hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
3452-
3453-
if (state == HNAE3_PORT_BASE_VLAN_DISABLE)
3454-
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE;
3455-
else
3456-
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
3463+
ret = hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
3464+
if (!ret) {
3465+
if (state == HNAE3_PORT_BASE_VLAN_DISABLE)
3466+
nic->port_base_vlan_state = state;
3467+
else
3468+
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
3469+
}
34573470

3458-
rtnl_lock();
34593471
hclgevf_notify_client(hdev, HNAE3_UP_CLIENT);
34603472
rtnl_unlock();
34613473
}

0 commit comments

Comments
 (0)