Skip to contentSkip to conversation

qla2xxx: Add qla2x00_async_done routine for async routines.

PATCH Applied Nilesh Javali 5 participants 6 messages Feb 8, 2022 – Feb 15, 2022

Subsystems (2)
lore
Share & tools
lore

Nilesh Javali

author maintainer
#0 lore raw

PATCH 1/1 qla2xxx: Add qla2x00_async_done routine for async routines.

From: Saurav Kashyap <[email protected]>

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")
---
 drivers/scsi/qla2xxx/qla_iocb.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_iocb.c +16 -1
index 7dd82214d59f..5e3ee1f7b43c 100644
@@ -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;
Signature · 1 line
2.23.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Nilesh Javali

From: Saurav Kashyap <[email protected]>

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")

FYI… You should add

Quoted 42 lines

---
drivers/scsi/qla2xxx/qla_iocb.c | 17 ++++++++++++++++-

1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_iocb.c +14 -0
index 7dd82214d59f..5e3ee1f7b43c 100644
@@ -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)
{

drivers/scsi/qla2xxx/qla_iocb.c +2 -1
@@ -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;
Signature · 1 line
2.23.1

Looks Good.

--
Himanshu Madhani Oracle Linux Engineering

Tested-by on v1 1/1
#2 lore raw
In reply to Nilesh Javali

Thanks, that appears to have resolved the crash on boot I was seeing.

Quoted 51 lines · Nilesh Javali

From: Saurav Kashyap <[email protected]>

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")
---
 drivers/scsi/qla2xxx/qla_iocb.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_iocb.c +16 -2
index 7dd82214d59f..5e3ee1f7b43c 100644
@@ -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;
--

2.23.1

#3 lore raw

Hi Ewan,
Thanks a lot for an update.

Hi Martin,
Can this be merged to original patch?

Fixes 31e6cdbe0eae ("scsi: qla2xxx: Implement ref count for SRB")

Thanks,
~Saurav

Quoted 68 lines

-----Original Message-----
From: Ewan Milne <[email protected]>
Sent: Thursday, February 10, 2022 1:39 AM
To: Nilesh Javali <[email protected]>
Cc: Martin K. Petersen <[email protected]>; linux- [email protected]; GR-QLogic-Storage-Upstream <GR-QLogic-Storage- [email protected]>
Subject: Re: [PATCH] qla2xxx: Add qla2x00_async_done routine for async routines.

Thanks, that appears to have resolved the crash on boot I was seeing.

drivers/scsi/qla2xxx/qla_iocb.c qla24xx_tm_iocb(srb_t *sp, struct

Quoted 18 lines · Nilesh Javali

From: Saurav Kashyap <[email protected]>

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")
---
 drivers/scsi/qla2xxx/qla_iocb.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_iocb.c +0 -0
index 7dd82214d59f..5e3ee1f7b43c 100644
@@ -2560,6 +2560,20 @@ qla24xx_tm_iocb(srb_t *sp, struct

tsk_mgmt_entry *tsk)

drivers/scsi/qla2xxx/qla_iocb.c qla2x00_init_async_sp(srb_t *sp, unsigned long

Quoted 21 lines
drivers/scsi/qla2xxx/qla_iocb.c +14 -0
        }
 }
 
+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,

Quoted 12 lines
drivers/scsi/qla2xxx/qla_iocb.c +2 -2
                     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;
--

2.23.1

#4 lore raw
In reply to Nilesh Javali

Nilesh,

Quoted 2 lines

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-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering