Commit 1a6d2819 authored by Yufeng Mo's avatar Yufeng Mo Committed by Jakub Kicinski

net: hns3: clear hardware resource when loading driver

If a PF is bonded to a virtual machine and the virtual machine exits
unexpectedly, some hardware resource cannot be cleared. In this case,
loading driver may cause exceptions. Therefore, the hardware resource
needs to be cleared when the driver is loaded.

Fixes: 46a3df9f ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: default avatarYufeng Mo <moyufeng@huawei.com>
Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 733c99ee
...@@ -270,6 +270,9 @@ enum hclge_opcode_type { ...@@ -270,6 +270,9 @@ enum hclge_opcode_type {
/* Led command */ /* Led command */
HCLGE_OPC_LED_STATUS_CFG = 0xB000, HCLGE_OPC_LED_STATUS_CFG = 0xB000,
/* clear hardware resource command */
HCLGE_OPC_CLEAR_HW_RESOURCE = 0x700B,
/* NCL config command */ /* NCL config command */
HCLGE_OPC_QUERY_NCL_CONFIG = 0x7011, HCLGE_OPC_QUERY_NCL_CONFIG = 0x7011,
......
...@@ -11443,6 +11443,28 @@ static void hclge_clear_resetting_state(struct hclge_dev *hdev) ...@@ -11443,6 +11443,28 @@ static void hclge_clear_resetting_state(struct hclge_dev *hdev)
} }
} }
static int hclge_clear_hw_resource(struct hclge_dev *hdev)
{
struct hclge_desc desc;
int ret;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CLEAR_HW_RESOURCE, false);
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
/* This new command is only supported by new firmware, it will
* fail with older firmware. Error value -EOPNOSUPP can only be
* returned by older firmware running this command, to keep code
* backward compatible we will override this value and return
* success.
*/
if (ret && ret != -EOPNOTSUPP) {
dev_err(&hdev->pdev->dev,
"failed to clear hw resource, ret = %d\n", ret);
return ret;
}
return 0;
}
static void hclge_init_rxd_adv_layout(struct hclge_dev *hdev) static void hclge_init_rxd_adv_layout(struct hclge_dev *hdev)
{ {
if (hnae3_ae_dev_rxd_adv_layout_supported(hdev->ae_dev)) if (hnae3_ae_dev_rxd_adv_layout_supported(hdev->ae_dev))
...@@ -11492,6 +11514,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -11492,6 +11514,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
if (ret) if (ret)
goto err_cmd_uninit; goto err_cmd_uninit;
ret = hclge_clear_hw_resource(hdev);
if (ret)
goto err_cmd_uninit;
ret = hclge_get_cap(hdev); ret = hclge_get_cap(hdev);
if (ret) if (ret)
goto err_cmd_uninit; goto err_cmd_uninit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment