linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_init.c
index f6948ff..b7a603a 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2004-2006 Emulex.  All rights reserved.           *
+ * Copyright (C) 2004-2005 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
  * www.emulex.com                                                  *
  * Portions Copyright (C) 2004-2005 Christoph Hellwig              *
@@ -42,7 +42,7 @@
 #include "lpfc_crtn.h"
 #include "lpfc_version.h"
 
-static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int);
+static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *);
 static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
 static int lpfc_post_rcv_buf(struct lpfc_hba *);
 
@@ -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,
@@ -165,6 +161,9 @@ lpfc_config_port_prep(struct lpfc_hba * phba)
                memcpy(phba->RandomData, (char *)&mb->un.varWords[24],
                                                sizeof (phba->RandomData));
 
+       /* Get the default values for Model Name and Description */
+       lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
+
        /* Get adapter VPD information */
        pmb->context2 = kmalloc(DMP_RSP_SIZE, GFP_KERNEL);
        if (!pmb->context2)
@@ -183,15 +182,16 @@ lpfc_config_port_prep(struct lpfc_hba * phba)
                                        "mbxCmd x%x DUMP VPD, mbxStatus x%x\n",
                                        phba->brd_no,
                                        mb->mbxCommand, mb->mbxStatus);
-                       mb->un.varDmp.word_cnt = 0;
+                       kfree(lpfc_vpd_data);
+                       lpfc_vpd_data = NULL;
+                       break;
                }
-               if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset)
-                       mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset;
+
                lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset,
                                                        mb->un.varDmp.word_cnt);
                offset += mb->un.varDmp.word_cnt;
-       } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE);
-       lpfc_parse_vpd(phba, lpfc_vpd_data, offset);
+       } while (mb->un.varDmp.word_cnt);
+       lpfc_parse_vpd(phba, lpfc_vpd_data);
 
        kfree(lpfc_vpd_data);
 out_free_context2:
@@ -298,6 +298,15 @@ lpfc_config_port_post(struct lpfc_hba * phba)
                }
        }
 
+       /* This should turn on DELAYED ABTS for ELS timeouts */
+       lpfc_set_slim(phba, pmb, 0x052198, 0x1);
+       if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
+               phba->hba_state = LPFC_HBA_ERROR;
+               mempool_free( pmb, phba->mbox_mem_pool);
+               return -EIO;
+       }
+
+
        lpfc_read_config(phba, pmb);
        if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
                lpfc_printf_log(phba,
@@ -318,22 +327,13 @@ lpfc_config_port_post(struct lpfc_hba * phba)
                        mb->un.varRdConfig.max_xri + 1;
 
        phba->lmt = mb->un.varRdConfig.lmt;
-
-       /* Get the default values for Model Name and Description */
-       lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
-
-       if ((phba->cfg_link_speed > LINK_SPEED_10G)
-           || ((phba->cfg_link_speed == LINK_SPEED_1G)
-               && !(phba->lmt & LMT_1Gb))
-           || ((phba->cfg_link_speed == LINK_SPEED_2G)
-               && !(phba->lmt & LMT_2Gb))
-           || ((phba->cfg_link_speed == LINK_SPEED_4G)
-               && !(phba->lmt & LMT_4Gb))
-           || ((phba->cfg_link_speed == LINK_SPEED_8G)
-               && !(phba->lmt & LMT_8Gb))
-           || ((phba->cfg_link_speed == LINK_SPEED_10G)
-               && !(phba->lmt & LMT_10Gb))) {
-               /* Reset link speed to auto */
+       /* HBA is not 4GB capable, or HBA is not 2GB capable,
+       don't let link speed ask for it */
+       if ((((phba->lmt & LMT_4250_10bit) != LMT_4250_10bit) &&
+               (phba->cfg_link_speed > LINK_SPEED_2G)) ||
+               (((phba->lmt & LMT_2125_10bit) != LMT_2125_10bit) &&
+               (phba->cfg_link_speed > LINK_SPEED_1G))) {
+               /* Reset link speed to auto. 1G/2GB HBA cfg'd for 4G */
                lpfc_printf_log(phba,
                        KERN_WARNING,
                        LOG_LINK_EVENT,
@@ -409,26 +409,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 +429,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);
 }
 
 /************************************************************************/
@@ -464,40 +462,6 @@ lpfc_hba_down_prep(struct lpfc_hba * phba)
        return (0);
 }
 
-/************************************************************************/
-/*                                                                      */
-/*    lpfc_hba_down_post                                                */
-/*    This routine will do uninitialization after the HBA is reset      */
-/*    when bringing down the SLI Layer.                                 */
-/*    This routine returns 0 on success. Any other return value         */
-/*    indicates an error.                                               */
-/*                                                                      */
-/************************************************************************/
-int
-lpfc_hba_down_post(struct lpfc_hba * phba)
-{
-       struct lpfc_sli *psli = &phba->sli;
-       struct lpfc_sli_ring *pring;
-       struct lpfc_dmabuf *mp, *next_mp;
-       int i;
-
-       /* Cleanup preposted buffers on the ELS ring */
-       pring = &psli->ring[LPFC_ELS_RING];
-       list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) {
-               list_del(&mp->list);
-               pring->postbufq_cnt--;
-               lpfc_mbuf_free(phba, mp->virt, mp->phys);
-               kfree(mp);
-       }
-
-       for (i = 0; i < psli->num_rings; i++) {
-               pring = &psli->ring[i];
-               lpfc_sli_abort_iocb_ring(phba, pring);
-       }
-
-       return 0;
-}
-
 /************************************************************************/
 /*                                                                      */
 /*    lpfc_handle_eratt                                                 */
@@ -512,6 +476,20 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
        struct lpfc_sli *psli = &phba->sli;
        struct lpfc_sli_ring  *pring;
 
+       /*
+        * If a reset is sent to the HBA restore PCI configuration registers.
+        */
+       if ( phba->hba_state == LPFC_INIT_START ) {
+               mdelay(1);
+               readl(phba->HCregaddr); /* flush */
+               writel(0, phba->HCregaddr);
+               readl(phba->HCregaddr); /* flush */
+
+               /* Restore PCI cmd register */
+               pci_write_config_word(phba->pcidev,
+                                     PCI_COMMAND, phba->pci_cfg_value);
+       }
+
        if (phba->work_hs & HS_FFER6) {
                /* Re-establishing Link */
                lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
@@ -521,7 +499,6 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
                                phba->work_status[0], phba->work_status[1]);
                spin_lock_irq(phba->host->host_lock);
                phba->fc_flag |= FC_ESTABLISH_LINK;
-               psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
                spin_unlock_irq(phba->host->host_lock);
 
                /*
@@ -539,7 +516,6 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
                 * attempt to restart it.
                 */
                lpfc_offline(phba);
-               lpfc_sli_brdrestart(phba);
                if (lpfc_online(phba) == 0) {   /* Initialize the HBA */
                        mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
                        return;
@@ -555,10 +531,8 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
                                phba->brd_no, phba->work_hs,
                                phba->work_status[0], phba->work_status[1]);
 
-               psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
                lpfc_offline(phba);
-               phba->hba_state = LPFC_HBA_ERROR;
-               lpfc_hba_down_post(phba);
+
        }
 }
 
@@ -649,7 +623,7 @@ lpfc_handle_latt_err_exit:
 /*                                                                      */
 /************************************************************************/
 static int
-lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
+lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd)
 {
        uint8_t lenlo, lenhi;
        uint32_t Length;
@@ -668,10 +642,9 @@ lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
                        phba->brd_no,
                        (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2],
                        (uint32_t) vpd[3]);
-       while (!finished && (index < (len - 4))) {
+       do {
                switch (vpd[index]) {
                case 0x82:
-               case 0x91:
                        index += 1;
                        lenlo = vpd[index];
                        index += 1;
@@ -687,8 +660,7 @@ lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
                        lenhi = vpd[index];
                        index += 1;
                        Length = ((((unsigned short)lenhi) << 8) + lenlo);
-                       if (Length > len - index)
-                               Length = len - index;
+
                        while (Length > 0) {
                        /* Look for Serial Number */
                        if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) {
@@ -782,7 +754,7 @@ lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
                        index ++;
                        break;
                }
-       }
+       } while (!finished && (index < 108));
 
        return(1);
 }
@@ -793,173 +765,137 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
        lpfc_vpd_t *vp;
        uint16_t dev_id = phba->pcidev->device;
        uint16_t dev_subid = phba->pcidev->subsystem_device;
-       uint8_t hdrtype;
-       int max_speed;
-       char * ports;
-       struct {
-               char * name;
-               int    max_speed;
-               char * ports;
-               char * bus;
-       } m = {"<Unknown>", 0, "", ""};
-
-       pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
-       ports = (hdrtype == 0x80) ? "2-port " : "";
-       if (mdp && mdp[0] != '\0'
-               && descp && descp[0] != '\0')
-               return;
-
-       if (phba->lmt & LMT_10Gb)
-               max_speed = 10;
-       else if (phba->lmt & LMT_8Gb)
-               max_speed = 8;
-       else if (phba->lmt & LMT_4Gb)
-               max_speed = 4;
-       else if (phba->lmt & LMT_2Gb)
-               max_speed = 2;
-       else
-               max_speed = 1;
+       uint8_t hdrtype = phba->pcidev->hdr_type;
+       char *model_str = "";
 
        vp = &phba->vpd;
 
        switch (dev_id) {
        case PCI_DEVICE_ID_FIREFLY:
-               m = (typeof(m)){"LP6000", max_speed, "", "PCI"};
+               model_str = "LP6000 1Gb PCI";
                break;
        case PCI_DEVICE_ID_SUPERFLY:
                if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
-                       m = (typeof(m)){"LP7000", max_speed, "", "PCI"};
+                       model_str = "LP7000 1Gb PCI";
                else
-                       m = (typeof(m)){"LP7000E", max_speed, "", "PCI"};
+                       model_str = "LP7000E 1Gb PCI";
                break;
        case PCI_DEVICE_ID_DRAGONFLY:
-               m = (typeof(m)){"LP8000", max_speed, "", "PCI"};
+               model_str = "LP8000 1Gb PCI";
                break;
        case PCI_DEVICE_ID_CENTAUR:
                if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
-                       m = (typeof(m)){"LP9002", max_speed, "", "PCI"};
+                       model_str = "LP9002 2Gb PCI";
                else
-                       m = (typeof(m)){"LP9000", max_speed, "", "PCI"};
+                       model_str = "LP9000 1Gb PCI";
                break;
        case PCI_DEVICE_ID_RFLY:
-               m = (typeof(m)){"LP952", max_speed, "", "PCI"};
+               model_str = "LP952 2Gb PCI";
                break;
        case PCI_DEVICE_ID_PEGASUS:
-               m = (typeof(m)){"LP9802", max_speed, "", "PCI-X"};
+               model_str = "LP9802 2Gb PCI-X";
                break;
        case PCI_DEVICE_ID_THOR:
                if (hdrtype == 0x80)
-                       m = (typeof(m)){"LP10000DC",
-                                       max_speed, ports, "PCI-X"};
+                       model_str = "LP10000DC 2Gb 2-port PCI-X";
                else
-                       m = (typeof(m)){"LP10000",
-                                       max_speed, ports, "PCI-X"};
+                       model_str = "LP10000 2Gb PCI-X";
                break;
        case PCI_DEVICE_ID_VIPER:
-               m = (typeof(m)){"LPX1000", max_speed, "", "PCI-X"};
+               model_str = "LPX1000 10Gb PCI-X";
                break;
        case PCI_DEVICE_ID_PFLY:
-               m = (typeof(m)){"LP982", max_speed, "", "PCI-X"};
+               model_str = "LP982 2Gb PCI-X";
                break;
        case PCI_DEVICE_ID_TFLY:
                if (hdrtype == 0x80)
-                       m = (typeof(m)){"LP1050DC", max_speed, ports, "PCI-X"};
+                       model_str = "LP1050DC 2Gb 2-port PCI-X";
                else
-                       m = (typeof(m)){"LP1050", max_speed, ports, "PCI-X"};
+                       model_str = "LP1050 2Gb PCI-X";
                break;
        case PCI_DEVICE_ID_HELIOS:
                if (hdrtype == 0x80)
-                       m = (typeof(m)){"LP11002", max_speed, ports, "PCI-X2"};
+                       model_str = "LP11002 4Gb 2-port PCI-X2";
                else
-                       m = (typeof(m)){"LP11000", max_speed, ports, "PCI-X2"};
+                       model_str = "LP11000 4Gb PCI-X2";
                break;
        case PCI_DEVICE_ID_HELIOS_SCSP:
-               m = (typeof(m)){"LP11000-SP", max_speed, ports, "PCI-X2"};
+               model_str = "LP11000-SP 4Gb PCI-X2";
                break;
        case PCI_DEVICE_ID_HELIOS_DCSP:
-               m = (typeof(m)){"LP11002-SP", max_speed, ports, "PCI-X2"};
+               model_str = "LP11002-SP 4Gb 2-port PCI-X2";
                break;
        case PCI_DEVICE_ID_NEPTUNE:
                if (hdrtype == 0x80)
-                       m = (typeof(m)){"LPe1002", max_speed, ports, "PCIe"};
+                       model_str = "LPe1002 4Gb 2-port";
                else
-                       m = (typeof(m)){"LPe1000", max_speed, ports, "PCIe"};
+                       model_str = "LPe1000 4Gb PCIe";
                break;
        case PCI_DEVICE_ID_NEPTUNE_SCSP:
-               m = (typeof(m)){"LPe1000-SP", max_speed, ports, "PCIe"};
+               model_str = "LPe1000-SP 4Gb PCIe";
                break;
        case PCI_DEVICE_ID_NEPTUNE_DCSP:
-               m = (typeof(m)){"LPe1002-SP", max_speed, ports, "PCIe"};
+               model_str = "LPe1002-SP 4Gb 2-port PCIe";
                break;
        case PCI_DEVICE_ID_BMID:
-               m = (typeof(m)){"LP1150", max_speed, ports, "PCI-X2"};
+               model_str = "LP1150 4Gb PCI-X2";
                break;
        case PCI_DEVICE_ID_BSMB:
-               m = (typeof(m)){"LP111", max_speed, ports, "PCI-X2"};
+               model_str = "LP111 4Gb PCI-X2";
                break;
        case PCI_DEVICE_ID_ZEPHYR:
                if (hdrtype == 0x80)
-                       m = (typeof(m)){"LPe11002", max_speed, ports, "PCIe"};
+                       model_str = "LPe11002 4Gb 2-port PCIe";
                else
-                       m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"};
+                       model_str = "LPe11000 4Gb PCIe";
                break;
        case PCI_DEVICE_ID_ZEPHYR_SCSP:
-               m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"};
+               model_str = "LPe11000-SP 4Gb PCIe";
                break;
        case PCI_DEVICE_ID_ZEPHYR_DCSP:
-               m = (typeof(m)){"LPe11002-SP", max_speed, ports, "PCIe"};
+               model_str = "LPe11002-SP 4Gb 2-port PCIe";
                break;
        case PCI_DEVICE_ID_ZMID:
-               m = (typeof(m)){"LPe1150", max_speed, ports, "PCIe"};
+               model_str = "LPe1150 4Gb PCIe";
                break;
        case PCI_DEVICE_ID_ZSMB:
-               m = (typeof(m)){"LPe111", max_speed, ports, "PCIe"};
+               model_str = "LPe111 4Gb PCIe";
                break;
        case PCI_DEVICE_ID_LP101:
-               m = (typeof(m)){"LP101", max_speed, ports, "PCI-X"};
+               model_str = "LP101 2Gb PCI-X";
                break;
        case PCI_DEVICE_ID_LP10000S:
-               m = (typeof(m)){"LP10000-S", max_speed, ports, "PCI"};
+               model_str = "LP10000-S 2Gb PCI";
                break;
        case PCI_DEVICE_ID_LP11000S:
        case PCI_DEVICE_ID_LPE11000S:
                switch (dev_subid) {
                case PCI_SUBSYSTEM_ID_LP11000S:
-                       m = (typeof(m)){"LP11000-S", max_speed,
-                                       ports, "PCI-X2"};
+                       model_str = "LP11002-S 4Gb PCI-X2";
                        break;
                case PCI_SUBSYSTEM_ID_LP11002S:
-                       m = (typeof(m)){"LP11002-S", max_speed,
-                                       ports, "PCI-X2"};
+                       model_str = "LP11000-S 4Gb 2-port PCI-X2";
                        break;
                case PCI_SUBSYSTEM_ID_LPE11000S:
-                       m = (typeof(m)){"LPe11000-S", max_speed,
-                                       ports, "PCIe"};
+                       model_str = "LPe11002-S 4Gb PCIe";
                        break;
                case PCI_SUBSYSTEM_ID_LPE11002S:
-                       m = (typeof(m)){"LPe11002-S", max_speed,
-                                       ports, "PCIe"};
+                       model_str = "LPe11002-S 4Gb 2-port PCIe";
                        break;
                case PCI_SUBSYSTEM_ID_LPE11010S:
-                       m = (typeof(m)){"LPe11010-S", max_speed,
-                                       "10-port ", "PCIe"};
+                       model_str = "LPe11010-S 4Gb 10-port PCIe";
                        break;
                default:
-                       m = (typeof(m)){ NULL };
                        break;
                }
                break;
        default:
-               m = (typeof(m)){ NULL };
                break;
        }
-
-       if (mdp && mdp[0] == '\0')
-               snprintf(mdp, 79,"%s", m.name);
-       if (descp && descp[0] == '\0')
-               snprintf(descp, 255,
-                        "Emulex %s %dGb %s%s Fibre Channel Adapter",
-                        m.name, m.max_speed, m.ports, m.bus);
+       if (mdp)
+               sscanf(model_str, "%s", mdp);
+       if (descp)
+               sprintf(descp, "Emulex %s Fibre Channel Adapter", model_str);
 }
 
 /**************************************************/
@@ -1345,8 +1281,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 +1290,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 +1393,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);
@@ -1537,23 +1462,9 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
        phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2);
        bar2map_len        = pci_resource_len(phba->pcidev, 2);
 
-       /* Map HBA SLIM to a kernel virtual address. */
+       /* Map HBA SLIM and Control Registers to a kernel virtual address. */
        phba->slim_memmap_p      = ioremap(phba->pci_bar0_map, bar0map_len);
-       if (!phba->slim_memmap_p) {
-               error = -ENODEV;
-               dev_printk(KERN_ERR, &pdev->dev,
-                          "ioremap failed for SLIM memory.\n");
-               goto out_idr_remove;
-       }
-
-       /* Map HBA Control Registers to a kernel virtual address. */
        phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len);
-       if (!phba->ctrl_regs_memmap_p) {
-               error = -ENODEV;
-               dev_printk(KERN_ERR, &pdev->dev,
-                          "ioremap failed for HBA control registers.\n");
-               goto out_iounmap_slim;
-       }
 
        /* Allocate memory for SLI-2 structures */
        phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE,
@@ -1617,11 +1528,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 */
@@ -1632,6 +1539,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
        INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list);
 
        host->transportt = lpfc_transport_template;
+       host->hostdata[0] = (unsigned long)phba;
        pci_set_drvdata(pdev, host);
        error = scsi_add_host(host, &pdev->dev);
        if (error)
@@ -1639,9 +1547,9 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
 
        error = lpfc_alloc_sysfs_attr(phba);
        if (error)
-               goto out_remove_host;
+               goto out_kthread_stop;
 
-       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,
@@ -1656,18 +1564,8 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
        phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET;
 
        error = lpfc_sli_hba_setup(phba);
-       if (error) {
-               error = -ENODEV;
+       if (error)
                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);
@@ -1692,14 +1590,21 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
        lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host));
 
        fc_host_supported_speeds(host) = 0;
-       if (phba->lmt & LMT_10Gb)
+       switch (FC_JEDEC_ID(phba->vpd.rev.biuRev)) {
+       case VIPER_JEDEC_ID:
                fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT;
-       if (phba->lmt & LMT_4Gb)
+               break;
+       case HELIOS_JEDEC_ID:
                fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT;
-       if (phba->lmt & LMT_2Gb)
+               /* Fall through */
+       case CENTAUR_2G_JEDEC_ID:
+       case PEGASUS_JEDEC_ID:
+       case THOR_JEDEC_ID:
                fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT;
-       if (phba->lmt & LMT_1Gb)
-               fc_host_supported_speeds(host) |= FC_PORTSPEED_1GBIT;
+               /* Fall through */
+       default:
+               fc_host_supported_speeds(host) = FC_PORTSPEED_1GBIT;
+       }
 
        fc_host_maxframe_size(host) =
                ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) |
@@ -1722,9 +1627,6 @@ out_free_irq:
        free_irq(phba->pcidev->irq, phba);
 out_free_sysfs_attr:
        lpfc_free_sysfs_attr(phba);
-out_remove_host:
-       fc_remove_host(phba->host);
-       scsi_remove_host(phba->host);
 out_kthread_stop:
        kthread_stop(phba->worker_thread);
 out_free_iocbq:
@@ -1741,19 +1643,16 @@ out_free_slim:
                                                        phba->slim2p_mapping);
 out_iounmap:
        iounmap(phba->ctrl_regs_memmap_p);
-out_iounmap_slim:
        iounmap(phba->slim_memmap_p);
 out_idr_remove:
        idr_remove(&lpfc_hba_index, phba->brd_no);
 out_put_host:
-       phba->host = NULL;
        scsi_host_put(host);
 out_release_regions:
        pci_release_regions(pdev);
 out_disable_device:
        pci_disable_device(pdev);
 out:
-       pci_set_drvdata(pdev, NULL);
        return error;
 }
 
@@ -1761,7 +1660,7 @@ static void __devexit
 lpfc_pci_remove_one(struct pci_dev *pdev)
 {
        struct Scsi_Host   *host = pci_get_drvdata(pdev);
-       struct lpfc_hba    *phba = (struct lpfc_hba *)host->hostdata;
+       struct lpfc_hba    *phba = (struct lpfc_hba *)host->hostdata[0];
        unsigned long iflag;
 
        lpfc_free_sysfs_attr(phba);
@@ -1782,7 +1681,6 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
         * the HBA.
         */
        lpfc_sli_hba_down(phba);
-       lpfc_sli_brdrestart(phba);
 
        /* Release the irq reservation */
        free_irq(phba->pcidev->irq, phba);