aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
authorJames Smart <james.smart@emulex.com>2010-09-29 11:18:45 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-10-07 18:26:19 -0400
commitd439d286f573afab8c164dbc953ce1d214585a40 (patch)
treeeec9c3089e49ae0938b4fff282afd2472d9b7fdc /drivers/scsi/lpfc
parentbf5eefb007e7c5498a41af2dd65d957ae9793a63 (diff)
[SCSI] lpfc 8.3.17: Code Cleanup and Locking fixes
- Move Unload flag earlier in vport deletei to stop ELS traffic - Replaced some unnecessary spin_lock_irqsave with spin_lock_irq - Fixed circular spinlock dependency between low-level driver and SCSI midlayer - Remove duplicate code from lpfc_els_retry routine - Make all error values negative Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com> Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/lpfc_bsg.c81
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c34
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c34
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c100
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.c8
6 files changed, 142 insertions, 117 deletions
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 49d0cf99c24c..10cfc64782ad 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -259,6 +259,7 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
259 struct bsg_job_data *dd_data; 259 struct bsg_job_data *dd_data;
260 uint32_t creg_val; 260 uint32_t creg_val;
261 int rc = 0; 261 int rc = 0;
262 int iocb_stat;
262 263
263 /* in case no data is transferred */ 264 /* in case no data is transferred */
264 job->reply->reply_payload_rcv_len = 0; 265 job->reply->reply_payload_rcv_len = 0;
@@ -373,14 +374,13 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
373 readl(phba->HCregaddr); /* flush */ 374 readl(phba->HCregaddr); /* flush */
374 } 375 }
375 376
376 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0); 377 iocb_stat = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
377 378 if (iocb_stat == IOCB_SUCCESS)
378 if (rc == IOCB_SUCCESS)
379 return 0; /* done for now */ 379 return 0; /* done for now */
380 else if (rc == IOCB_BUSY) 380 else if (iocb_stat == IOCB_BUSY)
381 rc = EAGAIN; 381 rc = -EAGAIN;
382 else 382 else
383 rc = EIO; 383 rc = -EIO;
384 384
385 385
386 /* iocb failed so cleanup */ 386 /* iocb failed so cleanup */
@@ -631,9 +631,9 @@ lpfc_bsg_rport_els(struct fc_bsg_job *job)
631 if (rc == IOCB_SUCCESS) 631 if (rc == IOCB_SUCCESS)
632 return 0; /* done for now */ 632 return 0; /* done for now */
633 else if (rc == IOCB_BUSY) 633 else if (rc == IOCB_BUSY)
634 rc = EAGAIN; 634 rc = -EAGAIN;
635 else 635 else
636 rc = EIO; 636 rc = -EIO;
637 637
638 pci_unmap_sg(phba->pcidev, job->request_payload.sg_list, 638 pci_unmap_sg(phba->pcidev, job->request_payload.sg_list,
639 job->request_payload.sg_cnt, DMA_TO_DEVICE); 639 job->request_payload.sg_cnt, DMA_TO_DEVICE);
@@ -1299,7 +1299,7 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
1299 /* Allocate buffer for command iocb */ 1299 /* Allocate buffer for command iocb */
1300 ctiocb = lpfc_sli_get_iocbq(phba); 1300 ctiocb = lpfc_sli_get_iocbq(phba);
1301 if (!ctiocb) { 1301 if (!ctiocb) {
1302 rc = ENOMEM; 1302 rc = -ENOMEM;
1303 goto no_ctiocb; 1303 goto no_ctiocb;
1304 } 1304 }
1305 1305
@@ -1649,17 +1649,18 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi)
1649 1649
1650 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 1650 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1651 if (!mbox) 1651 if (!mbox)
1652 return ENOMEM; 1652 return -ENOMEM;
1653 1653
1654 status = lpfc_reg_rpi(phba, 0, phba->pport->fc_myDID, 1654 status = lpfc_reg_rpi(phba, 0, phba->pport->fc_myDID,
1655 (uint8_t *)&phba->pport->fc_sparam, mbox, 0); 1655 (uint8_t *)&phba->pport->fc_sparam, mbox, 0);
1656 if (status) { 1656 if (status) {
1657 mempool_free(mbox, phba->mbox_mem_pool); 1657 mempool_free(mbox, phba->mbox_mem_pool);
1658 return ENOMEM; 1658 return -ENOMEM;
1659 } 1659 }
1660 1660
1661 dmabuff = (struct lpfc_dmabuf *) mbox->context1; 1661 dmabuff = (struct lpfc_dmabuf *) mbox->context1;
1662 mbox->context1 = NULL; 1662 mbox->context1 = NULL;
1663 mbox->context2 = NULL;
1663 status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO); 1664 status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
1664 1665
1665 if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) { 1666 if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) {
@@ -1667,7 +1668,7 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi)
1667 kfree(dmabuff); 1668 kfree(dmabuff);
1668 if (status != MBX_TIMEOUT) 1669 if (status != MBX_TIMEOUT)
1669 mempool_free(mbox, phba->mbox_mem_pool); 1670 mempool_free(mbox, phba->mbox_mem_pool);
1670 return ENODEV; 1671 return -ENODEV;
1671 } 1672 }
1672 1673
1673 *rpi = mbox->u.mb.un.varWords[0]; 1674 *rpi = mbox->u.mb.un.varWords[0];
@@ -1693,7 +1694,7 @@ static int lpfcdiag_loop_self_unreg(struct lpfc_hba *phba, uint16_t rpi)
1693 /* Allocate mboxq structure */ 1694 /* Allocate mboxq structure */
1694 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 1695 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1695 if (mbox == NULL) 1696 if (mbox == NULL)
1696 return ENOMEM; 1697 return -ENOMEM;
1697 1698
1698 lpfc_unreg_login(phba, 0, rpi, mbox); 1699 lpfc_unreg_login(phba, 0, rpi, mbox);
1699 status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO); 1700 status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
@@ -1701,7 +1702,7 @@ static int lpfcdiag_loop_self_unreg(struct lpfc_hba *phba, uint16_t rpi)
1701 if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) { 1702 if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) {
1702 if (status != MBX_TIMEOUT) 1703 if (status != MBX_TIMEOUT)
1703 mempool_free(mbox, phba->mbox_mem_pool); 1704 mempool_free(mbox, phba->mbox_mem_pool);
1704 return EIO; 1705 return -EIO;
1705 } 1706 }
1706 1707
1707 mempool_free(mbox, phba->mbox_mem_pool); 1708 mempool_free(mbox, phba->mbox_mem_pool);
@@ -1730,6 +1731,8 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
1730 struct ulp_bde64 *bpl = NULL; 1731 struct ulp_bde64 *bpl = NULL;
1731 struct lpfc_sli_ct_request *ctreq = NULL; 1732 struct lpfc_sli_ct_request *ctreq = NULL;
1732 int ret_val = 0; 1733 int ret_val = 0;
1734 int time_left;
1735 int iocb_stat;
1733 unsigned long flags; 1736 unsigned long flags;
1734 1737
1735 *txxri = 0; 1738 *txxri = 0;
@@ -1737,7 +1740,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
1737 evt = lpfc_bsg_event_new(FC_REG_CT_EVENT, current->pid, 1740 evt = lpfc_bsg_event_new(FC_REG_CT_EVENT, current->pid,
1738 SLI_CT_ELX_LOOPBACK); 1741 SLI_CT_ELX_LOOPBACK);
1739 if (!evt) 1742 if (!evt)
1740 return ENOMEM; 1743 return -ENOMEM;
1741 1744
1742 spin_lock_irqsave(&phba->ct_ev_lock, flags); 1745 spin_lock_irqsave(&phba->ct_ev_lock, flags);
1743 list_add(&evt->node, &phba->ct_ev_waiters); 1746 list_add(&evt->node, &phba->ct_ev_waiters);
@@ -1770,7 +1773,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
1770 if (cmdiocbq == NULL || rspiocbq == NULL || 1773 if (cmdiocbq == NULL || rspiocbq == NULL ||
1771 dmabuf == NULL || bpl == NULL || ctreq == NULL || 1774 dmabuf == NULL || bpl == NULL || ctreq == NULL ||
1772 dmabuf->virt == NULL) { 1775 dmabuf->virt == NULL) {
1773 ret_val = ENOMEM; 1776 ret_val = -ENOMEM;
1774 goto err_get_xri_exit; 1777 goto err_get_xri_exit;
1775 } 1778 }
1776 1779
@@ -1806,24 +1809,24 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
1806 cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC; 1809 cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC;
1807 cmdiocbq->vport = phba->pport; 1810 cmdiocbq->vport = phba->pport;
1808 1811
1809 ret_val = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq, 1812 iocb_stat = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq,
1810 rspiocbq, 1813 rspiocbq,
1811 (phba->fc_ratov * 2) 1814 (phba->fc_ratov * 2)
1812 + LPFC_DRVR_TIMEOUT); 1815 + LPFC_DRVR_TIMEOUT);
1813 if (ret_val) 1816 if (iocb_stat) {
1817 ret_val = -EIO;
1814 goto err_get_xri_exit; 1818 goto err_get_xri_exit;
1815 1819 }
1816 *txxri = rsp->ulpContext; 1820 *txxri = rsp->ulpContext;
1817 1821
1818 evt->waiting = 1; 1822 evt->waiting = 1;
1819 evt->wait_time_stamp = jiffies; 1823 evt->wait_time_stamp = jiffies;
1820 ret_val = wait_event_interruptible_timeout( 1824 time_left = wait_event_interruptible_timeout(
1821 evt->wq, !list_empty(&evt->events_to_see), 1825 evt->wq, !list_empty(&evt->events_to_see),
1822 ((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ); 1826 ((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ);
1823 if (list_empty(&evt->events_to_see)) 1827 if (list_empty(&evt->events_to_see))
1824 ret_val = (ret_val) ? EINTR : ETIMEDOUT; 1828 ret_val = (time_left) ? -EINTR : -ETIMEDOUT;
1825 else { 1829 else {
1826 ret_val = IOCB_SUCCESS;
1827 spin_lock_irqsave(&phba->ct_ev_lock, flags); 1830 spin_lock_irqsave(&phba->ct_ev_lock, flags);
1828 list_move(evt->events_to_see.prev, &evt->events_to_get); 1831 list_move(evt->events_to_see.prev, &evt->events_to_get);
1829 spin_unlock_irqrestore(&phba->ct_ev_lock, flags); 1832 spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
@@ -1845,7 +1848,7 @@ err_get_xri_exit:
1845 kfree(dmabuf); 1848 kfree(dmabuf);
1846 } 1849 }
1847 1850
1848 if (cmdiocbq && (ret_val != IOCB_TIMEDOUT)) 1851 if (cmdiocbq && (iocb_stat != IOCB_TIMEDOUT))
1849 lpfc_sli_release_iocbq(phba, cmdiocbq); 1852 lpfc_sli_release_iocbq(phba, cmdiocbq);
1850 if (rspiocbq) 1853 if (rspiocbq)
1851 lpfc_sli_release_iocbq(phba, rspiocbq); 1854 lpfc_sli_release_iocbq(phba, rspiocbq);
@@ -1959,6 +1962,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
1959 uint32_t num_bde; 1962 uint32_t num_bde;
1960 struct lpfc_dmabufext *rxbuffer = NULL; 1963 struct lpfc_dmabufext *rxbuffer = NULL;
1961 int ret_val = 0; 1964 int ret_val = 0;
1965 int iocb_stat;
1962 int i = 0; 1966 int i = 0;
1963 1967
1964 cmdiocbq = lpfc_sli_get_iocbq(phba); 1968 cmdiocbq = lpfc_sli_get_iocbq(phba);
@@ -1973,7 +1977,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
1973 } 1977 }
1974 1978
1975 if (!cmdiocbq || !rxbmp || !rxbpl || !rxbuffer) { 1979 if (!cmdiocbq || !rxbmp || !rxbpl || !rxbuffer) {
1976 ret_val = ENOMEM; 1980 ret_val = -ENOMEM;
1977 goto err_post_rxbufs_exit; 1981 goto err_post_rxbufs_exit;
1978 } 1982 }
1979 1983
@@ -2022,16 +2026,16 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
2022 cmd->ulpClass = CLASS3; 2026 cmd->ulpClass = CLASS3;
2023 cmd->ulpContext = rxxri; 2027 cmd->ulpContext = rxxri;
2024 2028
2025 ret_val = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0); 2029 iocb_stat = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq,
2026 2030 0);
2027 if (ret_val == IOCB_ERROR) { 2031 if (iocb_stat == IOCB_ERROR) {
2028 diag_cmd_data_free(phba, 2032 diag_cmd_data_free(phba,
2029 (struct lpfc_dmabufext *)mp[0]); 2033 (struct lpfc_dmabufext *)mp[0]);
2030 if (mp[1]) 2034 if (mp[1])
2031 diag_cmd_data_free(phba, 2035 diag_cmd_data_free(phba,
2032 (struct lpfc_dmabufext *)mp[1]); 2036 (struct lpfc_dmabufext *)mp[1]);
2033 dmp = list_entry(next, struct lpfc_dmabuf, list); 2037 dmp = list_entry(next, struct lpfc_dmabuf, list);
2034 ret_val = EIO; 2038 ret_val = -EIO;
2035 goto err_post_rxbufs_exit; 2039 goto err_post_rxbufs_exit;
2036 } 2040 }
2037 2041
@@ -2045,7 +2049,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
2045 cmdiocbq = lpfc_sli_get_iocbq(phba); 2049 cmdiocbq = lpfc_sli_get_iocbq(phba);
2046 if (!cmdiocbq) { 2050 if (!cmdiocbq) {
2047 dmp = list_entry(next, struct lpfc_dmabuf, list); 2051 dmp = list_entry(next, struct lpfc_dmabuf, list);
2048 ret_val = EIO; 2052 ret_val = -EIO;
2049 goto err_post_rxbufs_exit; 2053 goto err_post_rxbufs_exit;
2050 } 2054 }
2051 2055
@@ -2111,6 +2115,8 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2111 uint32_t num_bde; 2115 uint32_t num_bde;
2112 uint8_t *ptr = NULL, *rx_databuf = NULL; 2116 uint8_t *ptr = NULL, *rx_databuf = NULL;
2113 int rc = 0; 2117 int rc = 0;
2118 int time_left;
2119 int iocb_stat;
2114 unsigned long flags; 2120 unsigned long flags;
2115 void *dataout = NULL; 2121 void *dataout = NULL;
2116 uint32_t total_mem; 2122 uint32_t total_mem;
@@ -2185,22 +2191,18 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2185 ptr, size); 2191 ptr, size);
2186 2192
2187 rc = lpfcdiag_loop_self_reg(phba, &rpi); 2193 rc = lpfcdiag_loop_self_reg(phba, &rpi);
2188 if (rc) { 2194 if (rc)
2189 rc = -ENOMEM;
2190 goto loopback_test_exit; 2195 goto loopback_test_exit;
2191 }
2192 2196
2193 rc = lpfcdiag_loop_get_xri(phba, rpi, &txxri, &rxxri); 2197 rc = lpfcdiag_loop_get_xri(phba, rpi, &txxri, &rxxri);
2194 if (rc) { 2198 if (rc) {
2195 lpfcdiag_loop_self_unreg(phba, rpi); 2199 lpfcdiag_loop_self_unreg(phba, rpi);
2196 rc = -ENOMEM;
2197 goto loopback_test_exit; 2200 goto loopback_test_exit;
2198 } 2201 }
2199 2202
2200 rc = lpfcdiag_loop_post_rxbufs(phba, rxxri, full_size); 2203 rc = lpfcdiag_loop_post_rxbufs(phba, rxxri, full_size);
2201 if (rc) { 2204 if (rc) {
2202 lpfcdiag_loop_self_unreg(phba, rpi); 2205 lpfcdiag_loop_self_unreg(phba, rpi);
2203 rc = -ENOMEM;
2204 goto loopback_test_exit; 2206 goto loopback_test_exit;
2205 } 2207 }
2206 2208
@@ -2290,21 +2292,22 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2290 cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC; 2292 cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC;
2291 cmdiocbq->vport = phba->pport; 2293 cmdiocbq->vport = phba->pport;
2292 2294
2293 rc = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq, rspiocbq, 2295 iocb_stat = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq,
2294 (phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT); 2296 rspiocbq, (phba->fc_ratov * 2) +
2297 LPFC_DRVR_TIMEOUT);
2295 2298
2296 if ((rc != IOCB_SUCCESS) || (rsp->ulpStatus != IOCB_SUCCESS)) { 2299 if ((iocb_stat != IOCB_SUCCESS) || (rsp->ulpStatus != IOCB_SUCCESS)) {
2297 rc = -EIO; 2300 rc = -EIO;
2298 goto err_loopback_test_exit; 2301 goto err_loopback_test_exit;
2299 } 2302 }
2300 2303
2301 evt->waiting = 1; 2304 evt->waiting = 1;
2302 rc = wait_event_interruptible_timeout( 2305 time_left = wait_event_interruptible_timeout(
2303 evt->wq, !list_empty(&evt->events_to_see), 2306 evt->wq, !list_empty(&evt->events_to_see),
2304 ((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ); 2307 ((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ);
2305 evt->waiting = 0; 2308 evt->waiting = 0;
2306 if (list_empty(&evt->events_to_see)) 2309 if (list_empty(&evt->events_to_see))
2307 rc = (rc) ? -EINTR : -ETIMEDOUT; 2310 rc = (time_left) ? -EINTR : -ETIMEDOUT;
2308 else { 2311 else {
2309 spin_lock_irqsave(&phba->ct_ev_lock, flags); 2312 spin_lock_irqsave(&phba->ct_ev_lock, flags);
2310 list_move(evt->events_to_see.prev, &evt->events_to_get); 2313 list_move(evt->events_to_see.prev, &evt->events_to_get);
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 8d09191c327e..e6ca12f6c6cb 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -3250,6 +3250,8 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3250 lpfc_sli4_free_rpi(phba, pmb->u.mb.un.varUnregLogin.rpi); 3250 lpfc_sli4_free_rpi(phba, pmb->u.mb.un.varUnregLogin.rpi);
3251 3251
3252 pmb->context1 = NULL; 3252 pmb->context1 = NULL;
3253 pmb->context2 = NULL;
3254
3253 lpfc_mbuf_free(phba, mp->virt, mp->phys); 3255 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3254 kfree(mp); 3256 kfree(mp);
3255 mempool_free(pmb, phba->mbox_mem_pool); 3257 mempool_free(pmb, phba->mbox_mem_pool);
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 1f62ea8c165d..c3d7174e3469 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1015,7 +1015,6 @@ static void
1015lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) 1015lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1016{ 1016{
1017 struct lpfc_vport *vport = mboxq->vport; 1017 struct lpfc_vport *vport = mboxq->vport;
1018 unsigned long flags;
1019 1018
1020 if (mboxq->u.mb.mbxStatus) { 1019 if (mboxq->u.mb.mbxStatus) {
1021 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, 1020 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
@@ -1029,18 +1028,18 @@ lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1029 /* Start FCoE discovery by sending a FLOGI. */ 1028 /* Start FCoE discovery by sending a FLOGI. */
1030 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, &mboxq->u.mqe.un.reg_fcfi); 1029 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, &mboxq->u.mqe.un.reg_fcfi);
1031 /* Set the FCFI registered flag */ 1030 /* Set the FCFI registered flag */
1032 spin_lock_irqsave(&phba->hbalock, flags); 1031 spin_lock_irq(&phba->hbalock);
1033 phba->fcf.fcf_flag |= FCF_REGISTERED; 1032 phba->fcf.fcf_flag |= FCF_REGISTERED;
1034 spin_unlock_irqrestore(&phba->hbalock, flags); 1033 spin_unlock_irq(&phba->hbalock);
1035 /* If there is a pending FCoE event, restart FCF table scan. */ 1034 /* If there is a pending FCoE event, restart FCF table scan. */
1036 if (lpfc_check_pending_fcoe_event(phba, 1)) { 1035 if (lpfc_check_pending_fcoe_event(phba, 1)) {
1037 mempool_free(mboxq, phba->mbox_mem_pool); 1036 mempool_free(mboxq, phba->mbox_mem_pool);
1038 return; 1037 return;
1039 } 1038 }
1040 spin_lock_irqsave(&phba->hbalock, flags); 1039 spin_lock_irq(&phba->hbalock);
1041 phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); 1040 phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE);
1042 phba->hba_flag &= ~FCF_DISC_INPROGRESS; 1041 phba->hba_flag &= ~FCF_DISC_INPROGRESS;
1043 spin_unlock_irqrestore(&phba->hbalock, flags); 1042 spin_unlock_irq(&phba->hbalock);
1044 if (vport->port_state != LPFC_FLOGI) 1043 if (vport->port_state != LPFC_FLOGI)
1045 lpfc_initial_flogi(vport); 1044 lpfc_initial_flogi(vport);
1046 1045
@@ -1240,14 +1239,13 @@ lpfc_register_fcf(struct lpfc_hba *phba)
1240{ 1239{
1241 LPFC_MBOXQ_t *fcf_mbxq; 1240 LPFC_MBOXQ_t *fcf_mbxq;
1242 int rc; 1241 int rc;
1243 unsigned long flags;
1244 1242
1245 spin_lock_irqsave(&phba->hbalock, flags); 1243 spin_lock_irq(&phba->hbalock);
1246 1244
1247 /* If the FCF is not availabe do nothing. */ 1245 /* If the FCF is not availabe do nothing. */
1248 if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) { 1246 if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) {
1249 phba->hba_flag &= ~FCF_DISC_INPROGRESS; 1247 phba->hba_flag &= ~FCF_DISC_INPROGRESS;
1250 spin_unlock_irqrestore(&phba->hbalock, flags); 1248 spin_unlock_irq(&phba->hbalock);
1251 return; 1249 return;
1252 } 1250 }
1253 1251
@@ -1255,19 +1253,19 @@ lpfc_register_fcf(struct lpfc_hba *phba)
1255 if (phba->fcf.fcf_flag & FCF_REGISTERED) { 1253 if (phba->fcf.fcf_flag & FCF_REGISTERED) {
1256 phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); 1254 phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE);
1257 phba->hba_flag &= ~FCF_DISC_INPROGRESS; 1255 phba->hba_flag &= ~FCF_DISC_INPROGRESS;
1258 spin_unlock_irqrestore(&phba->hbalock, flags); 1256 spin_unlock_irq(&phba->hbalock);
1259 if (phba->pport->port_state != LPFC_FLOGI) 1257 if (phba->pport->port_state != LPFC_FLOGI)
1260 lpfc_initial_flogi(phba->pport); 1258 lpfc_initial_flogi(phba->pport);
1261 return; 1259 return;
1262 } 1260 }
1263 spin_unlock_irqrestore(&phba->hbalock, flags); 1261 spin_unlock_irq(&phba->hbalock);
1264 1262
1265 fcf_mbxq = mempool_alloc(phba->mbox_mem_pool, 1263 fcf_mbxq = mempool_alloc(phba->mbox_mem_pool,
1266 GFP_KERNEL); 1264 GFP_KERNEL);
1267 if (!fcf_mbxq) { 1265 if (!fcf_mbxq) {
1268 spin_lock_irqsave(&phba->hbalock, flags); 1266 spin_lock_irq(&phba->hbalock);
1269 phba->hba_flag &= ~FCF_DISC_INPROGRESS; 1267 phba->hba_flag &= ~FCF_DISC_INPROGRESS;
1270 spin_unlock_irqrestore(&phba->hbalock, flags); 1268 spin_unlock_irq(&phba->hbalock);
1271 return; 1269 return;
1272 } 1270 }
1273 1271
@@ -1276,9 +1274,9 @@ lpfc_register_fcf(struct lpfc_hba *phba)
1276 fcf_mbxq->mbox_cmpl = lpfc_mbx_cmpl_reg_fcfi; 1274 fcf_mbxq->mbox_cmpl = lpfc_mbx_cmpl_reg_fcfi;
1277 rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT); 1275 rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT);
1278 if (rc == MBX_NOT_FINISHED) { 1276 if (rc == MBX_NOT_FINISHED) {
1279 spin_lock_irqsave(&phba->hbalock, flags); 1277 spin_lock_irq(&phba->hbalock);
1280 phba->hba_flag &= ~FCF_DISC_INPROGRESS; 1278 phba->hba_flag &= ~FCF_DISC_INPROGRESS;
1281 spin_unlock_irqrestore(&phba->hbalock, flags); 1279 spin_unlock_irq(&phba->hbalock);
1282 mempool_free(fcf_mbxq, phba->mbox_mem_pool); 1280 mempool_free(fcf_mbxq, phba->mbox_mem_pool);
1283 } 1281 }
1284 1282
@@ -2851,6 +2849,7 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2851 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2849 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2852 2850
2853 pmb->context1 = NULL; 2851 pmb->context1 = NULL;
2852 pmb->context2 = NULL;
2854 2853
2855 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND) 2854 if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
2856 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; 2855 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
@@ -3149,6 +3148,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3149 ndlp = (struct lpfc_nodelist *) pmb->context2; 3148 ndlp = (struct lpfc_nodelist *) pmb->context2;
3150 pmb->context1 = NULL; 3149 pmb->context1 = NULL;
3151 pmb->context2 = NULL; 3150 pmb->context2 = NULL;
3151
3152 if (mb->mbxStatus) { 3152 if (mb->mbxStatus) {
3153 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, 3153 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
3154 "0258 Register Fabric login error: 0x%x\n", 3154 "0258 Register Fabric login error: 0x%x\n",
@@ -3218,6 +3218,9 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3218 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; 3218 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2;
3219 struct lpfc_vport *vport = pmb->vport; 3219 struct lpfc_vport *vport = pmb->vport;
3220 3220
3221 pmb->context1 = NULL;
3222 pmb->context2 = NULL;
3223
3221 if (mb->mbxStatus) { 3224 if (mb->mbxStatus) {
3222out: 3225out:
3223 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, 3226 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
@@ -3249,8 +3252,6 @@ out:
3249 return; 3252 return;
3250 } 3253 }
3251 3254
3252 pmb->context1 = NULL;
3253
3254 ndlp->nlp_rpi = mb->un.varWords[0]; 3255 ndlp->nlp_rpi = mb->un.varWords[0];
3255 ndlp->nlp_flag |= NLP_RPI_VALID; 3256 ndlp->nlp_flag |= NLP_RPI_VALID;
3256 ndlp->nlp_type |= NLP_FABRIC; 3257 ndlp->nlp_type |= NLP_FABRIC;
@@ -4784,6 +4785,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
4784 struct lpfc_vport *vport = pmb->vport; 4785 struct lpfc_vport *vport = pmb->vport;
4785 4786
4786 pmb->context1 = NULL; 4787 pmb->context1 = NULL;
4788 pmb->context2 = NULL;
4787 4789
4788 ndlp->nlp_rpi = mb->un.varWords[0]; 4790 ndlp->nlp_rpi = mb->un.varWords[0];
4789 ndlp->nlp_flag |= NLP_RPI_VALID; 4791 ndlp->nlp_flag |= NLP_RPI_VALID;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 87a4d09a6641..699c9cf2dad2 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4727,8 +4727,8 @@ out_free_mem:
4727 * 4727 *
4728 * Return codes 4728 * Return codes
4729 * 0 - successful 4729 * 0 - successful
4730 * ENOMEM - No availble memory 4730 * -ENOMEM - No availble memory
4731 * EIO - The mailbox failed to complete successfully. 4731 * -EIO - The mailbox failed to complete successfully.
4732 **/ 4732 **/
4733int 4733int
4734lpfc_sli4_init_rpi_hdrs(struct lpfc_hba *phba) 4734lpfc_sli4_init_rpi_hdrs(struct lpfc_hba *phba)
@@ -5421,7 +5421,7 @@ lpfc_sli4_bar2_register_memmap(struct lpfc_hba *phba, uint32_t vf)
5421 * 5421 *
5422 * Return codes 5422 * Return codes
5423 * 0 - successful 5423 * 0 - successful
5424 * ENOMEM - could not allocated memory. 5424 * -ENOMEM - could not allocated memory.
5425 **/ 5425 **/
5426static int 5426static int
5427lpfc_create_bootstrap_mbox(struct lpfc_hba *phba) 5427lpfc_create_bootstrap_mbox(struct lpfc_hba *phba)
@@ -5520,8 +5520,8 @@ lpfc_destroy_bootstrap_mbox(struct lpfc_hba *phba)
5520 * 5520 *
5521 * Return codes 5521 * Return codes
5522 * 0 - successful 5522 * 0 - successful
5523 * ENOMEM - No availble memory 5523 * -ENOMEM - No availble memory
5524 * EIO - The mailbox failed to complete successfully. 5524 * -EIO - The mailbox failed to complete successfully.
5525 **/ 5525 **/
5526static int 5526static int
5527lpfc_sli4_read_config(struct lpfc_hba *phba) 5527lpfc_sli4_read_config(struct lpfc_hba *phba)
@@ -5624,8 +5624,8 @@ lpfc_sli4_read_config(struct lpfc_hba *phba)
5624 * 5624 *
5625 * Return codes 5625 * Return codes
5626 * 0 - successful 5626 * 0 - successful
5627 * ENOMEM - No availble memory 5627 * -ENOMEM - No availble memory
5628 * EIO - The mailbox failed to complete successfully. 5628 * -EIO - The mailbox failed to complete successfully.
5629 **/ 5629 **/
5630static int 5630static int
5631lpfc_setup_endian_order(struct lpfc_hba *phba) 5631lpfc_setup_endian_order(struct lpfc_hba *phba)
@@ -5673,8 +5673,8 @@ lpfc_setup_endian_order(struct lpfc_hba *phba)
5673 * 5673 *
5674 * Return codes 5674 * Return codes
5675 * 0 - successful 5675 * 0 - successful
5676 * ENOMEM - No availble memory 5676 * -ENOMEM - No availble memory
5677 * EIO - The mailbox failed to complete successfully. 5677 * -EIO - The mailbox failed to complete successfully.
5678 **/ 5678 **/
5679static int 5679static int
5680lpfc_sli4_queue_create(struct lpfc_hba *phba) 5680lpfc_sli4_queue_create(struct lpfc_hba *phba)
@@ -5968,8 +5968,8 @@ out_error:
5968 * 5968 *
5969 * Return codes 5969 * Return codes
5970 * 0 - successful 5970 * 0 - successful
5971 * ENOMEM - No availble memory 5971 * -ENOMEM - No availble memory
5972 * EIO - The mailbox failed to complete successfully. 5972 * -EIO - The mailbox failed to complete successfully.
5973 **/ 5973 **/
5974static void 5974static void
5975lpfc_sli4_queue_destroy(struct lpfc_hba *phba) 5975lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
@@ -6032,8 +6032,8 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
6032 * 6032 *
6033 * Return codes 6033 * Return codes
6034 * 0 - successful 6034 * 0 - successful
6035 * ENOMEM - No availble memory 6035 * -ENOMEM - No availble memory
6036 * EIO - The mailbox failed to complete successfully. 6036 * -EIO - The mailbox failed to complete successfully.
6037 **/ 6037 **/
6038int 6038int
6039lpfc_sli4_queue_setup(struct lpfc_hba *phba) 6039lpfc_sli4_queue_setup(struct lpfc_hba *phba)
@@ -6277,8 +6277,8 @@ out_error:
6277 * 6277 *
6278 * Return codes 6278 * Return codes
6279 * 0 - successful 6279 * 0 - successful
6280 * ENOMEM - No availble memory 6280 * -ENOMEM - No availble memory
6281 * EIO - The mailbox failed to complete successfully. 6281 * -EIO - The mailbox failed to complete successfully.
6282 **/ 6282 **/
6283void 6283void
6284lpfc_sli4_queue_unset(struct lpfc_hba *phba) 6284lpfc_sli4_queue_unset(struct lpfc_hba *phba)
@@ -6483,8 +6483,8 @@ lpfc_sli4_cq_event_release_all(struct lpfc_hba *phba)
6483 * 6483 *
6484 * Return codes 6484 * Return codes
6485 * 0 - successful 6485 * 0 - successful
6486 * ENOMEM - No availble memory 6486 * -ENOMEM - No availble memory
6487 * EIO - The mailbox failed to complete successfully. 6487 * -EIO - The mailbox failed to complete successfully.
6488 **/ 6488 **/
6489int 6489int
6490lpfc_pci_function_reset(struct lpfc_hba *phba) 6490lpfc_pci_function_reset(struct lpfc_hba *phba)
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 23a47e536858..bbbd8ba5c1a7 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1730,10 +1730,11 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
1730void 1730void
1731lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 1731lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1732{ 1732{
1733 struct lpfc_vport *vport = pmb->vport;
1733 struct lpfc_dmabuf *mp; 1734 struct lpfc_dmabuf *mp;
1735 struct lpfc_nodelist *ndlp;
1734 uint16_t rpi, vpi; 1736 uint16_t rpi, vpi;
1735 int rc; 1737 int rc;
1736 struct lpfc_vport *vport = pmb->vport;
1737 1738
1738 mp = (struct lpfc_dmabuf *) (pmb->context1); 1739 mp = (struct lpfc_dmabuf *) (pmb->context1);
1739 1740
@@ -1774,6 +1775,12 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1774 return; 1775 return;
1775 } 1776 }
1776 1777
1778 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
1779 ndlp = (struct lpfc_nodelist *)pmb->context2;
1780 lpfc_nlp_put(ndlp);
1781 pmb->context2 = NULL;
1782 }
1783
1777 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG) 1784 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG)
1778 lpfc_sli4_mbox_cmd_free(phba, pmb); 1785 lpfc_sli4_mbox_cmd_free(phba, pmb);
1779 else 1786 else
@@ -4186,7 +4193,7 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba,
4186 * 4193 *
4187 * Return codes 4194 * Return codes
4188 * 0 - successful 4195 * 0 - successful
4189 * ENOMEM - could not allocated memory. 4196 * -ENOMEM - could not allocated memory.
4190 **/ 4197 **/
4191static int 4198static int
4192lpfc_sli4_read_rev(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, 4199lpfc_sli4_read_rev(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
@@ -9724,8 +9731,8 @@ out_fail:
9724 * command to finish before continuing. 9731 * command to finish before continuing.
9725 * 9732 *
9726 * On success this function will return a zero. If unable to allocate enough 9733 * On success this function will return a zero. If unable to allocate enough
9727 * memory this function will return ENOMEM. If the queue create mailbox command 9734 * memory this function will return -ENOMEM. If the queue create mailbox command
9728 * fails this function will return ENXIO. 9735 * fails this function will return -ENXIO.
9729 **/ 9736 **/
9730uint32_t 9737uint32_t
9731lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint16_t imax) 9738lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint16_t imax)
@@ -9840,8 +9847,8 @@ lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint16_t imax)
9840 * command to finish before continuing. 9847 * command to finish before continuing.
9841 * 9848 *
9842 * On success this function will return a zero. If unable to allocate enough 9849 * On success this function will return a zero. If unable to allocate enough
9843 * memory this function will return ENOMEM. If the queue create mailbox command 9850 * memory this function will return -ENOMEM. If the queue create mailbox command
9844 * fails this function will return ENXIO. 9851 * fails this function will return -ENXIO.
9845 **/ 9852 **/
9846uint32_t 9853uint32_t
9847lpfc_cq_create(struct lpfc_hba *phba, struct lpfc_queue *cq, 9854lpfc_cq_create(struct lpfc_hba *phba, struct lpfc_queue *cq,
@@ -10011,8 +10018,8 @@ lpfc_mq_create_fb_init(struct lpfc_hba *phba, struct lpfc_queue *mq,
10011 * command to finish before continuing. 10018 * command to finish before continuing.
10012 * 10019 *
10013 * On success this function will return a zero. If unable to allocate enough 10020 * On success this function will return a zero. If unable to allocate enough
10014 * memory this function will return ENOMEM. If the queue create mailbox command 10021 * memory this function will return -ENOMEM. If the queue create mailbox command
10015 * fails this function will return ENXIO. 10022 * fails this function will return -ENXIO.
10016 **/ 10023 **/
10017int32_t 10024int32_t
10018lpfc_mq_create(struct lpfc_hba *phba, struct lpfc_queue *mq, 10025lpfc_mq_create(struct lpfc_hba *phba, struct lpfc_queue *mq,
@@ -10146,8 +10153,8 @@ out:
10146 * command to finish before continuing. 10153 * command to finish before continuing.
10147 * 10154 *
10148 * On success this function will return a zero. If unable to allocate enough 10155 * On success this function will return a zero. If unable to allocate enough
10149 * memory this function will return ENOMEM. If the queue create mailbox command 10156 * memory this function will return -ENOMEM. If the queue create mailbox command
10150 * fails this function will return ENXIO. 10157 * fails this function will return -ENXIO.
10151 **/ 10158 **/
10152uint32_t 10159uint32_t
10153lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq, 10160lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
@@ -10234,8 +10241,8 @@ out:
10234 * mailbox command to finish before continuing. 10241 * mailbox command to finish before continuing.
10235 * 10242 *
10236 * On success this function will return a zero. If unable to allocate enough 10243 * On success this function will return a zero. If unable to allocate enough
10237 * memory this function will return ENOMEM. If the queue create mailbox command 10244 * memory this function will return -ENOMEM. If the queue create mailbox command
10238 * fails this function will return ENXIO. 10245 * fails this function will return -ENXIO.
10239 **/ 10246 **/
10240uint32_t 10247uint32_t
10241lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq, 10248lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
@@ -10403,7 +10410,7 @@ out:
10403 * The @eq struct is used to get the queue ID of the queue to destroy. 10410 * The @eq struct is used to get the queue ID of the queue to destroy.
10404 * 10411 *
10405 * On success this function will return a zero. If the queue destroy mailbox 10412 * On success this function will return a zero. If the queue destroy mailbox
10406 * command fails this function will return ENXIO. 10413 * command fails this function will return -ENXIO.
10407 **/ 10414 **/
10408uint32_t 10415uint32_t
10409lpfc_eq_destroy(struct lpfc_hba *phba, struct lpfc_queue *eq) 10416lpfc_eq_destroy(struct lpfc_hba *phba, struct lpfc_queue *eq)
@@ -10458,7 +10465,7 @@ lpfc_eq_destroy(struct lpfc_hba *phba, struct lpfc_queue *eq)
10458 * The @cq struct is used to get the queue ID of the queue to destroy. 10465 * The @cq struct is used to get the queue ID of the queue to destroy.
10459 * 10466 *
10460 * On success this function will return a zero. If the queue destroy mailbox 10467 * On success this function will return a zero. If the queue destroy mailbox
10461 * command fails this function will return ENXIO. 10468 * command fails this function will return -ENXIO.
10462 **/ 10469 **/
10463uint32_t 10470uint32_t
10464lpfc_cq_destroy(struct lpfc_hba *phba, struct lpfc_queue *cq) 10471lpfc_cq_destroy(struct lpfc_hba *phba, struct lpfc_queue *cq)
@@ -10511,7 +10518,7 @@ lpfc_cq_destroy(struct lpfc_hba *phba, struct lpfc_queue *cq)
10511 * The @mq struct is used to get the queue ID of the queue to destroy. 10518 * The @mq struct is used to get the queue ID of the queue to destroy.
10512 * 10519 *
10513 * On success this function will return a zero. If the queue destroy mailbox 10520 * On success this function will return a zero. If the queue destroy mailbox
10514 * command fails this function will return ENXIO. 10521 * command fails this function will return -ENXIO.
10515 **/ 10522 **/
10516uint32_t 10523uint32_t
10517lpfc_mq_destroy(struct lpfc_hba *phba, struct lpfc_queue *mq) 10524lpfc_mq_destroy(struct lpfc_hba *phba, struct lpfc_queue *mq)
@@ -10564,7 +10571,7 @@ lpfc_mq_destroy(struct lpfc_hba *phba, struct lpfc_queue *mq)
10564 * The @wq struct is used to get the queue ID of the queue to destroy. 10571 * The @wq struct is used to get the queue ID of the queue to destroy.
10565 * 10572 *
10566 * On success this function will return a zero. If the queue destroy mailbox 10573 * On success this function will return a zero. If the queue destroy mailbox
10567 * command fails this function will return ENXIO. 10574 * command fails this function will return -ENXIO.
10568 **/ 10575 **/
10569uint32_t 10576uint32_t
10570lpfc_wq_destroy(struct lpfc_hba *phba, struct lpfc_queue *wq) 10577lpfc_wq_destroy(struct lpfc_hba *phba, struct lpfc_queue *wq)
@@ -10616,7 +10623,7 @@ lpfc_wq_destroy(struct lpfc_hba *phba, struct lpfc_queue *wq)
10616 * The @rq struct is used to get the queue ID of the queue to destroy. 10623 * The @rq struct is used to get the queue ID of the queue to destroy.
10617 * 10624 *
10618 * On success this function will return a zero. If the queue destroy mailbox 10625 * On success this function will return a zero. If the queue destroy mailbox
10619 * command fails this function will return ENXIO. 10626 * command fails this function will return -ENXIO.
10620 **/ 10627 **/
10621uint32_t 10628uint32_t
10622lpfc_rq_destroy(struct lpfc_hba *phba, struct lpfc_queue *hrq, 10629lpfc_rq_destroy(struct lpfc_hba *phba, struct lpfc_queue *hrq,
@@ -11819,7 +11826,7 @@ lpfc_sli4_handle_received_buffer(struct lpfc_hba *phba,
11819 * 11826 *
11820 * Return codes 11827 * Return codes
11821 * 0 - successful 11828 * 0 - successful
11822 * EIO - The mailbox failed to complete successfully. 11829 * -EIO - The mailbox failed to complete successfully.
11823 * When this error occurs, the driver is not guaranteed 11830 * When this error occurs, the driver is not guaranteed
11824 * to have any rpi regions posted to the device and 11831 * to have any rpi regions posted to the device and
11825 * must either attempt to repost the regions or take a 11832 * must either attempt to repost the regions or take a
@@ -11857,8 +11864,8 @@ lpfc_sli4_post_all_rpi_hdrs(struct lpfc_hba *phba)
11857 * 11864 *
11858 * Return codes 11865 * Return codes
11859 * 0 - successful 11866 * 0 - successful
11860 * ENOMEM - No available memory 11867 * -ENOMEM - No available memory
11861 * EIO - The mailbox failed to complete successfully. 11868 * -EIO - The mailbox failed to complete successfully.
11862 **/ 11869 **/
11863int 11870int
11864lpfc_sli4_post_rpi_hdr(struct lpfc_hba *phba, struct lpfc_rpi_hdr *rpi_page) 11871lpfc_sli4_post_rpi_hdr(struct lpfc_hba *phba, struct lpfc_rpi_hdr *rpi_page)
@@ -12805,8 +12812,11 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
12805 LPFC_MBOXQ_t *mb, *nextmb; 12812 LPFC_MBOXQ_t *mb, *nextmb;
12806 struct lpfc_dmabuf *mp; 12813 struct lpfc_dmabuf *mp;
12807 struct lpfc_nodelist *ndlp; 12814 struct lpfc_nodelist *ndlp;
12815 struct lpfc_nodelist *act_mbx_ndlp = NULL;
12808 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 12816 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
12817 LIST_HEAD(mbox_cmd_list);
12809 12818
12819 /* Clean up internally queued mailbox commands with the vport */
12810 spin_lock_irq(&phba->hbalock); 12820 spin_lock_irq(&phba->hbalock);
12811 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { 12821 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
12812 if (mb->vport != vport) 12822 if (mb->vport != vport)
@@ -12816,6 +12826,28 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
12816 (mb->u.mb.mbxCommand != MBX_REG_VPI)) 12826 (mb->u.mb.mbxCommand != MBX_REG_VPI))
12817 continue; 12827 continue;
12818 12828
12829 list_del(&mb->list);
12830 list_add_tail(&mb->list, &mbox_cmd_list);
12831 }
12832 /* Clean up active mailbox command with the vport */
12833 mb = phba->sli.mbox_active;
12834 if (mb && (mb->vport == vport)) {
12835 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) ||
12836 (mb->u.mb.mbxCommand == MBX_REG_VPI))
12837 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
12838 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
12839 act_mbx_ndlp = (struct lpfc_nodelist *)mb->context2;
12840 /* Put reference count for delayed processing */
12841 act_mbx_ndlp = lpfc_nlp_get(act_mbx_ndlp);
12842 /* Unregister the RPI when mailbox complete */
12843 mb->mbox_flag |= LPFC_MBX_IMED_UNREG;
12844 }
12845 }
12846 spin_unlock_irq(&phba->hbalock);
12847
12848 /* Release the cleaned-up mailbox commands */
12849 while (!list_empty(&mbox_cmd_list)) {
12850 list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list);
12819 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { 12851 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
12820 if (phba->sli_rev == LPFC_SLI_REV4) 12852 if (phba->sli_rev == LPFC_SLI_REV4)
12821 __lpfc_sli4_free_rpi(phba, 12853 __lpfc_sli4_free_rpi(phba,
@@ -12826,36 +12858,24 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
12826 kfree(mp); 12858 kfree(mp);
12827 } 12859 }
12828 ndlp = (struct lpfc_nodelist *) mb->context2; 12860 ndlp = (struct lpfc_nodelist *) mb->context2;
12861 mb->context2 = NULL;
12829 if (ndlp) { 12862 if (ndlp) {
12830 spin_lock(shost->host_lock); 12863 spin_lock(shost->host_lock);
12831 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; 12864 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL;
12832 spin_unlock(shost->host_lock); 12865 spin_unlock(shost->host_lock);
12833 lpfc_nlp_put(ndlp); 12866 lpfc_nlp_put(ndlp);
12834 mb->context2 = NULL;
12835 } 12867 }
12836 } 12868 }
12837 list_del(&mb->list);
12838 mempool_free(mb, phba->mbox_mem_pool); 12869 mempool_free(mb, phba->mbox_mem_pool);
12839 } 12870 }
12840 mb = phba->sli.mbox_active; 12871
12841 if (mb && (mb->vport == vport)) { 12872 /* Release the ndlp with the cleaned-up active mailbox command */
12842 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) || 12873 if (act_mbx_ndlp) {
12843 (mb->u.mb.mbxCommand == MBX_REG_VPI)) 12874 spin_lock(shost->host_lock);
12844 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 12875 act_mbx_ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL;
12845 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { 12876 spin_unlock(shost->host_lock);
12846 ndlp = (struct lpfc_nodelist *) mb->context2; 12877 lpfc_nlp_put(act_mbx_ndlp);
12847 if (ndlp) {
12848 spin_lock(shost->host_lock);
12849 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL;
12850 spin_unlock(shost->host_lock);
12851 lpfc_nlp_put(ndlp);
12852 mb->context2 = NULL;
12853 }
12854 /* Unregister the RPI when mailbox complete */
12855 mb->mbox_flag |= LPFC_MBX_IMED_UNREG;
12856 }
12857 } 12878 }
12858 spin_unlock_irq(&phba->hbalock);
12859} 12879}
12860 12880
12861/** 12881/**
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
index 1655507a682c..a5281ce893d0 100644
--- a/drivers/scsi/lpfc/lpfc_vport.c
+++ b/drivers/scsi/lpfc/lpfc_vport.c
@@ -580,7 +580,9 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
580 "static vport.\n"); 580 "static vport.\n");
581 return VPORT_ERROR; 581 return VPORT_ERROR;
582 } 582 }
583 583 spin_lock_irq(&phba->hbalock);
584 vport->load_flag |= FC_UNLOADING;
585 spin_unlock_irq(&phba->hbalock);
584 /* 586 /*
585 * If we are not unloading the driver then prevent the vport_delete 587 * If we are not unloading the driver then prevent the vport_delete
586 * from happening until after this vport's discovery is finished. 588 * from happening until after this vport's discovery is finished.
@@ -618,10 +620,6 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
618 scsi_host_put(shost); 620 scsi_host_put(shost);
619 return VPORT_INVAL; 621 return VPORT_INVAL;
620 } 622 }
621 spin_lock_irq(&phba->hbalock);
622 vport->load_flag |= FC_UNLOADING;
623 spin_unlock_irq(&phba->hbalock);
624
625 lpfc_free_sysfs_attr(vport); 623 lpfc_free_sysfs_attr(vport);
626 624
627 lpfc_debugfs_terminate(vport); 625 lpfc_debugfs_terminate(vport);