From 863d8f73f4e56e03ff9fcd3548ecf6396341179c Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mar 28 2024 14:38:00 +0000 Subject: scsi: lpfc: Define lpfc_nodelist type for ctx_ndlp ptr (bsc#1221777). --- diff --git a/patches.suse/scsi-lpfc-Define-lpfc_nodelist-type-for-ctx_ndlp-ptr.patch b/patches.suse/scsi-lpfc-Define-lpfc_nodelist-type-for-ctx_ndlp-ptr.patch new file mode 100644 index 0000000..211f92a --- /dev/null +++ b/patches.suse/scsi-lpfc-Define-lpfc_nodelist-type-for-ctx_ndlp-ptr.patch @@ -0,0 +1,349 @@ +From: Justin Tee +Date: Tue, 5 Mar 2024 12:04:59 -0800 +Subject: scsi: lpfc: Define lpfc_nodelist type for ctx_ndlp ptr +Patch-mainline: Queued in subsystem maintainer repository +Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git +Git-commit: 18f7fe44bc79e67eccd4c118f10aa16647d446f8 +References: bsc#1221777 + +In LPFC_MBOXQ_t data structure, the ctx_ndlp ptr shouldn't be defined as a +generic void *ptr. It is named ctx_ndlp and it should only be used as an +lpfc_nodelist *ptr. Due to the void* declaration, there have been abuses +of ctx_ndlp for things not related to ndlp. + +So, set the ptr type for *ctx_ndlp as lpfc_nodelist. Remove all type casts +on ctx_ndlp because it is no longer a void *ptr. Convert the abuse of +ctx_ndlp for things not related to ndlps to use the void *context3 ptr. + +Signed-off-by: Justin Tee +Link: https://lore.kernel.org/r/20240305200503.57317-9-justintee8345@gmail.com +Signed-off-by: Martin K. Petersen +Acked-by: Daniel Wagner +--- + drivers/scsi/lpfc/lpfc_bsg.c | 4 ++-- + drivers/scsi/lpfc/lpfc_els.c | 10 ++++------ + drivers/scsi/lpfc/lpfc_hbadisc.c | 18 +++++++++--------- + drivers/scsi/lpfc/lpfc_mbox.c | 10 +++++----- + drivers/scsi/lpfc/lpfc_nportdisc.c | 6 +++--- + drivers/scsi/lpfc/lpfc_sli.c | 17 ++++++++--------- + drivers/scsi/lpfc/lpfc_sli.h | 10 +++++----- + 7 files changed, 36 insertions(+), 39 deletions(-) + +--- a/drivers/scsi/lpfc/lpfc_bsg.c ++++ b/drivers/scsi/lpfc/lpfc_bsg.c +@@ -3376,7 +3376,7 @@ lpfc_bsg_issue_mbox_cmpl(struct lpfc_hba + unsigned long flags; + uint8_t *pmb, *pmb_buf; + +- dd_data = pmboxq->ctx_ndlp; ++ dd_data = pmboxq->context3; + + /* + * The outgoing buffer is readily referred from the dma buffer, +@@ -4875,7 +4875,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phb + pmboxq->mbox_cmpl = lpfc_bsg_issue_mbox_cmpl; + + /* setup context field to pass wait_queue pointer to wake function */ +- pmboxq->ctx_ndlp = dd_data; ++ pmboxq->context3 = dd_data; + dd_data->type = TYPE_MBOX; + dd_data->set_job = job; + dd_data->context_un.mbox.pmboxq = pmboxq; +--- a/drivers/scsi/lpfc/lpfc_els.c ++++ b/drivers/scsi/lpfc/lpfc_els.c +@@ -7238,7 +7238,7 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, + goto rdp_fail; + mbox->vport = rdp_context->ndlp->vport; + mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0; +- mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; ++ mbox->context3 = (struct lpfc_rdp_context *)rdp_context; + rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); + if (rc == MBX_NOT_FINISHED) { + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); +@@ -7298,7 +7298,6 @@ int lpfc_get_sfp_info_wait(struct lpfc_h + mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys); + } + mbox->vport = phba->pport; +- mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; + + rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30); + if (rc == MBX_NOT_FINISHED) { +@@ -7358,7 +7357,6 @@ int lpfc_get_sfp_info_wait(struct lpfc_h + mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys); + } + +- mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; + rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30); + if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) { + rc = 1; +@@ -7500,9 +7498,9 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, + int rc; + + mb = &pmb->u.mb; +- lcb_context = (struct lpfc_lcb_context *)pmb->ctx_ndlp; ++ lcb_context = (struct lpfc_lcb_context *)pmb->context3; + ndlp = lcb_context->ndlp; +- pmb->ctx_ndlp = NULL; ++ pmb->context3 = NULL; + pmb->ctx_buf = NULL; + + shdr = (union lpfc_sli4_cfg_shdr *) +@@ -7642,7 +7640,7 @@ lpfc_sli4_set_beacon(struct lpfc_vport * + lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_COMMON, + LPFC_MBOX_OPCODE_SET_BEACON_CONFIG, len, + LPFC_SLI4_MBX_EMBED); +- mbox->ctx_ndlp = (void *)lcb_context; ++ mbox->context3 = (void *)lcb_context; + mbox->vport = phba->pport; + mbox->mbox_cmpl = lpfc_els_lcb_rsp; + bf_set(lpfc_mbx_set_beacon_port_num, &mbox->u.mqe.un.beacon_config, +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c +@@ -3851,7 +3851,7 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba + { + struct lpfc_vport *vport = pmb->vport; + struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf; +- struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; + + /* The driver calls the state machine with the pmb pointer + * but wants to make sure a stale ctx_buf isn't acted on. +@@ -4168,7 +4168,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lp + { + struct lpfc_vport *vport = pmb->vport; + MAILBOX_t *mb = &pmb->u.mb; +- struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; + + pmb->ctx_ndlp = NULL; + +@@ -4306,7 +4306,7 @@ void + lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) + { + MAILBOX_t *mb = &pmb->u.mb; +- struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; + struct lpfc_vport *vport = pmb->vport; + int rc; + +@@ -4430,7 +4430,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_h + { + struct lpfc_vport *vport = pmb->vport; + MAILBOX_t *mb = &pmb->u.mb; +- struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; + + pmb->ctx_ndlp = NULL; + if (mb->mbxStatus) { +@@ -5173,7 +5173,7 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phb + struct lpfc_vport *vport = pmb->vport; + struct lpfc_nodelist *ndlp; + +- ndlp = (struct lpfc_nodelist *)(pmb->ctx_ndlp); ++ ndlp = pmb->ctx_ndlp; + if (!ndlp) + return; + lpfc_issue_els_logo(vport, ndlp, 0); +@@ -5495,7 +5495,7 @@ lpfc_cleanup_node(struct lpfc_vport *vpo + if ((mb = phba->sli.mbox_active)) { + if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && + !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) && +- (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) { ++ (ndlp == mb->ctx_ndlp)) { + mb->ctx_ndlp = NULL; + mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; + } +@@ -5506,7 +5506,7 @@ lpfc_cleanup_node(struct lpfc_vport *vpo + list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { + if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) || + (mb->mbox_flag & LPFC_MBX_IMED_UNREG) || +- (ndlp != (struct lpfc_nodelist *)mb->ctx_ndlp)) ++ (ndlp != mb->ctx_ndlp)) + continue; + + mb->ctx_ndlp = NULL; +@@ -5516,7 +5516,7 @@ lpfc_cleanup_node(struct lpfc_vport *vpo + list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { + if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && + !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) && +- (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) { ++ (ndlp == mb->ctx_ndlp)) { + list_del(&mb->list); + lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED); + +@@ -6356,7 +6356,7 @@ void + lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) + { + MAILBOX_t *mb = &pmb->u.mb; +- struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; + struct lpfc_vport *vport = pmb->vport; + + pmb->ctx_ndlp = NULL; +--- a/drivers/scsi/lpfc/lpfc_mbox.c ++++ b/drivers/scsi/lpfc/lpfc_mbox.c +@@ -2367,7 +2367,7 @@ lpfc_mbx_cmpl_rdp_link_stat(struct lpfc_ + MAILBOX_t *mb; + int rc = FAILURE; + struct lpfc_rdp_context *rdp_context = +- (struct lpfc_rdp_context *)(mboxq->ctx_ndlp); ++ (struct lpfc_rdp_context *)(mboxq->context3); + + mb = &mboxq->u.mb; + if (mb->mbxStatus) +@@ -2387,7 +2387,7 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hb + { + struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)mbox->ctx_buf; + struct lpfc_rdp_context *rdp_context = +- (struct lpfc_rdp_context *)(mbox->ctx_ndlp); ++ (struct lpfc_rdp_context *)(mbox->context3); + + if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) + goto error_mbox_free; +@@ -2401,7 +2401,7 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hb + /* Save the dma buffer for cleanup in the final completion. */ + mbox->ctx_buf = mp; + mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat; +- mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; ++ mbox->context3 = (struct lpfc_rdp_context *)rdp_context; + if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED) + goto error_mbox_free; + +@@ -2418,7 +2418,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hb + int rc; + struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); + struct lpfc_rdp_context *rdp_context = +- (struct lpfc_rdp_context *)(mbox->ctx_ndlp); ++ (struct lpfc_rdp_context *)(mbox->context3); + + if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) + goto error; +@@ -2448,7 +2448,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hb + mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys); + + mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a2; +- mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; ++ mbox->context3 = (struct lpfc_rdp_context *)rdp_context; + rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); + if (rc == MBX_NOT_FINISHED) + goto error; +--- a/drivers/scsi/lpfc/lpfc_nportdisc.c ++++ b/drivers/scsi/lpfc/lpfc_nportdisc.c +@@ -683,7 +683,7 @@ lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba + uint32_t cmd; + + elsiocb = (struct lpfc_iocbq *)mboxq->ctx_buf; +- ndlp = (struct lpfc_nodelist *)mboxq->ctx_ndlp; ++ ndlp = mboxq->ctx_ndlp; + vport = mboxq->vport; + cmd = elsiocb->drvrTimeout; + +@@ -1875,7 +1875,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc + /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ + if ((mb = phba->sli.mbox_active)) { + if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && +- (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) { ++ (ndlp == mb->ctx_ndlp)) { + ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; + lpfc_nlp_put(ndlp); + mb->ctx_ndlp = NULL; +@@ -1886,7 +1886,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc + spin_lock_irq(&phba->hbalock); + list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { + if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && +- (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) { ++ (ndlp == mb->ctx_ndlp)) { + ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; + lpfc_nlp_put(ndlp); + list_del(&mb->list); +--- a/drivers/scsi/lpfc/lpfc_sli.c ++++ b/drivers/scsi/lpfc/lpfc_sli.c +@@ -2914,12 +2914,12 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba * + } + + if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) { +- ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ ndlp = pmb->ctx_ndlp; + lpfc_nlp_put(ndlp); + } + + if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { +- ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ ndlp = pmb->ctx_ndlp; + + /* Check to see if there are any deferred events to process */ + if (ndlp) { +@@ -2952,7 +2952,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba * + + /* This nlp_put pairs with lpfc_sli4_resume_rpi */ + if (pmb->u.mb.mbxCommand == MBX_RESUME_RPI) { +- ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ ndlp = pmb->ctx_ndlp; + lpfc_nlp_put(ndlp); + } + +@@ -13832,8 +13832,7 @@ lpfc_sli_sp_intr_handler(int irq, void * + if (!pmbox->mbxStatus) { + mp = (struct lpfc_dmabuf *) + (pmb->ctx_buf); +- ndlp = (struct lpfc_nodelist *) +- pmb->ctx_ndlp; ++ ndlp = pmb->ctx_ndlp; + + /* Reg_LOGIN of dflt RPI was + * successful. new lets get +@@ -14341,7 +14340,7 @@ lpfc_sli4_sp_handle_mbox_event(struct lp + pmbox->un.varWords[0], 0); + if (mcqe_status == MB_CQE_STATUS_SUCCESS) { + mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); +- ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; ++ ndlp = pmb->ctx_ndlp; + + /* Reg_LOGIN of dflt RPI was successful. Mark the + * node as having an UNREG_LOGIN in progress to stop +@@ -21035,7 +21034,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vp + (mb->u.mb.mbxCommand == MBX_REG_VPI)) + mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; + if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { +- act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; ++ act_mbx_ndlp = mb->ctx_ndlp; + + /* This reference is local to this routine. The + * reference is removed at routine exit. +@@ -21064,7 +21063,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vp + + mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; + if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { +- ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; ++ ndlp = mb->ctx_ndlp; + /* Unregister the RPI when mailbox complete */ + mb->mbox_flag |= LPFC_MBX_IMED_UNREG; + restart_loop = 1; +@@ -21084,7 +21083,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vp + while (!list_empty(&mbox_cmd_list)) { + list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list); + if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { +- ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; ++ ndlp = mb->ctx_ndlp; + mb->ctx_ndlp = NULL; + if (ndlp) { + spin_lock(&ndlp->lock); +--- a/drivers/scsi/lpfc/lpfc_sli.h ++++ b/drivers/scsi/lpfc/lpfc_sli.h +@@ -182,11 +182,11 @@ typedef struct lpfcMboxq { + struct lpfc_mqe mqe; + } u; + struct lpfc_vport *vport; /* virtual port pointer */ +- void *ctx_ndlp; /* an lpfc_nodelist pointer */ +- void *ctx_buf; /* an lpfc_dmabuf pointer */ +- void *context3; /* a generic pointer. Code must +- * accommodate the actual datatype. +- */ ++ struct lpfc_nodelist *ctx_ndlp; /* caller ndlp pointer */ ++ void *ctx_buf; /* caller buffer information */ ++ void *context3; /* a generic pointer. Code must ++ * accommodate the actual datatype. ++ */ + + void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); + uint8_t mbox_flag; diff --git a/series.conf b/series.conf index f83d4ae..029e900 100644 --- a/series.conf +++ b/series.conf @@ -20075,6 +20075,7 @@ patches.suse/scsi-lpfc-Replace-hbalock-with-ndlp-lock-in-lpfc_nvm.patch patches.suse/scsi-lpfc-Release-hbalock-before-calling-lpfc_worker.patch patches.suse/scsi-lpfc-Use-a-dedicated-lock-for-ras_fwlog-state.patch + patches.suse/scsi-lpfc-Define-lpfc_nodelist-type-for-ctx_ndlp-ptr.patch ######################################################## # end of sorted patches