Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_hbadisc.c
index b37fa20..a345dde 100644 (file)
@@ -588,7 +588,7 @@ lpfc_work_done(struct lpfc_hba *phba)
                                                        (status &
                                                         HA_RXMASK));
                }
-               if (pring->txq_cnt)
+               if ((phba->sli_rev == LPFC_SLI_REV4) && pring->txq_cnt)
                        lpfc_drain_txq(phba);
                /*
                 * Turn on Ring interrupts
@@ -1015,7 +1015,6 @@ static void
 lpfc_mbx_cmpl_reg_fcfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 {
        struct lpfc_vport *vport = mboxq->vport;
-       unsigned long flags;
 
        if (mboxq->u.mb.mbxStatus) {
                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)
        /* Start FCoE discovery by sending a FLOGI. */
        phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, &mboxq->u.mqe.un.reg_fcfi);
        /* Set the FCFI registered flag */
-       spin_lock_irqsave(&phba->hbalock, flags);
+       spin_lock_irq(&phba->hbalock);
        phba->fcf.fcf_flag |= FCF_REGISTERED;
-       spin_unlock_irqrestore(&phba->hbalock, flags);
+       spin_unlock_irq(&phba->hbalock);
        /* If there is a pending FCoE event, restart FCF table scan. */
        if (lpfc_check_pending_fcoe_event(phba, 1)) {
                mempool_free(mboxq, phba->mbox_mem_pool);
                return;
        }
-       spin_lock_irqsave(&phba->hbalock, flags);
+       spin_lock_irq(&phba->hbalock);
        phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE);
        phba->hba_flag &= ~FCF_DISC_INPROGRESS;
-       spin_unlock_irqrestore(&phba->hbalock, flags);
+       spin_unlock_irq(&phba->hbalock);
        if (vport->port_state != LPFC_FLOGI)
                lpfc_initial_flogi(vport);
 
@@ -1240,14 +1239,13 @@ lpfc_register_fcf(struct lpfc_hba *phba)
 {
        LPFC_MBOXQ_t *fcf_mbxq;
        int rc;
-       unsigned long flags;
 
-       spin_lock_irqsave(&phba->hbalock, flags);
+       spin_lock_irq(&phba->hbalock);
 
        /* If the FCF is not availabe do nothing. */
        if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) {
                phba->hba_flag &= ~FCF_DISC_INPROGRESS;
-               spin_unlock_irqrestore(&phba->hbalock, flags);
+               spin_unlock_irq(&phba->hbalock);
                return;
        }
 
@@ -1255,19 +1253,19 @@ lpfc_register_fcf(struct lpfc_hba *phba)
        if (phba->fcf.fcf_flag & FCF_REGISTERED) {
                phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE);
                phba->hba_flag &= ~FCF_DISC_INPROGRESS;
-               spin_unlock_irqrestore(&phba->hbalock, flags);
+               spin_unlock_irq(&phba->hbalock);
                if (phba->pport->port_state != LPFC_FLOGI)
                        lpfc_initial_flogi(phba->pport);
                return;
        }
-       spin_unlock_irqrestore(&phba->hbalock, flags);
+       spin_unlock_irq(&phba->hbalock);
 
        fcf_mbxq = mempool_alloc(phba->mbox_mem_pool,
                GFP_KERNEL);
        if (!fcf_mbxq) {
-               spin_lock_irqsave(&phba->hbalock, flags);
+               spin_lock_irq(&phba->hbalock);
                phba->hba_flag &= ~FCF_DISC_INPROGRESS;
-               spin_unlock_irqrestore(&phba->hbalock, flags);
+               spin_unlock_irq(&phba->hbalock);
                return;
        }
 
@@ -1276,9 +1274,9 @@ lpfc_register_fcf(struct lpfc_hba *phba)
        fcf_mbxq->mbox_cmpl = lpfc_mbx_cmpl_reg_fcfi;
        rc = lpfc_sli_issue_mbox(phba, fcf_mbxq, MBX_NOWAIT);
        if (rc == MBX_NOT_FINISHED) {
-               spin_lock_irqsave(&phba->hbalock, flags);
+               spin_lock_irq(&phba->hbalock);
                phba->hba_flag &= ~FCF_DISC_INPROGRESS;
-               spin_unlock_irqrestore(&phba->hbalock, flags);
+               spin_unlock_irq(&phba->hbalock);
                mempool_free(fcf_mbxq, phba->mbox_mem_pool);
        }
 
@@ -1852,8 +1850,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
                                __lpfc_sli4_stop_fcf_redisc_wait_timer(phba);
                        else if (phba->fcf.fcf_flag & FCF_REDISC_FOV)
                                /* If in fast failover, mark it's completed */
-                               phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV |
-                                                       FCF_DISCOVERY);
+                               phba->fcf.fcf_flag &= ~FCF_REDISC_FOV;
                        spin_unlock_irq(&phba->hbalock);
                        lpfc_printf_log(phba, KERN_INFO, LOG_FIP,
                                        "2836 The new FCF record (x%x) "
@@ -2651,7 +2648,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
                spin_unlock_irq(&phba->hbalock);
                lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY,
                                "2778 Start FCF table scan at linkup\n");
-
                rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba,
                                                     LPFC_FCOE_FCF_GET_FIRST);
                if (rc) {
@@ -2660,6 +2656,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
                        spin_unlock_irq(&phba->hbalock);
                        goto out;
                }
+               /* Reset FCF roundrobin bmask for new discovery */
+               memset(phba->fcf.fcf_rr_bmask, 0,
+                      sizeof(*phba->fcf.fcf_rr_bmask));
        }
 
        return;
@@ -2850,6 +2849,7 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        struct Scsi_Host  *shost = lpfc_shost_from_vport(vport);
 
        pmb->context1 = NULL;
+       pmb->context2 = NULL;
 
        if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND)
                ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
@@ -3148,6 +3148,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        ndlp = (struct lpfc_nodelist *) pmb->context2;
        pmb->context1 = NULL;
        pmb->context2 = NULL;
+
        if (mb->mbxStatus) {
                lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
                                 "0258 Register Fabric login error: 0x%x\n",
@@ -3217,6 +3218,9 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2;
        struct lpfc_vport *vport = pmb->vport;
 
+       pmb->context1 = NULL;
+       pmb->context2 = NULL;
+
        if (mb->mbxStatus) {
 out:
                lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
@@ -3248,8 +3252,6 @@ out:
                return;
        }
 
-       pmb->context1 = NULL;
-
        ndlp->nlp_rpi = mb->un.varWords[0];
        ndlp->nlp_flag |= NLP_RPI_VALID;
        ndlp->nlp_type |= NLP_FABRIC;
@@ -4783,6 +4785,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        struct lpfc_vport    *vport = pmb->vport;
 
        pmb->context1 = NULL;
+       pmb->context2 = NULL;
 
        ndlp->nlp_rpi = mb->un.varWords[0];
        ndlp->nlp_flag |= NLP_RPI_VALID;
@@ -5097,6 +5100,7 @@ static void
 lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 {
        struct lpfc_vport *vport = mboxq->vport;
+       struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
 
        if (mboxq->u.mb.mbxStatus) {
                lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX,
@@ -5104,6 +5108,9 @@ lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
                        "HBA state x%x\n",
                        mboxq->u.mb.mbxStatus, vport->port_state);
        }
+       spin_lock_irq(shost->host_lock);
+       phba->pport->fc_flag &= ~FC_VFI_REGISTERED;
+       spin_unlock_irq(shost->host_lock);
        mempool_free(mboxq, phba->mbox_mem_pool);
        return;
 }
@@ -5285,6 +5292,10 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba)
        spin_lock_irq(&phba->hbalock);
        phba->fcf.fcf_flag |= FCF_INIT_DISC;
        spin_unlock_irq(&phba->hbalock);
+
+       /* Reset FCF roundrobin bmask for new discovery */
+       memset(phba->fcf.fcf_rr_bmask, 0, sizeof(*phba->fcf.fcf_rr_bmask));
+
        rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST);
 
        if (rc) {