]> err.no Git - linux-2.6/blobdiff - drivers/scsi/lpfc/lpfc_sli.c
[SCSI] lpfc 8.2.7 : Rework the worker thread
[linux-2.6] / drivers / scsi / lpfc / lpfc_sli.c
index 741e94af4793873680463a74d105d37c8859484b..3dba3a967ed1f46b1caf6522aeb38ea0f6120fa8 100644 (file)
@@ -324,9 +324,7 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
                        phba->work_ha |= HA_ERATT;
                        phba->work_hs = HS_FFER3;
 
-                       /* hbalock should already be held */
-                       if (phba->work_wait)
-                               lpfc_worker_wake_up(phba);
+                       lpfc_worker_wake_up(phba);
 
                        return NULL;
                }
@@ -1309,9 +1307,7 @@ lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
        phba->work_ha |= HA_ERATT;
        phba->work_hs = HS_FFER3;
 
-       /* hbalock should already be held */
-       if (phba->work_wait)
-               lpfc_worker_wake_up(phba);
+       lpfc_worker_wake_up(phba);
 
        return;
 }
@@ -2611,12 +2607,9 @@ lpfc_mbox_timeout(unsigned long ptr)
                phba->pport->work_port_events |= WORKER_MBOX_TMO;
        spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag);
 
-       if (!tmo_posted) {
-               spin_lock_irqsave(&phba->hbalock, iflag);
-               if (phba->work_wait)
-                       lpfc_worker_wake_up(phba);
-               spin_unlock_irqrestore(&phba->hbalock, iflag);
-       }
+       if (!tmo_posted)
+               lpfc_worker_wake_up(phba);
+       return;
 }
 
 void
@@ -3374,8 +3367,12 @@ lpfc_sli_host_down(struct lpfc_vport *vport)
        for (i = 0; i < psli->num_rings; i++) {
                pring = &psli->ring[i];
                prev_pring_flag = pring->flag;
-               if (pring->ringno == LPFC_ELS_RING) /* Only slow rings */
+               /* Only slow rings */
+               if (pring->ringno == LPFC_ELS_RING) {
                        pring->flag |= LPFC_DEFERRED_RING_EVENT;
+                       /* Set the lpfc data pending flag */
+                       set_bit(LPFC_DATA_READY, &phba->data_flags);
+               }
                /*
                 * Error everything on the txq since these iocbs have not been
                 * given to the FW yet.
@@ -3434,8 +3431,12 @@ lpfc_sli_hba_down(struct lpfc_hba *phba)
        spin_lock_irqsave(&phba->hbalock, flags);
        for (i = 0; i < psli->num_rings; i++) {
                pring = &psli->ring[i];
-               if (pring->ringno == LPFC_ELS_RING) /* Only slow rings */
+               /* Only slow rings */
+               if (pring->ringno == LPFC_ELS_RING) {
                        pring->flag |= LPFC_DEFERRED_RING_EVENT;
+                       /* Set the lpfc data pending flag */
+                       set_bit(LPFC_DATA_READY, &phba->data_flags);
+               }
 
                /*
                 * Error everything on the txq since these iocbs have not been
@@ -3481,26 +3482,21 @@ lpfc_sli_hba_down(struct lpfc_hba *phba)
        phba->pport->work_port_events &= ~WORKER_MBOX_TMO;
        spin_unlock(&phba->pport->work_port_lock);
 
+       /* Return any pending or completed mbox cmds */
+       list_splice_init(&phba->sli.mboxq, &completions);
        if (psli->mbox_active) {
                list_add_tail(&psli->mbox_active->list, &completions);
                psli->mbox_active = NULL;
                psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
        }
-
-       /* Return any pending or completed mbox cmds */
-       list_splice_init(&phba->sli.mboxq, &completions);
        list_splice_init(&phba->sli.mboxq_cmpl, &completions);
-       INIT_LIST_HEAD(&psli->mboxq);
-       INIT_LIST_HEAD(&psli->mboxq_cmpl);
-
        spin_unlock_irqrestore(&phba->hbalock, flags);
 
        while (!list_empty(&completions)) {
                list_remove_head(&completions, pmb, LPFC_MBOXQ_t, list);
                pmb->mb.mbxStatus = MBX_NOT_FINISHED;
-               if (pmb->mbox_cmpl) {
+               if (pmb->mbox_cmpl)
                        pmb->mbox_cmpl(phba,pmb);
-               }
        }
        return 1;
 }
@@ -4164,7 +4160,7 @@ lpfc_intr_handler(int irq, void *dev_id)
                                                "pwork:x%x hawork:x%x wait:x%x",
                                                phba->work_ha, work_ha_copy,
                                                (uint32_t)((unsigned long)
-                                               phba->work_wait));
+                                               &phba->work_waitq));
 
                                        control &=
                                            ~(HC_R0INT_ENA << LPFC_ELS_RING);
@@ -4177,7 +4173,7 @@ lpfc_intr_handler(int irq, void *dev_id)
                                                "x%x hawork:x%x wait:x%x",
                                                phba->work_ha, work_ha_copy,
                                                (uint32_t)((unsigned long)
-                                               phba->work_wait));
+                                               &phba->work_waitq));
                                }
                                spin_unlock(&phba->hbalock);
                        }
@@ -4201,6 +4197,7 @@ lpfc_intr_handler(int irq, void *dev_id)
                        phba->pport->stopped = 1;
                }
 
+               spin_lock(&phba->hbalock);
                if ((work_ha_copy & HA_MBATT) &&
                    (phba->sli.mbox_active)) {
                        pmb = phba->sli.mbox_active;
@@ -4211,6 +4208,7 @@ lpfc_intr_handler(int irq, void *dev_id)
                        /* First check out the status word */
                        lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof(uint32_t));
                        if (pmbox->mbxOwner != OWN_HOST) {
+                               spin_unlock(&phba->hbalock);
                                /*
                                 * Stray Mailbox Interrupt, mbxCommand <cmd>
                                 * mbxStatus <status>
@@ -4226,10 +4224,10 @@ lpfc_intr_handler(int irq, void *dev_id)
                                /* clear mailbox attention bit */
                                work_ha_copy &= ~HA_MBATT;
                        } else {
+                               phba->sli.mbox_active = NULL;
+                               spin_unlock(&phba->hbalock);
                                phba->last_completion_time = jiffies;
                                del_timer(&phba->sli.mbox_tmo);
-
-                               phba->sli.mbox_active = NULL;
                                if (pmb->mbox_cmpl) {
                                        lpfc_sli_pcimem_bcopy(mbox, pmbox,
                                                        MAILBOX_CMD_SIZE);
@@ -4282,7 +4280,8 @@ lpfc_intr_handler(int irq, void *dev_id)
                                spin_unlock(&phba->pport->work_port_lock);
                                lpfc_mbox_cmpl_put(phba, pmb);
                        }
-               }
+               } else
+                       spin_unlock(&phba->hbalock);
                if ((work_ha_copy & HA_MBATT) &&
                    (phba->sli.mbox_active == NULL)) {
 send_current_mbox:
@@ -4299,9 +4298,8 @@ send_current_mbox:
 
                spin_lock(&phba->hbalock);
                phba->work_ha |= work_ha_copy;
-               if (phba->work_wait)
-                       lpfc_worker_wake_up(phba);
                spin_unlock(&phba->hbalock);
+               lpfc_worker_wake_up(phba);
        }
 
        ha_copy &= ~(phba->work_ha_mask);