Skip to content

Commit 7f04839

Browse files
James Smartmartinkpetersen
authored andcommitted
scsi: lpfc: Fix initial FLOGI failure due to BBSCN not supported
Initial FLOGIs are failing with the following message: lpfc 0000:13:00.1: 1:(0):0820 FLOGI Failed (x300). BBCredit Not Supported In a prior patch, the READ_SPARAM command was re-ordered to post after CONFIG_LINK as the driver is expected to update the driver's copy of the service parameters for the FLOGI payload. If the bb-credit recovery feature is enabled, this is fine. But on adapters were bb-credit recovery isn't enabled, it would cause the FLOGI to fail. Fix by restoring the original command order (READ_SPARAM before CONFIG_LINK), and after issuing CONFIG_LINK, detect bb-credit recovery support and reissuing READ_SPARAM to obtain the updated service parameters (effectively adding in the fix command order). [mkp: corrected SHA] Link: https://lore.kernel.org/r/20200911200147.110826-1-james.smart@broadcom.com Fixes: 835214f ("scsi: lpfc: Fix broken Credit Recovery after driver load") CC: <stable@vger.kernel.org> # v5.7+ Co-developed-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <james.smart@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 244359c commit 7f04839

1 file changed

Lines changed: 52 additions & 24 deletions

File tree

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static void lpfc_disc_timeout_handler(struct lpfc_vport *);
7171
static void lpfc_disc_flush_list(struct lpfc_vport *vport);
7272
static void lpfc_unregister_fcfi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *);
7373
static int lpfc_fcf_inuse(struct lpfc_hba *);
74+
static void lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *, LPFC_MBOXQ_t *);
7475

7576
void
7677
lpfc_terminate_rport_io(struct fc_rport *rport)
@@ -1138,11 +1139,13 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
11381139
return;
11391140
}
11401141

1141-
11421142
void
11431143
lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
11441144
{
11451145
struct lpfc_vport *vport = pmb->vport;
1146+
LPFC_MBOXQ_t *sparam_mb;
1147+
struct lpfc_dmabuf *sparam_mp;
1148+
int rc;
11461149

11471150
if (pmb->u.mb.mbxStatus)
11481151
goto out;
@@ -1167,12 +1170,42 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
11671170
}
11681171

11691172
/* Start discovery by sending a FLOGI. port_state is identically
1170-
* LPFC_FLOGI while waiting for FLOGI cmpl. Check if sending
1171-
* the FLOGI is being deferred till after MBX_READ_SPARAM completes.
1173+
* LPFC_FLOGI while waiting for FLOGI cmpl.
11721174
*/
11731175
if (vport->port_state != LPFC_FLOGI) {
1174-
if (!(phba->hba_flag & HBA_DEFER_FLOGI))
1176+
/* Issue MBX_READ_SPARAM to update CSPs before FLOGI if
1177+
* bb-credit recovery is in place.
1178+
*/
1179+
if (phba->bbcredit_support && phba->cfg_enable_bbcr &&
1180+
!(phba->link_flag & LS_LOOPBACK_MODE)) {
1181+
sparam_mb = mempool_alloc(phba->mbox_mem_pool,
1182+
GFP_KERNEL);
1183+
if (!sparam_mb)
1184+
goto sparam_out;
1185+
1186+
rc = lpfc_read_sparam(phba, sparam_mb, 0);
1187+
if (rc) {
1188+
mempool_free(sparam_mb, phba->mbox_mem_pool);
1189+
goto sparam_out;
1190+
}
1191+
sparam_mb->vport = vport;
1192+
sparam_mb->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
1193+
rc = lpfc_sli_issue_mbox(phba, sparam_mb, MBX_NOWAIT);
1194+
if (rc == MBX_NOT_FINISHED) {
1195+
sparam_mp = (struct lpfc_dmabuf *)
1196+
sparam_mb->ctx_buf;
1197+
lpfc_mbuf_free(phba, sparam_mp->virt,
1198+
sparam_mp->phys);
1199+
kfree(sparam_mp);
1200+
sparam_mb->ctx_buf = NULL;
1201+
mempool_free(sparam_mb, phba->mbox_mem_pool);
1202+
goto sparam_out;
1203+
}
1204+
1205+
phba->hba_flag |= HBA_DEFER_FLOGI;
1206+
} else {
11751207
lpfc_initial_flogi(vport);
1208+
}
11761209
} else {
11771210
if (vport->fc_flag & FC_PT2PT)
11781211
lpfc_disc_start(vport);
@@ -1184,6 +1217,7 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
11841217
"0306 CONFIG_LINK mbxStatus error x%x "
11851218
"HBA state x%x\n",
11861219
pmb->u.mb.mbxStatus, vport->port_state);
1220+
sparam_out:
11871221
mempool_free(pmb, phba->mbox_mem_pool);
11881222

11891223
lpfc_linkdown(phba);
@@ -3239,21 +3273,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
32393273
lpfc_linkup(phba);
32403274
sparam_mbox = NULL;
32413275

3242-
if (!(phba->hba_flag & HBA_FCOE_MODE)) {
3243-
cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3244-
if (!cfglink_mbox)
3245-
goto out;
3246-
vport->port_state = LPFC_LOCAL_CFG_LINK;
3247-
lpfc_config_link(phba, cfglink_mbox);
3248-
cfglink_mbox->vport = vport;
3249-
cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
3250-
rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT);
3251-
if (rc == MBX_NOT_FINISHED) {
3252-
mempool_free(cfglink_mbox, phba->mbox_mem_pool);
3253-
goto out;
3254-
}
3255-
}
3256-
32573276
sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
32583277
if (!sparam_mbox)
32593278
goto out;
@@ -3274,7 +3293,20 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
32743293
goto out;
32753294
}
32763295

3277-
if (phba->hba_flag & HBA_FCOE_MODE) {
3296+
if (!(phba->hba_flag & HBA_FCOE_MODE)) {
3297+
cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3298+
if (!cfglink_mbox)
3299+
goto out;
3300+
vport->port_state = LPFC_LOCAL_CFG_LINK;
3301+
lpfc_config_link(phba, cfglink_mbox);
3302+
cfglink_mbox->vport = vport;
3303+
cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
3304+
rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT);
3305+
if (rc == MBX_NOT_FINISHED) {
3306+
mempool_free(cfglink_mbox, phba->mbox_mem_pool);
3307+
goto out;
3308+
}
3309+
} else {
32783310
vport->port_state = LPFC_VPORT_UNKNOWN;
32793311
/*
32803312
* Add the driver's default FCF record at FCF index 0 now. This
@@ -3331,10 +3363,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
33313363
}
33323364
/* Reset FCF roundrobin bmask for new discovery */
33333365
lpfc_sli4_clear_fcf_rr_bmask(phba);
3334-
} else {
3335-
if (phba->bbcredit_support && phba->cfg_enable_bbcr &&
3336-
!(phba->link_flag & LS_LOOPBACK_MODE))
3337-
phba->hba_flag |= HBA_DEFER_FLOGI;
33383366
}
33393367

33403368
/* Prepare for LINK up registrations */

0 commit comments

Comments
 (0)