Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / drivers / scsi / lpfc / lpfc_hbadisc.c
index 2b227b3..b2f1552 100644 (file)
@@ -68,6 +68,15 @@ lpfc_process_nodev_timeout(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
                return;
        }
 
+       /*
+        * If a discovery event readded nodev_timer after timer
+        * firing and before processing the timer, cancel the
+        * nlp_tmofunc.
+        */
+       spin_unlock_irq(phba->host->host_lock);
+       del_timer_sync(&ndlp->nlp_tmofunc);
+       spin_lock_irq(phba->host->host_lock);
+
        ndlp->nlp_flag &= ~NLP_NODEV_TMO;
 
        if (ndlp->nlp_sid != NLP_NO_SID) {
@@ -146,6 +155,7 @@ lpfc_work_list_done(struct lpfc_hba * phba)
                case LPFC_EVT_WARM_START:
                        if (phba->hba_state >= LPFC_LINK_DOWN)
                                lpfc_offline(phba);
+                       lpfc_reset_barrier(phba);
                        lpfc_sli_brdreset(phba);
                        lpfc_hba_down_post(phba);
                        *(int *)(evtp->evt_arg1) =
@@ -155,7 +165,8 @@ lpfc_work_list_done(struct lpfc_hba * phba)
                case LPFC_EVT_KILL:
                        if (phba->hba_state >= LPFC_LINK_DOWN)
                                lpfc_offline(phba);
-                       *(int *)(evtp->evt_arg1)  = lpfc_sli_brdkill(phba);
+                       *(int *)(evtp->evt_arg1)
+                               = (phba->stopped) ? 0 : lpfc_sli_brdkill(phba);
                        complete((struct completion *)(evtp->evt_arg2));
                        break;
                }
@@ -300,8 +311,8 @@ lpfc_workq_post_event(struct lpfc_hba * phba, void *arg1, void *arg2,
        evtp->evt_arg2  = arg2;
        evtp->evt       = evt;
 
-       list_add_tail(&evtp->evt_listp, &phba->work_list);
        spin_lock_irq(phba->host->host_lock);
+       list_add_tail(&evtp->evt_listp, &phba->work_list);
        if (phba->work_wait)
                wake_up(phba->work_wait);
        spin_unlock_irq(phba->host->host_lock);
@@ -1060,10 +1071,6 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        /* initialize static port data */
        rport->maxframe_size = ndlp->nlp_maxframe;
        rport->supported_classes = ndlp->nlp_class_sup;
-       if ((rport->scsi_target_id != -1) &&
-               (rport->scsi_target_id < MAX_FCP_TARGET)) {
-               ndlp->nlp_sid = rport->scsi_target_id;
-       }
        rdata = rport->dd_data;
        rdata->pnode = ndlp;
 
@@ -1076,6 +1083,10 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        if (rport_ids.roles !=  FC_RPORT_ROLE_UNKNOWN)
                fc_remote_port_rolechg(rport, rport_ids.roles);
 
+       if ((rport->scsi_target_id != -1) &&
+               (rport->scsi_target_id < LPFC_MAX_TARGET)) {
+               ndlp->nlp_sid = rport->scsi_target_id;
+       }
 
        return;
 }
@@ -1152,13 +1163,9 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                /* Stop delay tmo if taking node off NPR list */
                if ((nlp->nlp_flag & NLP_DELAY_TMO) &&
                   (list != NLP_NPR_LIST)) {
-                       nlp->nlp_flag &= ~NLP_DELAY_TMO;
-                       nlp->nlp_last_elscmd = 0;
                        spin_unlock_irq(phba->host->host_lock);
-                       del_timer_sync(&nlp->nlp_delayfunc);
+                       lpfc_cancel_retry_delay_tmo(phba, nlp);
                        spin_lock_irq(phba->host->host_lock);
-                       if (!list_empty(&nlp->els_retry_evt.evt_listp))
-                               list_del_init(&nlp->els_retry_evt.evt_listp);
                }
                break;
        }
@@ -1231,6 +1238,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                                                evt_listp);
 
                }
+               nlp->nlp_flag &= ~NLP_NODEV_REMOVE;
                nlp->nlp_type |= NLP_FC_NODE;
                break;
        case NLP_MAPPED_LIST:
@@ -1251,6 +1259,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                                                evt_listp);
 
                }
+               nlp->nlp_flag &= ~NLP_NODEV_REMOVE;
                break;
        case NLP_NPR_LIST:
                nlp->nlp_flag |= list;
@@ -1304,7 +1313,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                        if ((rport_add == mapped) &&
                            ((!nlp->rport) ||
                             (nlp->rport->scsi_target_id == -1) ||
-                            (nlp->rport->scsi_target_id >= MAX_FCP_TARGET))) {
+                            (nlp->rport->scsi_target_id >= LPFC_MAX_TARGET))) {
                                nlp->nlp_state = NLP_STE_UNMAPPED_NODE;
                                spin_lock_irq(phba->host->host_lock);
                                nlp->nlp_flag |= NLP_TGT_NO_SCSIID;
@@ -1395,6 +1404,8 @@ lpfc_check_sli_ndlp(struct lpfc_hba * phba,
                        if (icmd->ulpContext == (volatile ushort)ndlp->nlp_rpi)
                                return 1;
                case CMD_ELS_REQUEST64_CR:
+                       if (icmd->un.elsreq64.remoteID == ndlp->nlp_DID)
+                               return 1;
                case CMD_XMIT_ELS_RSP64_CX:
                        if (iocb->context1 == (uint8_t *) ndlp)
                                return 1;
@@ -1546,6 +1557,8 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
                        mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
                }
        }
+
+       spin_lock_irq(phba->host->host_lock);
        list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
                if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
                   (ndlp == (struct lpfc_nodelist *) mb->context2)) {
@@ -1558,6 +1571,7 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
                        mempool_free(mb, phba->mbox_mem_pool);
                }
        }
+       spin_unlock_irq(phba->host->host_lock);
 
        lpfc_els_abort(phba,ndlp,0);
        spin_lock_irq(phba->host->host_lock);
@@ -1598,13 +1612,7 @@ lpfc_nlp_remove(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
 
 
        if (ndlp->nlp_flag & NLP_DELAY_TMO) {
-               spin_lock_irq(phba->host->host_lock);
-               ndlp->nlp_flag &= ~NLP_DELAY_TMO;
-               spin_unlock_irq(phba->host->host_lock);
-               ndlp->nlp_last_elscmd = 0;
-               del_timer_sync(&ndlp->nlp_delayfunc);
-               if (!list_empty(&ndlp->els_retry_evt.evt_listp))
-                       list_del_init(&ndlp->els_retry_evt.evt_listp);
+               lpfc_cancel_retry_delay_tmo(phba, ndlp);
        }
 
        if (ndlp->nlp_disc_refcnt) {
@@ -1759,6 +1767,7 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
                                                phba->brd_no,
                                                ndlp, ndlp->nlp_DID,
                                                ndlp->nlp_flag, data1);
+                               spin_unlock_irq(phba->host->host_lock);
                                return ndlp;
                        }
                }
@@ -1776,7 +1785,7 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
                                /* LOG change to REGLOGIN */
                                /* FIND node DID reglogin */
                                lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
-                                               "%d:0931 FIND node DID reglogin"
+                                               "%d:0901 FIND node DID reglogin"
                                                " Data: x%p x%x x%x x%x\n",
                                                phba->brd_no,
                                                ndlp, ndlp->nlp_DID,
@@ -1799,11 +1808,12 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
                                /* LOG change to PRLI */
                                /* FIND node DID prli */
                                lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
-                                               "%d:0931 FIND node DID prli "
+                                               "%d:0902 FIND node DID prli "
                                                "Data: x%p x%x x%x x%x\n",
                                                phba->brd_no,
                                                ndlp, ndlp->nlp_DID,
                                                ndlp->nlp_flag, data1);
+                               spin_unlock_irq(phba->host->host_lock);
                                return ndlp;
                        }
                }
@@ -1821,7 +1831,7 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
                                /* LOG change to NPR */
                                /* FIND node DID npr */
                                lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
-                                               "%d:0931 FIND node DID npr "
+                                               "%d:0903 FIND node DID npr "
                                                "Data: x%p x%x x%x x%x\n",
                                                phba->brd_no,
                                                ndlp, ndlp->nlp_DID,
@@ -1844,7 +1854,7 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
                                /* LOG change to UNUSED */
                                /* FIND node DID unused */
                                lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
-                                               "%d:0931 FIND node DID unused "
+                                               "%d:0905 FIND node DID unused "
                                                "Data: x%p x%x x%x x%x\n",
                                                phba->brd_no,
                                                ndlp, ndlp->nlp_DID,
@@ -1896,18 +1906,10 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
                        /* Since this node is marked for discovery,
                         * delay timeout is not needed.
                         */
-                       if (ndlp->nlp_flag & NLP_DELAY_TMO) {
-                               ndlp->nlp_flag &= ~NLP_DELAY_TMO;
-                               del_timer_sync(&ndlp->nlp_delayfunc);
-                               if (!list_empty(&ndlp->els_retry_evt.
-                                                               evt_listp))
-                                       list_del_init(&ndlp->els_retry_evt.
-                                                               evt_listp);
-                       }
-               } else {
-                       ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
+                       if (ndlp->nlp_flag & NLP_DELAY_TMO)
+                               lpfc_cancel_retry_delay_tmo(phba, ndlp);
+               } else
                        ndlp = NULL;
-               }
        } else {
                flg = ndlp->nlp_flag & NLP_LIST_MASK;
                if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST))
@@ -2336,7 +2338,7 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
                initlinkmbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
                if (!initlinkmbox) {
                        lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
-                                       "%d:0226 Device Discovery "
+                                       "%d:0206 Device Discovery "
                                        "completion error\n",
                                        phba->brd_no);
                        phba->hba_state = LPFC_HBA_ERROR;
@@ -2366,7 +2368,7 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
                if (!clearlambox) {
                        clrlaerr = 1;
                        lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
-                                       "%d:0226 Device Discovery "
+                                       "%d:0207 Device Discovery "
                                        "completion error\n",
                                        phba->brd_no);
                        phba->hba_state = LPFC_HBA_ERROR;