]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: hns3: Check hdev state when getting link status
authorPeng Li <lipeng321@huawei.com>
Wed, 19 Sep 2018 17:29:53 +0000 (18:29 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:12:24 +0000 (11:12 -0800)
[ Upstream commit 582d37bbb613b8ad86bf82845d3a74a02a5a0fa1 ]

By default, HW link status is up. If hclge_update_link_status is called
before net up, driver will print "link up". It is not suitable. hdev
state check is needed when getting link status.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

index 8179ecb089b77f82ded4bd21d0ec7dd2a676d67b..15f2dd4824f4ca5ae2c578eb7acd33c7dcc70ea7 100644 (file)
@@ -2398,6 +2398,9 @@ static int hclge_get_mac_phy_link(struct hclge_dev *hdev)
        int mac_state;
        int link_stat;
 
+       if (test_bit(HCLGE_STATE_DOWN, &hdev->state))
+               return 0;
+
        mac_state = hclge_get_mac_link_status(hdev);
 
        if (hdev->hw.mac.phydev) {
index 12aa1f1b99efc68843d305bf6921a068d25b4acb..212c7bf5ea4a857d88115d181af416a2cac4e1af 100644 (file)
@@ -299,6 +299,9 @@ void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state)
 
        client = handle->client;
 
+       link_state =
+               test_bit(HCLGEVF_STATE_DOWN, &hdev->state) ? 0 : link_state;
+
        if (link_state != hdev->hw.mac.link) {
                client->ops->link_status_change(handle, !!link_state);
                hdev->hw.mac.link = link_state;