diff mbox series

qedi: Add schedule_hw_err_handler callback for fan failure

Message ID 20200924070338.8270-1-mrangankar@marvell.com
State New
Headers show
Series qedi: Add schedule_hw_err_handler callback for fan failure | expand

Commit Message

Manish Rangankar Sept. 24, 2020, 7:03 a.m. UTC
On fan failure event from MFW, bring down active connections,
and unload the firmware context.

Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
---
 drivers/scsi/qedi/qedi.h      |  1 +
 drivers/scsi/qedi/qedi_main.c | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

Comments

Martin K. Petersen Oct. 3, 2020, 1:24 a.m. UTC | #1
Manish,

> On fan failure event from MFW, bring down active connections, and
> unload the firmware context.

Applied to 5.10/scsi-staging, thanks!
Martin K. Petersen Oct. 7, 2020, 3:47 a.m. UTC | #2
On Thu, 24 Sep 2020 00:03:38 -0700, Manish Rangankar wrote:

> On fan failure event from MFW, bring down active connections,
> and unload the firmware context.

Applied to 5.10/scsi-queue, thanks!

[1/1] scsi: qedi: Add schedule_hw_err_handler callback for fan failure
      https://git.kernel.org/mkp/scsi/c/7dc71ac8eb0b
diff mbox series

Patch

diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h
index 7e59d50f2fab..c342defc3f52 100644
--- a/drivers/scsi/qedi/qedi.h
+++ b/drivers/scsi/qedi/qedi.h
@@ -339,6 +339,7 @@  struct qedi_ctx {
 
 	struct workqueue_struct *dpc_wq;
 	struct delayed_work recovery_work;
+	struct delayed_work board_disable_work;
 
 	spinlock_t task_idx_lock;	/* To protect gbl context */
 	s32 last_tidx_alloc;
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index 10a7ee055552..ff71ea2589a8 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -1133,6 +1133,9 @@  void qedi_schedule_hw_err_handler(void *dev,
 		  err_type, qedi->qedi_err_flags);
 
 	switch (err_type) {
+	case QED_HW_ERR_FAN_FAIL:
+		schedule_delayed_work(&qedi->board_disable_work, 0);
+		break;
 	case QED_HW_ERR_MFW_RESP_FAIL:
 	case QED_HW_ERR_HW_ATTN:
 	case QED_HW_ERR_DMAE_FAIL:
@@ -2486,6 +2489,21 @@  static void __qedi_remove(struct pci_dev *pdev, int mode)
 	}
 }
 
+static void qedi_board_disable_work(struct work_struct *work)
+{
+	struct qedi_ctx *qedi =
+			container_of(work, struct qedi_ctx,
+				     board_disable_work.work);
+
+	QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
+		  "Fan failure, Unloading firmware context.\n");
+
+	if (test_and_set_bit(QEDI_IN_SHUTDOWN, &qedi->flags))
+		return;
+
+	__qedi_remove(qedi->pdev, QEDI_MODE_SHUTDOWN);
+}
+
 static void qedi_shutdown(struct pci_dev *pdev)
 {
 	struct qedi_ctx *qedi = pci_get_drvdata(pdev);
@@ -2753,6 +2771,8 @@  static int __qedi_probe(struct pci_dev *pdev, int mode)
 		}
 
 		INIT_DELAYED_WORK(&qedi->recovery_work, qedi_recovery_handler);
+		INIT_DELAYED_WORK(&qedi->board_disable_work,
+				  qedi_board_disable_work);
 
 		/* F/w needs 1st task context memory entry for performance */
 		set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map);