IB/{hfi1, qib}: Add handling of kernel restart
authorAlex Estrin <alex.estrin@intel.com>
Wed, 2 May 2018 13:43:15 +0000 (06:43 -0700)
committerDoug Ledford <dledford@redhat.com>
Wed, 9 May 2018 19:53:29 +0000 (15:53 -0400)
A warm restart will fail to unload the driver, leaving link state
potentially flapping up to the point the BIOS resets the adapter.
Correct the issue by hooking the shutdown pci method,
which will bring port down.

Cc: <stable@vger.kernel.org> # 4.9.x
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Alex Estrin <alex.estrin@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/hfi.h
drivers/infiniband/hw/hfi1/init.c
drivers/infiniband/hw/qib/qib.h
drivers/infiniband/hw/qib/qib_init.c

index cac2c62bc42d6d496c307e66dd4ac6c7f0ada16e..9c97c180c35e8d8d36ceb1f7ced8a31e25c8f355 100644 (file)
@@ -1856,6 +1856,7 @@ struct cc_state *get_cc_state_protected(struct hfi1_pportdata *ppd)
 #define HFI1_HAS_SDMA_TIMEOUT  0x8
 #define HFI1_HAS_SEND_DMA      0x10   /* Supports Send DMA */
 #define HFI1_FORCED_FREEZE     0x80   /* driver forced freeze mode */
+#define HFI1_SHUTDOWN          0x100  /* device is shutting down */
 
 /* IB dword length mask in PBC (lower 11 bits); same for all chips */
 #define HFI1_PBC_LENGTH_MASK                     ((1 << 11) - 1)
index 6309edf811df6e33d2ea3f64e6d7592231c8dd3a..790542ce89a5cb44ac0389feb4b9e057a08dfb92 100644 (file)
@@ -1058,6 +1058,10 @@ static void shutdown_device(struct hfi1_devdata *dd)
        unsigned pidx;
        int i;
 
+       if (dd->flags & HFI1_SHUTDOWN)
+               return;
+       dd->flags |= HFI1_SHUTDOWN;
+
        for (pidx = 0; pidx < dd->num_pports; ++pidx) {
                ppd = dd->pport + pidx;
 
@@ -1391,6 +1395,7 @@ void hfi1_disable_after_error(struct hfi1_devdata *dd)
 
 static void remove_one(struct pci_dev *);
 static int init_one(struct pci_dev *, const struct pci_device_id *);
+static void shutdown_one(struct pci_dev *);
 
 #define DRIVER_LOAD_MSG "Intel " DRIVER_NAME " loaded: "
 #define PFX DRIVER_NAME ": "
@@ -1407,6 +1412,7 @@ static struct pci_driver hfi1_pci_driver = {
        .name = DRIVER_NAME,
        .probe = init_one,
        .remove = remove_one,
+       .shutdown = shutdown_one,
        .id_table = hfi1_pci_tbl,
        .err_handler = &hfi1_pci_err_handler,
 };
@@ -1816,6 +1822,13 @@ static void remove_one(struct pci_dev *pdev)
        postinit_cleanup(dd);
 }
 
+static void shutdown_one(struct pci_dev *pdev)
+{
+       struct hfi1_devdata *dd = pci_get_drvdata(pdev);
+
+       shutdown_device(dd);
+}
+
 /**
  * hfi1_create_rcvhdrq - create a receive header queue
  * @dd: the hfi1_ib device
index 46072455130c97ec7d4b89cb134eb8ad1286aaa0..43a68d7b51bbb4089db6bd0641bca4b4fa9a5237 100644 (file)
@@ -1228,6 +1228,7 @@ static inline struct qib_ibport *to_iport(struct ib_device *ibdev, u8 port)
 #define QIB_BADINTR           0x8000 /* severe interrupt problems */
 #define QIB_DCA_ENABLED       0x10000 /* Direct Cache Access enabled */
 #define QIB_HAS_QSFP          0x20000 /* device (card instance) has QSFP */
+#define QIB_SHUTDOWN          0x40000 /* device is shutting down */
 
 /*
  * values for ppd->lflags (_ib_port_ related flags)
index 6c68f8a97018cde76de76c2f330b1aeb89f173cd..0155202897352e4eb52d93883e9806218e9f972f 100644 (file)
@@ -841,6 +841,10 @@ static void qib_shutdown_device(struct qib_devdata *dd)
        struct qib_pportdata *ppd;
        unsigned pidx;
 
+       if (dd->flags & QIB_SHUTDOWN)
+               return;
+       dd->flags |= QIB_SHUTDOWN;
+
        for (pidx = 0; pidx < dd->num_pports; ++pidx) {
                ppd = dd->pport + pidx;
 
@@ -1182,6 +1186,7 @@ void qib_disable_after_error(struct qib_devdata *dd)
 
 static void qib_remove_one(struct pci_dev *);
 static int qib_init_one(struct pci_dev *, const struct pci_device_id *);
+static void qib_shutdown_one(struct pci_dev *);
 
 #define DRIVER_LOAD_MSG "Intel " QIB_DRV_NAME " loaded: "
 #define PFX QIB_DRV_NAME ": "
@@ -1199,6 +1204,7 @@ static struct pci_driver qib_driver = {
        .name = QIB_DRV_NAME,
        .probe = qib_init_one,
        .remove = qib_remove_one,
+       .shutdown = qib_shutdown_one,
        .id_table = qib_pci_tbl,
        .err_handler = &qib_pci_err_handler,
 };
@@ -1549,6 +1555,13 @@ static void qib_remove_one(struct pci_dev *pdev)
        qib_postinit_cleanup(dd);
 }
 
+static void qib_shutdown_one(struct pci_dev *pdev)
+{
+       struct qib_devdata *dd = pci_get_drvdata(pdev);
+
+       qib_shutdown_device(dd);
+}
+
 /**
  * qib_create_rcvhdrq - create a receive header queue
  * @dd: the qlogic_ib device