All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <himanshu.madhani@cavium.com>
To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com
Cc: himanshu.madhani@cavium.com, linux-scsi@vger.kernel.org
Subject: [PATCH 11/43] qla2xxx: Move work element processing out of DPC thread
Date: Tue, 19 Dec 2017 22:56:12 -0800	[thread overview]
Message-ID: <20171220065644.21511-12-himanshu.madhani@cavium.com> (raw)
In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com>

From: Quinn Tran <quinn.tran@cavium.com>

DPC thread can stall during switch scan due to slow switch response.
This will stall other work element that needs attention. Moving work
element processing and relogin logic out of DPC thread and into its
own work queue.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
---
 drivers/scsi/qla2xxx/qla_def.h  |  6 ++--
 drivers/scsi/qla2xxx/qla_gbl.h  |  2 +-
 drivers/scsi/qla2xxx/qla_init.c |  1 +
 drivers/scsi/qla2xxx/qla_mid.c  |  6 +---
 drivers/scsi/qla2xxx/qla_os.c   | 76 +++++++++++++++++++++++++++++++----------
 5 files changed, 63 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 18b393453002..a2c0f3d78b35 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3183,6 +3183,7 @@ enum qla_work_type {
 	QLA_EVT_UPD_FCPORT,
 	QLA_EVT_GNL,
 	QLA_EVT_NACK,
+	QLA_EVT_RELOGIN,
 };
 
 
@@ -3513,10 +3514,6 @@ struct qlt_hw_data {
 
 #define LEAK_EXCHG_THRESH_HOLD_PERCENT 75	/* 75 percent */
 
-#define QLA_EARLY_LINKUP(_ha) \
-	((_ha->flags.n2n_ae || _ha->flags.lip_ae) && \
-	 _ha->flags.fw_started && !_ha->flags.fw_init_done)
-
 /*
  * Qlogic host adapter specific data structure.
 */
@@ -4222,6 +4219,7 @@ typedef struct scsi_qla_host {
 #define SET_ZIO_THRESHOLD_NEEDED	28
 #define DETECT_SFP_CHANGE	29
 #define N2N_LOGIN_NEEDED	30
+#define IOCB_WORK_ACTIVE	31
 
 	unsigned long	pci_flags;
 #define PFLG_DISCONNECTED	0	/* PCI device removed */
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 66dcbdb91244..fb1c9ffdc05a 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -204,7 +204,7 @@ void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
 	uint16_t *);
 int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *);
 int qla24xx_async_abort_cmd(srb_t *);
-
+int qla24xx_post_relogin_work(struct scsi_qla_host *vha);
 /*
  * Global Functions in qla_mid.c source file.
  */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 0a1c287c2d66..61b74fd220a3 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -901,6 +901,7 @@ void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea)
 		    __func__, fcport->port_name, fcport->last_rscn_gen,
 		    fcport->rscn_gen, fcport->last_login_gen,
 		    fcport->login_gen);
+		set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
 		return;
 	} else if (ea->sp->gen1 != fcport->rscn_gen) {
 		ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n",
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index fc61fef5e305..b2fda398a098 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -319,8 +319,6 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
 	ql_dbg(ql_dbg_dpc + ql_dbg_verbose, vha, 0x4012,
 	    "Entering %s vp_flags: 0x%lx.\n", __func__, vha->vp_flags);
 
-	qla2x00_do_work(vha);
-
 	/* Check if Fw is ready to configure VP first */
 	if (test_bit(VP_CONFIG_OK, &base_vha->vp_flags)) {
 		if (test_and_clear_bit(VP_IDX_ACQUIRED, &vha->vp_flags)) {
@@ -354,9 +352,7 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
 
 			ql_dbg(ql_dbg_dpc, vha, 0x4018,
 			    "Relogin needed scheduled.\n");
-			qla2x00_relogin(vha);
-			ql_dbg(ql_dbg_dpc, vha, 0x4019,
-			    "Relogin needed end.\n");
+			qla24xx_post_relogin_work(vha);
 		}
 	}
 
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 4a542a5a976d..66e6fe73a035 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2683,14 +2683,22 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)
 {
 	struct scsi_qla_host *vha = container_of(work,
 		struct scsi_qla_host, iocb_work);
-	int cnt = 0;
+	struct qla_hw_data *ha = vha->hw;
+	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
+	int i = 20;
+	unsigned long flags;
+
+	if (test_bit(UNLOADING, &base_vha->dpc_flags))
+		return;
 
-	while (!list_empty(&vha->work_list)) {
+	while (!list_empty(&vha->work_list) && i > 0) {
 		qla2x00_do_work(vha);
-		cnt++;
-		if (cnt > 10)
-			break;
+		i--;
 	}
+
+	spin_lock_irqsave(&vha->work_lock, flags);
+	clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags);
+	spin_unlock_irqrestore(&vha->work_lock, flags);
 }
 
 /*
@@ -3192,7 +3200,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	    host->can_queue, base_vha->req,
 	    base_vha->mgmt_svr_loop_id, host->sg_tablesize);
 
-	ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 0);
+	ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0);
 
 	if (ha->mqenable) {
 		bool mq = false;
@@ -4544,6 +4552,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
 	INIT_LIST_HEAD(&vha->gnl.fcports);
 	INIT_LIST_HEAD(&vha->nvme_rport_list);
 	INIT_LIST_HEAD(&vha->gpnid_list);
+	INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn);
 
 	spin_lock_init(&vha->work_lock);
 	spin_lock_init(&vha->cmd_list_lock);
@@ -4596,15 +4605,18 @@ int
 qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e)
 {
 	unsigned long flags;
+	bool q = false;
 
 	spin_lock_irqsave(&vha->work_lock, flags);
 	list_add_tail(&e->list, &vha->work_list);
+
+	if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags))
+		q = true;
+
 	spin_unlock_irqrestore(&vha->work_lock, flags);
 
-	if (QLA_EARLY_LINKUP(vha->hw))
-		schedule_work(&vha->iocb_work);
-	else
-		qla2xxx_wake_dpc(vha);
+	if (q)
+		queue_work(vha->hw->wq, &vha->iocb_work);
 
 	return QLA_SUCCESS;
 }
@@ -4736,6 +4748,9 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
 		fcport->d_id = e->u.new_sess.id;
 		if (pla) {
 			fcport->fw_login_state = DSC_LS_PLOGI_PEND;
+			memcpy(fcport->node_name,
+			    pla->iocb.u.isp24.u.plogi.node_name,
+			    WWN_SIZE);
 			qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN);
 			/* we took an extra ref_count to prevent PLOGI ACK when
 			 * fcport/sess has not been created.
@@ -4886,6 +4901,9 @@ qla2x00_do_work(struct scsi_qla_host *vha)
 		case QLA_EVT_GPNID_DONE:
 			qla24xx_async_gpnid_done(vha, e->u.iosb.sp);
 			break;
+		case QLA_EVT_RELOGIN:
+			qla2x00_relogin(vha);
+			break;
 		case QLA_EVT_NEW_SESS:
 			qla24xx_create_new_sess(vha, e);
 			break;
@@ -4917,6 +4935,20 @@ qla2x00_do_work(struct scsi_qla_host *vha)
 	}
 }
 
+int qla24xx_post_relogin_work(struct scsi_qla_host *vha)
+{
+	struct qla_work_evt *e;
+
+	e = qla2x00_alloc_work(vha, QLA_EVT_RELOGIN);
+
+	if (!e) {
+		set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+		return QLA_FUNCTION_FAILED;
+	}
+
+	return qla2x00_post_work(vha, e);
+}
+
 /* Relogins all the fcports of a vport
  * Context: dpc thread
  */
@@ -4972,6 +5004,9 @@ void qla2x00_relogin(struct scsi_qla_host *vha)
 		if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
 			break;
 	}
+
+	ql_dbg(ql_dbg_disc, vha, 0x400e,
+	    "Relogin end.\n");
 }
 
 /* Schedule work on any of the dpc-workqueues */
@@ -5747,8 +5782,6 @@ qla2x00_do_dpc(void *data)
 		if (test_bit(UNLOADING, &base_vha->dpc_flags))
 			break;
 
-		qla2x00_do_work(base_vha);
-
 		if (IS_P3P_TYPE(ha)) {
 			if (IS_QLA8044(ha)) {
 				if (test_and_clear_bit(ISP_UNRECOVERABLE,
@@ -5936,11 +5969,9 @@ qla2x00_do_dpc(void *data)
 				base_vha->relogin_jif = jiffies + HZ;
 				clear_bit(RELOGIN_NEEDED, &base_vha->dpc_flags);
 
-				ql_dbg(ql_dbg_dpc, base_vha, 0x400d,
+				ql_dbg(ql_dbg_disc, base_vha, 0x400d,
 				    "Relogin scheduled.\n");
-				qla2x00_relogin(base_vha);
-				ql_dbg(ql_dbg_dpc, base_vha, 0x400e,
-				    "Relogin end.\n");
+				qla24xx_post_relogin_work(base_vha);
 			}
 		}
 loop_resync_check:
@@ -6200,8 +6231,17 @@ qla2x00_timer(struct timer_list *t)
 	}
 
 	/* Process any deferred work. */
-	if (!list_empty(&vha->work_list))
-		start_dpc++;
+	if (!list_empty(&vha->work_list)) {
+		unsigned long flags;
+		bool q = false;
+
+		spin_lock_irqsave(&vha->work_lock, flags);
+		if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags))
+			q = true;
+		spin_unlock_irqrestore(&vha->work_lock, flags);
+		if (q)
+			queue_work(vha->hw->wq, &vha->iocb_work);
+	}
 
 	/*
 	 * FC-NVME
-- 
2.12.0

  parent reply	other threads:[~2017-12-20  6:57 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20  6:56 [PATCH 00/43] qla2xxx: Driver update Himanshu Madhani
2017-12-20  6:56 ` [PATCH 01/43] qla2xxx: Fix stale memory access for name pointer Himanshu Madhani
2017-12-20 16:25   ` Bart Van Assche
2017-12-20 20:37     ` Madhani, Himanshu
2017-12-21  5:26   ` kbuild test robot
2017-12-21  5:26   ` [RFC PATCH] qla2xxx: sp_str[] can be static kbuild test robot
2017-12-20  6:56 ` [PATCH 02/43] qla2xxx: Fix NULL pointer access for fcport structure Himanshu Madhani
2017-12-20 16:26   ` Bart Van Assche
2017-12-20 20:38     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 03/43] qla2xxx: Use IOCB path to submit Control VP MBX command Himanshu Madhani
2017-12-20 16:29   ` Bart Van Assche
2017-12-20 20:39     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 04/43] qla2xxx: Use chip reset to bring down laser on unload Himanshu Madhani
2017-12-20  6:56 ` [PATCH 05/43] qla2xxx: Add boundary checks for exchanges to be offloaded Himanshu Madhani
2017-12-20  6:56 ` [PATCH 06/43] qla2xxx: Fix stale mem access for IRQ name Himanshu Madhani
2017-12-20 16:39   ` Bart Van Assche
2017-12-20 20:41     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 07/43] qla2xxx: Add ability to track IOCB resource for FW Himanshu Madhani
2017-12-20 16:51   ` Bart Van Assche
2017-12-20 20:57     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 08/43] qla2xxx: Chip reset uses wrong lock during IO flush Himanshu Madhani
2017-12-20  6:56 ` [PATCH 09/43] qla2xxx: Fix Firmware dump size for Extended login and Exchange Offload Himanshu Madhani
2017-12-20  6:56 ` [PATCH 10/43] qla2xxx: Replace GPDB with async ADISC command Himanshu Madhani
2017-12-20  6:56 ` Himanshu Madhani [this message]
2017-12-20  6:56 ` [PATCH 12/43] qla2xxx: Enable ATIO interrupt handshake for ISP27XX Himanshu Madhani
2017-12-20  6:56 ` [PATCH 13/43] qla2xxx: Use shadow register " Himanshu Madhani
2017-12-20  6:56 ` [PATCH 14/43] qla2xxx: Add option for use reserve exch for ELS Himanshu Madhani
2017-12-20 16:53   ` Bart Van Assche
2017-12-20 21:40     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 15/43] qla2xxx: Add ability to send PRLO Himanshu Madhani
2017-12-20  6:56 ` [PATCH 16/43] qla2xxx: Don't call dma_free_coherent with IRQ disabled Himanshu Madhani
2017-12-20  6:56 ` [PATCH 17/43] qla2xxx: Allow target mode to accept PRLI in dual mode Himanshu Madhani
2017-12-20  6:56 ` [PATCH 18/43] qla2xxx: Tweak resource count dump Himanshu Madhani
2017-12-20  6:56 ` [PATCH 19/43] qla2xxx: Fix session cleanup for N2N Himanshu Madhani
2017-12-21  6:01   ` kbuild test robot
2017-12-20  6:56 ` [PATCH 20/43] qla2xxx: Use known NPort ID for Management Server login Himanshu Madhani
2017-12-20  6:56 ` [PATCH 21/43] qla2xxx: Remove calling cancel_work_sync() Himanshu Madhani
2017-12-20 16:56   ` Bart Van Assche
2017-12-20 21:41     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 22/43] qla2xxx: Add switch command to simplify fabric discovery Himanshu Madhani
2017-12-20 18:09   ` Ewan D. Milne
2017-12-21  0:04     ` Madhani, Himanshu
2017-12-20  6:56 ` [PATCH 23/43] qla2xxx: Add lock protection around host lookup Himanshu Madhani
2017-12-20  6:56 ` [PATCH 24/43] qla2xxx: Reduce the use of terminate exchange Himanshu Madhani
2017-12-20  6:56 ` [PATCH 25/43] qla2xxx: Reduce trace noise for Async Events Himanshu Madhani
2017-12-20  6:56 ` [PATCH 26/43] qla2xxx: Fix login state machine freeze Himanshu Madhani
2017-12-20  6:56 ` [PATCH 27/43] qla2xxx: Migrate switch registration commands away from mailbox interface Himanshu Madhani
2017-12-20  6:56 ` [PATCH 28/43] qla2xxx: Remove session creation redundant code Himanshu Madhani
2017-12-20  6:56 ` [PATCH 29/43] qla2xxx: Fix GPNFT/GNNFT error handling Himanshu Madhani
2017-12-20  6:56 ` [PATCH 30/43] qla2xxx: Properly extract ADISC error codes Himanshu Madhani
2017-12-20  6:56 ` [PATCH 31/43] qla2xxx: Add ability to use GPNFT/GNNFT for RSCN handling Himanshu Madhani
2017-12-20  6:56 ` [PATCH 32/43] qla2xxx: Allow relogin and session creation after reset Himanshu Madhani
2017-12-20  6:56 ` [PATCH 33/43] qla2xxx: Increase verbosity of debug messages logged Himanshu Madhani
2017-12-20  6:56 ` [PATCH 34/43] qla2xxx: Delay loop id allocation at login Himanshu Madhani
2017-12-20  6:56 ` [PATCH 35/43] qla2xxx: Add retry limit for fabric scan logic Himanshu Madhani
2017-12-20  6:56 ` [PATCH 36/43] qla2xxx: Add counters for Exchange Buffer to debugfs Himanshu Madhani
2017-12-20  6:56 ` [PATCH 37/43] qla2xxx: Prevent multiple active discovery commands per session Himanshu Madhani
2017-12-20  6:56 ` [PATCH 38/43] qla2xxx: Prevent relogin trigger from sending too many commands Himanshu Madhani
2017-12-20  6:56 ` [PATCH 39/43] qla2xxx: Check FCF_ASYNC_SENT flag Himanshu Madhani
2017-12-20  6:56 ` [PATCH 40/43] qla2xxx: Remove unused argument from qlt_schedule_sess_for_deletion() Himanshu Madhani
2017-12-20  6:56 ` [PATCH 41/43] qla2xxx: Serialize session deletion by using work_lock Himanshu Madhani
2017-12-20  6:56 ` [PATCH 42/43] qla2xxx: Serialize session free in qlt_free_session_done Himanshu Madhani
2017-12-20  6:56 ` [PATCH 43/43] qla2xxx: Update driver version to 10.00.00.04-k Himanshu Madhani

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=20171220065644.21511-12-himanshu.madhani@cavium.com \
    --to=himanshu.madhani@cavium.com \
    --cc=James.Bottomley@HansenPartnership.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.