Commit 2ba5fbd6 authored by Yishai Hadas's avatar Yishai Hadas Committed by David S. Miller

net/mlx4_core: Handle AER flow properly

Fix AER callbacks to work properly, it includes:
- Refractoring AER to be aligned with Reset flow support.
- Sync with concurrent catas flow.

In addition, fix the shutdown PCI callback to sync with
concurrent catas flow.
Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c69453e2
...@@ -3120,7 +3120,10 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -3120,7 +3120,10 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret) { if (ret) {
kfree(dev->persist); kfree(dev->persist);
kfree(priv); kfree(priv);
} else {
pci_save_state(pdev);
} }
return ret; return ret;
} }
...@@ -3351,23 +3354,79 @@ MODULE_DEVICE_TABLE(pci, mlx4_pci_table); ...@@ -3351,23 +3354,79 @@ MODULE_DEVICE_TABLE(pci, mlx4_pci_table);
static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev, static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev,
pci_channel_state_t state) pci_channel_state_t state)
{ {
mlx4_unload_one(pdev); struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
mlx4_err(persist->dev, "mlx4_pci_err_detected was called\n");
mlx4_enter_error_state(persist);
return state == pci_channel_io_perm_failure ? mutex_lock(&persist->interface_state_mutex);
PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
mlx4_unload_one(pdev);
mutex_unlock(&persist->interface_state_mutex);
if (state == pci_channel_io_perm_failure)
return PCI_ERS_RESULT_DISCONNECT;
pci_disable_device(pdev);
return PCI_ERS_RESULT_NEED_RESET;
} }
static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev) static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev)
{ {
struct mlx4_dev *dev = pci_get_drvdata(pdev); struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_priv *priv = mlx4_priv(dev);
int ret; int ret;
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
int total_vfs;
ret = __mlx4_init_one(pdev, priv->pci_dev_data, priv); mlx4_err(dev, "mlx4_pci_slot_reset was called\n");
ret = pci_enable_device(pdev);
if (ret) {
mlx4_err(dev, "Can not re-enable device, ret=%d\n", ret);
return PCI_ERS_RESULT_DISCONNECT;
}
pci_set_master(pdev);
pci_restore_state(pdev);
pci_save_state(pdev);
total_vfs = dev->persist->num_vfs;
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
mutex_lock(&persist->interface_state_mutex);
if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs, nvfs,
priv);
if (ret) {
mlx4_err(dev, "%s: mlx4_load_one failed, ret=%d\n",
__func__, ret);
goto end;
}
ret = restore_current_port_types(dev, dev->persist->
curr_port_type, dev->persist->
curr_port_poss_type);
if (ret)
mlx4_err(dev, "could not restore original port types (%d)\n", ret);
}
end:
mutex_unlock(&persist->interface_state_mutex);
return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
} }
static void mlx4_shutdown(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
mlx4_info(persist->dev, "mlx4_shutdown was called\n");
mutex_lock(&persist->interface_state_mutex);
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
mlx4_unload_one(pdev);
mutex_unlock(&persist->interface_state_mutex);
}
static const struct pci_error_handlers mlx4_err_handler = { static const struct pci_error_handlers mlx4_err_handler = {
.error_detected = mlx4_pci_err_detected, .error_detected = mlx4_pci_err_detected,
.slot_reset = mlx4_pci_slot_reset, .slot_reset = mlx4_pci_slot_reset,
...@@ -3377,7 +3436,7 @@ static struct pci_driver mlx4_driver = { ...@@ -3377,7 +3436,7 @@ static struct pci_driver mlx4_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = mlx4_pci_table, .id_table = mlx4_pci_table,
.probe = mlx4_init_one, .probe = mlx4_init_one,
.shutdown = mlx4_unload_one, .shutdown = mlx4_shutdown,
.remove = mlx4_remove_one, .remove = mlx4_remove_one,
.err_handler = &mlx4_err_handler, .err_handler = &mlx4_err_handler,
}; };
......
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