scsi: lpfc: use spin_lock_irqsave instead of spin_lock_irq in IRQ context
diff mbox series

Message ID 20190812083134.7033-1-huangfq.daxian@gmail.com
State Accepted
Headers show
Series
  • scsi: lpfc: use spin_lock_irqsave instead of spin_lock_irq in IRQ context
Related show

Commit Message

Fuqian Huang Aug. 12, 2019, 8:31 a.m. UTC
As spin_unlock_irq will enable interrupts.
Function lpfc_findnode_rpi is called from
    lpfc_sli_abts_err_handler (./drivers/scsi/lpfc/lpfc_sli.c)
 <- lpfc_sli_async_event_handler
 <- lpfc_sli_process_unsol_iocb
 <- lpfc_sli_handle_fast_ring_event
 <- lpfc_sli_fp_intr_handler
 <- lpfc_sli_intr_handler
 and lpfc_sli_intr_handler is an interrupt handler.
Interrupts are enabled in interrupt handler.
Use spin_lock_irqsave/spin_unlock_irqrestore instead of spin_(un)lock_irq
in IRQ context to avoid this.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
 drivers/scsi/lpfc/lpfc_hbadisc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

James Smart Aug. 16, 2019, 6:29 p.m. UTC | #1
On 8/12/2019 1:31 AM, Fuqian Huang wrote:
> As spin_unlock_irq will enable interrupts.
> Function lpfc_findnode_rpi is called from
>      lpfc_sli_abts_err_handler (./drivers/scsi/lpfc/lpfc_sli.c)
>   <- lpfc_sli_async_event_handler
>   <- lpfc_sli_process_unsol_iocb
>   <- lpfc_sli_handle_fast_ring_event
>   <- lpfc_sli_fp_intr_handler
>   <- lpfc_sli_intr_handler
>   and lpfc_sli_intr_handler is an interrupt handler.
> Interrupts are enabled in interrupt handler.
> Use spin_lock_irqsave/spin_unlock_irqrestore instead of spin_(un)lock_irq
> in IRQ context to avoid this.
>
> Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
> ---
>   drivers/scsi/lpfc/lpfc_hbadisc.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
> index 28ecaa7fc715..cf02c352b324 100644
> --- a/drivers/scsi/lpfc/lpfc_hbadisc.c
> +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
> @@ -6065,10 +6065,11 @@ lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)
>   {
>   	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
>   	struct lpfc_nodelist *ndlp;
> +	unsigned long flags;
>   
> -	spin_lock_irq(shost->host_lock);
> +	spin_lock_irqsave(shost->host_lock, flags);
>   	ndlp = __lpfc_findnode_rpi(vport, rpi);
> -	spin_unlock_irq(shost->host_lock);
> +	spin_unlock_irqrestore(shost->host_lock, flags);
>   	return ndlp;
>   }
>   

Thank you.

Reviewed-by: James Smart <james.smart@broadcom.com>

-- james
Martin K. Petersen Aug. 20, 2019, 2:10 a.m. UTC | #2
Fuqian,

> As spin_unlock_irq will enable interrupts.
> Function lpfc_findnode_rpi is called from
>     lpfc_sli_abts_err_handler (./drivers/scsi/lpfc/lpfc_sli.c)
>  <- lpfc_sli_async_event_handler
>  <- lpfc_sli_process_unsol_iocb
>  <- lpfc_sli_handle_fast_ring_event
>  <- lpfc_sli_fp_intr_handler
>  <- lpfc_sli_intr_handler
>  and lpfc_sli_intr_handler is an interrupt handler.
> Interrupts are enabled in interrupt handler.
> Use spin_lock_irqsave/spin_unlock_irqrestore instead of spin_(un)lock_irq
> in IRQ context to avoid this.

Applied to 5.4/scsi-queue, thanks.

Patch
diff mbox series

diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 28ecaa7fc715..cf02c352b324 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -6065,10 +6065,11 @@  lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi)
 {
 	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
 	struct lpfc_nodelist *ndlp;
+	unsigned long flags;
 
-	spin_lock_irq(shost->host_lock);
+	spin_lock_irqsave(shost->host_lock, flags);
 	ndlp = __lpfc_findnode_rpi(vport, rpi);
-	spin_unlock_irq(shost->host_lock);
+	spin_unlock_irqrestore(shost->host_lock, flags);
 	return ndlp;
 }