From e34ccdfe0e08a6acb8c5e649fef1e94e6cd637f9 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 13 Jul 2009 23:25:54 +0200 Subject: [SCSI] lpfc: don't dereference NULL When kzalloc fails in lpfc_hba_alloc, don't dereference the NULL by lpfc_printf_log. Use dev_err instead. Signed-off-by: Jiri Slaby Acked-By: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index fc67cc65c63..2452dc9c901 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -4130,8 +4130,7 @@ lpfc_hba_alloc(struct pci_dev *pdev) /* Allocate memory for HBA structure */ phba = kzalloc(sizeof(struct lpfc_hba), GFP_KERNEL); if (!phba) { - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, - "1417 Failed to allocate hba struct.\n"); + dev_err(&pdev->dev, "failed to allocate hba struct\n"); return NULL; } -- cgit v1.2.3 From 8fa38513ddc1076f3e26c651f3567b084c273ba2 Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:03 -0400 Subject: [SCSI] lpfc 8.3.4: Various SLI4 fixes Various SLI4 fixes - Fix switch name not used in the FCF record for FCoE HBAs - Enabled HBA UE error polling error-condition action code - Rewrite lpfc_sli4_scmd_to_wqidx_distr() to handle counter rollover cleanly - Modify resume_rpi mailbox data structure to match current SLI4 spec - Do not issue mailbox command in MBX_POLL mode when LPFC_HBA_ERROR is set - Wait for HBA POST completion before checking Online and UE registers - Fix accumulated total length not being filled in on unsolicited IOCBs - Use PCI config space register to determine SLI rev of HBA - Turn on starting ELS tmo function timer during device initialization Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 48 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 2452dc9c901..f8271a587aa 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -4488,23 +4488,6 @@ lpfc_sli4_post_status_check(struct lpfc_hba *phba) if (!phba->sli4_hba.STAregaddr) return -ENODEV; - /* With uncoverable error, log the error message and return error */ - onlnreg0 = readl(phba->sli4_hba.ONLINE0regaddr); - onlnreg1 = readl(phba->sli4_hba.ONLINE1regaddr); - if ((onlnreg0 != LPFC_ONLINE_NERR) || (onlnreg1 != LPFC_ONLINE_NERR)) { - uerrlo_reg.word0 = readl(phba->sli4_hba.UERRLOregaddr); - uerrhi_reg.word0 = readl(phba->sli4_hba.UERRHIregaddr); - if (uerrlo_reg.word0 || uerrhi_reg.word0) { - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, - "1422 HBA Unrecoverable error: " - "uerr_lo_reg=0x%x, uerr_hi_reg=0x%x, " - "online0_reg=0x%x, online1_reg=0x%x\n", - uerrlo_reg.word0, uerrhi_reg.word0, - onlnreg0, onlnreg1); - } - return -ENODEV; - } - /* Wait up to 30 seconds for the SLI Port POST done and ready */ for (i = 0; i < 3000; i++) { sta_reg.word0 = readl(phba->sli4_hba.STAregaddr); @@ -4544,6 +4527,23 @@ lpfc_sli4_post_status_check(struct lpfc_hba *phba) bf_get(lpfc_scratchpad_featurelevel1, &scratchpad), bf_get(lpfc_scratchpad_featurelevel2, &scratchpad)); + /* With uncoverable error, log the error message and return error */ + onlnreg0 = readl(phba->sli4_hba.ONLINE0regaddr); + onlnreg1 = readl(phba->sli4_hba.ONLINE1regaddr); + if ((onlnreg0 != LPFC_ONLINE_NERR) || (onlnreg1 != LPFC_ONLINE_NERR)) { + uerrlo_reg.word0 = readl(phba->sli4_hba.UERRLOregaddr); + uerrhi_reg.word0 = readl(phba->sli4_hba.UERRHIregaddr); + if (uerrlo_reg.word0 || uerrhi_reg.word0) { + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, + "1422 HBA Unrecoverable error: " + "uerr_lo_reg=0x%x, uerr_hi_reg=0x%x, " + "online0_reg=0x%x, online1_reg=0x%x\n", + uerrlo_reg.word0, uerrhi_reg.word0, + onlnreg0, onlnreg1); + } + return -ENODEV; + } + return port_error; } @@ -7635,19 +7635,17 @@ static int __devinit lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) { int rc; - uint16_t dev_id; + struct lpfc_sli_intf intf; - if (pci_read_config_word(pdev, PCI_DEVICE_ID, &dev_id)) + if (pci_read_config_dword(pdev, LPFC_SLIREV_CONF_WORD, &intf.word0)) return -ENODEV; - switch (dev_id) { - case PCI_DEVICE_ID_TIGERSHARK: + if ((bf_get(lpfc_sli_intf_valid, &intf) == LPFC_SLI_INTF_VALID) && + (bf_get(lpfc_sli_intf_rev, &intf) == LPFC_SLIREV_CONF_SLI4)) rc = lpfc_pci_probe_one_s4(pdev, pid); - break; - default: + else rc = lpfc_pci_probe_one_s3(pdev, pid); - break; - } + return rc; } -- cgit v1.2.3 From a0c87cbdb52467a16343b31251f2722643db603c Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:10 -0400 Subject: [SCSI] lpfc 8.3.4: Consistently Implement persistent port disable Consistently implement persistent port disable. Ability was to be managed in the adapter via firmware via flash settings. However, not all firmware images supported it. Uniformly support it everywhere. Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 59 ++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 17 deletions(-) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index f8271a587aa..900b5628ceb 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -211,7 +211,7 @@ lpfc_config_port_prep(struct lpfc_hba *phba) goto out_free_mbox; do { - lpfc_dump_mem(phba, pmb, offset); + lpfc_dump_mem(phba, pmb, offset, DMP_REGION_VPD); rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); if (rc != MBX_SUCCESS) { @@ -425,6 +425,9 @@ lpfc_config_port_post(struct lpfc_hba *phba) return -EIO; } + /* Check if the port is disabled */ + lpfc_sli_read_link_ste(phba); + /* Reset the DFT_HBA_Q_DEPTH to the max xri */ if (phba->cfg_hba_queue_depth > (mb->un.varRdConfig.max_xri+1)) phba->cfg_hba_queue_depth = @@ -524,27 +527,49 @@ lpfc_config_port_post(struct lpfc_hba *phba) /* Set up error attention (ERATT) polling timer */ mod_timer(&phba->eratt_poll, jiffies + HZ * LPFC_ERATT_POLL_INTERVAL); - lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); - pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; - lpfc_set_loopback_flag(phba); - rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); - if (rc != MBX_SUCCESS) { - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, + /* Check if the port is disabled */ + lpfc_sli_read_serdes_param(phba); + + if (phba->hba_flag & LINK_DISABLED) { + lpfc_printf_log(phba, + KERN_ERR, LOG_INIT, + "2598 Adapter Link is disabled.\n"); + lpfc_down_link(phba, pmb); + pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; + rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); + if ((rc != MBX_SUCCESS) && (rc != MBX_BUSY)) { + lpfc_printf_log(phba, + KERN_ERR, LOG_INIT, + "2599 Adapter failed to issue DOWN_LINK" + " mbox command rc 0x%x\n", rc); + + mempool_free(pmb, phba->mbox_mem_pool); + return -EIO; + } + } else { + lpfc_init_link(phba, pmb, phba->cfg_topology, + phba->cfg_link_speed); + pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; + lpfc_set_loopback_flag(phba); + rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); + if (rc != MBX_SUCCESS) { + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0454 Adapter failed to init, mbxCmd x%x " "INIT_LINK, mbxStatus x%x\n", mb->mbxCommand, mb->mbxStatus); - /* Clear all interrupt enable conditions */ - writel(0, phba->HCregaddr); - readl(phba->HCregaddr); /* flush */ - /* Clear all pending interrupts */ - writel(0xffffffff, phba->HAregaddr); - readl(phba->HAregaddr); /* flush */ + /* Clear all interrupt enable conditions */ + writel(0, phba->HCregaddr); + readl(phba->HCregaddr); /* flush */ + /* Clear all pending interrupts */ + writel(0xffffffff, phba->HAregaddr); + readl(phba->HAregaddr); /* flush */ - phba->link_state = LPFC_HBA_ERROR; - if (rc != MBX_BUSY) - mempool_free(pmb, phba->mbox_mem_pool); - return -EIO; + phba->link_state = LPFC_HBA_ERROR; + if (rc != MBX_BUSY) + mempool_free(pmb, phba->mbox_mem_pool); + return -EIO; + } } /* MBOX buffer will be freed in mbox compl */ pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); -- cgit v1.2.3 From 8568a4d2495ebcf5da38a2141c7633399143b1a5 Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:16 -0400 Subject: [SCSI] lpfc 8.3.4: Various SLI3 fixes Various SLI3 fixes - Fix for firmware dump failure - Fix inband remote management Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 900b5628ceb..dc561e3c8b9 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -527,9 +527,6 @@ lpfc_config_port_post(struct lpfc_hba *phba) /* Set up error attention (ERATT) polling timer */ mod_timer(&phba->eratt_poll, jiffies + HZ * LPFC_ERATT_POLL_INTERVAL); - /* Check if the port is disabled */ - lpfc_sli_read_serdes_param(phba); - if (phba->hba_flag & LINK_DISABLED) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, -- cgit v1.2.3 From 32b9793fe6ff09a85f36b8bd7d6ff214653a7497 Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:21 -0400 Subject: [SCSI] lpfc 8.3.4: Fix a pair of FCoE issues Fix a pair of FCoE issues - Fix Region 23 FCoE Parameters not being read correctly - Fix race condition when there are FCoE events during FCF table read Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index dc561e3c8b9..a7f32ed256b 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -2829,6 +2829,7 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, att_type = lpfc_sli4_parse_latt_type(phba, acqe_link); if (att_type != AT_LINK_DOWN && att_type != AT_LINK_UP) return; + phba->fcoe_eventtag = acqe_link->event_tag; pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); if (!pmb) { lpfc_printf_log(phba, KERN_ERR, LOG_SLI, @@ -2916,6 +2917,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, uint8_t event_type = bf_get(lpfc_acqe_fcoe_event_type, acqe_fcoe); int rc; + phba->fcoe_eventtag = acqe_fcoe->event_tag; switch (event_type) { case LPFC_FCOE_EVENT_TYPE_NEW_FCF: lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, @@ -2923,11 +2925,12 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, acqe_fcoe->fcf_index, acqe_fcoe->event_tag); /* - * If the current FCF is in discovered state, - * do nothing. + * If the current FCF is in discovered state, or + * FCF discovery is in progress do nothing. */ spin_lock_irq(&phba->hbalock); - if (phba->fcf.fcf_flag & FCF_DISCOVERED) { + if ((phba->fcf.fcf_flag & FCF_DISCOVERED) || + (phba->hba_flag & FCF_DISC_INPROGRESS)) { spin_unlock_irq(&phba->hbalock); break; } -- cgit v1.2.3 From 1c6834a7e85715a4ac07c1cac25a1950040decb0 Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:26 -0400 Subject: [SCSI] lpfc 8.3.4: NPIV vport fixes NPIV vport fixes - Fixed static vport creation on SLI4 HBAs - Fixed vport create sending init_vpi before REG_VFI - Fix unable to create vports on SLI4 HBA's Port2 Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index a7f32ed256b..18bc5905c44 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -2155,6 +2155,8 @@ lpfc_online(struct lpfc_hba *phba) vports[i]->fc_flag &= ~FC_OFFLINE_MODE; if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; + if (phba->sli_rev == LPFC_SLI_REV4) + vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; spin_unlock_irq(shost->host_lock); } lpfc_destroy_vport_work_array(phba, vports); @@ -7371,6 +7373,9 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid) /* Perform post initialization setup */ lpfc_post_init_setup(phba); + /* Check if there are static vports to be created. */ + lpfc_create_static_vport(phba); + return 0; out_disable_intr: -- cgit v1.2.3 From f1c3b0fcbb8104dac92d65d5016500a09beea287 Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:32 -0400 Subject: [SCSI] lpfc 8.3.4: Add bsg (SGIOv4) support for ELS/CT support Add bsg (SGIOv4) support for sending and receiving ELS, CT commands This patch adds a new file, lpfc_bsg.c. Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 18bc5905c44..08112e7a834 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -4171,6 +4171,9 @@ lpfc_hba_alloc(struct pci_dev *pdev) return NULL; } + mutex_init(&phba->ct_event_mutex); + INIT_LIST_HEAD(&phba->ct_ev_waiters); + return phba; } -- cgit v1.2.3 From e4e74273c3e8d0dc54ddce4fed27e266927c7ad0 Mon Sep 17 00:00:00 2001 From: James Smart Date: Sun, 19 Jul 2009 10:01:38 -0400 Subject: [SCSI] lpfc 8.3.4: Remove spaces before newlines in several log messages Remove spaces before newlines in several log messages Signed-off-by: James Smart Signed-off-by: James Bottomley Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/lpfc/lpfc_init.c') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 08112e7a834..562d8cee874 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -580,7 +580,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) KERN_ERR, LOG_INIT, "0456 Adapter failed to issue " - "ASYNCEVT_ENABLE mbox status x%x \n.", + "ASYNCEVT_ENABLE mbox status x%x\n", rc); mempool_free(pmb, phba->mbox_mem_pool); } @@ -594,7 +594,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0435 Adapter failed " - "to get Option ROM version status x%x\n.", rc); + "to get Option ROM version status x%x\n", rc); mempool_free(pmb, phba->mbox_mem_pool); } @@ -2923,7 +2923,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, switch (event_type) { case LPFC_FCOE_EVENT_TYPE_NEW_FCF: lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, - "2546 New FCF found index 0x%x tag 0x%x \n", + "2546 New FCF found index 0x%x tag 0x%x\n", acqe_fcoe->fcf_index, acqe_fcoe->event_tag); /* @@ -2949,7 +2949,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, case LPFC_FCOE_EVENT_TYPE_FCF_TABLE_FULL: lpfc_printf_log(phba, KERN_ERR, LOG_SLI, - "2548 FCF Table full count 0x%x tag 0x%x \n", + "2548 FCF Table full count 0x%x tag 0x%x\n", bf_get(lpfc_acqe_fcoe_fcf_count, acqe_fcoe), acqe_fcoe->event_tag); break; @@ -2957,7 +2957,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, case LPFC_FCOE_EVENT_TYPE_FCF_DEAD: lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, "2549 FCF disconnected fron network index 0x%x" - " tag 0x%x \n", acqe_fcoe->fcf_index, + " tag 0x%x\n", acqe_fcoe->fcf_index, acqe_fcoe->event_tag); /* If the event is not for currently used fcf do nothing */ if (phba->fcf.fcf_indx != acqe_fcoe->fcf_index) -- cgit v1.2.3