diff mbox series

[v3,2/5] scsi: qla2xxx: check UNLOADING before posting async work

Message ID 20200327164711.5358-3-mwilck@suse.com (mailing list archive)
State Superseded
Headers show
Series scsi: qla2xxx: fixes for driver unloading | expand

Commit Message

Martin Wilck March 27, 2020, 4:47 p.m. UTC
From: Martin Wilck <mwilck@suse.com>

qlt_free_session_done() tries to post async PRLO / LOGO, and
waits for the completion of these async commands. If UNLOADING
is set, this is doomed to timeout, because the async logout
command will never complete.

The only way to avoid waiting pointlessly is to fail posting
these commands in the first place if the driver is in UNLOADING state.
In general, posting any command should be avoided when the driver
is UNLOADING.

With this patch, "rmmod qla2xxx" completes without noticeable delay.

Fixes: 45235022da99 ("scsi: qla2xxx: Fix driver unload by shutting down chip")
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 drivers/scsi/qla2xxx/qla_os.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Arun Easi April 1, 2020, 5:04 p.m. UTC | #1
On Fri, 27 Mar 2020, 9:47am, mwilck@suse.com wrote:

> From: Martin Wilck <mwilck@suse.com>
> 
> qlt_free_session_done() tries to post async PRLO / LOGO, and
> waits for the completion of these async commands. If UNLOADING
> is set, this is doomed to timeout, because the async logout
> command will never complete.
> 
> The only way to avoid waiting pointlessly is to fail posting
> these commands in the first place if the driver is in UNLOADING state.
> In general, posting any command should be avoided when the driver
> is UNLOADING.
> 
> With this patch, "rmmod qla2xxx" completes without noticeable delay.
> 
> Fixes: 45235022da99 ("scsi: qla2xxx: Fix driver unload by shutting down chip")
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  drivers/scsi/qla2xxx/qla_os.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index ce0dabb..eb25cf5 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -4933,6 +4933,9 @@ int qla2x00_post_async_##name##_work(		\
>  {						\
>  	struct qla_work_evt *e;			\
>  						\
> +	if (test_bit(UNLOADING, &vha->dpc_flags)) \
> +		return QLA_FUNCTION_FAILED;	\
> +						\

Martin,

Could you move this check to qla2x00_alloc_work() so that other callers of 
qla2x00_alloc_work() can also benefit.

Regards,
-Arun

>  	e = qla2x00_alloc_work(vha, type);	\
>  	if (!e)					\
>  		return QLA_FUNCTION_FAILED;	\
>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index ce0dabb..eb25cf5 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4933,6 +4933,9 @@  int qla2x00_post_async_##name##_work(		\
 {						\
 	struct qla_work_evt *e;			\
 						\
+	if (test_bit(UNLOADING, &vha->dpc_flags)) \
+		return QLA_FUNCTION_FAILED;	\
+						\
 	e = qla2x00_alloc_work(vha, type);	\
 	if (!e)					\
 		return QLA_FUNCTION_FAILED;	\