Skip to content

Commit

Permalink
scsi: lpfc: Fix mailbox command failure during driver initialization
Browse files Browse the repository at this point in the history
commit efe1dc5 upstream.

Contention for the mailbox interface may occur during driver initialization
(immediately after a function reset), between mailbox commands initiated
via ioctl (bsg) and those driver requested by the driver.

After setting SLI_ACTIVE flag for a port, there is a window in which the
driver will allow an ioctl to be initiated while the adapter is
initializing and issuing mailbox commands via polling. The polling logic
then gets confused.

Correct by having thread setting SLI_ACTIVE spot an active mailbox command
and allow it complete before proceeding.

Link: https://lore.kernel.org/r/20210921143008.64212-1-jsmart2021@gmail.com
Co-developed-by: Nigel Kirkland <nkirkland2304@gmail.com>
Signed-off-by: Nigel Kirkland <nkirkland2304@gmail.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jsmart-gh authored and gregkh committed Feb 23, 2022
1 parent 4578b97 commit f100e75
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/scsi/lpfc/lpfc_sli.c
Expand Up @@ -7372,6 +7372,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
struct lpfc_vport *vport = phba->pport;
struct lpfc_dmabuf *mp;
struct lpfc_rqb *rqbp;
u32 flg;

/* Perform a PCI function reset to start from clean */
rc = lpfc_pci_function_reset(phba);
Expand All @@ -7385,7 +7386,17 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
else {
spin_lock_irq(&phba->hbalock);
phba->sli.sli_flag |= LPFC_SLI_ACTIVE;
flg = phba->sli.sli_flag;
spin_unlock_irq(&phba->hbalock);
/* Allow a little time after setting SLI_ACTIVE for any polled
* MBX commands to complete via BSG.
*/
for (i = 0; i < 50 && (flg & LPFC_SLI_MBOX_ACTIVE); i++) {
msleep(20);
spin_lock_irq(&phba->hbalock);
flg = phba->sli.sli_flag;
spin_unlock_irq(&phba->hbalock);
}
}

lpfc_sli4_dip(phba);
Expand Down Expand Up @@ -8922,7 +8933,7 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
"(%d):2541 Mailbox command x%x "
"(x%x/x%x) failure: "
"mqe_sta: x%x mcqe_sta: x%x/x%x "
"Data: x%x x%x\n,",
"Data: x%x x%x\n",
mboxq->vport ? mboxq->vport->vpi : 0,
mboxq->u.mb.mbxCommand,
lpfc_sli_config_mbox_subsys_get(phba,
Expand Down Expand Up @@ -8956,7 +8967,7 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
"(%d):2597 Sync Mailbox command "
"x%x (x%x/x%x) failure: "
"mqe_sta: x%x mcqe_sta: x%x/x%x "
"Data: x%x x%x\n,",
"Data: x%x x%x\n",
mboxq->vport ? mboxq->vport->vpi : 0,
mboxq->u.mb.mbxCommand,
lpfc_sli_config_mbox_subsys_get(phba,
Expand Down

0 comments on commit f100e75

Please sign in to comment.