Skip to content

Commit 2bf8185

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Ensure PLOGI_ACC is sent prior to PRLI in Point to Point topology
There is a timing race condition when a PRLI may be sent on the wire before PLOGI_ACC in Point to Point topology. Fix by deferring REG_RPI mbox completion handling to after PLOGI_ACC's CQE completion. Because the discovery state machine only sends PRLI after REG_RPI mbox completion, PRLI is now guaranteed to be sent after PLOGI_ACC. Signed-off-by: Justin Tee <justin.tee@broadcom.com> Message-ID: <20250915180811.137530-8-justintee8345@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f408dde commit 2bf8185

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5339,12 +5339,12 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
53395339
ulp_status, ulp_word4, did);
53405340
/* ELS response tag <ulpIoTag> completes */
53415341
lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
5342-
"0110 ELS response tag x%x completes "
5342+
"0110 ELS response tag x%x completes fc_flag x%lx"
53435343
"Data: x%x x%x x%x x%x x%lx x%x x%x x%x %p %p\n",
5344-
iotag, ulp_status, ulp_word4, tmo,
5344+
iotag, vport->fc_flag, ulp_status, ulp_word4, tmo,
53455345
ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
53465346
ndlp->nlp_rpi, kref_read(&ndlp->kref), mbox, ndlp);
5347-
if (mbox) {
5347+
if (mbox && !test_bit(FC_PT2PT, &vport->fc_flag)) {
53485348
if (ulp_status == 0 &&
53495349
test_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag)) {
53505350
if (!lpfc_unreg_rpi(vport, ndlp) &&
@@ -5403,6 +5403,10 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
54035403
}
54045404
out_free_mbox:
54055405
lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
5406+
} else if (mbox && test_bit(FC_PT2PT, &vport->fc_flag) &&
5407+
test_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag)) {
5408+
lpfc_mbx_cmpl_reg_login(phba, mbox);
5409+
clear_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag);
54065410
}
54075411
out:
54085412
if (ndlp && shost) {

drivers/scsi/lpfc/lpfc_nportdisc.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,31 @@ lpfc_defer_plogi_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *login_mbox)
326326
/* Now that REG_RPI completed successfully,
327327
* we can now proceed with sending the PLOGI ACC.
328328
*/
329-
rc = lpfc_els_rsp_acc(login_mbox->vport, ELS_CMD_PLOGI,
330-
save_iocb, ndlp, NULL);
329+
if (test_bit(FC_PT2PT, &ndlp->vport->fc_flag)) {
330+
rc = lpfc_els_rsp_acc(login_mbox->vport, ELS_CMD_PLOGI,
331+
save_iocb, ndlp, login_mbox);
332+
} else {
333+
rc = lpfc_els_rsp_acc(login_mbox->vport, ELS_CMD_PLOGI,
334+
save_iocb, ndlp, NULL);
335+
}
336+
331337
if (rc) {
332338
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
333339
"4576 PLOGI ACC fails pt2pt discovery: "
334340
"DID %x Data: %x\n", ndlp->nlp_DID, rc);
335341
}
336342
}
337343

338-
/* Now process the REG_RPI cmpl */
339-
lpfc_mbx_cmpl_reg_login(phba, login_mbox);
340-
clear_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag);
344+
/* If this is a fabric topology, complete the reg_rpi and prli now.
345+
* For Pt2Pt, the reg_rpi and PRLI are deferred until after the LS_ACC
346+
* completes. This ensures, in Pt2Pt, that the PLOGI LS_ACC is sent
347+
* before the PRLI.
348+
*/
349+
if (!test_bit(FC_PT2PT, &ndlp->vport->fc_flag)) {
350+
/* Now process the REG_RPI cmpl */
351+
lpfc_mbx_cmpl_reg_login(phba, login_mbox);
352+
clear_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag);
353+
}
341354
kfree(save_iocb);
342355
}
343356

0 commit comments

Comments
 (0)