All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nilesh Javali <njavali@marvell.com>
To: <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <GR-QLogic-Storage-Upstream@marvell.com>
Subject: [PATCH v2 08/13] qla2xxx: Fix laggy FC remote port session recovery
Date: Thu, 10 Mar 2022 01:25:59 -0800	[thread overview]
Message-ID: <20220310092604.22950-9-njavali@marvell.com> (raw)
In-Reply-To: <20220310092604.22950-1-njavali@marvell.com>

From: Quinn Tran <qutran@marvell.com>

For session recovery, driver relies on the dpc thread to
initiate certain operation. The dpc thread runs exclusively
without the Mailbox interface being occupied. Recent code change
for heartbeat check via mailbox cmd 0 is causing the dpc thread
from carrying out its operation. This patch allows the higher
priority error recovery to run first before running the lower priority
heartbeat check.

Cc: stable@vger.kernel.org
Fixes: d94d8158e184 ("scsi: qla2xxx: Add heartbeat check")
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
---
 drivers/scsi/qla2xxx/qla_def.h |  1 +
 drivers/scsi/qla2xxx/qla_os.c  | 20 +++++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 25b884701267..2de5920126ca 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -4621,6 +4621,7 @@ struct qla_hw_data {
 	struct workqueue_struct *wq;
 	struct work_struct heartbeat_work;
 	struct qlfc_fw fw_buf;
+	unsigned long last_heartbeat_run_jiffies;
 
 	/* FCP_CMND priority support */
 	struct qla_fcp_prio_cfg *fcp_prio_cfg;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index d572a76d0fa0..89c7ac36a41a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -7218,7 +7218,7 @@ static bool qla_do_heartbeat(struct scsi_qla_host *vha)
 	return do_heartbeat;
 }
 
-static void qla_heart_beat(struct scsi_qla_host *vha)
+static void qla_heart_beat(struct scsi_qla_host *vha, u16 dpc_started)
 {
 	struct qla_hw_data *ha = vha->hw;
 
@@ -7228,8 +7228,19 @@ static void qla_heart_beat(struct scsi_qla_host *vha)
 	if (vha->hw->flags.eeh_busy || qla2x00_chip_is_down(vha))
 		return;
 
-	if (qla_do_heartbeat(vha))
+	/*
+	 * dpc thread cannot run if heartbeat is running at the same time.
+	 * We also do not want to starve heartbeat task. Therefore, do
+	 * heartbeat task at least once every 5 seconds.
+	 */
+	if (dpc_started &&
+	    time_before(jiffies, ha->last_heartbeat_run_jiffies + 5 * HZ))
+		return;
+
+	if (qla_do_heartbeat(vha)) {
+		ha->last_heartbeat_run_jiffies = jiffies;
 		queue_work(ha->wq, &ha->heartbeat_work);
+	}
 }
 
 /**************************************************************************
@@ -7420,6 +7431,8 @@ qla2x00_timer(struct timer_list *t)
 		start_dpc++;
 	}
 
+	/* borrowing w to signify dpc will run */
+	w = 0;
 	/* Schedule the DPC routine if needed */
 	if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
 	    test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
@@ -7452,9 +7465,10 @@ qla2x00_timer(struct timer_list *t)
 		    test_bit(RELOGIN_NEEDED, &vha->dpc_flags),
 		    test_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags));
 		qla2xxx_wake_dpc(vha);
+		w = 1;
 	}
 
-	qla_heart_beat(vha);
+	qla_heart_beat(vha, w);
 
 	qla2x00_restart_timer(vha, WATCH_INTERVAL);
 }
-- 
2.19.0.rc0


  parent reply	other threads:[~2022-03-10  9:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10  9:25 [PATCH v2 00/13] qla2xxx driver fixes Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 01/13] qla2xxx: Fix incorrect reporting of task management failure Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 02/13] qla2xxx: Fix disk failure to rediscover Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 03/13] qla2xxx: Fix loss of NVME namespaces after driver reload test Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 04/13] qla2xxx: Fix missed DMA unmap for NVME ls requests Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 05/13] qla2xxx: Fix crash during module load unload test Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 06/13] qla2xxx: fix n2n inconsistent plogi Nilesh Javali
2022-03-10  9:25 ` [PATCH v2 07/13] qla2xxx: Fix hang due to session stuck Nilesh Javali
2022-03-10  9:25 ` Nilesh Javali [this message]
2022-03-10  9:26 ` [PATCH v2 09/13] qla2xxx: reduce false trigger to login Nilesh Javali
2022-03-10  9:26 ` [PATCH v2 10/13] qla2xxx: Fix stuck session of prli reject Nilesh Javali
2022-03-10  9:26 ` [PATCH v2 11/13] qla2xxx: Use correct feature type field during rffid processing Nilesh Javali
2022-03-10  9:26 ` [PATCH v2 12/13] qla2xxx: Increase max limit of ql2xnvme_queues Nilesh Javali
2022-03-10  9:26 ` [PATCH v2 13/13] qla2xxx: Update version to 10.02.07.400-k Nilesh Javali
2022-03-15  4:29 ` [PATCH v2 00/13] qla2xxx driver fixes Martin K. Petersen
2022-03-19  3:57 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220310092604.22950-9-njavali@marvell.com \
    --to=njavali@marvell.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.