net: hns3: remove useless mutex vport_cfg_mutex in the struct hclge_dev
authorHuazhong Tan <tanhuazhong@huawei.com>
Thu, 19 Dec 2019 06:57:41 +0000 (14:57 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 21 Dec 2019 05:20:39 +0000 (21:20 -0800)
Mutex vport_cfg_mutex has been used to protect uc_mac_list,
mc_mac_list and vlan_list from being modified by unloading
or reset task at the same time. But now unloading will
set up HCLGE_STATE_REMOVING flag and call cancel_work_sync to
break down this race condition, so this mutex is unnecessary.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c

index 4e7a07877e5d75f7578ebbf26f8a9f6855d62ae0..76b4418d937c34d3710f5247cff7ce5eaa86673b 100644 (file)
@@ -7534,7 +7534,6 @@ void hclge_uninit_vport_mac_table(struct hclge_dev *hdev)
        struct hclge_vport *vport;
        int i;
 
-       mutex_lock(&hdev->vport_cfg_mutex);
        for (i = 0; i < hdev->num_alloc_vport; i++) {
                vport = &hdev->vport[i];
                list_for_each_entry_safe(mac, tmp, &vport->uc_mac_list, node) {
@@ -7547,7 +7546,6 @@ void hclge_uninit_vport_mac_table(struct hclge_dev *hdev)
                        kfree(mac);
                }
        }
-       mutex_unlock(&hdev->vport_cfg_mutex);
 }
 
 static int hclge_get_mac_ethertype_cmd_status(struct hclge_dev *hdev,
@@ -8308,7 +8306,6 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
        struct hclge_vport *vport;
        int i;
 
-       mutex_lock(&hdev->vport_cfg_mutex);
        for (i = 0; i < hdev->num_alloc_vport; i++) {
                vport = &hdev->vport[i];
                list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
@@ -8316,7 +8313,6 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
                        kfree(vlan);
                }
        }
-       mutex_unlock(&hdev->vport_cfg_mutex);
 }
 
 static void hclge_restore_vlan_table(struct hnae3_handle *handle)
@@ -8328,7 +8324,6 @@ static void hclge_restore_vlan_table(struct hnae3_handle *handle)
        u16 state, vlan_id;
        int i;
 
-       mutex_lock(&hdev->vport_cfg_mutex);
        for (i = 0; i < hdev->num_alloc_vport; i++) {
                vport = &hdev->vport[i];
                vlan_proto = vport->port_base_vlan_cfg.vlan_info.vlan_proto;
@@ -8354,8 +8349,6 @@ static void hclge_restore_vlan_table(struct hnae3_handle *handle)
                                break;
                }
        }
-
-       mutex_unlock(&hdev->vport_cfg_mutex);
 }
 
 int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
@@ -9390,7 +9383,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
        hdev->mps = ETH_FRAME_LEN + ETH_FCS_LEN + 2 * VLAN_HLEN;
 
        mutex_init(&hdev->vport_lock);
-       mutex_init(&hdev->vport_cfg_mutex);
        spin_lock_init(&hdev->fd_rule_lock);
 
        ret = hclge_pci_init(hdev);
@@ -9943,7 +9935,6 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
        mutex_destroy(&hdev->vport_lock);
        hclge_uninit_vport_mac_table(hdev);
        hclge_uninit_vport_vlan_table(hdev);
-       mutex_destroy(&hdev->vport_cfg_mutex);
        ae_dev->priv = NULL;
 }
 
index 3a913976b820d6cde918dd84bb21f5467469aecc..4e5cfda16eb7342d9fc4f35fe485998437a73df0 100644 (file)
@@ -821,8 +821,6 @@ struct hclge_dev {
        u16 share_umv_size;
        struct mutex umv_mutex; /* protect share_umv_size */
 
-       struct mutex vport_cfg_mutex;   /* Protect stored vf table */
-
        DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats,
                      HCLGE_MAC_TNL_LOG_SIZE);
 
index a79d1512119d244d9905fd935703d048271f7f1c..f905dd3386b3b1f74f303e46d002ce99c6b99be7 100644 (file)
@@ -797,13 +797,11 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
                        hclge_get_link_mode(vport, req);
                        break;
                case HCLGE_MBX_GET_VF_FLR_STATUS:
-                       mutex_lock(&hdev->vport_cfg_mutex);
                        hclge_rm_vport_all_mac_table(vport, true,
                                                     HCLGE_MAC_ADDR_UC);
                        hclge_rm_vport_all_mac_table(vport, true,
                                                     HCLGE_MAC_ADDR_MC);
                        hclge_rm_vport_all_vlan_table(vport, true);
-                       mutex_unlock(&hdev->vport_cfg_mutex);
                        break;
                case HCLGE_MBX_GET_MEDIA_TYPE:
                        ret = hclge_get_vf_media_type(vport, req);