diff mbox series

qla2xxx: Add qla2x00_async_done routine for async routines.

Message ID 20220208093946.4471-1-njavali@marvell.com
State New
Headers show
Series qla2xxx: Add qla2x00_async_done routine for async routines. | expand

Commit Message

Nilesh Javali Feb. 8, 2022, 9:39 a.m. UTC
From: Saurav Kashyap <skashyap@marvell.com>

This done routine will delete the timer and check for it's return
value and accordingly decrease the reference count.

Fixes: 31e6cdbe0eae ("scsi: qla2xxx: Implement ref count for SRB")
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_iocb.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Martin K. Petersen Feb. 15, 2022, 3:19 a.m. UTC | #1
On Tue, 8 Feb 2022 01:39:46 -0800, Nilesh Javali wrote:

> From: Saurav Kashyap <skashyap@marvell.com>
> 
> This done routine will delete the timer and check for it's return
> value and accordingly decrease the reference count.
> 
> 

Applied to 5.18/scsi-queue, thanks!

[1/1] qla2xxx: Add qla2x00_async_done routine for async routines.
      https://git.kernel.org/mkp/scsi/c/49b729f58e7a
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 7dd82214d59f..5e3ee1f7b43c 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2560,6 +2560,20 @@  qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk)
 	}
 }
 
+static void
+qla2x00_async_done(struct srb *sp, int res)
+{
+	if (del_timer(&sp->u.iocb_cmd.timer)) {
+		/*
+		 * Successfully cancelled the timeout handler
+		 * ref: TMR
+		 */
+		if (kref_put(&sp->cmd_kref, qla2x00_sp_release))
+			return;
+	}
+	sp->async_done(sp, res);
+}
+
 void
 qla2x00_sp_release(struct kref *kref)
 {
@@ -2573,7 +2587,8 @@  qla2x00_init_async_sp(srb_t *sp, unsigned long tmo,
 		     void (*done)(struct srb *sp, int res))
 {
 	timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0);
-	sp->done = done;
+	sp->done = qla2x00_async_done;
+	sp->async_done = done;
 	sp->free = qla2x00_sp_free;
 	sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
 	sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ;