diff mbox

[1/4] ipr: Fix locking for unit attention handling

Message ID 201506120145.t5C1jFQW016709@d01av04.pok.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Brian King June 12, 2015, 1:45 a.m. UTC
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.

Cc: <stable@vger.kernel.org>
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 drivers/scsi/ipr.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

wenxiong@linux.vnet.ibm.com June 15, 2015, 2:44 p.m. UTC | #1
We have done stress test for a week with the patch and works fine.

Reviewed-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>

Thanks,
Wendy

Quoting Brian King <brking@linux.vnet.ibm.com>:

> 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.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> ---
>
>  drivers/scsi/ipr.c |   12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff -puN drivers/scsi/ipr.c~ipr_erp_start_locking drivers/scsi/ipr.c
> --- linux/drivers/scsi/ipr.c~ipr_erp_start_locking	2015-06-11  
> 20:18:13.806674185 -0500
> +++ linux-bjking1/drivers/scsi/ipr.c	2015-06-11 20:18:13.814674115 -0500
> @@ -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);
>  	}
>  }
>
> _


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gabriel Krisman Bertazi June 16, 2015, 2:40 p.m. UTC | #2
Brian King <brking@linux.vnet.ibm.com> writes:

> 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.

Brian,

The patch series look good to me as a whole, thanks for doing that.
Please add the tag:

Reviewed-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>

Thanks,
diff mbox

Patch

diff -puN drivers/scsi/ipr.c~ipr_erp_start_locking drivers/scsi/ipr.c
--- linux/drivers/scsi/ipr.c~ipr_erp_start_locking	2015-06-11 20:18:13.806674185 -0500
+++ linux-bjking1/drivers/scsi/ipr.c	2015-06-11 20:18:13.814674115 -0500
@@ -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);
 	}
 }