summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qedf
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.com>2019-03-26 00:38:45 -0700
committerMartin K. Petersen <martin.petersen@oracle.com>2019-03-27 21:54:52 -0400
commit78a8ab3cc0f95a66c8fb2429030289103de173e7 (patch)
tree5fe33202c67a24b03a69d535962cfda5e4597467 /drivers/scsi/qedf
parent6d1368e8f987dd4bb1be6506d5416cb90b4ecf7a (diff)
downloadblackbird-op-linux-78a8ab3cc0f95a66c8fb2429030289103de173e7.tar.gz
blackbird-op-linux-78a8ab3cc0f95a66c8fb2429030289103de173e7.zip
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: Hannes Reinecke <hare@suse.com> Signed-off-by: Saurav Kashyap <skashyap@marvell.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/qedf')
-rw-r--r--drivers/scsi/qedf/qedf_els.c4
-rw-r--r--drivers/scsi/qedf/qedf_main.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index aad1f7c464fd..f1f576375de4 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -358,20 +358,24 @@ void qedf_restart_rport(struct qedf_rport *fcport)
struct fc_lport *lport;
struct fc_rport_priv *rdata;
u32 port_id;
+ unsigned long flags;
if (!fcport)
return;
+ spin_lock_irqsave(&fcport->rport_lock, flags);
if (test_bit(QEDF_RPORT_IN_RESET, &fcport->flags) ||
!test_bit(QEDF_RPORT_SESSION_READY, &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",
fcport);
+ spin_unlock_irqrestore(&fcport->rport_lock, flags);
return;
}
/* Set that we are now in reset */
set_bit(QEDF_RPORT_IN_RESET, &fcport->flags);
+ spin_unlock_irqrestore(&fcport->rport_lock, flags);
rdata = fcport->rdata;
if (rdata) {
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index b216a0f757a1..bc787ce0b526 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -1435,12 +1435,14 @@ static void qedf_rport_event_handler(struct fc_lport *lport,
*/
fcport = (struct qedf_rport *)&rp[1];
+ spin_lock_irqsave(&fcport->rport_lock, flags);
/* Only free this fcport if it is offloaded already */
if (test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags) &&
!test_bit(QEDF_RPORT_UPLOADING_CONNECTION,
&fcport->flags)) {
set_bit(QEDF_RPORT_UPLOADING_CONNECTION,
&fcport->flags);
+ spin_unlock_irqrestore(&fcport->rport_lock, flags);
qedf_cleanup_fcport(qedf, fcport);
/*
* Remove fcport to list of qedf_ctx list of offloaded
@@ -1453,8 +1455,9 @@ static void qedf_rport_event_handler(struct fc_lport *lport,
clear_bit(QEDF_RPORT_UPLOADING_CONNECTION,
&fcport->flags);
atomic_dec(&qedf->num_offloads);
+ } else {
+ spin_unlock_irqrestore(&fcport->rport_lock, flags);
}
-
break;
case RPORT_EV_NONE:
OpenPOWER on IntegriCloud