Skip to contentSkip to conversation

ipr: Fix locking for unit attention handling

PATCH RESEND In review Brian King 2 participants 3 messages Jul 14, 2015 – Jul 17, 2015

Subsystems (3)
lore
Share & tools
lore

Brian King

author
#0 lore raw

PATCH RESEND 1/3 ipr: Fix locking for unit attention handling

Make sure we have the host lock held when calling scsi_report_bus_reset. Fixes a crash seen as the __devices list in the scsi host was changing as we were iterating through it.

---

 drivers/scsi/ipr.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/ipr.c renamed from drivers/scsi/ipr.c~ipr_erp_start_locking +7 -5
diff -puN drivers/scsi/ipr.c~ipr_erp_start_locking drivers/scsi/ipr.c
@@ -6263,21 +6263,23 @@ static void ipr_scsi_done(struct ipr_cmn
 	struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
 	struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd;
 	u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc);
-	unsigned long hrrq_flags;
+	unsigned long lock_flags;
 
 	scsi_set_resid(scsi_cmd, be32_to_cpu(ipr_cmd->s.ioasa.hdr.residual_data_len));
 
 	if (likely(IPR_IOASC_SENSE_KEY(ioasc) == 0)) {
 		scsi_dma_unmap(scsi_cmd);
 
-		spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags);
+		spin_lock_irqsave(ipr_cmd->hrrq->lock, lock_flags);
 		list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
 		scsi_cmd->scsi_done(scsi_cmd);
-		spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags);
+		spin_unlock_irqrestore(ipr_cmd->hrrq->lock, lock_flags);
 	} else {
-		spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags);
+		spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
+		spin_lock(&ipr_cmd->hrrq->_lock);
 		ipr_erp_start(ioa_cfg, ipr_cmd);
-		spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags);
+		spin_unlock(&ipr_cmd->hrrq->_lock);
+		spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
 	}
 }
 

_

Reviewed-by on v1 1/3
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Brian" == Brian King <[email protected]> writes:

Brian> Make sure we have the host lock held when calling Brian> scsi_report_bus_reset. Fixes a crash seen as the __devices list Brian> in the scsi host was changing as we were iterating through it.

Nit: I take it that renaming lock_flags to hrrq_flags makes sense. But it muddles what is supposed to be a bugfix patch.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
author
#2 lore raw
Quoted 11 lines · Martin K. Petersen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Brian" == Brian King <[email protected]> writes:

Brian> Make sure we have the host lock held when calling Brian> scsi_report_bus_reset. Fixes a crash seen as the __devices list Brian> in the scsi host was changing as we were iterating through it.

Nit: I take it that renaming lock_flags to hrrq_flags makes sense. But it muddles what is supposed to be a bugfix patch.

Correct. Thanks for the review.

-Brian

Signature · 3 lines
Brian King
Power Linux I/O
IBM Linux Technology Center