Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge patch series "lpfc: Update lpfc to revision 14.2.0.16"

Justin Tee <justintee8345@gmail.com> says:

Update lpfc to revision 14.2.0.16

This patch set contains a user input range check correction, static
code analyzer fixes, refactoring of clean up code, and logging
enhancements.

The patches were cut against Martin's 6.7/scsi-queue tree.

Link: https://lore.kernel.org/r/20231031191224.150862-1-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+93 -56
+1
drivers/scsi/lpfc/lpfc.h
··· 33 33 struct lpfc_sli2_slim; 34 34 35 35 #define ELX_MODEL_NAME_SIZE 80 36 + #define ELX_FW_NAME_SIZE 84 36 37 37 38 #define LPFC_PCI_DEV_LP 0x1 38 39 #define LPFC_PCI_DEV_OC 0x2
+2 -2
drivers/scsi/lpfc/lpfc_attr.c
··· 5905 5905 /* 5906 5906 * lpfc_ras_fwlog_func: Firmware logging enabled on function number 5907 5907 * Default function which has RAS support : 0 5908 - * Value Range is [0..7]. 5908 + * Value Range is [0..3]. 5909 5909 * FW logging is a global action and enablement is via a specific 5910 5910 * port. 5911 5911 */ 5912 - LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function"); 5912 + LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 3, "Firmware Logging Enabled on Function"); 5913 5913 5914 5914 /* 5915 5915 * lpfc_enable_bbcr: Enable BB Credit Recovery
+33 -20
drivers/scsi/lpfc/lpfc_els.c
··· 2062 2062 /* PLOGI completes to NPort <nlp_DID> */ 2063 2063 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 2064 2064 "0102 PLOGI completes to NPort x%06x " 2065 - "Data: x%x x%x x%x x%x x%x\n", 2066 - ndlp->nlp_DID, ndlp->nlp_fc4_type, 2065 + "IoTag x%x Data: x%x x%x x%x x%x x%x\n", 2066 + ndlp->nlp_DID, iotag, 2067 + ndlp->nlp_fc4_type, 2067 2068 ulp_status, ulp_word4, 2068 2069 disc, vport->num_disc_nodes); 2069 2070 ··· 2129 2128 NLP_EVT_DEVICE_RM); 2130 2129 } else { 2131 2130 /* Good status, call state machine */ 2132 - prsp = list_entry(cmdiocb->cmd_dmabuf->list.next, 2133 - struct lpfc_dmabuf, list); 2131 + prsp = list_get_first(&cmdiocb->cmd_dmabuf->list, 2132 + struct lpfc_dmabuf, list); 2134 2133 if (!prsp) 2135 2134 goto out; 2136 2135 if (!lpfc_is_els_acc_rsp(prsp)) ··· 2363 2362 /* PRLI completes to NPort <nlp_DID> */ 2364 2363 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 2365 2364 "0103 PRLI completes to NPort x%06x " 2366 - "Data: x%x x%x x%x x%x\n", 2365 + "Data: x%x x%x x%x x%x x%x\n", 2367 2366 ndlp->nlp_DID, ulp_status, ulp_word4, 2368 - vport->num_disc_nodes, ndlp->fc4_prli_sent); 2367 + vport->num_disc_nodes, ndlp->fc4_prli_sent, 2368 + ndlp->fc4_xpt_flags); 2369 2369 2370 2370 /* Check to see if link went down during discovery */ 2371 2371 if (lpfc_els_chk_latt(vport)) ··· 2807 2805 IOCB_t *irsp; 2808 2806 struct lpfc_nodelist *ndlp; 2809 2807 int disc; 2810 - u32 ulp_status, ulp_word4, tmo; 2808 + u32 ulp_status, ulp_word4, tmo, iotag; 2811 2809 bool release_node = false; 2812 2810 2813 2811 /* we pass cmdiocb to state machine which needs rspiocb as well */ ··· 2820 2818 2821 2819 if (phba->sli_rev == LPFC_SLI_REV4) { 2822 2820 tmo = get_wqe_tmo(cmdiocb); 2821 + iotag = get_wqe_reqtag(cmdiocb); 2823 2822 } else { 2824 2823 irsp = &rspiocb->iocb; 2825 2824 tmo = irsp->ulpTimeout; 2825 + iotag = irsp->ulpIoTag; 2826 2826 } 2827 2827 2828 2828 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, ··· 2842 2838 /* ADISC completes to NPort <nlp_DID> */ 2843 2839 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 2844 2840 "0104 ADISC completes to NPort x%x " 2845 - "Data: x%x x%x x%x x%x x%x\n", 2846 - ndlp->nlp_DID, ulp_status, ulp_word4, 2841 + "IoTag x%x Data: x%x x%x x%x x%x x%x\n", 2842 + ndlp->nlp_DID, iotag, 2843 + ulp_status, ulp_word4, 2847 2844 tmo, disc, vport->num_disc_nodes); 2845 + 2848 2846 /* Check to see if link went down during discovery */ 2849 2847 if (lpfc_els_chk_latt(vport)) { 2850 2848 spin_lock_irq(&ndlp->lock); ··· 3007 3001 int wake_up_waiter = 0; 3008 3002 u32 ulp_status; 3009 3003 u32 ulp_word4; 3010 - u32 tmo; 3004 + u32 tmo, iotag; 3011 3005 3012 3006 /* we pass cmdiocb to state machine which needs rspiocb as well */ 3013 3007 cmdiocb->rsp_iocb = rspiocb; ··· 3017 3011 3018 3012 if (phba->sli_rev == LPFC_SLI_REV4) { 3019 3013 tmo = get_wqe_tmo(cmdiocb); 3014 + iotag = get_wqe_reqtag(cmdiocb); 3020 3015 } else { 3021 3016 irsp = &rspiocb->iocb; 3022 3017 tmo = irsp->ulpTimeout; 3018 + iotag = irsp->ulpIoTag; 3023 3019 } 3024 3020 3025 3021 spin_lock_irq(&ndlp->lock); ··· 3040 3032 /* LOGO completes to NPort <nlp_DID> */ 3041 3033 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 3042 3034 "0105 LOGO completes to NPort x%x " 3043 - "refcnt %d nflags x%x Data: x%x x%x x%x x%x\n", 3044 - ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp->nlp_flag, 3045 - ulp_status, ulp_word4, 3035 + "IoTag x%x refcnt %d nflags x%x xflags x%x " 3036 + "Data: x%x x%x x%x x%x\n", 3037 + ndlp->nlp_DID, iotag, 3038 + kref_read(&ndlp->kref), ndlp->nlp_flag, 3039 + ndlp->fc4_xpt_flags, ulp_status, ulp_word4, 3046 3040 tmo, vport->num_disc_nodes); 3047 3041 3048 3042 if (lpfc_els_chk_latt(vport)) { ··· 5085 5075 if (logerr) { 5086 5076 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 5087 5077 "0137 No retry ELS command x%x to remote " 5088 - "NPORT x%x: Out of Resources: Error:x%x/%x\n", 5089 - cmd, did, ulp_status, 5090 - ulp_word4); 5078 + "NPORT x%x: Out of Resources: Error:x%x/%x " 5079 + "IoTag x%x\n", 5080 + cmd, did, ulp_status, ulp_word4, 5081 + cmdiocb->iotag); 5091 5082 } 5092 5083 else { 5093 5084 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 5094 - "0108 No retry ELS command x%x to remote " 5095 - "NPORT x%x Retried:%d Error:x%x/%x\n", 5096 - cmd, did, cmdiocb->retry, ulp_status, 5097 - ulp_word4); 5085 + "0108 No retry ELS command x%x to remote " 5086 + "NPORT x%x Retried:%d Error:x%x/%x " 5087 + "IoTag x%x nflags x%x\n", 5088 + cmd, did, cmdiocb->retry, ulp_status, 5089 + ulp_word4, cmdiocb->iotag, 5090 + (ndlp ? ndlp->nlp_flag : 0)); 5098 5091 } 5099 5092 return 0; 5100 5093 }
+1 -1
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 411 411 "port_state = x%x\n", 412 412 ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp, 413 413 ndlp->nlp_flag, vport->port_state); 414 - spin_lock_irqsave(&ndlp->lock, iflags); 414 + return; 415 415 } 416 416 spin_unlock_irqrestore(&ndlp->lock, iflags); 417 417 }
+2 -2
drivers/scsi/lpfc/lpfc_init.c
··· 14721 14721 int 14722 14722 lpfc_sli4_request_firmware_update(struct lpfc_hba *phba, uint8_t fw_upgrade) 14723 14723 { 14724 - uint8_t file_name[ELX_MODEL_NAME_SIZE]; 14724 + char file_name[ELX_FW_NAME_SIZE] = {0}; 14725 14725 int ret; 14726 14726 const struct firmware *fw; 14727 14727 ··· 14730 14730 LPFC_SLI_INTF_IF_TYPE_2) 14731 14731 return -EPERM; 14732 14732 14733 - snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName); 14733 + scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); 14734 14734 14735 14735 if (fw_upgrade == INT_FW_UPGRADE) { 14736 14736 ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
+4 -2
drivers/scsi/lpfc/lpfc_mbox.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 1814 1814 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, 1815 1815 mbox->sge_array->addr[sgentry], phyaddr); 1816 1816 } 1817 - /* Free the sge address array memory */ 1817 + /* Reinitialize the context pointers to avoid stale usage. */ 1818 + mbox->ctx_buf = NULL; 1819 + mbox->context3 = NULL; 1818 1820 kfree(mbox->sge_array); 1819 1821 /* Finally, free the mailbox command itself */ 1820 1822 mempool_free(mbox, phba->mbox_mem_pool);
+27 -20
drivers/scsi/lpfc/lpfc_mem.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2014 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 47 47 #define LPFC_DEVICE_DATA_POOL_SIZE 64 /* max elements in device data pool */ 48 48 #define LPFC_RRQ_POOL_SIZE 256 /* max elements in non-DMA pool */ 49 49 #define LPFC_MBX_POOL_SIZE 256 /* max elements in MBX non-DMA pool */ 50 + 51 + /* lpfc_mbox_free_sli_mbox 52 + * 53 + * @phba: HBA to free memory for 54 + * @mbox: mailbox command to free 55 + * 56 + * This routine detects the mbox type and calls the correct 57 + * free routine to fully release all associated memory. 58 + */ 59 + static void 60 + lpfc_mem_free_sli_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) 61 + { 62 + /* Detect if the caller's mbox is an SLI4_CONFIG type. If so, this 63 + * mailbox type requires a different cleanup routine. Otherwise, the 64 + * mailbox is just an mbuf and mem_pool release. 65 + */ 66 + if (phba->sli_rev == LPFC_SLI_REV4 && 67 + bf_get(lpfc_mqe_command, &mbox->u.mqe) == MBX_SLI4_CONFIG) { 68 + lpfc_sli4_mbox_cmd_free(phba, mbox); 69 + } else { 70 + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); 71 + } 72 + } 50 73 51 74 int 52 75 lpfc_mem_alloc_active_rrq_pool_s4(struct lpfc_hba *phba) { ··· 311 288 { 312 289 struct lpfc_sli *psli = &phba->sli; 313 290 LPFC_MBOXQ_t *mbox, *next_mbox; 314 - struct lpfc_dmabuf *mp; 315 291 316 292 /* Free memory used in mailbox queue back to mailbox memory pool */ 317 293 list_for_each_entry_safe(mbox, next_mbox, &psli->mboxq, list) { 318 - mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); 319 - if (mp) { 320 - lpfc_mbuf_free(phba, mp->virt, mp->phys); 321 - kfree(mp); 322 - } 323 294 list_del(&mbox->list); 324 - mempool_free(mbox, phba->mbox_mem_pool); 295 + lpfc_mem_free_sli_mbox(phba, mbox); 325 296 } 326 297 /* Free memory used in mailbox cmpl list back to mailbox memory pool */ 327 298 list_for_each_entry_safe(mbox, next_mbox, &psli->mboxq_cmpl, list) { 328 - mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); 329 - if (mp) { 330 - lpfc_mbuf_free(phba, mp->virt, mp->phys); 331 - kfree(mp); 332 - } 333 299 list_del(&mbox->list); 334 - mempool_free(mbox, phba->mbox_mem_pool); 300 + lpfc_mem_free_sli_mbox(phba, mbox); 335 301 } 336 302 /* Free the active mailbox command back to the mailbox memory pool */ 337 303 spin_lock_irq(&phba->hbalock); ··· 328 316 spin_unlock_irq(&phba->hbalock); 329 317 if (psli->mbox_active) { 330 318 mbox = psli->mbox_active; 331 - mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); 332 - if (mp) { 333 - lpfc_mbuf_free(phba, mp->virt, mp->phys); 334 - kfree(mp); 335 - } 336 - mempool_free(mbox, phba->mbox_mem_pool); 319 + lpfc_mem_free_sli_mbox(phba, mbox); 337 320 psli->mbox_active = NULL; 338 321 } 339 322
+16 -4
drivers/scsi/lpfc/lpfc_sli.c
··· 2995 2995 LPFC_SLI_INTF_IF_TYPE_2)) { 2996 2996 if (ndlp) { 2997 2997 lpfc_printf_vlog( 2998 - vport, KERN_INFO, LOG_MBOX | LOG_SLI, 2999 - "0010 UNREG_LOGIN vpi:%x " 2998 + vport, KERN_INFO, 2999 + LOG_MBOX | LOG_SLI | LOG_NODE, 3000 + "0010 UNREG_LOGIN vpi:x%x " 3000 3001 "rpi:%x DID:%x defer x%x flg x%x " 3001 3002 "x%px\n", 3002 3003 vport->vpi, ndlp->nlp_rpi, ··· 3013 3012 (ndlp->nlp_defer_did != 3014 3013 NLP_EVT_NOTHING_PENDING)) { 3015 3014 lpfc_printf_vlog( 3016 - vport, KERN_INFO, LOG_DISCOVERY, 3015 + vport, KERN_INFO, 3016 + LOG_MBOX | LOG_SLI | LOG_NODE, 3017 3017 "4111 UNREG cmpl deferred " 3018 3018 "clr x%x on " 3019 3019 "NPort x%x Data: x%x x%px\n", ··· 3938 3936 3939 3937 phba = from_timer(phba, t, eratt_poll); 3940 3938 if (!(phba->hba_flag & HBA_SETUP)) 3939 + return; 3940 + 3941 + if (phba->pport->load_flag & FC_UNLOADING) 3941 3942 return; 3942 3943 3943 3944 /* Here we will also keep track of interrupts per sec of the hba */ ··· 10146 10141 spin_unlock_irqrestore(&phba->hbalock, iflags); 10147 10142 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 10148 10143 "(%d):0354 Mbox cmd issue - Enqueue Data: " 10149 - "x%x (x%x/x%x) x%x x%x x%x\n", 10144 + "x%x (x%x/x%x) x%x x%x x%x x%x\n", 10150 10145 mboxq->vport ? mboxq->vport->vpi : 0xffffff, 10151 10146 bf_get(lpfc_mqe_command, &mboxq->u.mqe), 10152 10147 lpfc_sli_config_mbox_subsys_get(phba, mboxq), 10153 10148 lpfc_sli_config_mbox_opcode_get(phba, mboxq), 10149 + mboxq->u.mb.un.varUnregLogin.rpi, 10154 10150 phba->pport->port_state, 10155 10151 psli->sli_flag, MBX_NOWAIT); 10156 10152 /* Wake up worker thread to transport mailbox command from head */ ··· 22173 22167 * The data will be truncated if datasz is not large enough. 22174 22168 * Version 1 is not supported with Embedded mbox cmd, so we must use version 0. 22175 22169 * Returns the actual bytes read from the object. 22170 + * 22171 + * This routine is hard coded to use a poll completion. Unlike other 22172 + * sli4_config mailboxes, it uses lpfc_mbuf memory which is not 22173 + * cleaned up in lpfc_sli4_cmd_mbox_free. If this routine is modified 22174 + * to use interrupt-based completions, code is needed to fully cleanup 22175 + * the memory. 22176 22176 */ 22177 22177 int 22178 22178 lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap,
+6 -4
drivers/scsi/lpfc/lpfc_sli.h
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 182 182 struct lpfc_mqe mqe; 183 183 } u; 184 184 struct lpfc_vport *vport; /* virtual port pointer */ 185 - void *ctx_ndlp; /* caller ndlp information */ 186 - void *ctx_buf; /* caller buffer information */ 187 - void *context3; 185 + void *ctx_ndlp; /* an lpfc_nodelist pointer */ 186 + void *ctx_buf; /* an lpfc_dmabuf pointer */ 187 + void *context3; /* a generic pointer. Code must 188 + * accommodate the actual datatype. 189 + */ 188 190 189 191 void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); 190 192 uint8_t mbox_flag;
+1 -1
drivers/scsi/lpfc/lpfc_version.h
··· 20 20 * included with this package. * 21 21 *******************************************************************/ 22 22 23 - #define LPFC_DRIVER_VERSION "14.2.0.15" 23 + #define LPFC_DRIVER_VERSION "14.2.0.16" 24 24 #define LPFC_DRIVER_NAME "lpfc" 25 25 26 26 /* Used for SLI 2/3 */