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

scsi: qedf: fixup bit operations

test_bit() is atomic, test_bit() || test_bit() is not. So protect
consecutive bit tests with a lock to avoid races.
Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarSaurav Kashyap <skashyap@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 6d1368e8
...@@ -358,20 +358,24 @@ void qedf_restart_rport(struct qedf_rport *fcport) ...@@ -358,20 +358,24 @@ void qedf_restart_rport(struct qedf_rport *fcport)
struct fc_lport *lport; struct fc_lport *lport;
struct fc_rport_priv *rdata; struct fc_rport_priv *rdata;
u32 port_id; u32 port_id;
unsigned long flags;
if (!fcport) if (!fcport)
return; return;
spin_lock_irqsave(&fcport->rport_lock, flags);
if (test_bit(QEDF_RPORT_IN_RESET, &fcport->flags) || if (test_bit(QEDF_RPORT_IN_RESET, &fcport->flags) ||
!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) || !test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) ||
test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) { test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) {
QEDF_ERR(&(fcport->qedf->dbg_ctx), "fcport %p already in reset or not offloaded.\n", QEDF_ERR(&(fcport->qedf->dbg_ctx), "fcport %p already in reset or not offloaded.\n",
fcport); fcport);
spin_unlock_irqrestore(&fcport->rport_lock, flags);
return; return;
} }
/* Set that we are now in reset */ /* Set that we are now in reset */
set_bit(QEDF_RPORT_IN_RESET, &fcport->flags); set_bit(QEDF_RPORT_IN_RESET, &fcport->flags);
spin_unlock_irqrestore(&fcport->rport_lock, flags);
rdata = fcport->rdata; rdata = fcport->rdata;
if (rdata) { if (rdata) {
......
...@@ -1435,12 +1435,14 @@ static void qedf_rport_event_handler(struct fc_lport *lport, ...@@ -1435,12 +1435,14 @@ static void qedf_rport_event_handler(struct fc_lport *lport,
*/ */
fcport = (struct qedf_rport *)&rp[1]; fcport = (struct qedf_rport *)&rp[1];
spin_lock_irqsave(&fcport->rport_lock, flags);
/* Only free this fcport if it is offloaded already */ /* Only free this fcport if it is offloaded already */
if (test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) && if (test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) &&
!test_bit(QEDF_RPORT_UPLOADING_CONNECTION, !test_bit(QEDF_RPORT_UPLOADING_CONNECTION,
&fcport->flags)) { &fcport->flags)) {
set_bit(QEDF_RPORT_UPLOADING_CONNECTION, set_bit(QEDF_RPORT_UPLOADING_CONNECTION,
&fcport->flags); &fcport->flags);
spin_unlock_irqrestore(&fcport->rport_lock, flags);
qedf_cleanup_fcport(qedf, fcport); qedf_cleanup_fcport(qedf, fcport);
/* /*
* Remove fcport to list of qedf_ctx list of offloaded * Remove fcport to list of qedf_ctx list of offloaded
...@@ -1453,8 +1455,9 @@ static void qedf_rport_event_handler(struct fc_lport *lport, ...@@ -1453,8 +1455,9 @@ static void qedf_rport_event_handler(struct fc_lport *lport,
clear_bit(QEDF_RPORT_UPLOADING_CONNECTION, clear_bit(QEDF_RPORT_UPLOADING_CONNECTION,
&fcport->flags); &fcport->flags);
atomic_dec(&qedf->num_offloads); atomic_dec(&qedf->num_offloads);
} else {
spin_unlock_irqrestore(&fcport->rport_lock, flags);
} }
break; break;
case RPORT_EV_NONE: case RPORT_EV_NONE:
......
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