Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_init.c
index f6948ff..908d0f2 100644 (file)
@@ -71,7 +71,6 @@ lpfc_config_port_prep(struct lpfc_hba * phba)
        uint16_t offset = 0;
        static char licensed[56] =
                    "key unlock for use with gnu public licensed code only\0";
-       static int init_key = 1;
 
        pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
        if (!pmb) {
@@ -83,13 +82,10 @@ lpfc_config_port_prep(struct lpfc_hba * phba)
        phba->hba_state = LPFC_INIT_MBX_CMDS;
 
        if (lpfc_is_LC_HBA(phba->pcidev->device)) {
-               if (init_key) {
-                       uint32_t *ptext = (uint32_t *) licensed;
+               uint32_t *ptext = (uint32_t *) licensed;
 
-                       for (i = 0; i < 56; i += sizeof (uint32_t), ptext++)
-                               *ptext = cpu_to_be32(*ptext);
-                       init_key = 0;
-               }
+               for (i = 0; i < 56; i += sizeof (uint32_t), ptext++)
+                       *ptext = cpu_to_be32(*ptext);
 
                lpfc_read_nv(phba, pmb);
                memset((char*)mb->un.varRDnvp.rsvd3, 0,
@@ -409,26 +405,19 @@ lpfc_config_port_post(struct lpfc_hba * phba)
        }
        /* MBOX buffer will be freed in mbox compl */
 
-       return (0);
-}
-
-static int
-lpfc_discovery_wait(struct lpfc_hba *phba)
-{
-       int i = 0;
-
+       i = 0;
        while ((phba->hba_state != LPFC_HBA_READY) ||
               (phba->num_disc_nodes) || (phba->fc_prli_sent) ||
               ((phba->fc_map_cnt == 0) && (i<2)) ||
-              (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) {
+              (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) {
                /* Check every second for 30 retries. */
                i++;
                if (i > 30) {
-                       return -ETIMEDOUT;
+                       break;
                }
                if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) {
                        /* The link is down.  Set linkdown timeout */
-                       return -ETIMEDOUT;
+                       break;
                }
 
                /* Delay for 1 second to give discovery time to complete. */
@@ -436,7 +425,12 @@ lpfc_discovery_wait(struct lpfc_hba *phba)
 
        }
 
-       return 0;
+       /* Since num_disc_nodes keys off of PLOGI, delay a bit to let
+        * any potential PRLIs to flush thru the SLI sub-system.
+        */
+       msleep(50);
+
+       return (0);
 }
 
 /************************************************************************/
@@ -945,12 +939,12 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
                                        "10-port ", "PCIe"};
                        break;
                default:
-                       m = (typeof(m)){ NULL };
+                       m = (typeof(m)){ 0 };
                        break;
                }
                break;
        default:
-               m = (typeof(m)){ NULL };
+               m = (typeof(m)){ 0 };
                break;
        }
 
@@ -1345,8 +1339,7 @@ lpfc_offline(struct lpfc_hba * phba)
        struct lpfc_sli_ring *pring;
        struct lpfc_sli *psli;
        unsigned long iflag;
-       int i;
-       int cnt = 0;
+       int i = 0;
 
        if (!phba)
                return 0;
@@ -1355,31 +1348,20 @@ lpfc_offline(struct lpfc_hba * phba)
                return 0;
 
        psli = &phba->sli;
+       pring = &psli->ring[psli->fcp_ring];
 
        lpfc_linkdown(phba);
-       lpfc_sli_flush_mbox_queue(phba);
 
-       for (i = 0; i < psli->num_rings; i++) {
-               pring = &psli->ring[i];
-               /* The linkdown event takes 30 seconds to timeout. */
-               while (pring->txcmplq_cnt) {
-                       mdelay(10);
-                       if (cnt++ > 3000) {
-                               lpfc_printf_log(phba,
-                                       KERN_WARNING, LOG_INIT,
-                                       "%d:0466 Outstanding IO when "
-                                       "bringing Adapter offline\n",
-                                       phba->brd_no);
-                               break;
-                       }
-               }
+       /* The linkdown event takes 30 seconds to timeout. */
+       while (pring->txcmplq_cnt) {
+               mdelay(10);
+               if (i++ > 3000)
+                       break;
        }
 
-
        /* stop all timers associated with this hba */
        lpfc_stop_timer(phba);
        phba->work_hba_events = 0;
-       phba->work_ha = 0;
 
        lpfc_printf_log(phba,
                       KERN_WARNING,
@@ -1469,6 +1451,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
                goto out_put_host;
 
        host->unique_id = phba->brd_no;
+       init_MUTEX(&phba->hba_can_block);
        INIT_LIST_HEAD(&phba->ctrspbuflist);
        INIT_LIST_HEAD(&phba->rnidrspbuflist);
        INIT_LIST_HEAD(&phba->freebufList);
@@ -1617,11 +1600,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
                goto out_free_iocbq;
        }
 
-       /*
-        * Set initial can_queue value since 0 is no longer supported and
-        * scsi_add_host will fail. This will be adjusted later based on the
-        * max xri value determined in hba setup.
-        */
+       /* We can rely on a queue depth attribute only after SLI HBA setup */
        host->can_queue = phba->cfg_hba_queue_depth - 10;
 
        /* Tell the midlayer we support 16 byte commands */
@@ -1641,7 +1620,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
        if (error)
                goto out_remove_host;
 
-       error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED,
+       error = request_irq(phba->pcidev->irq, lpfc_intr_handler, SA_SHIRQ,
                                                        LPFC_DRIVER_NAME, phba);
        if (error) {
                lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -1661,14 +1640,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
                goto out_free_irq;
        }
 
-       /*
-        * hba setup may have changed the hba_queue_depth so we need to adjust
-        * the value of can_queue.
-        */
-       host->can_queue = phba->cfg_hba_queue_depth - 10;
-
-       lpfc_discovery_wait(phba);
-
        if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
                spin_lock_irq(phba->host->host_lock);
                lpfc_poll_start_timer(phba);