Merge ../linux-2.6
[powerpc.git] / drivers / scsi / qla2xxx / qla_os.c
index 9f91f1a..ccaad0b 100644 (file)
@@ -8,8 +8,8 @@
 
 #include <linux/moduleparam.h>
 #include <linux/vmalloc.h>
-#include <linux/smp_lock.h>
 #include <linux/delay.h>
+#include <linux/kthread.h>
 
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsicam.h>
@@ -54,13 +54,6 @@ module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
 MODULE_PARM_DESC(ql2xloginretrycount,
                "Specify an alternate value for the NVRAM login retry count.");
 
-#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
-int ql2xfwloadflash;
-module_param(ql2xfwloadflash, int, S_IRUGO|S_IRUSR);
-MODULE_PARM_DESC(ql2xfwloadflash,
-               "Load ISP24xx firmware image from FLASH (onboard memory).");
-#endif
-
 static void qla2x00_free_device(scsi_qla_host_t *);
 
 static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha);
@@ -71,12 +64,6 @@ MODULE_PARM_DESC(ql2xfdmienable,
                "Enables FDMI registratons "
                "Default is 0 - no FDMI. 1 - perfom FDMI.");
 
-int ql2xprocessrscn;
-module_param(ql2xprocessrscn, int, S_IRUGO|S_IRUSR);
-MODULE_PARM_DESC(ql2xprocessrscn,
-               "Option to enable port RSCN handling via a series of less"
-               "fabric intrusive ADISCs and PLOGIs.");
-
 /*
  * SCSI host template entry points
  */
@@ -99,7 +86,7 @@ static int qla2x00_change_queue_type(struct scsi_device *, int);
 
 static struct scsi_host_template qla2x00_driver_template = {
        .module                 = THIS_MODULE,
-       .name                   = "qla2xxx",
+       .name                   = QLA2XXX_DRIVER_NAME,
        .queuecommand           = qla2x00_queuecommand,
 
        .eh_abort_handler       = qla2xxx_eh_abort,
@@ -128,7 +115,7 @@ static struct scsi_host_template qla2x00_driver_template = {
 
 static struct scsi_host_template qla24xx_driver_template = {
        .module                 = THIS_MODULE,
-       .name                   = "qla2xxx",
+       .name                   = QLA2XXX_DRIVER_NAME,
        .queuecommand           = qla24xx_queuecommand,
 
        .eh_abort_handler       = qla2xxx_eh_abort,
@@ -340,7 +327,6 @@ qla2x00_get_new_sp(scsi_qla_host_t *ha, fc_port_t *fcport,
        if (!sp)
                return sp;
 
-       atomic_set(&sp->ref_count, 1);
        sp->ha = ha;
        sp->fcport = fcport;
        sp->cmd = cmd;
@@ -577,6 +563,10 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
        while ((!atomic_read(&ha->loop_down_timer) &&
            atomic_read(&ha->loop_state) == LOOP_DOWN) ||
            atomic_read(&ha->loop_state) != LOOP_READY) {
+               if (atomic_read(&ha->loop_state) == LOOP_DEAD) {
+                       return_status = QLA_FUNCTION_FAILED;
+                       break;
+               }
                msleep(1000);
                if (time_after_eq(jiffies, loop_timeout)) {
                        return_status = QLA_FUNCTION_FAILED;
@@ -599,6 +589,7 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
 *    Either SUCCESS or FAILED.
 *
 * Note:
+*    Only return FAILED if command not returned by firmware.
 **************************************************************************/
 int
 qla2xxx_eh_abort(struct scsi_cmnd *cmd)
@@ -609,11 +600,12 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
        unsigned int id, lun;
        unsigned long serial;
        unsigned long flags;
+       int wait = 0;
 
        if (!CMD_SP(cmd))
-               return FAILED;
+               return SUCCESS;
 
-       ret = FAILED;
+       ret = SUCCESS;
 
        id = cmd->device->id;
        lun = cmd->device->lun;
@@ -630,9 +622,8 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
                if (sp->cmd != cmd)
                        continue;
 
-               DEBUG2(printk("%s(%ld): aborting sp %p from RISC. pid=%ld "
-                   "sp->state=%x\n", __func__, ha->host_no, sp, serial,
-                   sp->state));
+               DEBUG2(printk("%s(%ld): aborting sp %p from RISC. pid=%ld.\n",
+                   __func__, ha->host_no, sp, serial));
                DEBUG3(qla2x00_print_scsi_cmd(cmd);)
 
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -642,7 +633,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
                } else {
                        DEBUG3(printk("%s(%ld): abort_command "
                            "mbx success.\n", __func__, ha->host_no));
-                       ret = SUCCESS;
+                       wait = 1;
                }
                spin_lock_irqsave(&ha->hardware_lock, flags);
 
@@ -651,17 +642,18 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
        /* Wait for the command to be returned. */
-       if (ret == SUCCESS) {
+       if (wait) {
                if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) {
                        qla_printk(KERN_ERR, ha,
                            "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
                            "%x.\n", ha->host_no, id, lun, serial, ret);
+                       ret = FAILED;
                }
        }
 
        qla_printk(KERN_INFO, ha,
-           "scsi(%ld:%d:%d): Abort command issued -- %lx %x.\n", ha->host_no,
-           id, lun, serial, ret);
+           "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
+           ha->host_no, id, lun, wait, serial, ret);
 
        return ret;
 }
@@ -1146,6 +1138,68 @@ qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
        pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK);
 }
 
+static inline void
+qla2x00_set_isp_flags(scsi_qla_host_t *ha)
+{
+       ha->device_type = DT_EXTENDED_IDS;
+       switch (ha->pdev->device) {
+       case PCI_DEVICE_ID_QLOGIC_ISP2100:
+               ha->device_type |= DT_ISP2100;
+               ha->device_type &= ~DT_EXTENDED_IDS;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2100;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2200:
+               ha->device_type |= DT_ISP2200;
+               ha->device_type &= ~DT_EXTENDED_IDS;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2100;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2300:
+               ha->device_type |= DT_ISP2300;
+               ha->device_type |= DT_ZIO_SUPPORTED;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2300;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2312:
+               ha->device_type |= DT_ISP2312;
+               ha->device_type |= DT_ZIO_SUPPORTED;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2300;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2322:
+               ha->device_type |= DT_ISP2322;
+               ha->device_type |= DT_ZIO_SUPPORTED;
+               if (ha->pdev->subsystem_vendor == 0x1028 &&
+                   ha->pdev->subsystem_device == 0x0170)
+                       ha->device_type |= DT_OEM_001;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2300;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP6312:
+               ha->device_type |= DT_ISP6312;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2300;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP6322:
+               ha->device_type |= DT_ISP6322;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2300;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2422:
+               ha->device_type |= DT_ISP2422;
+               ha->device_type |= DT_ZIO_SUPPORTED;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2400;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2432:
+               ha->device_type |= DT_ISP2432;
+               ha->device_type |= DT_ZIO_SUPPORTED;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2400;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP5422:
+               ha->device_type |= DT_ISP5422;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2400;
+               break;
+       case PCI_DEVICE_ID_QLOGIC_ISP5432:
+               ha->device_type |= DT_ISP5432;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2400;
+               break;
+       }
+}
+
 static int
 qla2x00_iospace_config(scsi_qla_host_t *ha)
 {
@@ -1188,7 +1242,7 @@ qla2x00_iospace_config(scsi_qla_host_t *ha)
                goto iospace_error_exit;
        }
 
-       if (pci_request_regions(ha->pdev, ha->brd_info->drv_name)) {
+       if (pci_request_regions(ha->pdev, QLA2XXX_DRIVER_NAME)) {
                qla_printk(KERN_WARNING, ha,
                    "Failed to reserve PIO/MMIO regions (%s)\n",
                    pci_name(ha->pdev));
@@ -1270,7 +1324,7 @@ qla24xx_disable_intrs(scsi_qla_host_t *ha)
 /*
  * PCI driver interface
  */
-int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
+static int qla2x00_probe_one(struct pci_dev *pdev)
 {
        int     ret = -ENODEV;
        device_reg_t __iomem *reg;
@@ -1304,10 +1358,10 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
        ha->pdev = pdev;
        ha->host = host;
        ha->host_no = host->host_no;
-       ha->brd_info = brd_info;
-       sprintf(ha->host_str, "%s_%ld", ha->brd_info->drv_name, ha->host_no);
+       sprintf(ha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, ha->host_no);
 
-       ha->dpc_pid = -1;
+       /* Set ISP-type information. */
+       qla2x00_set_isp_flags(ha);
 
        /* Configure PCI I/O space */
        ret = qla2x00_iospace_config(ha);
@@ -1321,7 +1375,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
        spin_lock_init(&ha->hardware_lock);
 
        ha->prev_topology = 0;
-       ha->ports = MAX_BUSES;
        ha->init_cb_size = sizeof(init_cb_t);
        ha->mgmt_svr_loop_id = MANAGEMENT_SERVER;
        ha->link_data_rate = LDR_UNKNOWN;
@@ -1386,7 +1439,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
                ha->gid_list_info_size = 6;
                if (IS_QLA2322(ha) || IS_QLA6322(ha))
                        ha->optrom_size = OPTROM_SIZE_2322;
-       } else if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
+       } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                host->max_id = MAX_TARGETS_2200;
                ha->mbx_count = MAILBOX_REGISTER_COUNT;
                ha->request_q_length = REQUEST_ENTRY_CNT_24XX;
@@ -1402,10 +1455,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
                ha->isp_ops.nvram_config = qla24xx_nvram_config;
                ha->isp_ops.update_fw_options = qla24xx_update_fw_options;
                ha->isp_ops.load_risc = qla24xx_load_risc;
-#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
-               if (ql2xfwloadflash)
-                       ha->isp_ops.load_risc = qla24xx_load_risc_flash;
-#endif
                ha->isp_ops.pci_info_str = qla24xx_pci_info_str;
                ha->isp_ops.fw_version_str = qla24xx_fw_version_str;
                ha->isp_ops.intr_handler = qla24xx_intr_handler;
@@ -1439,7 +1488,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
 
        INIT_LIST_HEAD(&ha->list);
        INIT_LIST_HEAD(&ha->fcports);
-       INIT_LIST_HEAD(&ha->rscn_fcports);
 
        /*
         * These locks are used to prevent more than one CPU
@@ -1449,9 +1497,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
         */
        spin_lock_init(&ha->mbx_reg_lock);
 
-       init_completion(&ha->dpc_inited);
-       init_completion(&ha->dpc_exited);
-
        qla2x00_config_dma_addressing(ha);
        if (qla2x00_mem_alloc(ha)) {
                qla_printk(KERN_WARNING, ha,
@@ -1478,27 +1523,25 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
        /*
         * Startup the kernel thread for this host adapter
         */
-       ha->dpc_should_die = 0;
-       ha->dpc_pid = kernel_thread(qla2x00_do_dpc, ha, 0);
-       if (ha->dpc_pid < 0) {
+       ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha,
+                       "%s_dpc", ha->host_str);
+       if (IS_ERR(ha->dpc_thread)) {
                qla_printk(KERN_WARNING, ha,
                    "Unable to start DPC thread!\n");
-
-               ret = -ENODEV;
+               ret = PTR_ERR(ha->dpc_thread);
                goto probe_failed;
        }
-       wait_for_completion(&ha->dpc_inited);
 
        host->this_id = 255;
        host->cmd_per_lun = 3;
        host->unique_id = ha->instance;
        host->max_cmd_len = MAX_CMDSZ;
-       host->max_channel = ha->ports - 1;
+       host->max_channel = MAX_BUSES - 1;
        host->max_lun = MAX_LUNS;
        host->transportt = qla2xxx_transport_template;
 
        ret = request_irq(pdev->irq, ha->isp_ops.intr_handler,
-           SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
+           SA_INTERRUPT|SA_SHIRQ, QLA2XXX_DRIVER_NAME, ha);
        if (ret) {
                qla_printk(KERN_WARNING, ha,
                    "Failed to reserve interrupt %d already in use.\n",
@@ -1517,7 +1560,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
        reg = ha->iobase;
-       if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
+       if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_HOST_INT);
                WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_RISC_INT);
        } else {
@@ -1596,9 +1639,8 @@ probe_disable_device:
 probe_out:
        return ret;
 }
-EXPORT_SYMBOL_GPL(qla2x00_probe_one);
 
-void qla2x00_remove_one(struct pci_dev *pdev)
+static void qla2x00_remove_one(struct pci_dev *pdev)
 {
        scsi_qla_host_t *ha;
 
@@ -1616,34 +1658,24 @@ void qla2x00_remove_one(struct pci_dev *pdev)
 
        pci_set_drvdata(pdev, NULL);
 }
-EXPORT_SYMBOL_GPL(qla2x00_remove_one);
 
 static void
 qla2x00_free_device(scsi_qla_host_t *ha)
 {
-       int ret;
-
-       /* Abort any outstanding IO descriptors. */
-       if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
-               qla2x00_cancel_io_descriptors(ha);
-
        /* Disable timer */
        if (ha->timer_active)
                qla2x00_stop_timer(ha);
 
        /* Kill the kernel thread for this host */
-       if (ha->dpc_pid >= 0) {
-               ha->dpc_should_die = 1;
-               wmb();
-               ret = kill_proc(ha->dpc_pid, SIGHUP, 1);
-               if (ret) {
-                       qla_printk(KERN_ERR, ha,
-                           "Unable to signal DPC thread -- (%d)\n", ret);
+       if (ha->dpc_thread) {
+               struct task_struct *t = ha->dpc_thread;
 
-                       /* TODO: SOMETHING MORE??? */
-               } else {
-                       wait_for_completion(&ha->dpc_exited);
-               }
+               /*
+                * qla2xxx_wake_dpc checks for ->dpc_thread
+                * so we need to zero it out.
+                */
+               ha->dpc_thread = NULL;
+               kthread_stop(t);
        }
 
        /* Stop currently executing firmware. */
@@ -1658,8 +1690,8 @@ qla2x00_free_device(scsi_qla_host_t *ha)
        ha->flags.online = 0;
 
        /* Detach interrupts */
-       if (ha->pdev->irq)
-               free_irq(ha->pdev->irq, ha);
+       if (ha->host->irq)
+               free_irq(ha->host->irq, ha);
 
        /* release io space registers  */
        if (ha->iobase)
@@ -1775,8 +1807,8 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
                atomic_set(&fcport->state, FCS_DEVICE_LOST);
        }
 
-       if (defer && ha->dpc_wait && !ha->dpc_active)
-               up(ha->dpc_wait);
+       if (defer)
+               qla2xxx_wake_dpc(ha);
 }
 
 /*
@@ -1839,19 +1871,8 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
                        continue;
                }
 
-               ha->rlc_rsp = dma_alloc_coherent(&ha->pdev->dev,
-                   sizeof(rpt_lun_cmd_rsp_t), &ha->rlc_rsp_dma, GFP_KERNEL);
-               if (ha->rlc_rsp == NULL) {
-                       qla_printk(KERN_WARNING, ha,
-                               "Memory Allocation failed - rlc");
-
-                       qla2x00_mem_free(ha);
-                       msleep(100);
-
-                       continue;
-               }
-
-               snprintf(name, sizeof(name), "qla2xxx_%ld", ha->host_no);
+               snprintf(name, sizeof(name), "%s_%ld", QLA2XXX_DRIVER_NAME,
+                   ha->host_no);
                ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
                    DMA_POOL_SIZE, 8, 0);
                if (ha->s_dma_pool == NULL) {
@@ -1878,21 +1899,6 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
                }
                memset(ha->init_cb, 0, ha->init_cb_size);
 
-               /* Get consistent memory allocated for Get Port Database cmd */
-               ha->iodesc_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
-                   &ha->iodesc_pd_dma);
-               if (ha->iodesc_pd == NULL) {
-                       /* error */
-                       qla_printk(KERN_WARNING, ha,
-                           "Memory Allocation failed - iodesc_pd\n");
-
-                       qla2x00_mem_free(ha);
-                       msleep(100);
-
-                       continue;
-               }
-               memset(ha->iodesc_pd, 0, PORT_DATABASE_SIZE);
-
                /* Allocate ioctl related memory. */
                if (qla2x00_alloc_ioctl_mem(ha)) {
                        qla_printk(KERN_WARNING, ha,
@@ -1993,7 +1999,6 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 {
        struct list_head        *fcpl, *fcptemp;
        fc_port_t       *fcport;
-       unsigned int    wtime;/* max wait time if mbx cmd is busy. */
 
        if (ha == NULL) {
                /* error */
@@ -2001,11 +2006,6 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
                return;
        }
 
-       /* Make sure all other threads are stopped. */
-       wtime = 60 * 1000;
-       while (ha->dpc_wait && wtime)
-               wtime = msleep_interruptible(wtime);
-
        /* free ioctl memory */
        qla2x00_free_ioctl_mem(ha);
 
@@ -2023,20 +2023,12 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
        if (ha->ms_iocb)
                dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
 
-       if (ha->iodesc_pd)
-               dma_pool_free(ha->s_dma_pool, ha->iodesc_pd, ha->iodesc_pd_dma);
-
        if (ha->init_cb)
                dma_pool_free(ha->s_dma_pool, ha->init_cb, ha->init_cb_dma);
 
        if (ha->s_dma_pool)
                dma_pool_destroy(ha->s_dma_pool);
 
-       if (ha->rlc_rsp)
-               dma_free_coherent(&ha->pdev->dev,
-                   sizeof(rpt_lun_cmd_rsp_t), ha->rlc_rsp,
-                   ha->rlc_rsp_dma);
-
        if (ha->gid_list)
                dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
                    ha->gid_list_dma);
@@ -2057,15 +2049,11 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
        ha->ct_sns_dma = 0;
        ha->ms_iocb = NULL;
        ha->ms_iocb_dma = 0;
-       ha->iodesc_pd = NULL;
-       ha->iodesc_pd_dma = 0;
        ha->init_cb = NULL;
        ha->init_cb_dma = 0;
 
        ha->s_dma_pool = NULL;
 
-       ha->rlc_rsp = NULL;
-       ha->rlc_rsp_dma = 0;
        ha->gid_list = NULL;
        ha->gid_list_dma = 0;
 
@@ -2083,15 +2071,10 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
        }
        INIT_LIST_HEAD(&ha->fcports);
 
-       if (ha->fw_dump)
-               free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
-
-       vfree(ha->fw_dump24);
-
+       vfree(ha->fw_dump);
        vfree(ha->fw_dump_buffer);
 
        ha->fw_dump = NULL;
-       ha->fw_dump24 = NULL;
        ha->fw_dumped = 0;
        ha->fw_dump_reading = 0;
        ha->fw_dump_buffer = NULL;
@@ -2109,8 +2092,6 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
  *
  * Context:
  *      Kernel context.
- *
- * Note: Sets the ref_count for non Null sp to one.
  */
 static int
 qla2x00_allocate_sp_pool(scsi_qla_host_t *ha)
@@ -2118,8 +2099,7 @@ qla2x00_allocate_sp_pool(scsi_qla_host_t *ha)
        int      rval;
 
        rval = QLA_SUCCESS;
-       ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab,
-           mempool_free_slab, srb_cachep);
+       ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
        if (ha->srb_mempool == NULL) {
                qla_printk(KERN_INFO, ha, "Unable to allocate SRB mempool.\n");
                rval = QLA_FUNCTION_FAILED;
@@ -2156,7 +2136,6 @@ qla2x00_free_sp_pool( scsi_qla_host_t *ha)
 static int
 qla2x00_do_dpc(void *data)
 {
-       DECLARE_MUTEX_LOCKED(sem);
        scsi_qla_host_t *ha;
        fc_port_t       *fcport;
        uint8_t         status;
@@ -2164,32 +2143,19 @@ qla2x00_do_dpc(void *data)
 
        ha = (scsi_qla_host_t *)data;
 
-       lock_kernel();
-
-       daemonize("%s_dpc", ha->host_str);
-       allow_signal(SIGHUP);
-
-       ha->dpc_wait = &sem;
-
        set_user_nice(current, -20);
 
-       unlock_kernel();
-
-       complete(&ha->dpc_inited);
-
-       while (1) {
+       while (!kthread_should_stop()) {
                DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
 
-               if (down_interruptible(&sem))
-                       break;
-
-               if (ha->dpc_should_die)
-                       break;
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule();
+               __set_current_state(TASK_RUNNING);
 
                DEBUG3(printk("qla2x00: DPC handler waking up\n"));
 
                /* Initialization not yet finished. Don't do anything yet. */
-               if (!ha->flags.init_done || ha->dpc_active)
+               if (!ha->flags.init_done)
                        continue;
 
                DEBUG3(printk("scsi(%ld): DPC handler\n", ha->host_no));
@@ -2273,7 +2239,7 @@ qla2x00_do_dpc(void *data)
                                        } else
                                                status =
                                                    qla2x00_local_device_login(
-                                                       ha, fcport->loop_id);
+                                                       ha, fcport);
 
                                        if (status == QLA_SUCCESS) {
                                                fcport->old_loop_id = fcport->loop_id;
@@ -2356,10 +2322,16 @@ qla2x00_do_dpc(void *data)
        /*
         * Make sure that nobody tries to wake us up again.
         */
-       ha->dpc_wait = NULL;
        ha->dpc_active = 0;
 
-       complete_and_exit(&ha->dpc_exited, 0);
+       return 0;
+}
+
+void
+qla2xxx_wake_dpc(scsi_qla_host_t *ha)
+{
+       if (ha->dpc_thread)
+               wake_up_process(ha->dpc_thread);
 }
 
 /*
@@ -2540,11 +2512,8 @@ qla2x00_timer(scsi_qla_host_t *ha)
            test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) ||
            test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) ||
            test_bit(BEACON_BLINK_NEEDED, &ha->dpc_flags) ||
-           test_bit(RELOGIN_NEEDED, &ha->dpc_flags)) &&
-           ha->dpc_wait && !ha->dpc_active) {
-
-               up(ha->dpc_wait);
-       }
+           test_bit(RELOGIN_NEEDED, &ha->dpc_flags)))
+               qla2xxx_wake_dpc(ha);
 
        qla2x00_restart_timer(ha, WATCH_INTERVAL);
 }
@@ -2566,23 +2535,14 @@ qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
        return -ETIMEDOUT;
 }
 
-#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
-
-#define qla2x00_release_firmware()     do { } while (0)
-#define qla2x00_pci_module_init()      (0)
-#define qla2x00_pci_module_exit()      do { } while (0)
-
-#else  /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */
-
 /* Firmware interface routines. */
 
-#define FW_BLOBS       6
+#define FW_BLOBS       5
 #define FW_ISP21XX     0
 #define FW_ISP22XX     1
 #define FW_ISP2300     2
 #define FW_ISP2322     3
-#define FW_ISP63XX     4
-#define FW_ISP24XX     5
+#define FW_ISP24XX     4
 
 static DECLARE_MUTEX(qla_fw_lock);
 
@@ -2591,7 +2551,6 @@ static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
        { .name = "ql2200_fw.bin", .segs = { 0x1000, 0 }, },
        { .name = "ql2300_fw.bin", .segs = { 0x800, 0 }, },
        { .name = "ql2322_fw.bin", .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
-       { .name = "ql6312_fw.bin", .segs = { 0x800, 0 }, },
        { .name = "ql2400_fw.bin", },
 };
 
@@ -2605,13 +2564,11 @@ qla2x00_request_firmware(scsi_qla_host_t *ha)
                blob = &qla_fw_blobs[FW_ISP21XX];
        } else if (IS_QLA2200(ha)) {
                blob = &qla_fw_blobs[FW_ISP22XX];
-       } else if (IS_QLA2300(ha) || IS_QLA2312(ha)) {
+       } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
                blob = &qla_fw_blobs[FW_ISP2300];
-       } else if (IS_QLA2322(ha)) {
+       } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
                blob = &qla_fw_blobs[FW_ISP2322];
-       } else if (IS_QLA6312(ha) || IS_QLA6322(ha)) {
-               blob = &qla_fw_blobs[FW_ISP63XX];
-       } else if (IS_QLA24XX(ha)) {
+       } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
                blob = &qla_fw_blobs[FW_ISP24XX];
        }
 
@@ -2644,29 +2601,18 @@ qla2x00_release_firmware(void)
        up(&qla_fw_lock);
 }
 
-static struct qla_board_info qla_board_tbl = {
-       .drv_name       = "qla2xxx",
-};
-
 static struct pci_device_id qla2xxx_pci_tbl[] = {
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422,
-               PCI_ANY_ID, PCI_ANY_ID, },
-       { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432,
-               PCI_ANY_ID, PCI_ANY_ID, },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
        { 0 },
 };
 MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
@@ -2674,7 +2620,7 @@ MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
 static int __devinit
 qla2xxx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-       return qla2x00_probe_one(pdev, &qla_board_tbl);
+       return qla2x00_probe_one(pdev);
 }
 
 static void __devexit
@@ -2684,7 +2630,7 @@ qla2xxx_remove_one(struct pci_dev *pdev)
 }
 
 static struct pci_driver qla2xxx_pci_driver = {
-       .name           = "qla2xxx",
+       .name           = QLA2XXX_DRIVER_NAME,
        .driver         = {
                .owner          = THIS_MODULE,
        },
@@ -2705,8 +2651,6 @@ qla2x00_pci_module_exit(void)
        pci_unregister_driver(&qla2xxx_pci_driver);
 }
 
-#endif
-
 /**
  * qla2x00_module_init - Module initialization.
  **/
@@ -2726,9 +2670,6 @@ qla2x00_module_init(void)
 
        /* Derive version string. */
        strcpy(qla2x00_version_str, QLA2XXX_VERSION);
-#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
-       strcat(qla2x00_version_str, "-fw");
-#endif
 #if DEBUG_QLA2100
        strcat(qla2x00_version_str, "-debug");
 #endif