Commit a1d3a588 authored by Justin Tee's avatar Justin Tee Committed by Jingtong Meng
Browse files

scsi: lpfc: Update phba link state conditional before sending CMF_SYNC_WQE

mainline inclusion
from mainline-v6.12-rc1
commit fc318cac66ac50398f9fc7cbec7b339e6d08a7e6
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBJNQJ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc318cac66ac50398f9fc7cbec7b339e6d08a7e6



--------------------------------

It's possible for the driver to send a CMF_SYNC_WQE to nonresponsive
firmware during reset of the adapter.  The phba link_state conditional
check is currently a strict == LPFC_LINK_DOWN, which does not cover
initialization states before reaching the LPFC_LINK_UP state.

Update the phba->link_state conditional to < LPFC_LINK_UP so that all
initialization states are covered before allowing sending CMF_SYNC_WQE.

Update taking of the hbalock to be during this link_state check as well.

Signed-off-by: default avatarJustin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240912232447.45607-3-justintee8345@gmail.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJingtong Meng <jingtong.meng@windriver.com>
parent 0e868d3d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1938,12 +1938,15 @@ lpfc_issue_cmf_sync_wqe(struct lpfc_hba *phba, u32 ms, u64 total)
	atot = atomic_xchg(&phba->cgn_sync_alarm_cnt, 0);
	wtot = atomic_xchg(&phba->cgn_sync_warn_cnt, 0);
	spin_lock_irqsave(&phba->hbalock, iflags);
	/* ONLY Managed mode will send the CMF_SYNC_WQE to the HBA */
	if (phba->cmf_active_mode != LPFC_CFG_MANAGED ||
	    phba->link_state == LPFC_LINK_DOWN)
		return 0;
	    phba->link_state < LPFC_LINK_UP) {
		ret_val = 0;
		goto out_unlock;
	}
	spin_lock_irqsave(&phba->hbalock, iflags);
	sync_buf = __lpfc_sli_get_iocbq(phba);
	if (!sync_buf) {
		lpfc_printf_log(phba, KERN_ERR, LOG_CGN_MGMT,