Commit 0cb4bc66 authored by Dany Madden's avatar Dany Madden Committed by Jakub Kicinski

ibmvnic: restore adapter state on failed reset

In a failed reset, driver could end up in VNIC_PROBED or VNIC_CLOSED
state and cannot recover in subsequent resets, leaving it offline.
This patch restores the adapter state to reset_state, the original
state when reset was called.

Fixes: b27507bb ("net/ibmvnic: unlock rtnl_lock in reset so linkwatch_event can run")
Fixes: 2770a798 ("ibmvnic: Introduce hard reset recovery")
Signed-off-by: default avatarDany Madden <drt@linux.ibm.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9281cf2d
...@@ -1857,7 +1857,7 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter, ...@@ -1857,7 +1857,7 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter,
if (reset_state == VNIC_OPEN) { if (reset_state == VNIC_OPEN) {
rc = __ibmvnic_close(netdev); rc = __ibmvnic_close(netdev);
if (rc) if (rc)
return rc; goto out;
} }
release_resources(adapter); release_resources(adapter);
...@@ -1875,24 +1875,25 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter, ...@@ -1875,24 +1875,25 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter,
} }
rc = ibmvnic_reset_init(adapter, true); rc = ibmvnic_reset_init(adapter, true);
if (rc) if (rc) {
return IBMVNIC_INIT_FAILED; rc = IBMVNIC_INIT_FAILED;
goto out;
}
/* If the adapter was in PROBE state prior to the reset, /* If the adapter was in PROBE state prior to the reset,
* exit here. * exit here.
*/ */
if (reset_state == VNIC_PROBED) if (reset_state == VNIC_PROBED)
return 0; goto out;
rc = ibmvnic_login(netdev); rc = ibmvnic_login(netdev);
if (rc) { if (rc) {
adapter->state = reset_state; goto out;
return rc;
} }
rc = init_resources(adapter); rc = init_resources(adapter);
if (rc) if (rc)
return rc; goto out;
ibmvnic_disable_irqs(adapter); ibmvnic_disable_irqs(adapter);
...@@ -1902,8 +1903,10 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter, ...@@ -1902,8 +1903,10 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter,
return 0; return 0;
rc = __ibmvnic_open(netdev); rc = __ibmvnic_open(netdev);
if (rc) if (rc) {
return IBMVNIC_OPEN_FAILED; rc = IBMVNIC_OPEN_FAILED;
goto out;
}
/* refresh device's multicast list */ /* refresh device's multicast list */
ibmvnic_set_multi(netdev); ibmvnic_set_multi(netdev);
...@@ -1912,7 +1915,10 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter, ...@@ -1912,7 +1915,10 @@ static int do_change_param_reset(struct ibmvnic_adapter *adapter,
for (i = 0; i < adapter->req_rx_queues; i++) for (i = 0; i < adapter->req_rx_queues; i++)
napi_schedule(&adapter->napi[i]); napi_schedule(&adapter->napi[i]);
return 0; out:
if (rc)
adapter->state = reset_state;
return rc;
} }
/** /**
...@@ -2015,7 +2021,6 @@ static int do_reset(struct ibmvnic_adapter *adapter, ...@@ -2015,7 +2021,6 @@ static int do_reset(struct ibmvnic_adapter *adapter,
rc = ibmvnic_login(netdev); rc = ibmvnic_login(netdev);
if (rc) { if (rc) {
adapter->state = reset_state;
goto out; goto out;
} }
...@@ -2083,6 +2088,9 @@ static int do_reset(struct ibmvnic_adapter *adapter, ...@@ -2083,6 +2088,9 @@ static int do_reset(struct ibmvnic_adapter *adapter,
rc = 0; rc = 0;
out: out:
/* restore the adapter state if reset failed */
if (rc)
adapter->state = reset_state;
rtnl_unlock(); rtnl_unlock();
return rc; return rc;
...@@ -2115,43 +2123,46 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter, ...@@ -2115,43 +2123,46 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter,
if (rc) { if (rc) {
netdev_err(adapter->netdev, netdev_err(adapter->netdev,
"Couldn't initialize crq. rc=%d\n", rc); "Couldn't initialize crq. rc=%d\n", rc);
return rc; goto out;
} }
rc = ibmvnic_reset_init(adapter, false); rc = ibmvnic_reset_init(adapter, false);
if (rc) if (rc)
return rc; goto out;
/* If the adapter was in PROBE state prior to the reset, /* If the adapter was in PROBE state prior to the reset,
* exit here. * exit here.
*/ */
if (reset_state == VNIC_PROBED) if (reset_state == VNIC_PROBED)
return 0; goto out;
rc = ibmvnic_login(netdev); rc = ibmvnic_login(netdev);
if (rc) { if (rc)
adapter->state = VNIC_PROBED; goto out;
return 0;
}
rc = init_resources(adapter); rc = init_resources(adapter);
if (rc) if (rc)
return rc; goto out;
ibmvnic_disable_irqs(adapter); ibmvnic_disable_irqs(adapter);
adapter->state = VNIC_CLOSED; adapter->state = VNIC_CLOSED;
if (reset_state == VNIC_CLOSED) if (reset_state == VNIC_CLOSED)
return 0; goto out;
rc = __ibmvnic_open(netdev); rc = __ibmvnic_open(netdev);
if (rc) if (rc) {
return IBMVNIC_OPEN_FAILED; rc = IBMVNIC_OPEN_FAILED;
goto out;
}
call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, netdev); call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, netdev);
call_netdevice_notifiers(NETDEV_RESEND_IGMP, netdev); call_netdevice_notifiers(NETDEV_RESEND_IGMP, netdev);
out:
return 0; /* restore adapter state if reset failed */
if (rc)
adapter->state = reset_state;
return rc;
} }
static struct ibmvnic_rwi *get_next_rwi(struct ibmvnic_adapter *adapter) static struct ibmvnic_rwi *get_next_rwi(struct ibmvnic_adapter *adapter)
...@@ -2235,13 +2246,7 @@ static void __ibmvnic_reset(struct work_struct *work) ...@@ -2235,13 +2246,7 @@ static void __ibmvnic_reset(struct work_struct *work)
rc = do_reset(adapter, rwi, reset_state); rc = do_reset(adapter, rwi, reset_state);
} }
kfree(rwi); kfree(rwi);
if (rc == IBMVNIC_OPEN_FAILED) {
if (list_empty(&adapter->rwi_list))
adapter->state = VNIC_CLOSED;
else
adapter->state = reset_state;
rc = 0;
}
if (rc) if (rc)
netdev_dbg(adapter->netdev, "Reset failed, rc=%d\n", rc); netdev_dbg(adapter->netdev, "Reset failed, rc=%d\n", rc);
......
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