aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx4/main.c
diff options
context:
space:
mode:
authorKleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>2012-07-20 05:55:43 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-25 18:24:13 -0400
commit57dbf29a54bda5773f9ed1d00e3cc633294259da (patch)
tree311f1973354a10fa997db812299982b560dc821f /drivers/net/ethernet/mellanox/mlx4/main.c
parentf94898ea6682977f15c5a8f9ffb293a14f95455a (diff)
mlx4: Add support for EEH error recovery
Currently the mlx4 drivers don't have the necessary callbacks to implement EEH errors detection and recovery, so the PCI layer uses the probe and remove callbacks to try to recover the device after an error on the bus. However, these callbacks have race conditions with the internal catastrophic error recovery functions, which will also detect the error and this can cause the system to crash if both EEH and catas functions try to reset the device. This patch adds the necessary error recovery callbacks and makes sure that the internal catastrophic error functions will not try to reset the device in such scenarios. It also adds some calls to pci_channel_offline() to suppress reads/writes on the bus when the slot cannot accept I/O operations so we prevent unnecessary accesses to the bus and speed up the device removal. Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com> Acked-by: Shlomo Pongratz <shlomop@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/main.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 42645166bae2..e717091734d0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1775,6 +1775,9 @@ static int mlx4_get_ownership(struct mlx4_dev *dev)
1775 void __iomem *owner; 1775 void __iomem *owner;
1776 u32 ret; 1776 u32 ret;
1777 1777
1778 if (pci_channel_offline(dev->pdev))
1779 return -EIO;
1780
1778 owner = ioremap(pci_resource_start(dev->pdev, 0) + MLX4_OWNER_BASE, 1781 owner = ioremap(pci_resource_start(dev->pdev, 0) + MLX4_OWNER_BASE,
1779 MLX4_OWNER_SIZE); 1782 MLX4_OWNER_SIZE);
1780 if (!owner) { 1783 if (!owner) {
@@ -1791,6 +1794,9 @@ static void mlx4_free_ownership(struct mlx4_dev *dev)
1791{ 1794{
1792 void __iomem *owner; 1795 void __iomem *owner;
1793 1796
1797 if (pci_channel_offline(dev->pdev))
1798 return;
1799
1794 owner = ioremap(pci_resource_start(dev->pdev, 0) + MLX4_OWNER_BASE, 1800 owner = ioremap(pci_resource_start(dev->pdev, 0) + MLX4_OWNER_BASE,
1795 MLX4_OWNER_SIZE); 1801 MLX4_OWNER_SIZE);
1796 if (!owner) { 1802 if (!owner) {
@@ -2237,11 +2243,33 @@ static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
2237 2243
2238MODULE_DEVICE_TABLE(pci, mlx4_pci_table); 2244MODULE_DEVICE_TABLE(pci, mlx4_pci_table);
2239 2245
2246static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev,
2247 pci_channel_state_t state)
2248{
2249 mlx4_remove_one(pdev);
2250
2251 return state == pci_channel_io_perm_failure ?
2252 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
2253}
2254
2255static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev)
2256{
2257 int ret = __mlx4_init_one(pdev, NULL);
2258
2259 return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
2260}
2261
2262static struct pci_error_handlers mlx4_err_handler = {
2263 .error_detected = mlx4_pci_err_detected,
2264 .slot_reset = mlx4_pci_slot_reset,
2265};
2266
2240static struct pci_driver mlx4_driver = { 2267static struct pci_driver mlx4_driver = {
2241 .name = DRV_NAME, 2268 .name = DRV_NAME,
2242 .id_table = mlx4_pci_table, 2269 .id_table = mlx4_pci_table,
2243 .probe = mlx4_init_one, 2270 .probe = mlx4_init_one,
2244 .remove = __devexit_p(mlx4_remove_one) 2271 .remove = __devexit_p(mlx4_remove_one),
2272 .err_handler = &mlx4_err_handler,
2245}; 2273};
2246 2274
2247static int __init mlx4_verify_params(void) 2275static int __init mlx4_verify_params(void)