linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] qedf misc bug fixes
@ 2024-05-15  9:10 Saurav Kashyap
  2024-05-15  9:10 ` [PATCH v2 1/3] qedf: Don't process stag work during unload and recovery Saurav Kashyap
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Saurav Kashyap @ 2024-05-15  9:10 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, Saurav Kashyap

Hi Martin,

Please apply the qedf driver fixes to the
scsi tree at your earliest convenience.

Thanks,
Saurav

v1->v2:
- Merged uininitalize qedf warning patch.

Saurav Kashyap (3):
  qedf: Don't process stag work during unload and recovery.
  qedf: Wait for stag work during unload.
  qedf: Memset qed_slowpath_params to zero before use.

 drivers/scsi/qedf/qedf.h      |  1 +
 drivers/scsi/qedf/qedf_main.c | 47 ++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 3 deletions(-)

-- 
2.23.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] qedf: Don't process stag work during unload and recovery.
  2024-05-15  9:10 [PATCH v2 0/3] qedf misc bug fixes Saurav Kashyap
@ 2024-05-15  9:10 ` Saurav Kashyap
  2024-05-15  9:11 ` [PATCH v2 2/3] qedf: Wait for stag work during unload Saurav Kashyap
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Saurav Kashyap @ 2024-05-15  9:10 UTC (permalink / raw)
  To: martin.petersen
  Cc: GR-QLogic-Storage-Upstream, linux-scsi, Saurav Kashyap, Nilesh Javali

Stag work can cause issues during unload and recovery,
hence don't process it.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qedf/qedf_main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index a58353b7b4e8..e882aec86765 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3997,6 +3997,22 @@ void qedf_stag_change_work(struct work_struct *work)
 	struct qedf_ctx *qedf =
 	    container_of(work, struct qedf_ctx, stag_work.work);
 
+	if (!qedf) {
+		QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
+		return;
+	}
+
+	if (test_bit(QEDF_IN_RECOVERY, &qedf->flags)) {
+		QEDF_ERR(&qedf->dbg_ctx,
+			 "Already is in recovery, hence not calling software context reset.\n");
+		return;
+	}
+
+	if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
+		QEDF_ERR(&qedf->dbg_ctx, "Driver unloading\n");
+		return;
+	}
+
 	printk_ratelimited("[%s]:[%s:%d]:%d: Performing software context reset.",
 			dev_name(&qedf->pdev->dev), __func__, __LINE__,
 			qedf->dbg_ctx.host_no);
-- 
2.23.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] qedf: Wait for stag work during unload.
  2024-05-15  9:10 [PATCH v2 0/3] qedf misc bug fixes Saurav Kashyap
  2024-05-15  9:10 ` [PATCH v2 1/3] qedf: Don't process stag work during unload and recovery Saurav Kashyap
@ 2024-05-15  9:11 ` Saurav Kashyap
  2024-05-15  9:11 ` [PATCH v2 3/3] qedf: Memset qed_slowpath_params to zero before use Saurav Kashyap
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Saurav Kashyap @ 2024-05-15  9:11 UTC (permalink / raw)
  To: martin.petersen
  Cc: GR-QLogic-Storage-Upstream, linux-scsi, Saurav Kashyap, Nilesh Javali

If stag work is already schedule and unload is called, it can
lead to issues as unload cleanups the work element, wait for
stag work to get completed before cleanup during unload.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qedf/qedf.h      |  1 +
 drivers/scsi/qedf/qedf_main.c | 30 +++++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 5058e01b65a2..98afdfe63600 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -363,6 +363,7 @@ struct qedf_ctx {
 #define QEDF_IN_RECOVERY		5
 #define QEDF_DBG_STOP_IO		6
 #define QEDF_PROBING			8
+#define QEDF_STAG_IN_PROGRESS		9
 	unsigned long flags; /* Miscellaneous state flags */
 	int fipvlan_retries;
 	u8 num_queues;
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index e882aec86765..c98cc666e3e9 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -318,11 +318,18 @@ static struct fc_seq *qedf_elsct_send(struct fc_lport *lport, u32 did,
 	 */
 	if (resp == fc_lport_flogi_resp) {
 		qedf->flogi_cnt++;
+		qedf->flogi_pending++;
+
+		if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
+			QEDF_ERR(&qedf->dbg_ctx, "Driver unloading\n");
+			qedf->flogi_pending = 0;
+		}
+
 		if (qedf->flogi_pending >= QEDF_FLOGI_RETRY_CNT) {
 			schedule_delayed_work(&qedf->stag_work, 2);
 			return NULL;
 		}
-		qedf->flogi_pending++;
+
 		return fc_elsct_send(lport, did, fp, op, qedf_flogi_resp,
 		    arg, timeout);
 	}
@@ -912,13 +919,14 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
 	struct qedf_ctx *qedf;
 	struct qed_link_output if_link;
 
+	qedf = lport_priv(lport);
+
 	if (lport->vport) {
+		clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
 		printk_ratelimited("Cannot issue host reset on NPIV port.\n");
 		return;
 	}
 
-	qedf = lport_priv(lport);
-
 	qedf->flogi_pending = 0;
 	/* For host reset, essentially do a soft link up/down */
 	atomic_set(&qedf->link_state, QEDF_LINK_DOWN);
@@ -938,6 +946,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
 	if (!if_link.link_up) {
 		QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
 			  "Physical link is not up.\n");
+		clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
 		return;
 	}
 	/* Flush and wait to make sure link down is processed */
@@ -950,6 +959,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
 		  "Queue link up work.\n");
 	queue_delayed_work(qedf->link_update_wq, &qedf->link_update,
 	    0);
+	clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
 }
 
 /* Reset the host by gracefully logging out and then logging back in */
@@ -3721,6 +3731,7 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
 {
 	struct qedf_ctx *qedf;
 	int rc;
+	int cnt = 0;
 
 	if (!pdev) {
 		QEDF_ERR(NULL, "pdev is NULL.\n");
@@ -3738,6 +3749,17 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
 		return;
 	}
 
+stag_in_prog:
+	if (test_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags)) {
+		QEDF_ERR(&qedf->dbg_ctx, "Stag in progress, cnt=%d.\n", cnt);
+		cnt++;
+
+		if (cnt < 5) {
+			msleep(500);
+			goto stag_in_prog;
+		}
+	}
+
 	if (mode != QEDF_MODE_RECOVERY)
 		set_bit(QEDF_UNLOADING, &qedf->flags);
 
@@ -4013,6 +4035,8 @@ void qedf_stag_change_work(struct work_struct *work)
 		return;
 	}
 
+	set_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
+
 	printk_ratelimited("[%s]:[%s:%d]:%d: Performing software context reset.",
 			dev_name(&qedf->pdev->dev), __func__, __LINE__,
 			qedf->dbg_ctx.host_no);
-- 
2.23.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] qedf: Memset qed_slowpath_params to zero before use.
  2024-05-15  9:10 [PATCH v2 0/3] qedf misc bug fixes Saurav Kashyap
  2024-05-15  9:10 ` [PATCH v2 1/3] qedf: Don't process stag work during unload and recovery Saurav Kashyap
  2024-05-15  9:11 ` [PATCH v2 2/3] qedf: Wait for stag work during unload Saurav Kashyap
@ 2024-05-15  9:11 ` Saurav Kashyap
  2024-05-15 14:27 ` [PATCH v2 0/3] qedf misc bug fixes Martin K. Petersen
  2024-05-21  2:40 ` Martin K. Petersen
  4 siblings, 0 replies; 6+ messages in thread
From: Saurav Kashyap @ 2024-05-15  9:11 UTC (permalink / raw)
  To: martin.petersen
  Cc: GR-QLogic-Storage-Upstream, linux-scsi, Saurav Kashyap, Nilesh Javali

- Memset qed_slowpath_params to zero before use.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qedf/qedf_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index c98cc666e3e9..b97a8712d3f6 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3473,6 +3473,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	}
 
 	/* Start the Slowpath-process */
+	memset(&slowpath_params, 0, sizeof(struct qed_slowpath_params));
 	slowpath_params.int_mode = QED_INT_MODE_MSIX;
 	slowpath_params.drv_major = QEDF_DRIVER_MAJOR_VER;
 	slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;
-- 
2.23.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/3] qedf misc bug fixes
  2024-05-15  9:10 [PATCH v2 0/3] qedf misc bug fixes Saurav Kashyap
                   ` (2 preceding siblings ...)
  2024-05-15  9:11 ` [PATCH v2 3/3] qedf: Memset qed_slowpath_params to zero before use Saurav Kashyap
@ 2024-05-15 14:27 ` Martin K. Petersen
  2024-05-21  2:40 ` Martin K. Petersen
  4 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2024-05-15 14:27 UTC (permalink / raw)
  To: Saurav Kashyap; +Cc: martin.petersen, GR-QLogic-Storage-Upstream, linux-scsi


Saurav,

> Please apply the qedf driver fixes to the scsi tree at your earliest
> convenience.

Applied to 6.10/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/3] qedf misc bug fixes
  2024-05-15  9:10 [PATCH v2 0/3] qedf misc bug fixes Saurav Kashyap
                   ` (3 preceding siblings ...)
  2024-05-15 14:27 ` [PATCH v2 0/3] qedf misc bug fixes Martin K. Petersen
@ 2024-05-21  2:40 ` Martin K. Petersen
  4 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2024-05-21  2:40 UTC (permalink / raw)
  To: Saurav Kashyap
  Cc: Martin K . Petersen, GR-QLogic-Storage-Upstream, linux-scsi

On Wed, 15 May 2024 14:40:58 +0530, Saurav Kashyap wrote:

> Please apply the qedf driver fixes to the
> scsi tree at your earliest convenience.
> 
> Thanks,
> Saurav
> 
> v1->v2:
> - Merged uininitalize qedf warning patch.
> 
> [...]

Applied to 6.10/scsi-queue, thanks!

[1/3] qedf: Don't process stag work during unload and recovery.
      https://git.kernel.org/mkp/scsi/c/51071f0831ea
[2/3] qedf: Wait for stag work during unload.
      https://git.kernel.org/mkp/scsi/c/78e88472b609
[3/3] qedf: Memset qed_slowpath_params to zero before use.
      https://git.kernel.org/mkp/scsi/c/6c3bb589debd

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-21  2:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  9:10 [PATCH v2 0/3] qedf misc bug fixes Saurav Kashyap
2024-05-15  9:10 ` [PATCH v2 1/3] qedf: Don't process stag work during unload and recovery Saurav Kashyap
2024-05-15  9:11 ` [PATCH v2 2/3] qedf: Wait for stag work during unload Saurav Kashyap
2024-05-15  9:11 ` [PATCH v2 3/3] qedf: Memset qed_slowpath_params to zero before use Saurav Kashyap
2024-05-15 14:27 ` [PATCH v2 0/3] qedf misc bug fixes Martin K. Petersen
2024-05-21  2:40 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).