Commit a1b2c39f authored by Jian Shen's avatar Jian Shen Committed by Greg Kroah-Hartman

net: hns3: Fix client initialize state issue when roce client initialize failed

[ Upstream commit d9f28fc2 ]

When roce is loaded before nic, the roce client will not be initialized
until nic client is initialized, but roce init flag is set before it.
Furthermore, in this case of nic initialized success and roce failed,
the nic init flag is not set, and roce init flag is not cleared.

This patch fixes it by set init flag only after the client is initialized
successfully.

Fixes: e2cb1dec ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support")
Fixes: 46a3df9f ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 20f2b72f
...@@ -29,8 +29,8 @@ static bool hnae3_client_match(enum hnae3_client_type client_type, ...@@ -29,8 +29,8 @@ static bool hnae3_client_match(enum hnae3_client_type client_type,
return false; return false;
} }
static void hnae3_set_client_init_flag(struct hnae3_client *client, void hnae3_set_client_init_flag(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev, int inited) struct hnae3_ae_dev *ae_dev, int inited)
{ {
switch (client->type) { switch (client->type) {
case HNAE3_CLIENT_KNIC: case HNAE3_CLIENT_KNIC:
...@@ -46,6 +46,7 @@ static void hnae3_set_client_init_flag(struct hnae3_client *client, ...@@ -46,6 +46,7 @@ static void hnae3_set_client_init_flag(struct hnae3_client *client,
break; break;
} }
} }
EXPORT_SYMBOL(hnae3_set_client_init_flag);
static int hnae3_get_client_init_flag(struct hnae3_client *client, static int hnae3_get_client_init_flag(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev) struct hnae3_ae_dev *ae_dev)
...@@ -86,14 +87,11 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client, ...@@ -86,14 +87,11 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client,
/* now, (un-)instantiate client by calling lower layer */ /* now, (un-)instantiate client by calling lower layer */
if (is_reg) { if (is_reg) {
ret = ae_dev->ops->init_client_instance(client, ae_dev); ret = ae_dev->ops->init_client_instance(client, ae_dev);
if (ret) { if (ret)
dev_err(&ae_dev->pdev->dev, dev_err(&ae_dev->pdev->dev,
"fail to instantiate client, ret = %d\n", ret); "fail to instantiate client, ret = %d\n", ret);
return ret;
}
hnae3_set_client_init_flag(client, ae_dev, 1); return ret;
return 0;
} }
if (hnae3_get_client_init_flag(client, ae_dev)) { if (hnae3_get_client_init_flag(client, ae_dev)) {
......
...@@ -521,4 +521,7 @@ void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo); ...@@ -521,4 +521,7 @@ void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo);
void hnae3_unregister_client(struct hnae3_client *client); void hnae3_unregister_client(struct hnae3_client *client);
int hnae3_register_client(struct hnae3_client *client); int hnae3_register_client(struct hnae3_client *client);
void hnae3_set_client_init_flag(struct hnae3_client *client,
struct hnae3_ae_dev *ae_dev, int inited);
#endif #endif
...@@ -5485,6 +5485,8 @@ static int hclge_init_client_instance(struct hnae3_client *client, ...@@ -5485,6 +5485,8 @@ static int hclge_init_client_instance(struct hnae3_client *client,
goto clear_nic; goto clear_nic;
} }
hnae3_set_client_init_flag(client, ae_dev, 1);
if (hdev->roce_client && if (hdev->roce_client &&
hnae3_dev_roce_supported(hdev)) { hnae3_dev_roce_supported(hdev)) {
struct hnae3_client *rc = hdev->roce_client; struct hnae3_client *rc = hdev->roce_client;
...@@ -5496,6 +5498,9 @@ static int hclge_init_client_instance(struct hnae3_client *client, ...@@ -5496,6 +5498,9 @@ static int hclge_init_client_instance(struct hnae3_client *client,
ret = rc->ops->init_instance(&vport->roce); ret = rc->ops->init_instance(&vport->roce);
if (ret) if (ret)
goto clear_roce; goto clear_roce;
hnae3_set_client_init_flag(hdev->roce_client,
ae_dev, 1);
} }
break; break;
...@@ -5507,6 +5512,8 @@ static int hclge_init_client_instance(struct hnae3_client *client, ...@@ -5507,6 +5512,8 @@ static int hclge_init_client_instance(struct hnae3_client *client,
if (ret) if (ret)
goto clear_nic; goto clear_nic;
hnae3_set_client_init_flag(client, ae_dev, 1);
break; break;
case HNAE3_CLIENT_ROCE: case HNAE3_CLIENT_ROCE:
if (hnae3_dev_roce_supported(hdev)) { if (hnae3_dev_roce_supported(hdev)) {
...@@ -5522,6 +5529,8 @@ static int hclge_init_client_instance(struct hnae3_client *client, ...@@ -5522,6 +5529,8 @@ static int hclge_init_client_instance(struct hnae3_client *client,
ret = client->ops->init_instance(&vport->roce); ret = client->ops->init_instance(&vport->roce);
if (ret) if (ret)
goto clear_roce; goto clear_roce;
hnae3_set_client_init_flag(client, ae_dev, 1);
} }
} }
} }
......
...@@ -1631,6 +1631,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ...@@ -1631,6 +1631,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client,
if (ret) if (ret)
goto clear_nic; goto clear_nic;
hnae3_set_client_init_flag(client, ae_dev, 1);
if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) {
struct hnae3_client *rc = hdev->roce_client; struct hnae3_client *rc = hdev->roce_client;
...@@ -1640,6 +1642,9 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ...@@ -1640,6 +1642,9 @@ static int hclgevf_init_client_instance(struct hnae3_client *client,
ret = rc->ops->init_instance(&hdev->roce); ret = rc->ops->init_instance(&hdev->roce);
if (ret) if (ret)
goto clear_roce; goto clear_roce;
hnae3_set_client_init_flag(hdev->roce_client, ae_dev,
1);
} }
break; break;
case HNAE3_CLIENT_UNIC: case HNAE3_CLIENT_UNIC:
...@@ -1649,6 +1654,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ...@@ -1649,6 +1654,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client,
ret = client->ops->init_instance(&hdev->nic); ret = client->ops->init_instance(&hdev->nic);
if (ret) if (ret)
goto clear_nic; goto clear_nic;
hnae3_set_client_init_flag(client, ae_dev, 1);
break; break;
case HNAE3_CLIENT_ROCE: case HNAE3_CLIENT_ROCE:
if (hnae3_dev_roce_supported(hdev)) { if (hnae3_dev_roce_supported(hdev)) {
...@@ -1665,6 +1672,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ...@@ -1665,6 +1672,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client,
if (ret) if (ret)
goto clear_roce; goto clear_roce;
} }
hnae3_set_client_init_flag(client, ae_dev, 1);
} }
return 0; return 0;
......
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