• James Smart's avatar
    scsi: lpfc: Fix scheduling call while in softirq context in lpfc_unreg_rpi · e7dab164
    James Smart authored
    The following call trace was seen during HBA reset testing:
    
    BUG: scheduling while atomic: swapper/2/0/0x10000100
    ...
    Call Trace:
    dump_stack+0x19/0x1b
    __schedule_bug+0x64/0x72
    __schedule+0x782/0x840
    __cond_resched+0x26/0x30
    _cond_resched+0x3a/0x50
    mempool_alloc+0xa0/0x170
    lpfc_unreg_rpi+0x151/0x630 [lpfc]
    lpfc_sli_abts_recover_port+0x171/0x190 [lpfc]
    lpfc_sli4_abts_err_handler+0xb2/0x1f0 [lpfc]
    lpfc_sli4_io_xri_aborted+0x256/0x300 [lpfc]
    lpfc_sli4_sp_handle_abort_xri_wcqe.isra.51+0xa3/0x190 [lpfc]
    lpfc_sli4_fp_handle_cqe+0x89/0x4d0 [lpfc]
    __lpfc_sli4_process_cq+0xdb/0x2e0 [lpfc]
    __lpfc_sli4_hba_process_cq+0x41/0x100 [lpfc]
    lpfc_cq_poll_hdler+0x1a/0x30 [lpfc]
    irq_poll_softirq+0xc7/0x100
    __do_softirq+0xf5/0x280
    call_softirq+0x1c/0x30
    do_softirq+0x65/0xa0
    irq_exit+0x105/0x110
    do_IRQ+0x56/0xf0
    common_interrupt+0x16a/0x16a
    
    With the conversion to blk_io_poll for better interrupt latency in normal
    cases, it introduced this code path, executed when I/O aborts or logouts
    are seen, which attempts to allocate memory for a mailbox command to be
    issued.  The allocation is GFP_KERNEL, thus it could attempt to sleep.
    
    Fix by creating a work element that performs the event handling for the
    remote port. This will have the mailbox commands and other items performed
    in the work element, not the irq. A much better method as the "irq" routine
    does not stall while performing all this deep handling code.
    
    Ensure that allocation failures are handled and send LOGO on failure.
    
    Additionally, enlarge the mailbox memory pool to reduce the possibility of
    additional allocation in this path.
    
    Link: https://lore.kernel.org/r/20201020202719.54726-3-james.smart@broadcom.com
    Fixes: 317aeb83 ("scsi: lpfc: Add blk_io_poll support for latency improvment")
    Cc: <stable@vger.kernel.org> # v5.9+
    Co-developed-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
    Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
    Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    e7dab164
lpfc_nvme.c 82.2 KB