RDMA/efa: Reset device on probe failure
authorMichael Margolin <mrgolin@amazon.com>
Wed, 25 Dec 2024 13:15:48 +0000 (13:15 +0000)
committerLeon Romanovsky <leon@kernel.org>
Mon, 30 Dec 2024 18:41:13 +0000 (13:41 -0500)
Make sure the device is being reset on driver exit whatever the reason
is, to keep the device aligned and allow it to close shared resources
(e.g. admin queue).

Reviewed-by: Firas Jahjah <firasj@amazon.com>
Reviewed-by: Yonatan Nachum <ynachum@amazon.com>
Signed-off-by: Michael Margolin <mrgolin@amazon.com>
Link: https://patch.msgid.link/20241225131548.15155-1-mrgolin@amazon.com
Reviewed-by: Gal Pressman <gal.pressman@linux.dev>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/efa/efa_main.c

index ad225823e6f2fe772f74862064b009ca941ef67a..45a4564c670c01bb70231d652f94e1bf4bf17f39 100644 (file)
@@ -470,7 +470,6 @@ static void efa_ib_device_remove(struct efa_dev *dev)
        ibdev_info(&dev->ibdev, "Unregister ib device\n");
        ib_unregister_device(&dev->ibdev);
        efa_destroy_eqs(dev);
-       efa_com_dev_reset(&dev->edev, EFA_REGS_RESET_NORMAL);
        efa_release_doorbell_bar(dev);
 }
 
@@ -643,12 +642,14 @@ err_disable_device:
        return ERR_PTR(err);
 }
 
-static void efa_remove_device(struct pci_dev *pdev)
+static void efa_remove_device(struct pci_dev *pdev,
+                             enum efa_regs_reset_reason_types reset_reason)
 {
        struct efa_dev *dev = pci_get_drvdata(pdev);
        struct efa_com_dev *edev;
 
        edev = &dev->edev;
+       efa_com_dev_reset(edev, reset_reason);
        efa_com_admin_destroy(edev);
        efa_free_irq(dev, &dev->admin_irq);
        efa_disable_msix(dev);
@@ -676,7 +677,7 @@ static int efa_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        return 0;
 
 err_remove_device:
-       efa_remove_device(pdev);
+       efa_remove_device(pdev, EFA_REGS_RESET_INIT_ERR);
        return err;
 }
 
@@ -685,7 +686,7 @@ static void efa_remove(struct pci_dev *pdev)
        struct efa_dev *dev = pci_get_drvdata(pdev);
 
        efa_ib_device_remove(dev);
-       efa_remove_device(pdev);
+       efa_remove_device(pdev, EFA_REGS_RESET_NORMAL);
 }
 
 static void efa_shutdown(struct pci_dev *pdev)