Skip to content

Commit

Permalink
be2net: Fix crash on 2nd invocation of PCI AER/EEH error_detected hook
Browse files Browse the repository at this point in the history
During a PCI EEH/AER error recovery flow, if the device did not successfully
restart, the error_detected() hook may be called a second time with a
"perm_failure" state. This patch skips over driver cleanup for the second
invocation of the callback.

Also, Lancer error recovery code is fixed-up to handle these changes.

Signed-off-by: Kalesh AP <kalesh.purayil@emulex.com>
Signed-off-by: Somnath kotur <somnath.kotur@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Somnath Kotur authored and David S. Miller committed May 30, 2013
1 parent e38b170 commit 01e5b2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/emulex/benet/be_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ int lancer_test_and_set_rdy_state(struct be_adapter *adapter)

resource_error = lancer_provisioning_error(adapter);
if (resource_error)
return -1;
return -EAGAIN;

status = lancer_wait_ready(adapter);
if (!status) {
Expand Down Expand Up @@ -590,8 +590,8 @@ int lancer_test_and_set_rdy_state(struct be_adapter *adapter)
* when PF provisions resources.
*/
resource_error = lancer_provisioning_error(adapter);
if (status == -1 && !resource_error)
adapter->eeh_error = true;
if (resource_error)
status = -EAGAIN;

return status;
}
Expand Down
48 changes: 23 additions & 25 deletions drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4098,6 +4098,7 @@ static int be_get_initial_config(struct be_adapter *adapter)

static int lancer_recover_func(struct be_adapter *adapter)
{
struct device *dev = &adapter->pdev->dev;
int status;

status = lancer_test_and_set_rdy_state(adapter);
Expand All @@ -4109,8 +4110,7 @@ static int lancer_recover_func(struct be_adapter *adapter)

be_clear(adapter);

adapter->hw_error = false;
adapter->fw_timeout = false;
be_clear_all_error(adapter);

status = be_setup(adapter);
if (status)
Expand All @@ -4122,13 +4122,13 @@ static int lancer_recover_func(struct be_adapter *adapter)
goto err;
}

dev_err(&adapter->pdev->dev,
"Adapter SLIPORT recovery succeeded\n");
dev_err(dev, "Error recovery successful\n");
return 0;
err:
if (adapter->eeh_error)
dev_err(&adapter->pdev->dev,
"Adapter SLIPORT recovery failed\n");
if (status == -EAGAIN)
dev_err(dev, "Waiting for resource provisioning\n");
else
dev_err(dev, "Error recovery failed\n");

return status;
}
Expand All @@ -4137,28 +4137,27 @@ static void be_func_recovery_task(struct work_struct *work)
{
struct be_adapter *adapter =
container_of(work, struct be_adapter, func_recovery_work.work);
int status;
int status = 0;

be_detect_error(adapter);

if (adapter->hw_error && lancer_chip(adapter)) {

if (adapter->eeh_error)
goto out;

rtnl_lock();
netif_device_detach(adapter->netdev);
rtnl_unlock();

status = lancer_recover_func(adapter);

if (!status)
netif_device_attach(adapter->netdev);
}

out:
schedule_delayed_work(&adapter->func_recovery_work,
msecs_to_jiffies(1000));
/* In Lancer, for all errors other than provisioning error (-EAGAIN),
* no need to attempt further recovery.
*/
if (!status || status == -EAGAIN)
schedule_delayed_work(&adapter->func_recovery_work,
msecs_to_jiffies(1000));
}

static void be_worker(struct work_struct *work)
Expand Down Expand Up @@ -4441,20 +4440,19 @@ static pci_ers_result_t be_eeh_err_detected(struct pci_dev *pdev,

dev_err(&adapter->pdev->dev, "EEH error detected\n");

adapter->eeh_error = true;

cancel_delayed_work_sync(&adapter->func_recovery_work);
if (!adapter->eeh_error) {
adapter->eeh_error = true;

rtnl_lock();
netif_device_detach(netdev);
rtnl_unlock();
cancel_delayed_work_sync(&adapter->func_recovery_work);

if (netif_running(netdev)) {
rtnl_lock();
be_close(netdev);
netif_device_detach(netdev);
if (netif_running(netdev))
be_close(netdev);
rtnl_unlock();

be_clear(adapter);
}
be_clear(adapter);

if (state == pci_channel_io_perm_failure)
return PCI_ERS_RESULT_DISCONNECT;
Expand All @@ -4479,7 +4477,6 @@ static pci_ers_result_t be_eeh_reset(struct pci_dev *pdev)
int status;

dev_info(&adapter->pdev->dev, "EEH reset\n");
be_clear_all_error(adapter);

status = pci_enable_device(pdev);
if (status)
Expand All @@ -4497,6 +4494,7 @@ static pci_ers_result_t be_eeh_reset(struct pci_dev *pdev)
return PCI_ERS_RESULT_DISCONNECT;

pci_cleanup_aer_uncorrect_error_status(pdev);
be_clear_all_error(adapter);
return PCI_ERS_RESULT_RECOVERED;
}

Expand Down

0 comments on commit 01e5b2c

Please sign in to comment.