Merge master.kernel.org:/home/rmk/linux-2.6-arm
[sfrench/cifs-2.6.git] / drivers / scsi / qla2xxx / qla_init.c
index 7e18b9c126542d66250e31a2b6492ab8d018eb1b..3d4487eac9b7f35d469fbf9331024482d3ae3d43 100644 (file)
@@ -383,9 +383,7 @@ qla2x00_isp_firmware(scsi_qla_host_t *ha)
                qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n");
 
                /* Verify checksum of loaded RISC code. */
-               rval = qla2x00_verify_checksum(ha,
-                   IS_QLA24XX(ha) || IS_QLA54XX(ha) ? RISC_SADDRESS :
-                   *ha->brd_info->fw_info[0].fwstart);
+               rval = qla2x00_verify_checksum(ha, ha->fw_srisc_address);
        }
 
        if (rval) {
@@ -775,16 +773,26 @@ qla24xx_chip_diag(scsi_qla_host_t *ha)
 static void
 qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
 {
+       uint32_t dump_size = 0;
+
        ha->fw_dumped = 0;
-       ha->fw_dump24_len = sizeof(struct qla24xx_fw_dump);
-       ha->fw_dump24_len += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t);
-       ha->fw_dump24 = vmalloc(ha->fw_dump24_len);
-       if (ha->fw_dump24)
+       if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
+               dump_size = sizeof(struct qla2100_fw_dump);
+       } else if (IS_QLA23XX(ha)) {
+               dump_size = sizeof(struct qla2300_fw_dump);
+               dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t);
+        } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
+               dump_size = sizeof(struct qla24xx_fw_dump);
+               dump_size += (ha->fw_memory_size - 0x100000) * sizeof(uint32_t);
+       }
+
+       ha->fw_dump = vmalloc(dump_size);
+       if (ha->fw_dump)
                qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware "
-                   "dump...\n", ha->fw_dump24_len / 1024);
+                   "dump...\n", dump_size / 1024);
        else
                qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for "
-                   "firmware dump!!!\n", ha->fw_dump24_len / 1024);
+                   "firmware dump!!!\n", dump_size / 1024);
 }
 
 /**
@@ -802,13 +810,12 @@ qla2x00_resize_request_q(scsi_qla_host_t *ha)
        dma_addr_t request_dma;
        request_t *request_ring;
 
+       qla2x00_alloc_fw_dump(ha);
+
        /* Valid only on recent ISPs. */
        if (IS_QLA2100(ha) || IS_QLA2200(ha))
                return;
 
-       if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
-               qla2x00_alloc_fw_dump(ha);
-
        /* Retrieve IOCB counts available to the firmware. */
        rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt);
        if (rval)
@@ -1708,7 +1715,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
        fcport->ha = ha;
        fcport->port_type = FCT_UNKNOWN;
        fcport->loop_id = FC_NO_LOOP_ID;
-       fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
        atomic_set(&fcport->state, FCS_UNCONFIGURED);
        fcport->flags = FCF_RLC_SUPPORT;
        fcport->supported_classes = FC_COS_UNSPECIFIED;
@@ -1772,6 +1778,9 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
                set_bit(RSCN_UPDATE, &flags);
                clear_bit(LOCAL_LOOP_UPDATE, &flags);
 
+       } else if (ha->current_topology == ISP_CFG_N) {
+               clear_bit(RSCN_UPDATE, &flags);
+
        } else if (!ha->flags.online ||
            (test_bit(ABORT_ISP_ACTIVE, &flags))) {
 
@@ -2249,8 +2258,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
                        }
 
                        /* Remove device from the new list and add it to DB */
-                       list_del(&fcport->list);
-                       list_add_tail(&fcport->list, &ha->fcports);
+                       list_move_tail(&fcport->list, &ha->fcports);
 
                        /* Login and update database */
                        qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
@@ -2563,7 +2571,6 @@ static int
 qla2x00_device_resync(scsi_qla_host_t *ha)
 {
        int     rval;
-       int     rval2;
        uint32_t mask;
        fc_port_t *fcport;
        uint32_t rscn_entry;
@@ -2619,17 +2626,6 @@ qla2x00_device_resync(scsi_qla_host_t *ha)
 
                switch (format) {
                case 0:
-                       if (ql2xprocessrscn &&
-                           !IS_QLA2100(ha) && !IS_QLA2200(ha) &&
-                           !IS_QLA6312(ha) && !IS_QLA6322(ha) &&
-                           !IS_QLA24XX(ha) && !IS_QLA54XX(ha) &&
-                           ha->flags.init_done) {
-                               /* Handle port RSCN via asyncronous IOCBs */
-                               rval2 = qla2x00_handle_port_rscn(ha, rscn_entry,
-                                   NULL, 0);
-                               if (rval2 == QLA_SUCCESS)
-                                       continue;
-                       }
                        mask = 0xffffff;
                        break;
                case 1:
@@ -2647,10 +2643,6 @@ qla2x00_device_resync(scsi_qla_host_t *ha)
 
                rval = QLA_SUCCESS;
 
-               /* Abort any outstanding IO descriptors. */
-               if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
-                       qla2x00_cancel_io_descriptors(ha);
-
                list_for_each_entry(fcport, &ha->fcports, list) {
                        if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 ||
                            (fcport->d_id.b24 & mask) != d_id.b24 ||
@@ -3562,135 +3554,6 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr)
        return rval;
 }
 
-#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
-
-int
-qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
-{
-       int     rval, num, i;
-       uint32_t cnt;
-       uint16_t *risc_code;
-       uint32_t risc_addr, risc_size;
-       uint16_t *req_ring;
-       struct qla_fw_info *fw_iter;
-
-       rval = QLA_SUCCESS;
-
-       /* Load firmware sequences */
-       fw_iter = ha->brd_info->fw_info;
-       *srisc_addr = *ha->brd_info->fw_info->fwstart;
-       while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) {
-               risc_code = fw_iter->fwcode;
-               risc_size = *fw_iter->fwlen;
-               if (fw_iter->addressing == FW_INFO_ADDR_NORMAL)
-                       risc_addr = *fw_iter->fwstart;
-               else
-                       risc_addr = *fw_iter->lfwstart;
-
-               num = 0;
-               rval = 0;
-               while (risc_size > 0 && !rval) {
-                       cnt = (uint16_t)(ha->fw_transfer_size >> 1);
-                       if (cnt > risc_size)
-                               cnt = risc_size;
-
-                       DEBUG7(printk("scsi(%ld): Loading risc segment@ "
-                           "addr %p, number of bytes 0x%x, offset 0x%lx.\n",
-                           ha->host_no, risc_code, cnt, risc_addr));
-
-                       req_ring = (uint16_t *)ha->request_ring;
-                       for (i = 0; i < cnt; i++)
-                               req_ring[i] = cpu_to_le16(risc_code[i]);
-
-                       rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
-                           cnt);
-                       if (rval) {
-                               DEBUG(printk("scsi(%ld): [ERROR] Failed to "
-                                   "load segment %d of firmware\n",
-                                   ha->host_no, num));
-                               qla_printk(KERN_WARNING, ha,
-                                   "[ERROR] Failed to load segment %d of "
-                                   "firmware\n", num);
-
-                               qla2x00_dump_regs(ha);
-                               break;
-                       }
-
-                       risc_code += cnt;
-                       risc_addr += cnt;
-                       risc_size -= cnt;
-                       num++;
-               }
-
-               /* Next firmware sequence */
-               fw_iter++;
-       }
-       return rval;
-}
-
-int
-qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
-{
-       int     rval, num, i;
-       uint32_t cnt;
-       uint32_t *risc_code;
-       uint32_t risc_addr, risc_size;
-       uint32_t *req_ring;
-       struct qla_fw_info *fw_iter;
-
-       rval = QLA_SUCCESS;
-
-       /* Load firmware sequences */
-       fw_iter = ha->brd_info->fw_info;
-       *srisc_addr = *((uint32_t *)fw_iter->lfwstart);
-       while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) {
-               risc_code = (uint32_t *)fw_iter->fwcode;
-               risc_size = *((uint32_t *)fw_iter->fwlen);
-               risc_addr = *((uint32_t *)fw_iter->lfwstart);
-
-               num = 0;
-               rval = 0;
-               while (risc_size > 0 && !rval) {
-                       cnt = (uint32_t)(ha->fw_transfer_size >> 2);
-                       if (cnt > risc_size)
-                               cnt = risc_size;
-
-                       DEBUG7(printk("scsi(%ld): Loading risc segment@ "
-                           "addr %p, number of bytes 0x%x, offset 0x%lx.\n",
-                           ha->host_no, risc_code, cnt, risc_addr));
-
-                       req_ring = (uint32_t *)ha->request_ring;
-                       for (i = 0; i < cnt; i++)
-                               req_ring[i] = cpu_to_le32(risc_code[i]);
-
-                       rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
-                           cnt);
-                       if (rval) {
-                               DEBUG(printk("scsi(%ld): [ERROR] Failed to "
-                                   "load segment %d of firmware\n",
-                                   ha->host_no, num));
-                               qla_printk(KERN_WARNING, ha,
-                                   "[ERROR] Failed to load segment %d of "
-                                   "firmware\n", num);
-
-                               qla2x00_dump_regs(ha);
-                               break;
-                       }
-
-                       risc_code += cnt;
-                       risc_addr += cnt;
-                       risc_size -= cnt;
-                       num++;
-               }
-
-               /* Next firmware sequence */
-               fw_iter++;
-       }
-       return rval;
-}
-
-#else  /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */
-
 #define QLA_FW_URL "ftp://ftp.qlogic.com/outgoing/linux/firmware/"
 
 int
@@ -3901,4 +3764,3 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
 fail_fw_integrity:
        return QLA_FUNCTION_FAILED;
 }
-#endif