lpfc: Update lpfc to revision 12.6.0.1
Subsystems (3)
cover lpfc: Update lpfc to revision 12.6.0.1
Update lpfc to revision 12.6.0.2
This patch set contains:
two fixes for coverity reports
one fix for a compilation error
a driver fix to address hot-cpu add conditions
and a oneliner that is cleanup
The patches were cut against Martin's 5.5/scsi-queue tree
James Smart (6):
lpfc: fix: Coverity: lpfc_get_scsi_buf_s3(): Null pointer dereferences
lpfc: fix: Coverity: lpfc_cmpl_els_rsp(): Null pointer dereferences
lpfc: fix inlining of lpfc_sli4_cleanup_poll_list()
lpfc: Initialize cpu_map for not present cpus
lpfc: revise nvme max queues to be hdwq count
lpfc: Update lpfc version to 12.6.0.2
drivers/scsi/lpfc/lpfc_crtn.h | 2 +- drivers/scsi/lpfc/lpfc_els.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 19 ++++++++++++++++++- drivers/scsi/lpfc/lpfc_nvme.c | 10 ++++------ drivers/scsi/lpfc/lpfc_scsi.c | 2 +- drivers/scsi/lpfc/lpfc_sli.c | 2 +- drivers/scsi/lpfc/lpfc_version.h | 2 +- 7 files changed, 27 insertions(+), 12 deletions(-)
Signature · 1 line
2.13.7
PATCH 1/6 lpfc: fix: Coverity: lpfc_get_scsi_buf_s3(): Null pointer dereferences
Coverity reported the following:
*** CID 1487391: Null pointer dereferences (FORWARD_NULL) /drivers/scsi/lpfc/lpfc_scsi.c: 614 in lpfc_get_scsi_buf_s3()
608 spin_unlock(&phba->scsi_buf_list_put_lock);
609 }
610 spin_unlock_irqrestore(&phba->scsi_buf_list_get_lock, iflag);
611
612 if (lpfc_ndlp_check_qdepth(phba, ndlp)) {
613 atomic_inc(&ndlp->cmd_pending);
vvv CID 1487391: Null pointer dereferences (FORWARD_NULL)
vvv Dereferencing null pointer "lpfc_cmd".
614 lpfc_cmd->flags |= LPFC_SBUF_BUMP_QDEPTH;
615 }
616 return lpfc_cmd;
617 }
618 /**619 * lpfc_get_scsi_buf_s4 - Get a scsi buffer from io_buf_list of the HBA
Fix by checking lpfc_cmd to be non-NULL as part of line 612
Addresses-Coverity-ID: 1487391 ("Null pointer dereferences")
--- drivers/scsi/lpfc/lpfc_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -611,7 +611,7 @@ lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, }spin_unlock_irqrestore (&phba->scsi_buf_list_get_lock, iflag); -if (lpfc_ndlp_check_qdepth (phba, ndlp)) { +if (lpfc_ndlp_check_qdepth (phba, ndlp) && lpfc_cmd) {atomic_inc (&ndlp->cmd_pending); lpfc_cmd->flags |=LPFC_SBUF_BUMP_QDEPTH ; }
Signature · 1 line
2.13.7
Re: [PATCH 1/6] lpfc: fix: Coverity: lpfc_get_scsi_buf_s3(): Null pointer dereferences
Quoted 39 lines · James Smart
Coverity reported the following:
*** CID 1487391: Null pointer dereferences (
FORWARD_NULL) /drivers/scsi/lpfc/lpfc_scsi.c: 614 inlpfc_get_scsi_buf_s3()608 spin_unlock(&phba->scsi_buf_list_put_lock); 609 } 610 spin_unlock_irqrestore(&phba->scsi_buf_list_get_lock, iflag); 611 612 if (lpfc_ndlp_check_qdepth(phba, ndlp)) { 613 atomic_inc(&ndlp->cmd_pending); vvv CID 1487391: Null pointer dereferences (FORWARD_NULL) vvv Dereferencing null pointer "lpfc_cmd". 614 lpfc_cmd->flags |= LPFC_SBUF_BUMP_QDEPTH; 615 } 616 return lpfc_cmd; 617 } 618 /**619 *
lpfc_get_scsi_buf_s4- Get a scsi buffer fromio_buf_listof the HBAFix by checking
lpfc_cmdto be non-NULL as part of line 612Reported-by coverity-bot <[email protected]>Addresses-Coverity-ID: 1487391 ("Null pointer dereferences")
Fixes 2a5b7d626ed2 ("scsi: lpfc: Limit tracking of tgt queue depth in fast path")Signed-off-by Dick Kennedy <[email protected]>Signed-off-by James Smart <[email protected]>CC "Martin K. Petersen" <[email protected]>CC "Gustavo A. R. Silva" <[email protected]>--- drivers/scsi/lpfc/lpfc_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_scsi.c +0
-0
drivers/scsi/lpfc/lpfc_scsi.c lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · line 617
Quoted 8 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-1@@ -611,7 +611,7 @@ lpfc_get_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, }spin_unlock_irqrestore (&phba->scsi_buf_list_get_lock, iflag); -if (lpfc_ndlp_check_qdepth (phba, ndlp)) { +if (lpfc_ndlp_check_qdepth (phba, ndlp) && lpfc_cmd) {atomic_inc (&ndlp->cmd_pending); lpfc_cmd->flags |=LPFC_SBUF_BUMP_QDEPTH ; }
PATCH 2/6 lpfc: fix: Coverity: lpfc_cmpl_els_rsp(): Null pointer dereferences
In reply to James SmartCoverity reported the following:
*** CID 101747: Null pointer dereferences (FORWARD_NULL) /drivers/scsi/lpfc/lpfc_els.c: 4439 in lpfc_cmpl_els_rsp()
4433 kfree(mp);
4434 }
4435 mempool_free(mbox, phba->mbox_mem_pool);
4436 }
4437 out:
4438 if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
vvv CID 101747: Null pointer dereferences (FORWARD_NULL)
vvv Dereferencing null pointer "shost".
4439 spin_lock_irq(shost->host_lock);
4440 ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI);
4441 spin_unlock_irq(shost->host_lock);4442
4443 /* If the node is not being used by another discovery thread,
4444 * and we are sending a reject, we are done with it.
Fix by adding a check for non-null shost in line 4438. The scenario when shost is set to null is when ndlp is null. As such, the ndlp check present was sufficient. But better safe than sorry so add the shost check.
Addresses-Coverity-ID: 101747 ("Null pointer dereferences")
--- drivers/scsi/lpfc/lpfc_els.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +1 -1
@@ -4445,7 +4445,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,mempool_free (mbox, phba->mbox_mem_pool); } out: -if (ndlp &&NLP_CHK_NODE_ACT (ndlp)) { +if (ndlp &&NLP_CHK_NODE_ACT (ndlp) && shost) {spin_lock_irq (shost->host_lock); ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN |NLP_RM_DFLT_RPI );spin_unlock_irq (shost->host_lock);
Signature · 1 line
2.13.7
Re: [PATCH 2/6] lpfc: fix: Coverity: lpfc_cmpl_els_rsp(): Null pointer dereferences
Quoted 42 lines · James Smart
Coverity reported the following:
*** CID 101747: Null pointer dereferences (
FORWARD_NULL) /drivers/scsi/lpfc/lpfc_els.c: 4439 inlpfc_cmpl_els_rsp()4433 kfree(mp); 4434 } 4435 mempool_free(mbox, phba->mbox_mem_pool); 4436 } 4437 out: 4438 if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { vvv CID 101747: Null pointer dereferences (FORWARD_NULL) vvv Dereferencing null pointer "shost". 4439 spin_lock_irq(shost->host_lock); 4440 ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); 4441 spin_unlock_irq(shost->host_lock);4442
4443 /* If the node is not being used by another discovery thread,
4444 * and we are sending a reject, we are done with it.Fix by adding a check for non-null shost in line 4438. The scenario when shost is set to null is when ndlp is null. As such, the ndlp check present was sufficient. But better safe than sorry so add the shost check.
Reported-by coverity-bot <[email protected]>Addresses-Coverity-ID: 101747 ("Null pointer dereferences")
Fixes 2e0fef85e098 ("[SCSI] lpfc: NPIV: split ports")Signed-off-by Dick Kennedy <[email protected]>Signed-off-by James Smart <[email protected]>CC James Bottomley <[email protected]>CC "Gustavo A. R. Silva" <[email protected]>--- drivers/scsi/lpfc/lpfc_els.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_els.c +0
-0
drivers/scsi/lpfc/lpfc_els.c lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · line 4451
Quoted 8 lines
drivers/scsi/lpfc/lpfc_els.c +1
-1@@ -4445,7 +4445,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,mempool_free (mbox, phba->mbox_mem_pool); } out: -if (ndlp &&NLP_CHK_NODE_ACT (ndlp)) { +if (ndlp &&NLP_CHK_NODE_ACT (ndlp) && shost) {spin_lock_irq (shost->host_lock); ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN |NLP_RM_DFLT_RPI );spin_unlock_irq (shost->host_lock);
PATCH 3/6 lpfc: fix inlining of lpfc_sli4_cleanup_poll_list()
In reply to James SmartCompilation can fail due to having an inline function reference where the function body is not present.
Fix by removing the inline tag.
---
patch is in the 12.6.0.1 set which is in 5.5/scsi-queue
--- drivers/scsi/lpfc/lpfc_crtn.h | 2 +- drivers/scsi/lpfc/lpfc_sli.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_crtn.h +1 -1
@@ -215,7 +215,7 @@ irqreturn_t lpfc_sli_fp_intr_handler(int, void *);irqreturn_t lpfc_sli4_intr_handler (int ,void *);irqreturn_t lpfc_sli4_hba_intr_handler (int ,void *); -inline void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba); +void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba);int lpfc_sli4_poll_eq (struct lpfc_queue *q,uint8_t path);void lpfc_sli4_poll_hbtimer (struct timer_list *t);void lpfc_sli4_start_polling (struct lpfc_queue *q);
drivers/scsi/lpfc/lpfc_sli.c +1 -1
@@ -14466,7 +14466,7 @@ static inline void lpfc_sli4_remove_from_poll_list(struct lpfc_queue *eq)del_timer_sync (&phba->cpuhp_poll_timer); } -inline void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba) +void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba) {struct lpfc_queue *eq, *next;
Signature · 1 line
2.13.7
Re: [PATCH 3/6] lpfc: fix inlining of lpfc_sli4_cleanup_poll_list()
Quoted 34 lines · James Smart
Compilation can fail due to having an inline function reference where the function body is not present.
Fix by removing the inline tag.
Fixes 93a4d6f40198 ("scsi: lpfc: Add registration for CPU Offline/Online events")Signed-off-by Dick Kennedy <[email protected]>Signed-off-by James Smart <[email protected]>---
patch is in the 12.6.0.1 set which is in 5.5/scsi-queue--- drivers/scsi/lpfc/lpfc_crtn.h | 2 +- drivers/scsi/lpfc/lpfc_sli.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/scsi/lpfc/lpfc_crtn.h +1
-1@@ -215,7 +215,7 @@ irqreturn_t lpfc_sli_fp_intr_handler(int, void *);irqreturn_t lpfc_sli4_intr_handler (int ,void *);irqreturn_t lpfc_sli4_hba_intr_handler (int ,void *); -inline void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba); +void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba);int lpfc_sli4_poll_eq (struct lpfc_queue *q,uint8_t path);void lpfc_sli4_poll_hbtimer (struct timer_list *t);void lpfc_sli4_start_polling (struct lpfc_queue *q);drivers/scsi/lpfc/lpfc_sli.c +0
-0
drivers/scsi/lpfc/lpfc_sli.c static inline void lpfc_sli4_remove_from_poll_list(struct lpfc_queue *eq) · line 14472
Quoted 8 lines
drivers/scsi/lpfc/lpfc_sli.c +1
-1@@ -14466,7 +14466,7 @@ static inline void lpfc_sli4_remove_from_poll_list(struct lpfc_queue *eq)del_timer_sync (&phba->cpuhp_poll_timer); } -inline void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba) +void lpfc_sli4_cleanup_poll_list (struct lpfc_hba *phba) {struct lpfc_queue *eq, *next;
PATCH 4/6 lpfc: Initialize cpu_map for not present cpus
In reply to James SmartCurrently, cpu_map[cpu#]->hdwq is left to equal LPFC_VECTOR_MAP_EMPTY for not present CPUs. If a CPU is dynamically hot-added, it is possible we may crash due to not assigning an allocated hdwq.
Correct by assigning a hdwq at initialization for all not-present cpu's.
---
Issue applies as of the 12.2.0.0 patch kit, but this fix requires the above patch set for resolution. Referenced patch is in the 5.5/scsi-queue branch
--- drivers/scsi/lpfc/lpfc_init.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_init.c +18 -1
@@ -11004,7 +11004,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) cpu, cpup->phys_id, cpup->core_id, cpup->hdwq, cpup->eq, cpup->flag); } -/* Finally we need to associate a hdwq with each cpu_map entry +/* Associate a hdwq with each cpu_map entry * This will be 1 to 1 - hdwq to cpu, unless there are less * hardware queues then CPUs. For that case we will just round-robin * the available hardware queues as they get assigned to CPUs.
@@ -11083,6 +11083,23 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) cpup->hdwq, cpup->eq, cpup->flag); } +/* +* Initialize the cpu_map slots for not-present cpus in case +* a cpu is hot-added. Perform a simple hdwq round robin assignment. +*/ + idx =0 ; +for_each_possible_cpu (cpu) { + cpup = &phba->sli4_hba.cpu_map[cpu]; +if (cpup->hdwq !=LPFC_VECTOR_MAP_EMPTY ) +continue ; + + cpup->hdwq = idx++ % phba->cfg_hdw_queue; +lpfc_printf_log (phba,KERN_INFO ,LOG_INIT , +"3340 Set Affinity: not present " +"CPU %d hdwq %d\n" , + cpu, cpup->hdwq); + } +/* The cpu_map array will be used later during initialization * when EQ / CQ / WQs are allocated and configured. */
Signature · 1 line
2.13.7
Re: [PATCH 4/6] lpfc: Initialize cpu_map for not present cpus
Quoted 46 lines · James Smart
Currently, cpu_map[cpu#]->hdwq is left to equal
LPFC_VECTOR_MAP_EMPTYfor not present CPUs. If a CPU is dynamically hot-added, it is possible we may crash due to not assigning an allocated hdwq.Correct by assigning a hdwq at initialization for all not-present cpu's.
Fixes dcaa21367938 ("scsi: lpfc: Change default IRQ model on AMD architectures")Signed-off-by Dick Kennedy <[email protected]>Signed-off-by James Smart <[email protected]>---
Issue applies as of the 12.2.0.0 patch kit, but this fix requires the above patch set for resolution. Referenced patch is in the 5.5/scsi-queue branch--- drivers/scsi/lpfc/lpfc_init.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_init.c +11
-1@@ -11004,7 +11004,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) cpu, cpup->phys_id, cpup->core_id, cpup->hdwq, cpup->eq, cpup->flag); } -/* Finally we need to associate a hdwq with each cpu_map entry +/* Associate a hdwq with each cpu_map entry * This will be 1 to 1 - hdwq to cpu, unless there are less * hardware queues then CPUs. For that case we will just round-robin * the available hardware queues as they get assigned to CPUs. @@ -11083,6 +11083,23 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) cpup->hdwq, cpup->eq, cpup->flag); } +/* +* Initialize the cpu_map slots for not-present cpus in case +* a cpu is hot-added. Perform a simple hdwq round robin assignment. +*/ + idx =0 ; +for_each_possible_cpu (cpu) { + cpup = &phba->sli4_hba.cpu_map[cpu]; +if (cpup->hdwq !=LPFC_VECTOR_MAP_EMPTY ) +continue ; +
drivers/scsi/lpfc/lpfc_init.c lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) · line 11105
Quoted 10 lines
drivers/scsi/lpfc/lpfc_init.c +7
-0+ cpup->hdwq = idx++ % phba->cfg_hdw_queue; +lpfc_printf_log (phba,KERN_INFO ,LOG_INIT , +"3340 Set Affinity: not present " +"CPU %d hdwq %d\n" , + cpu, cpup->hdwq); + } +/* The cpu_map array will be used later during initialization * when EQ / CQ / WQs are allocated and configured. */
PATCH 5/6 lpfc: revise nvme max queues to be hdwq count
In reply to James SmartDriver is setting the initiator nvme template with a max hw queues value of the present cpu count which is odd. It should be registering the number of hdwq queues (queues created on the adapter).
Change to set nvme tempate, in all cases, to the number of hardware queues.
--- drivers/scsi/lpfc/lpfc_nvme.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_nvme.c +4 -6
@@ -2148,12 +2148,10 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)*/ lpfc_nvme_template.max_sgl_segments = phba->cfg_nvme_seg_cnt +1 ; -/* Advertise how many hw queues we support based on fcp_io_sched */ -if (phba->cfg_fcp_io_sched ==LPFC_FCP_SCHED_BY_HDWQ ) - lpfc_nvme_template.max_hw_queues = phba->cfg_hdw_queue; -else - lpfc_nvme_template.max_hw_queues = - phba->sli4_hba.num_present_cpu; +/* Advertise how many hw queues we support based on cfg_hdw_queue, +* which will not exceed cpu count. +*/ + lpfc_nvme_template.max_hw_queues = phba->cfg_hdw_queue;if (!IS_ENABLED (CONFIG_NVME_FC ))return ret;
Signature · 1 line
2.13.7
PATCH 6/6 lpfc: Update lpfc version to 12.6.0.2
In reply to James SmartUpdate lpfc version to 12.6.0.2
--- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_version.h +1 -1
@@ -20,7 +20,7 @@* included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "12.6.0.1" +#define LPFC_DRIVER_VERSION "12.6.0.2"#define LPFC_DRIVER_NAME "lpfc"/* Used for SLI 2/3 */
Signature · 1 line
2.13.7
Re: [PATCH 6/6] lpfc: Update lpfc version to 12.6.0.2
Quoted 13 lines · James Smart
Update lpfc version to 12.6.0.2
Signed-off-by Dick Kennedy <[email protected]>Signed-off-by James Smart <[email protected]>--- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_version.h +0
-0
drivers/scsi/lpfc/lpfc_version.h line 26
Quoted 8 lines
drivers/scsi/lpfc/lpfc_version.h +1
-1@@ -20,7 +20,7 @@* included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "12.6.0.1" +#define LPFC_DRIVER_VERSION "12.6.0.2"#define LPFC_DRIVER_NAME "lpfc"/* Used for SLI 2/3 */
Martin K. Petersen
AppliedJames,
Quoted 1 line
Update lpfc to revision 12.6.0.2
Applied to 5.5/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering