Commit fa83e658 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: qla2xxx: ensure async flags are reset correctly

The fcport flags FCF_ASYNC_ACTIVE and FCF_ASYNC_SENT are used to
throttle the state machine, so we need to ensure to always set and unset
them correctly. Not doing so will lead to the state machine getting
confused and no login attempt into remote ports.

Cc: Quinn Tran <quinn.tran@cavium.com>
Cc: Himanshu Madhani <himanshu.madhani@cavium.com>
Fixes: 3dbec59b ("scsi: qla2xxx: Prevent multiple active discovery commands per session")
Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Acked-by: default avatarHimanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 07ea4b60
...@@ -3179,6 +3179,7 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3179,6 +3179,7 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport)
sp->free(sp); sp->free(sp);
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done: done:
fcport->flags &= ~FCF_ASYNC_ACTIVE;
return rval; return rval;
} }
...@@ -3370,6 +3371,7 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport) ...@@ -3370,6 +3371,7 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport)
sp->free(sp); sp->free(sp);
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done: done:
fcport->flags &= ~FCF_ASYNC_ACTIVE;
return rval; return rval;
} }
......
...@@ -213,6 +213,7 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -213,6 +213,7 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
sp->free(sp); sp->free(sp);
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~FCF_ASYNC_SENT;
done: done:
fcport->flags &= ~FCF_ASYNC_ACTIVE;
return rval; return rval;
} }
...@@ -263,7 +264,7 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -263,7 +264,7 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done: done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
return rval; return rval;
} }
...@@ -271,6 +272,7 @@ void ...@@ -271,6 +272,7 @@ void
qla2x00_async_prlo_done(struct scsi_qla_host *vha, fc_port_t *fcport, qla2x00_async_prlo_done(struct scsi_qla_host *vha, fc_port_t *fcport,
uint16_t *data) uint16_t *data)
{ {
fcport->flags &= ~FCF_ASYNC_ACTIVE;
/* Don't re-login in target mode */ /* Don't re-login in target mode */
if (!fcport->tgt_session) if (!fcport->tgt_session)
qla2x00_mark_device_lost(vha, fcport, 1, 0); qla2x00_mark_device_lost(vha, fcport, 1, 0);
...@@ -284,6 +286,7 @@ qla2x00_async_prlo_sp_done(void *s, int res) ...@@ -284,6 +286,7 @@ qla2x00_async_prlo_sp_done(void *s, int res)
struct srb_iocb *lio = &sp->u.iocb_cmd; struct srb_iocb *lio = &sp->u.iocb_cmd;
struct scsi_qla_host *vha = sp->vha; struct scsi_qla_host *vha = sp->vha;
sp->fcport->flags &= ~FCF_ASYNC_ACTIVE;
if (!test_bit(UNLOADING, &vha->dpc_flags)) if (!test_bit(UNLOADING, &vha->dpc_flags))
qla2x00_post_async_prlo_done_work(sp->fcport->vha, sp->fcport, qla2x00_post_async_prlo_done_work(sp->fcport->vha, sp->fcport,
lio->u.logio.data); lio->u.logio.data);
...@@ -322,6 +325,7 @@ qla2x00_async_prlo(struct scsi_qla_host *vha, fc_port_t *fcport) ...@@ -322,6 +325,7 @@ qla2x00_async_prlo(struct scsi_qla_host *vha, fc_port_t *fcport)
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done: done:
fcport->flags &= ~FCF_ASYNC_ACTIVE;
return rval; return rval;
} }
...@@ -375,6 +379,8 @@ qla2x00_async_adisc_sp_done(void *ptr, int res) ...@@ -375,6 +379,8 @@ qla2x00_async_adisc_sp_done(void *ptr, int res)
"Async done-%s res %x %8phC\n", "Async done-%s res %x %8phC\n",
sp->name, res, sp->fcport->port_name); sp->name, res, sp->fcport->port_name);
sp->fcport->flags &= ~FCF_ASYNC_SENT;
memset(&ea, 0, sizeof(ea)); memset(&ea, 0, sizeof(ea));
ea.event = FCME_ADISC_DONE; ea.event = FCME_ADISC_DONE;
ea.rc = res; ea.rc = res;
...@@ -425,7 +431,7 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -425,7 +431,7 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
done_free_sp: done_free_sp:
sp->free(sp); sp->free(sp);
done: done:
fcport->flags &= ~FCF_ASYNC_SENT; fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
qla2x00_post_async_adisc_work(vha, fcport, data); qla2x00_post_async_adisc_work(vha, fcport, data);
return rval; return rval;
} }
...@@ -1799,6 +1805,7 @@ qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -1799,6 +1805,7 @@ qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport,
qla2x00_mark_device_lost(vha, fcport, 1, 0); qla2x00_mark_device_lost(vha, fcport, 1, 0);
qlt_logo_completion_handler(fcport, data[0]); qlt_logo_completion_handler(fcport, data[0]);
fcport->login_gen++; fcport->login_gen++;
fcport->flags &= ~FCF_ASYNC_ACTIVE;
return; return;
} }
...@@ -1806,6 +1813,7 @@ void ...@@ -1806,6 +1813,7 @@ void
qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport,
uint16_t *data) uint16_t *data)
{ {
fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
if (data[0] == MBS_COMMAND_COMPLETE) { if (data[0] == MBS_COMMAND_COMPLETE) {
qla2x00_update_fcport(vha, fcport); qla2x00_update_fcport(vha, fcport);
...@@ -1813,7 +1821,6 @@ qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport, ...@@ -1813,7 +1821,6 @@ qla2x00_async_adisc_done(struct scsi_qla_host *vha, fc_port_t *fcport,
} }
/* Retry login. */ /* Retry login. */
fcport->flags &= ~FCF_ASYNC_SENT;
if (data[1] & QLA_LOGIO_LOGIN_RETRIED) if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
set_bit(RELOGIN_NEEDED, &vha->dpc_flags); set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment