aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_sli.c
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/lpfc_sli.c
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/lpfc_sli.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c100
1 files changed, 60 insertions, 40 deletions
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/**