All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qedf: Added the synchronization between IO completions and abort.
@ 2023-09-01  6:06 Saurav Kashyap
  2023-09-05  9:58 ` Martin K. Petersen
  2023-09-14  1:40 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Saurav Kashyap @ 2023-09-01  6:06 UTC (permalink / raw)
  To: martin.petersen; +Cc: linux-scsi, njavali

From: Javed Hasan <jhasan@marvell.com>

This fix is added to avoid the race condition between IO completion and
abort process by protecting the cmd_type with the lock.

Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf_io.c   | 10 ++++++++--
 drivers/scsi/qedf/qedf_main.c |  7 ++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 4750ec5789a8..10fe3383855c 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1904,6 +1904,7 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts)
 		goto drop_rdata_kref;
 	}
 
+	spin_lock_irqsave(&fcport->rport_lock, flags);
 	if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) ||
 	    test_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags) ||
 	    test_bit(QEDF_CMD_IN_ABORT, &io_req->flags)) {
@@ -1911,17 +1912,20 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts)
 			 "io_req xid=0x%x sc_cmd=%p already in cleanup or abort processing or already completed.\n",
 			 io_req->xid, io_req->sc_cmd);
 		rc = 1;
+		spin_unlock_irqrestore(&fcport->rport_lock, flags);
 		goto drop_rdata_kref;
 	}
 
+	/* Set the command type to abort */
+	io_req->cmd_type = QEDF_ABTS;
+	spin_unlock_irqrestore(&fcport->rport_lock, flags);
+
 	kref_get(&io_req->refcount);
 
 	xid = io_req->xid;
 	qedf->control_requests++;
 	qedf->packet_aborts++;
 
-	/* Set the command type to abort */
-	io_req->cmd_type = QEDF_ABTS;
 	io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts;
 
 	set_bit(QEDF_CMD_IN_ABORT, &io_req->flags);
@@ -2210,7 +2214,9 @@ int qedf_initiate_cleanup(struct qedf_ioreq *io_req,
 		  refcount, fcport, fcport->rdata->ids.port_id);
 
 	/* Cleanup cmds re-use the same TID as the original I/O */
+	spin_lock_irqsave(&fcport->rport_lock, flags);
 	io_req->cmd_type = QEDF_CLEANUP;
+	spin_unlock_irqrestore(&fcport->rport_lock, flags);
 	io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts;
 
 	init_completion(&io_req->cleanup_done);
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 2a31ddc99dde..b5202026b0b9 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2804,6 +2804,8 @@ void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe)
 	struct qedf_ioreq *io_req;
 	struct qedf_rport *fcport;
 	u32 comp_type;
+	u8 io_comp_type;
+	unsigned long flags;
 
 	comp_type = (cqe->cqe_data >> FCOE_CQE_CQE_TYPE_SHIFT) &
 	    FCOE_CQE_CQE_TYPE_MASK;
@@ -2837,11 +2839,14 @@ void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe)
 		return;
 	}
 
+	spin_lock_irqsave(&fcport->rport_lock, flags);
+	io_comp_type = io_req->cmd_type;
+	spin_unlock_irqrestore(&fcport->rport_lock, flags);
 
 	switch (comp_type) {
 	case FCOE_GOOD_COMPLETION_CQE_TYPE:
 		atomic_inc(&fcport->free_sqes);
-		switch (io_req->cmd_type) {
+		switch (io_comp_type) {
 		case QEDF_SCSI_CMD:
 			qedf_scsi_completion(qedf, cqe, io_req);
 			break;
-- 
2.23.1


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

* Re: [PATCH] qedf: Added the synchronization between IO completions and abort.
  2023-09-01  6:06 [PATCH] qedf: Added the synchronization between IO completions and abort Saurav Kashyap
@ 2023-09-05  9:58 ` Martin K. Petersen
  2023-09-14  1:40 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-09-05  9:58 UTC (permalink / raw)
  To: Saurav Kashyap; +Cc: martin.petersen, linux-scsi, njavali


Saurav,

> This fix is added to avoid the race condition between IO completion
> and abort process by protecting the cmd_type with the lock.

Applied to 6.6/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] qedf: Added the synchronization between IO completions and abort.
  2023-09-01  6:06 [PATCH] qedf: Added the synchronization between IO completions and abort Saurav Kashyap
  2023-09-05  9:58 ` Martin K. Petersen
@ 2023-09-14  1:40 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-09-14  1:40 UTC (permalink / raw)
  To: Saurav Kashyap; +Cc: Martin K . Petersen, linux-scsi, njavali

On Fri, 01 Sep 2023 11:36:46 +0530, Saurav Kashyap wrote:

> This fix is added to avoid the race condition between IO completion and
> abort process by protecting the cmd_type with the lock.
> 
> 

Applied to 6.6/scsi-fixes, thanks!

[1/1] qedf: Added the synchronization between IO completions and abort.
      https://git.kernel.org/mkp/scsi/c/7df0b2605489

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2023-09-14  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01  6:06 [PATCH] qedf: Added the synchronization between IO completions and abort Saurav Kashyap
2023-09-05  9:58 ` Martin K. Petersen
2023-09-14  1:40 ` Martin K. Petersen

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.