diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-04-14 06:29:07 +0900 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-04-14 06:29:07 +0900 |
commit | f499cae1e59d75d5eb24c23d47cf8986e6032c6d (patch) | |
tree | 1af6235c18391212c40116eb90b01eae8938efee /drivers/scsi/qla2xxx | |
parent | fc3f55e672e1ed917dd9e215af81939cd3d717da (diff) | |
parent | 80a04d3f2f94fb68b5df05e3ac6697130bc3467a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 295 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_def.h | 136 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_dfs.c | 4 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_fw.h | 42 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_gbl.h | 25 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 136 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_iocb.c | 37 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_isr.c | 32 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mbx.c | 238 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mid.c | 12 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 266 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_sup.c | 103 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_version.h | 4 |
13 files changed, 858 insertions, 472 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index ee9d4015243..b09993a0657 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -96,7 +96,9 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, if (!capable(CAP_SYS_ADMIN)) return 0; - /* Read NVRAM data from cache. */ + if (IS_NOCACHE_VPD_TYPE(ha)) + ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_nvram << 2, + ha->nvram_size); return memory_read_from_buffer(buf, count, &off, ha->nvram, ha->nvram_size); } @@ -111,7 +113,8 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, struct qla_hw_data *ha = vha->hw; uint16_t cnt; - if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) + if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size || + !ha->isp_ops->write_nvram) return 0; /* Checksum NVRAM. */ @@ -137,12 +140,21 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, *iter = chksum; } + if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { + qla_printk(KERN_WARNING, ha, + "HBA not online, failing NVRAM update.\n"); + return -EAGAIN; + } + /* Write NVRAM. */ ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count); ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base, count); + /* NVRAM settings take effect immediately. */ set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + qla2x00_wait_for_chip_reset(vha); return (count); } @@ -330,6 +342,12 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj, if (ha->optrom_state != QLA_SWRITING) break; + if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { + qla_printk(KERN_WARNING, ha, + "HBA not online, failing flash update.\n"); + return -EAGAIN; + } + DEBUG2(qla_printk(KERN_INFO, ha, "Writing flash region -- 0x%x/0x%x.\n", ha->optrom_region_start, ha->optrom_region_size)); @@ -364,7 +382,9 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj, if (!capable(CAP_SYS_ADMIN)) return 0; - /* Read NVRAM data from cache. */ + if (IS_NOCACHE_VPD_TYPE(ha)) + ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, + ha->vpd_size); return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size); } @@ -376,14 +396,35 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj, struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, struct device, kobj))); struct qla_hw_data *ha = vha->hw; + uint8_t *tmp_data; - if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size) + if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size || + !ha->isp_ops->write_nvram) return 0; + if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { + qla_printk(KERN_WARNING, ha, + "HBA not online, failing VPD update.\n"); + return -EAGAIN; + } + /* Write NVRAM. */ ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count); ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count); + /* Update flash version information for 4Gb & above. */ + if (!IS_FWI2_CAPABLE(ha)) + goto done; + + tmp_data = vmalloc(256); + if (!tmp_data) { + qla_printk(KERN_WARNING, ha, + "Unable to allocate memory for VPD information update.\n"); + goto done; + } + ha->isp_ops->get_flash_version(vha, tmp_data); + vfree(tmp_data); +done: return count; } @@ -458,6 +499,199 @@ static struct bin_attribute sysfs_sfp_attr = { .read = qla2x00_sysfs_read_sfp, }; +static ssize_t +qla2x00_sysfs_write_reset(struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, + struct device, kobj))); + struct qla_hw_data *ha = vha->hw; + int type; + + if (off != 0) + return 0; + + type = simple_strtol(buf, NULL, 10); + switch (type) { + case 0x2025c: + qla_printk(KERN_INFO, ha, + "Issuing ISP reset on (%ld).\n", vha->host_no); + + scsi_block_requests(vha->host); + set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + qla2x00_wait_for_chip_reset(vha); + scsi_unblock_requests(vha->host); + break; + case 0x2025d: + if (!IS_QLA81XX(ha)) + break; + + qla_printk(KERN_INFO, ha, + "Issuing MPI reset on (%ld).\n", vha->host_no); + + /* Make sure FC side is not in reset */ + qla2x00_wait_for_hba_online(vha); + + /* Issue MPI reset */ + scsi_block_requests(vha->host); + if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS) + qla_printk(KERN_WARNING, ha, + "MPI reset failed on (%ld).\n", vha->host_no); + scsi_unblock_requests(vha->host); + break; + } + return count; +} + +static struct bin_attribute sysfs_reset_attr = { + .attr = { + .name = "reset", + .mode = S_IWUSR, + }, + .size = 0, + .write = qla2x00_sysfs_write_reset, +}; + +static ssize_t +qla2x00_sysfs_write_edc(struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, + struct device, kobj))); + struct qla_hw_data *ha = vha->hw; + uint16_t dev, adr, opt, len; + int rval; + + ha->edc_data_len = 0; + + if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) + return 0; + + if (!ha->edc_data) { + ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, + &ha->edc_data_dma); + if (!ha->edc_data) { + DEBUG2(qla_printk(KERN_INFO, ha, + "Unable to allocate memory for EDC write.\n")); + return 0; + } + } + + dev = le16_to_cpup((void *)&buf[0]); + adr = le16_to_cpup((void *)&buf[2]); + opt = le16_to_cpup((void *)&buf[4]); + len = le16_to_cpup((void *)&buf[6]); + + if (!(opt & BIT_0)) + if (len == 0 || len > DMA_POOL_SIZE || len > count - 8) + return -EINVAL; + + memcpy(ha->edc_data, &buf[8], len); + + rval = qla2x00_write_edc(vha, dev, adr, ha->edc_data_dma, + ha->edc_data, len, opt); + if (rval != QLA_SUCCESS) { + DEBUG2(qla_printk(KERN_INFO, ha, + "Unable to write EDC (%x) %02x:%02x:%04x:%02x:%02x.\n", + rval, dev, adr, opt, len, *buf)); + return 0; + } + + return count; +} + +static struct bin_attribute sysfs_edc_attr = { + .attr = { + .name = "edc", + .mode = S_IWUSR, + }, + .size = 0, + .write = qla2x00_sysfs_write_edc, +}; + +static ssize_t +qla2x00_sysfs_write_edc_status(struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, + struct device, kobj))); + struct qla_hw_data *ha = vha->hw; + uint16_t dev, adr, opt, len; + int rval; + + ha->edc_data_len = 0; + + if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8) + return 0; + + if (!ha->edc_data) { + ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, + &ha->edc_data_dma); + if (!ha->edc_data) { + DEBUG2(qla_printk(KERN_INFO, ha, + "Unable to allocate memory for EDC status.\n")); + return 0; + } + } + + dev = le16_to_cpup((void *)&buf[0]); + adr = le16_to_cpup((void *)&buf[2]); + opt = le16_to_cpup((void *)&buf[4]); + len = le16_to_cpup((void *)&buf[6]); + + if (!(opt & BIT_0)) + if (len == 0 || len > DMA_POOL_SIZE) + return -EINVAL; + + memset(ha->edc_data, 0, len); + rval = qla2x00_read_edc(vha, dev, adr, ha->edc_data_dma, + ha->edc_data, len, opt); + if (rval != QLA_SUCCESS) { + DEBUG2(qla_printk(KERN_INFO, ha, + "Unable to write EDC status (%x) %02x:%02x:%04x:%02x.\n", + rval, dev, adr, opt, len)); + return 0; + } + + ha->edc_data_len = len; + + return count; +} + +static ssize_t +qla2x00_sysfs_read_edc_status(struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, + struct device, kobj))); + struct qla_hw_data *ha = vha->hw; + + if (!capable(CAP_SYS_ADMIN) || off != 0 || count == 0) + return 0; + + if (!ha->edc_data || ha->edc_data_len == 0 || ha->edc_data_len > count) + return -EINVAL; + + memcpy(buf, ha->edc_data, ha->edc_data_len); + + return ha->edc_data_len; +} + +static struct bin_attribute sysfs_edc_status_attr = { + .attr = { + .name = "edc_status", + .mode = S_IRUSR | S_IWUSR, + }, + .size = 0, + .write = qla2x00_sysfs_write_edc_status, + .read = qla2x00_sysfs_read_edc_status, +}; + static struct sysfs_entry { char *name; struct bin_attribute *attr; @@ -469,6 +703,9 @@ static struct sysfs_entry { { "optrom_ctl", &sysfs_optrom_ctl_attr, }, { "vpd", &sysfs_vpd_attr, 1 }, { "sfp", &sysfs_sfp_attr, 1 }, + { "reset", &sysfs_reset_attr, }, + { "edc", &sysfs_edc_attr, 2 }, + { "edc_status", &sysfs_edc_status_attr, 2 }, { NULL }, }; @@ -482,6 +719,8 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha) for (iter = bin_file_entries; iter->name; iter++) { if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw)) continue; + if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw)) + continue; ret = sysfs_create_bin_file(&host->shost_gendev.kobj, iter->attr); @@ -502,6 +741,8 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *vha) for (iter = bin_file_entries; iter->name; iter++) { if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) continue; + if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha)) + continue; sysfs_remove_bin_file(&host->shost_gendev.kobj, iter->attr); @@ -818,9 +1059,33 @@ qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr, if (!IS_QLA81XX(ha)) return snprintf(buf, PAGE_SIZE, "\n"); - return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x (%x)\n", + return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n", ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2], - ha->mpi_version[3], ha->mpi_capabilities); + ha->mpi_capabilities); +} + +static ssize_t +qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); + struct qla_hw_data *ha = vha->hw; + + if (!IS_QLA81XX(ha)) + return snprintf(buf, PAGE_SIZE, "\n"); + + return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n", + ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]); +} + +static ssize_t +qla2x00_flash_block_size_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); + struct qla_hw_data *ha = vha->hw; + + return snprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size); } static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); @@ -848,6 +1113,9 @@ static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show, static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show, NULL); static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL); +static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL); +static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show, + NULL); struct device_attribute *qla2x00_host_attrs[] = { &dev_attr_driver_version, @@ -868,6 +1136,8 @@ struct device_attribute *qla2x00_host_attrs[] = { &dev_attr_optrom_fw_version, &dev_attr_total_isp_aborts, &dev_attr_mpi_version, + &dev_attr_phy_version, + &dev_attr_flash_block_size, NULL, }; @@ -1012,7 +1282,10 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport) if (!fcport) return; - qla2x00_abort_fcport_cmds(fcport); + if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) + qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); + else + qla2x00_abort_fcport_cmds(fcport); /* * Transport has effectively 'deleted' the rport, clear @@ -1032,16 +1305,18 @@ qla2x00_terminate_rport_io(struct fc_rport *rport) if (!fcport) return; + if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) { + qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); + return; + } /* * At this point all fcport's software-states are cleared. Perform any * final cleanup of firmware resources (PCBs and XCBs). */ - if (fcport->loop_id != FC_NO_LOOP_ID) { + if (fcport->loop_id != FC_NO_LOOP_ID) fcport->vha->hw->isp_ops->fabric_logout(fcport->vha, fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa); - fcport->loop_id = FC_NO_LOOP_ID; - } qla2x00_abort_fcport_cmds(fcport); } diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index e0c5bb54b25..714ee67567e 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -176,8 +176,7 @@ /* ISP request and response entry counts (37-65535) */ #define REQUEST_ENTRY_CNT_2100 128 /* Number of request entries. */ #define REQUEST_ENTRY_CNT_2200 2048 /* Number of request entries. */ -#define REQUEST_ENTRY_CNT_2XXX_EXT_MEM 4096 /* Number of request entries. */ -#define REQUEST_ENTRY_CNT_24XX 4096 /* Number of request entries. */ +#define REQUEST_ENTRY_CNT_24XX 2048 /* Number of request entries. */ #define RESPONSE_ENTRY_CNT_2100 64 /* Number of response entries.*/ #define RESPONSE_ENTRY_CNT_2300 512 /* Number of response entries.*/ @@ -201,20 +200,7 @@ typedef struct srb { /* * SRB flag definitions */ -#define SRB_TIMEOUT BIT_0 /* Command timed out */ -#define SRB_DMA_VALID BIT_1 /* Command sent to ISP */ -#define SRB_WATCHDOG BIT_2 /* Command on watchdog list */ -#define SRB_ABORT_PENDING BIT_3 /* Command abort sent to device */ - -#define SRB_ABORTED BIT_4 /* Command aborted command already */ -#define SRB_RETRY BIT_5 /* Command needs retrying */ -#define SRB_GOT_SENSE BIT_6 /* Command has sense data */ -#define SRB_FAILOVER BIT_7 /* Command in failover state */ - -#define SRB_BUSY BIT_8 /* Command is in busy retry state */ -#define SRB_FO_CANCEL BIT_9 /* Command don't need to do failover */ -#define SRB_IOCTL BIT_10 /* IOCTL command. */ -#define SRB_TAPE BIT_11 /* FCP2 (Tape) command. */ +#define SRB_DMA_VALID BIT_0 /* Command sent to ISP */ /* * ISP I/O Register Set structure definitions. @@ -372,10 +358,10 @@ struct device_reg_2xxx { }; struct device_reg_25xxmq { - volatile uint32_t req_q_in; - volatile uint32_t req_q_out; - volatile uint32_t rsp_q_in; - volatile uint32_t rsp_q_out; + uint32_t req_q_in; + uint32_t req_q_out; + uint32_t rsp_q_in; + uint32_t rsp_q_out; }; typedef union { @@ -620,6 +606,7 @@ typedef struct { #define MBC_GET_TIMEOUT_PARAMS 0x22 /* Get FW timeouts. */ #define MBC_TRACE_CONTROL 0x27 /* Trace control command. */ #define MBC_GEN_SYSTEM_ERROR 0x2a /* Generate System Error. */ +#define MBC_WRITE_SFP 0x30 /* Write SFP Data. */ #define MBC_READ_SFP 0x31 /* Read SFP Data. */ #define MBC_SET_TIMEOUT_PARAMS 0x32 /* Set FW timeouts. */ #define MBC_MID_INITIALIZE_FIRMWARE 0x48 /* MID Initialize firmware. */ @@ -1570,39 +1557,13 @@ typedef struct fc_port { #define FCS_DEVICE_DEAD 2 #define FCS_DEVICE_LOST 3 #define FCS_ONLINE 4 -#define FCS_NOT_SUPPORTED 5 -#define FCS_FAILOVER 6 -#define FCS_FAILOVER_FAILED 7 /* * FC port flags. */ #define FCF_FABRIC_DEVICE BIT_0 #define FCF_LOGIN_NEEDED BIT_1 -#define FCF_FO_MASKED BIT_2 -#define FCF_FAILOVER_NEEDED BIT_3 -#define FCF_RESET_NEEDED BIT_4 -#define FCF_PERSISTENT_BOUND BIT_5 -#define FCF_TAPE_PRESENT BIT_6 -#define FCF_FARP_DONE BIT_7 -#define FCF_FARP_FAILED BIT_8 -#define FCF_FARP_REPLY_NEEDED BIT_9 -#define FCF_AUTH_REQ BIT_10 -#define FCF_SEND_AUTH_REQ BIT_11 -#define FCF_RECEIVE_AUTH_REQ BIT_12 -#define FCF_AUTH_SUCCESS BIT_13 -#define FCF_RLC_SUPPORT BIT_14 -#define FCF_CONFIG BIT_15 /* Needed? */ -#define FCF_RESCAN_NEEDED BIT_16 -#define FCF_XP_DEVICE BIT_17 -#define FCF_MSA_DEVICE BIT_18 -#define FCF_EVA_DEVICE BIT_19 -#define FCF_MSA_PORT_ACTIVE BIT_20 -#define FCF_FAILBACK_DISABLE BIT_21 -#define FCF_FAILOVER_DISABLE BIT_22 -#define FCF_DSXXX_DEVICE BIT_23 -#define FCF_AA_EVA_DEVICE BIT_24 -#define FCF_AA_MSA_DEVICE BIT_25 +#define FCF_TAPE_PRESENT BIT_2 /* No loop ID flag. */ #define FC_NO_LOOP_ID 0x1000 @@ -2102,9 +2063,6 @@ struct isp_operations { int (*get_flash_version) (struct scsi_qla_host *, void *); int (*start_scsi) (srb_t *); - void (*wrt_req_reg) (struct qla_hw_data *, uint16_t, uint16_t); - void (*wrt_rsp_reg) (struct qla_hw_data *, uint16_t, uint16_t); - uint16_t (*rd_req_reg) (struct qla_hw_data *, uint16_t); }; /* MSI-X Support *************************************************************/ @@ -2200,6 +2158,8 @@ struct rsp_que { dma_addr_t dma; response_t *ring; response_t *ring_ptr; + uint32_t __iomem *rsp_q_in; /* FWI2-capable only. */ + uint32_t __iomem *rsp_q_out; uint16_t ring_index; uint16_t out_ptr; uint16_t length; @@ -2217,6 +2177,8 @@ struct req_que { dma_addr_t dma; request_t *ring; request_t *ring_ptr; + uint32_t __iomem *req_q_in; /* FWI2-capable only. */ + uint32_t __iomem *req_q_out; uint16_t ring_index; uint16_t in_ptr; uint16_t cnt; @@ -2256,10 +2218,10 @@ struct qla_hw_data { uint32_t msix_enabled :1; uint32_t disable_serdes :1; uint32_t gpsc_supported :1; - uint32_t vsan_enabled :1; uint32_t npiv_supported :1; uint32_t fce_enabled :1; - uint32_t hw_event_marker_found:1; + uint32_t fac_supported :1; + uint32_t chip_reset_done :1; } flags; /* This spinlock is used to protect "io transactions", you must @@ -2277,7 +2239,7 @@ struct qla_hw_data { #define MIN_IOBASE_LEN 0x100 /* Multi queue data structs */ - device_reg_t *mqiobase; + device_reg_t __iomem *mqiobase; uint16_t msix_count; uint8_t mqenable; struct req_que **req_q_map; @@ -2300,7 +2262,6 @@ struct qla_hw_data { uint16_t max_loop_id; uint16_t fb_rev; - uint16_t max_public_loop_ids; uint16_t min_external_loopid; /* First external loop Id */ #define PORT_SPEED_UNKNOWN 0xFFFF @@ -2381,6 +2342,8 @@ struct qla_hw_data { IS_QLA25XX(ha) || IS_QLA81XX(ha)) #define IS_NOPOLLING_TYPE(ha) ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && \ (ha)->flags.msix_enabled) +#define IS_FAC_REQUIRED(ha) (IS_QLA81XX(ha)) +#define IS_NOCACHE_VPD_TYPE(ha) (IS_QLA81XX(ha)) #define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA) #define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2) @@ -2425,6 +2388,10 @@ struct qla_hw_data { void *sfp_data; dma_addr_t sfp_data_dma; + uint8_t *edc_data; + dma_addr_t edc_data_dma; + uint16_t edc_data_len; + struct task_struct *dpc_thread; uint8_t dpc_active; /* DPC routine is active */ @@ -2439,6 +2406,8 @@ struct qla_hw_data { dma_addr_t init_cb_dma; init_cb_t *init_cb; int init_cb_size; + dma_addr_t ex_init_cb_dma; + struct ex_init_cb_81xx *ex_init_cb; /* These are used by mailbox operations. */ volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT]; @@ -2453,15 +2422,6 @@ struct qla_hw_data { struct completion mbx_cmd_comp; /* Serialize mbx access */ struct completion mbx_intr_comp; /* Used for completion notification */ - uint32_t mbx_flags; -#define MBX_IN_PROGRESS BIT_0 -#define MBX_BUSY BIT_1 /* Got the Access */ -#define MBX_SLEEPING_ON_SEM BIT_2 -#define MBX_POLLING_FOR_COMP BIT_3 -#define MBX_COMPLETED BIT_4 -#define MBX_TIMEDOUT BIT_5 -#define MBX_ACCESS_TIMEDOUT BIT_6 - /* Basic firmware related information. */ uint16_t fw_major_version; uint16_t fw_minor_version; @@ -2473,13 +2433,15 @@ struct qla_hw_data { #define RISC_START_ADDRESS_2100 0x1000 #define RISC_START_ADDRESS_2300 0x800 #define RISC_START_ADDRESS_2400 0x100000 + uint16_t fw_xcb_count; uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */ uint8_t fw_seriallink_options[4]; uint16_t fw_seriallink_options24[4]; - uint8_t mpi_version[4]; + uint8_t mpi_version[3]; uint32_t mpi_capabilities; + uint8_t phy_version[3]; /* Firmware dump information. */ struct qla2xxx_fw_dump *fw_dump; @@ -2545,6 +2507,8 @@ struct qla_hw_data { uint32_t flt_region_boot; uint32_t flt_region_fw; uint32_t flt_region_vpd_nvram; + uint32_t flt_region_vpd; + uint32_t flt_region_nvram; uint32_t flt_region_npiv_conf; /* Needed for BEACON */ @@ -2613,36 +2577,19 @@ typedef struct scsi_qla_host { #define LOOP_RESYNC_ACTIVE 5 #define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */ #define RSCN_UPDATE 7 /* Perform an RSCN update. */ -#define MAILBOX_RETRY 8 -#define ISP_RESET_NEEDED 9 /* Initiate a ISP reset. */ -#define FAILOVER_EVENT_NEEDED 10 -#define FAILOVER_EVENT 11 -#define FAILOVER_NEEDED 12 -#define SCSI_RESTART_NEEDED 13 /* Processes SCSI retry queue. */ -#define PORT_RESTART_NEEDED 14 /* Processes Retry queue. */ -#define RESTART_QUEUES_NEEDED 15 /* Restarts the Lun queue. */ -#define ABORT_QUEUES_NEEDED 16 -#define RELOGIN_NEEDED 17 -#define LOGIN_RETRY_NEEDED 18 /* Initiate required fabric logins. */ -#define REGISTER_FC4_NEEDED 19 /* SNS FC4 registration required. */ -#define ISP_ABORT_RETRY 20 /* ISP aborted. */ -#define FCPORT_RESCAN_NEEDED 21 /* IO descriptor processing needed */ -#define IODESC_PROCESS_NEEDED 22 /* IO descriptor processing needed */ -#define IOCTL_ERROR_RECOVERY 23 -#define LOOP_RESET_NEEDED 24 -#define BEACON_BLINK_NEEDED 25 -#define REGISTER_FDMI_NEEDED 26 -#define FCPORT_UPDATE_NEEDED 27 -#define VP_DPC_NEEDED 28 /* wake up for VP dpc handling */ -#define UNLOADING 29 -#define NPIV_CONFIG_NEEDED 30 +#define RELOGIN_NEEDED 8 +#define REGISTER_FC4_NEEDED 9 /* SNS FC4 registration required. */ +#define ISP_ABORT_RETRY 10 /* ISP aborted. */ +#define BEACON_BLINK_NEEDED 11 +#define REGISTER_FDMI_NEEDED 12 +#define FCPORT_UPDATE_NEEDED 13 +#define VP_DPC_NEEDED 14 /* wake up for VP dpc handling */ +#define UNLOADING 15 +#define NPIV_CONFIG_NEEDED 16 uint32_t device_flags; -#define DFLG_LOCAL_DEVICES BIT_0 -#define DFLG_RETRY_LOCAL_DEVICES BIT_1 -#define DFLG_FABRIC_DEVICES BIT_2 -#define SWITCH_FOUND BIT_3 -#define DFLG_NO_CABLE BIT_4 +#define SWITCH_FOUND BIT_0 +#define DFLG_NO_CABLE BIT_1 srb_t *status_srb; /* Status continuation entry. */ @@ -2755,10 +2702,5 @@ typedef struct scsi_qla_host { #include "qla_inline.h" #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) -#define CMD_COMPL_STATUS(Cmnd) ((Cmnd)->SCp.this_residual) -#define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual) -#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) -#define CMD_ACTUAL_SNSLEN(Cmnd) ((Cmnd)->SCp.Message) -#define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in) #endif diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c index c66036da7d2..3a9a6ca4226 100644 --- a/drivers/scsi/qla2xxx/qla_dfs.c +++ b/drivers/scsi/qla2xxx/qla_dfs.c @@ -71,7 +71,7 @@ qla2x00_dfs_fce_open(struct inode *inode, struct file *file) mutex_unlock(&ha->fce_mutex); out: - return single_open(file, qla2x00_dfs_fce_show, ha); + return single_open(file, qla2x00_dfs_fce_show, vha); } static int @@ -145,7 +145,7 @@ create_dir: atomic_inc(&qla2x00_dfs_root_count); create_nodes: - ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, ha, + ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, vha, &dfs_fce_ops); if (!ha->dfs_fce) { qla_printk(KERN_NOTICE, ha, diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h index ffff4255408..96ccb9642ba 100644 --- a/drivers/scsi/qla2xxx/qla_fw.h +++ b/drivers/scsi/qla2xxx/qla_fw.h @@ -1403,6 +1403,21 @@ struct access_chip_rsp_84xx { #define MBA_IDC_TIME_EXT 0x8102 #define MBC_IDC_ACK 0x101 +#define MBC_RESTART_MPI_FW 0x3d +#define MBC_FLASH_ACCESS_CTRL 0x3e /* Control flash access. */ + +/* Flash access control option field bit definitions */ +#define FAC_OPT_FORCE_SEMAPHORE BIT_15 +#define FAC_OPT_REQUESTOR_ID BIT_14 +#define FAC_OPT_CMD_SUBCODE 0xff + +/* Flash access control command subcodes */ +#define FAC_OPT_CMD_WRITE_PROTECT 0x00 +#define FAC_OPT_CMD_WRITE_ENABLE 0x01 +#define FAC_OPT_CMD_ERASE_SECTOR 0x02 +#define FAC_OPT_CMD_LOCK_SEMAPHORE 0x03 +#define FAC_OPT_CMD_UNLOCK_SEMAPHORE 0x04 +#define FAC_OPT_CMD_GET_SECTOR_SIZE 0x05 struct nvram_81xx { /* NVRAM header. */ @@ -1440,7 +1455,17 @@ struct nvram_81xx { uint16_t reserved_6[24]; /* Offset 128. */ - uint16_t reserved_7[64]; + uint16_t ex_version; + uint8_t prio_fcf_matching_flags; + uint8_t reserved_6_1[3]; + uint16_t pri_fcf_vlan_id; + uint8_t pri_fcf_fabric_name[8]; + uint16_t reserved_6_2[7]; + uint8_t spma_mac_addr[6]; + uint16_t reserved_6_3[14]; + + /* Offset 192. */ + uint16_t reserved_7[32]; /* * BIT 0 = Enable spinup delay @@ -1664,6 +1689,17 @@ struct mid_init_cb_81xx { struct mid_conf_entry_24xx entries[MAX_MULTI_ID_FABRIC]; }; +struct ex_init_cb_81xx { + uint16_t ex_version; + uint8_t prio_fcf_matching_flags; + uint8_t reserved_1[3]; + uint16_t pri_fcf_vlan_id; + uint8_t pri_fcf_fabric_name[8]; + uint16_t reserved_2[7]; + uint8_t spma_mac_addr[6]; + uint16_t reserved_3[14]; +}; + #define FARX_ACCESS_FLASH_CONF_81XX 0x7FFD0000 #define FARX_ACCESS_FLASH_DATA_81XX 0x7F800000 @@ -1672,6 +1708,10 @@ struct mid_init_cb_81xx { #define FA_RISC_CODE_ADDR_81 0xA0000 #define FA_FW_AREA_ADDR_81 0xC0000 #define FA_VPD_NVRAM_ADDR_81 0xD0000 +#define FA_VPD0_ADDR_81 0xD0000 +#define FA_VPD1_ADDR_81 0xD0400 +#define FA_NVRAM0_ADDR_81 0xD0080 +#define FA_NVRAM1_ADDR_81 0xD0480 #define FA_FEATURE_ADDR_81 0xD4000 #define FA_FLASH_DESCR_ADDR_81 0xD8000 #define FA_FLASH_LAYOUT_ADDR_81 0xD8400 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 6de283f8f11..528913f6bed 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -73,6 +73,7 @@ extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int); extern int qla2x00_post_aen_work(struct scsi_qla_host *, enum fc_host_event_code, u32); extern int qla2x00_post_idc_ack_work(struct scsi_qla_host *, uint16_t *); +extern int qla81xx_restart_mpi_firmware(scsi_qla_host_t *); extern void qla2x00_abort_fcport_cmds(fc_port_t *); extern struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *, @@ -82,7 +83,7 @@ extern void qla2x00_relogin(struct scsi_qla_host *); /* * Global Functions in qla_mid.c source file. */ -extern struct scsi_host_template qla24xx_driver_template; +extern struct scsi_host_template qla2xxx_driver_template; extern struct scsi_transport_template *qla2xxx_transport_vport_template; extern void qla2x00_timer(scsi_qla_host_t *); extern void qla2x00_start_timer(scsi_qla_host_t *, void *, unsigned long); @@ -110,6 +111,7 @@ extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *, int); extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *); extern int qla2x00_wait_for_hba_online(scsi_qla_host_t *); +extern int qla2x00_wait_for_chip_reset(scsi_qla_host_t *); extern void qla2xxx_wake_dpc(struct scsi_qla_host *); extern void qla2x00_alert_all_vps(struct rsp_que *, uint16_t *); @@ -144,8 +146,8 @@ extern int qla2x00_execute_fw(scsi_qla_host_t *, uint32_t); extern void -qla2x00_get_fw_version(scsi_qla_host_t *, uint16_t *, - uint16_t *, uint16_t *, uint16_t *, uint32_t *, uint8_t *, uint32_t *); +qla2x00_get_fw_version(scsi_qla_host_t *, uint16_t *, uint16_t *, uint16_t *, + uint16_t *, uint32_t *, uint8_t *, uint32_t *, uint8_t *); extern int qla2x00_get_fw_options(scsi_qla_host_t *, uint16_t *); @@ -263,12 +265,29 @@ extern int qla2x00_read_sfp(scsi_qla_host_t *, dma_addr_t, uint16_t, uint16_t, uint16_t); extern int +qla2x00_read_edc(scsi_qla_host_t *, uint16_t, uint16_t, dma_addr_t, + uint8_t *, uint16_t, uint16_t); + +extern int +qla2x00_write_edc(scsi_qla_host_t *, uint16_t, uint16_t, dma_addr_t, + uint8_t *, uint16_t, uint16_t); + +extern int qla2x00_set_idma_speed(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t *); extern int qla84xx_verify_chip(struct scsi_qla_host *, uint16_t *); extern int qla81xx_idc_ack(scsi_qla_host_t *, uint16_t *); +extern int +qla81xx_fac_get_sector_size(scsi_qla_host_t *, uint32_t *); + +extern int +qla81xx_fac_do_write_enable(scsi_qla_host_t *, int); + +extern int +qla81xx_fac_erase_sector(scsi_qla_host_t *, uint32_t, uint32_t); + /* * Global Function Prototypes in qla_isr.c source file. */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 87f9abc7146..bd7dd84c064 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -20,7 +20,6 @@ * QLogic ISP2x00 Hardware Support Function Prototypes. */ static int qla2x00_isp_firmware(scsi_qla_host_t *); -static void qla2x00_resize_request_q(scsi_qla_host_t *); static int qla2x00_setup_chip(scsi_qla_host_t *); static int qla2x00_init_rings(scsi_qla_host_t *); static int qla2x00_fw_ready(scsi_qla_host_t *); @@ -61,8 +60,10 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha) int rval; struct qla_hw_data *ha = vha->hw; struct req_que *req = ha->req_q_map[0]; + /* Clear adapter flags. */ vha->flags.online = 0; + ha->flags.chip_reset_done = 0; vha->flags.reset_active = 0; atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); atomic_set(&vha->loop_state, LOOP_DOWN); @@ -70,7 +71,6 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha) vha->dpc_flags = 0; vha->flags.management_server_logged_in = 0; vha->marker_needed = 0; - ha->mbx_flags = 0; ha->isp_abort_cnt = 0; ha->beacon_blink_led = 0; set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); @@ -131,6 +131,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha) } } rval = qla2x00_init_rings(vha); + ha->flags.chip_reset_done = 1; return (rval); } @@ -512,7 +513,6 @@ qla2x00_reset_chip(scsi_qla_host_t *vha) static inline void qla24xx_reset_risc(scsi_qla_host_t *vha) { - int hw_evt = 0; unsigned long flags = 0; struct qla_hw_data *ha = vha->hw; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; @@ -542,8 +542,6 @@ qla24xx_reset_risc(scsi_qla_host_t *vha) d2 = (uint32_t) RD_REG_WORD(®->mailbox0); barrier(); } - if (cnt == 0) - hw_evt = 1; /* Wait for soft-reset to complete. */ d2 = RD_REG_DWORD(®->ctrl_status); @@ -816,7 +814,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) qla_printk(KERN_INFO, ha, "Allocated (%d KB) for FCE...\n", FCE_SIZE / 1024); - fce_size = sizeof(struct qla2xxx_fce_chain) + EFT_SIZE; + fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; ha->flags.fce_enabled = 1; ha->fce_dma = tc_dma; ha->fce = tc; @@ -894,62 +892,6 @@ cont_alloc: } /** - * qla2x00_resize_request_q() - Resize request queue given available ISP memory. - * @ha: HA context - * - * Returns 0 on success. - */ -static void -qla2x00_resize_request_q(scsi_qla_host_t *vha) -{ - int rval; - uint16_t fw_iocb_cnt = 0; - uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM; - dma_addr_t request_dma; - request_t *request_ring; - struct qla_hw_data *ha = vha->hw; - struct req_que *req = ha->req_q_map[0]; - - /* Valid only on recent ISPs. */ - if (IS_QLA2100(ha) || IS_QLA2200(ha)) - return; - - /* Retrieve IOCB counts available to the firmware. */ - rval = qla2x00_get_resource_cnts(vha, NULL, NULL, NULL, &fw_iocb_cnt, - &ha->max_npiv_vports); - if (rval) - return; - /* No point in continuing if current settings are sufficient. */ - if (fw_iocb_cnt < 1024) - return; - if (req->length >= request_q_length) - return; - - /* Attempt to claim larger area for request queue. */ - request_ring = dma_alloc_coherent(&ha->pdev->dev, - (request_q_length + 1) * sizeof(request_t), &request_dma, - GFP_KERNEL); - if (request_ring == NULL) - return; - - /* Resize successful, report extensions. */ - qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n", - (ha->fw_memory_size + 1) / 1024); - qla_printk(KERN_INFO, ha, "Resizing request queue depth " - "(%d -> %d)...\n", req->length, request_q_length); - - /* Clear old allocations. */ - dma_free_coherent(&ha->pdev->dev, - (req->length + 1) * sizeof(request_t), req->ring, - req->dma); - - /* Begin using larger queue. */ - req->length = request_q_length; - req->ring = request_ring; - req->dma = request_dma; -} - -/** * qla2x00_setup_chip() - Load and start RISC firmware. * @ha: HA context * @@ -963,6 +905,7 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) struct qla_hw_data *ha = vha->hw; struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; unsigned long flags; + uint16_t fw_major_version; if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { /* Disable SRAM, Instruction RAM and GP RAM parity. */ @@ -986,13 +929,15 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) rval = qla2x00_execute_fw(vha, srisc_address); /* Retrieve firmware information. */ - if (rval == QLA_SUCCESS && ha->fw_major_version == 0) { + if (rval == QLA_SUCCESS) { + fw_major_version = ha->fw_major_version; qla2x00_get_fw_version(vha, &ha->fw_major_version, &ha->fw_minor_version, &ha->fw_subminor_version, &ha->fw_attributes, &ha->fw_memory_size, - ha->mpi_version, &ha->mpi_capabilities); + ha->mpi_version, &ha->mpi_capabilities, + ha->phy_version); ha->flags.npiv_supported = 0; if (IS_QLA2XXX_MIDTYPE(ha) && (ha->fw_attributes & BIT_2)) { @@ -1003,9 +948,11 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) ha->max_npiv_vports = MIN_MULTI_ID_FABRIC - 1; } - qla2x00_resize_request_q(vha); + qla2x00_get_resource_cnts(vha, NULL, + &ha->fw_xcb_count, NULL, NULL, + &ha->max_npiv_vports); - if (ql2xallocfwdump) + if (!fw_major_version && ql2xallocfwdump) qla2x00_alloc_fw_dump(vha); } } else { @@ -1028,6 +975,21 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) spin_unlock_irqrestore(&ha->hardware_lock, flags); } + if (rval == QLA_SUCCESS && IS_FAC_REQUIRED(ha)) { + uint32_t size; + + rval = qla81xx_fac_get_sector_size(vha, &size); + if (rval == QLA_SUCCESS) { + ha->flags.fac_supported = 1; + ha->fdt_block_size = size << 2; + } else { + qla_printk(KERN_ERR, ha, + "Unsupported FAC firmware (%d.%02d.%02d).\n", + ha->fw_major_version, ha->fw_minor_version, + ha->fw_subminor_version); + } + } + if (rval) { DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n", vha->host_no)); @@ -1314,8 +1276,11 @@ qla2x00_init_rings(scsi_qla_host_t *vha) mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); } - - mid_init_cb->options = __constant_cpu_to_le16(BIT_1); + if (IS_FWI2_CAPABLE(ha)) { + mid_init_cb->options = __constant_cpu_to_le16(BIT_1); + mid_init_cb->init_cb.execution_throttle = + cpu_to_le16(ha->fw_xcb_count); + } rval = qla2x00_init_firmware(vha, ha->init_cb_size); if (rval) { @@ -1989,7 +1954,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) fcport->port_type = FCT_UNKNOWN; fcport->loop_id = FC_NO_LOOP_ID; atomic_set(&fcport->state, FCS_UNCONFIGURED); - fcport->flags = FCF_RLC_SUPPORT; fcport->supported_classes = FC_COS_UNSPECIFIED; return fcport; @@ -2171,7 +2135,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) vha->host_no, fcport->loop_id)); atomic_set(&fcport->state, FCS_DEVICE_LOST); - fcport->flags &= ~FCF_FARP_DONE; } } @@ -2228,8 +2191,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) WWN_SIZE)) continue; - fcport->flags &= ~(FCF_FABRIC_DEVICE | - FCF_PERSISTENT_BOUND); + fcport->flags &= ~FCF_FABRIC_DEVICE; fcport->loop_id = new_fcport->loop_id; fcport->port_type = new_fcport->port_type; fcport->d_id.b24 = new_fcport->d_id.b24; @@ -2242,7 +2204,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) if (!found) { /* New device, add to fcports list. */ - new_fcport->flags &= ~FCF_PERSISTENT_BOUND; if (vha->vp_idx) { new_fcport->vha = vha; new_fcport->vp_idx = vha->vp_idx; @@ -2275,11 +2236,6 @@ cleanup_allocation: "rval=%x\n", vha->host_no, rval)); } - if (found_devs) { - vha->device_flags |= DFLG_LOCAL_DEVICES; - vha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES; - } - return (rval); } @@ -2765,7 +2721,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, fcport->loop_id = FC_NO_LOOP_ID; fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); - fcport->flags &= ~FCF_PERSISTENT_BOUND; break; } @@ -2808,9 +2763,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, kfree(swl); kfree(new_fcport); - if (!list_empty(new_fcports)) - vha->device_flags |= DFLG_FABRIC_DEVICES; - return (rval); } @@ -2993,7 +2945,6 @@ qla2x00_device_resync(scsi_qla_host_t *vha) 0, 0); } } - fcport->flags &= ~FCF_FARP_DONE; } } return (rval); @@ -3302,6 +3253,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) if (vha->flags.online) { vha->flags.online = 0; + ha->flags.chip_reset_done = 0; clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); ha->qla_stats.total_isp_aborts++; @@ -3451,6 +3403,7 @@ qla2x00_restart_isp(scsi_qla_host_t *vha) if (!status && !(status = qla2x00_init_rings(vha))) { clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); + ha->flags.chip_reset_done = 1; /* Initialize the queues in use */ qla25xx_init_queues(ha); @@ -4338,23 +4291,17 @@ qla81xx_nvram_config(scsi_qla_host_t *vha) /* Determine NVRAM starting address. */ ha->nvram_size = sizeof(struct nvram_81xx); - ha->nvram_base = FA_NVRAM_FUNC0_ADDR; ha->vpd_size = FA_NVRAM_VPD_SIZE; - ha->vpd_base = FA_NVRAM_VPD0_ADDR; - if (PCI_FUNC(ha->pdev->devfn) & 1) { - ha->nvram_base = FA_NVRAM_FUNC1_ADDR; - ha->vpd_base = FA_NVRAM_VPD1_ADDR; - } /* Get VPD data into cache */ ha->vpd = ha->nvram + VPD_OFFSET; - ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, - ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); + ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2, + ha->vpd_size); /* Get NVRAM data into cache and calculate checksum. */ - dptr = (uint32_t *)nv; - ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base, + ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2, ha->nvram_size); + dptr = (uint32_t *)nv; for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) chksum += le32_to_cpu(*dptr++); @@ -4452,6 +4399,9 @@ qla81xx_nvram_config(scsi_qla_host_t *vha) icb->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn); } + /* Use extended-initialization control block. */ + memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb)); + /* * Setup driver NVRAM options. */ diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 2258152b1f4..a8abbb95730 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -776,7 +776,7 @@ qla24xx_start_scsi(srb_t *sp) req_cnt = qla24xx_calc_iocbs(tot_dsds); if (req->cnt < (req_cnt + 2)) { - cnt = ha->isp_ops->rd_req_reg(ha, req->id); + cnt = RD_REG_DWORD_RELAXED(req->req_q_out); if (req->ring_index < cnt) req->cnt = cnt - req->ring_index; @@ -836,7 +836,8 @@ qla24xx_start_scsi(srb_t *sp) sp->flags |= SRB_DMA_VALID; /* Set chip new ring index. */ - ha->isp_ops->wrt_req_reg(ha, req->id, req->ring_index); + WRT_REG_DWORD(req->req_q_in, req->ring_index); + RD_REG_DWORD_RELAXED(&ha->iobase->isp24.hccr); /* Manage unprocessed RIO/ZIO commands in response queue. */ if (vha->flags.process_response_queue && @@ -854,35 +855,3 @@ queuing_error: return QLA_FUNCTION_FAILED; } - -uint16_t -qla24xx_rd_req_reg(struct qla_hw_data *ha, uint16_t id) -{ - device_reg_t __iomem *reg = (void *) ha->iobase; - return RD_REG_DWORD_RELAXED(®->isp24.req_q_out); -} - -uint16_t -qla25xx_rd_req_reg(struct qla_hw_data *ha, uint16_t id) -{ - device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id; - return RD_REG_DWORD_RELAXED(®->isp25mq.req_q_out); -} - -void -qla24xx_wrt_req_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index) -{ - device_reg_t __iomem *reg = (void *) ha->iobase; - WRT_REG_DWORD(®->isp24.req_q_in, index); - RD_REG_DWORD_RELAXED(®->isp24.req_q_in); -} - -void -qla25xx_wrt_req_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index) -{ - device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id; - struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp; - WRT_REG_DWORD(®->isp25mq.req_q_in, index); - RD_REG_DWORD(&ioreg->hccr); /* PCI posting */ -} - diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index f250e5b7897..d04981848e5 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -852,9 +852,6 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha, /* Free outstanding command slot. */ req->outstanding_cmds[index] = NULL; - CMD_COMPL_STATUS(sp->cmd) = 0L; - CMD_SCSI_STATUS(sp->cmd) = 0L; - /* Save ISP completion status */ sp->cmd->result = DID_OK << 16; @@ -955,7 +952,6 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len) if (sense_len >= SCSI_SENSE_BUFFERSIZE) sense_len = SCSI_SENSE_BUFFERSIZE; - CMD_ACTUAL_SNSLEN(cp) = sense_len; sp->request_sense_length = sense_len; sp->request_sense_ptr = cp->sense_buffer; if (sp->request_sense_length > 32) @@ -973,8 +969,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len) cp->device->channel, cp->device->id, cp->device->lun, cp, cp->serial_number)); if (sense_len) - DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, - CMD_ACTUAL_SNSLEN(cp))); + DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, sense_len)); } /** @@ -1043,9 +1038,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) } lscsi_status = scsi_status & STATUS_MASK; - CMD_ENTRY_STATUS(cp) = sts->entry_status; - CMD_COMPL_STATUS(cp) = comp_status; - CMD_SCSI_STATUS(cp) = scsi_status; fcport = sp->fcport; @@ -1104,7 +1096,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { resid = resid_len; scsi_set_resid(cp, resid); - CMD_RESID_LEN(cp) = resid; if (!lscsi_status && ((unsigned)(scsi_bufflen(cp) - resid) < @@ -1160,7 +1151,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) if (scsi_status & SS_RESIDUAL_UNDER) { scsi_set_resid(cp, resid); - CMD_RESID_LEN(cp) = resid; } else { DEBUG2(printk(KERN_INFO "scsi(%ld:%d:%d) UNDERRUN status detected " @@ -1499,7 +1489,6 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) void qla24xx_process_response_queue(struct rsp_que *rsp) { - struct qla_hw_data *ha = rsp->hw; struct sts_entry_24xx *pkt; struct scsi_qla_host *vha; @@ -1553,7 +1542,7 @@ qla24xx_process_response_queue(struct rsp_que *rsp) } /* Adjust ring index */ - ha->isp_ops->wrt_rsp_reg(ha, rsp->id, rsp->ring_index); + WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index); } static void @@ -2029,7 +2018,7 @@ skip_msix: skip_msi: ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, - IRQF_DISABLED|IRQF_SHARED, QLA2XXX_DRIVER_NAME, rsp); + IRQF_SHARED, QLA2XXX_DRIVER_NAME, rsp); if (ret) { qla_printk(KERN_WARNING, ha, "Failed to reserve interrupt %d already in use.\n", @@ -2117,18 +2106,3 @@ int qla25xx_request_irq(struct rsp_que *rsp) msix->rsp = rsp; return ret; } - -void -qla25xx_wrt_rsp_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index) -{ - device_reg_t __iomem *reg = (void *) ha->mqiobase + QLA_QUE_PAGE * id; - WRT_REG_DWORD(®->isp25mq.rsp_q_out, index); -} - -void -qla24xx_wrt_rsp_reg(struct qla_hw_data *ha, uint16_t id, uint16_t index) -{ - device_reg_t __iomem *reg = (void *) ha->iobase; - WRT_REG_DWORD(®->isp24.rsp_q_out, index); -} - diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 4aab7acf752..e67c1660bf4 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -45,6 +45,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) struct qla_hw_data *ha = vha->hw; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); + if (ha->pdev->error_state > pci_channel_io_frozen) + return QLA_FUNCTION_TIMEOUT; + reg = ha->iobase; io_lock_on = base_vha->flags.init_done; @@ -408,7 +411,7 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr) void qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor, uint16_t *subminor, uint16_t *attributes, uint32_t *memory, uint8_t *mpi, - uint32_t *mpi_caps) + uint32_t *mpi_caps, uint8_t *phy) { int rval; mbx_cmd_t mc; @@ -420,7 +423,7 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor, mcp->out_mb = MBX_0; mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; if (IS_QLA81XX(vha->hw)) - mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10; + mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8; mcp->flags = 0; mcp->tov = MBX_TOV_SECONDS; rval = qla2x00_mailbox_command(vha, mcp); @@ -435,11 +438,13 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor, else *memory = (mcp->mb[5] << 16) | mcp->mb[4]; if (IS_QLA81XX(vha->hw)) { - mpi[0] = mcp->mb[10] >> 8; - mpi[1] = mcp->mb[10] & 0xff; - mpi[2] = mcp->mb[11] >> 8; - mpi[3] = mcp->mb[11] & 0xff; + mpi[0] = mcp->mb[10] & 0xff; + mpi[1] = mcp->mb[11] >> 8; + mpi[2] = mcp->mb[11] & 0xff; *mpi_caps = (mcp->mb[12] << 16) | mcp->mb[13]; + phy[0] = mcp->mb[8] & 0xff; + phy[1] = mcp->mb[9] >> 8; + phy[2] = mcp->mb[9] & 0xff; } if (rval != QLA_SUCCESS) { @@ -1043,14 +1048,22 @@ qla2x00_init_firmware(scsi_qla_host_t *vha, uint16_t size) else mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; + mcp->mb[1] = 0; mcp->mb[2] = MSW(ha->init_cb_dma); mcp->mb[3] = LSW(ha->init_cb_dma); - mcp->mb[4] = 0; - mcp->mb[5] = 0; mcp->mb[6] = MSW(MSD(ha->init_cb_dma)); mcp->mb[7] = LSW(MSD(ha->init_cb_dma)); - mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; - mcp->in_mb = MBX_5|MBX_4|MBX_0; + mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; + if (IS_QLA81XX(ha) && ha->ex_init_cb->ex_version) { + mcp->mb[1] = BIT_0; + mcp->mb[10] = MSW(ha->ex_init_cb_dma); + mcp->mb[11] = LSW(ha->ex_init_cb_dma); + mcp->mb[12] = MSW(MSD(ha->ex_init_cb_dma)); + mcp->mb[13] = LSW(MSD(ha->ex_init_cb_dma)); + mcp->mb[14] = sizeof(*ha->ex_init_cb); + mcp->out_mb |= MBX_14|MBX_13|MBX_12|MBX_11|MBX_10; + } + mcp->in_mb = MBX_0; mcp->buf_size = size; mcp->flags = MBX_DMA_OUT; mcp->tov = MBX_TOV_SECONDS; @@ -1187,10 +1200,6 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt) fcport->d_id.b.al_pa = pd->port_id[2]; fcport->d_id.b.rsvd_1 = 0; - /* Check for device require authentication. */ - pd->common_features & BIT_5 ? (fcport->flags |= FCF_AUTH_REQ) : - (fcport->flags &= ~FCF_AUTH_REQ); - /* If not target must be initiator or unknown type. */ if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) fcport->port_type = FCT_INITIATOR; @@ -3218,3 +3227,204 @@ qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb) return rval; } + +int +qla81xx_fac_get_sector_size(scsi_qla_host_t *vha, uint32_t *sector_size) +{ + int rval; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + if (!IS_QLA81XX(vha->hw)) + return QLA_FUNCTION_FAILED; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); + + mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; + mcp->mb[1] = FAC_OPT_CMD_GET_SECTOR_SIZE; + mcp->out_mb = MBX_1|MBX_0; + mcp->in_mb = MBX_1|MBX_0; + mcp->tov = MBX_TOV_SECONDS; + mcp->flags = 0; + rval = qla2x00_mailbox_command(vha, mcp); + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", + __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); + *sector_size = mcp->mb[1]; + } + + return rval; +} + +int +qla81xx_fac_do_write_enable(scsi_qla_host_t *vha, int enable) +{ + int rval; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + if (!IS_QLA81XX(vha->hw)) + return QLA_FUNCTION_FAILED; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); + + mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; + mcp->mb[1] = enable ? FAC_OPT_CMD_WRITE_ENABLE : + FAC_OPT_CMD_WRITE_PROTECT; + mcp->out_mb = MBX_1|MBX_0; + mcp->in_mb = MBX_1|MBX_0; + mcp->tov = MBX_TOV_SECONDS; + mcp->flags = 0; + rval = qla2x00_mailbox_command(vha, mcp); + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n", + __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); + } + + return rval; +} + +int +qla81xx_fac_erase_sector(scsi_qla_host_t *vha, uint32_t start, uint32_t finish) +{ + int rval; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + if (!IS_QLA81XX(vha->hw)) + return QLA_FUNCTION_FAILED; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); + + mcp->mb[0] = MBC_FLASH_ACCESS_CTRL; + mcp->mb[1] = FAC_OPT_CMD_ERASE_SECTOR; + mcp->mb[2] = LSW(start); + mcp->mb[3] = MSW(start); + mcp->mb[4] = LSW(finish); + mcp->mb[5] = MSW(finish); + mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; + mcp->in_mb = MBX_2|MBX_1|MBX_0; + mcp->tov = MBX_TOV_SECONDS; + mcp->flags = 0; + rval = qla2x00_mailbox_command(vha, mcp); + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x " + "mb[2]=%x.\n", __func__, vha->host_no, rval, mcp->mb[0], + mcp->mb[1], mcp->mb[2])); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); + } + + return rval; +} + +int +qla81xx_restart_mpi_firmware(scsi_qla_host_t *vha) +{ + int rval = 0; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); + + mcp->mb[0] = MBC_RESTART_MPI_FW; + mcp->out_mb = MBX_0; + mcp->in_mb = MBX_0|MBX_1; + mcp->tov = MBX_TOV_SECONDS; + mcp->flags = 0; + rval = qla2x00_mailbox_command(vha, mcp); + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n", + __func__, vha->host_no, rval, mcp->mb[0], mcp->mb[1])); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); + } + + return rval; +} + +int +qla2x00_read_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr, + dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt) +{ + int rval; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); + + mcp->mb[0] = MBC_READ_SFP; + mcp->mb[1] = dev; + mcp->mb[2] = MSW(sfp_dma); + mcp->mb[3] = LSW(sfp_dma); + mcp->mb[6] = MSW(MSD(sfp_dma)); + mcp->mb[7] = LSW(MSD(sfp_dma)); + mcp->mb[8] = len; + mcp->mb[9] = adr; + mcp->mb[10] = opt; + mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; + mcp->in_mb = MBX_0; + mcp->tov = MBX_TOV_SECONDS; + mcp->flags = 0; + rval = qla2x00_mailbox_command(vha, mcp); + + if (opt & BIT_0) + if (sfp) + *sfp = mcp->mb[8]; + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, + vha->host_no, rval, mcp->mb[0])); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); + } + + return rval; +} + +int +qla2x00_write_edc(scsi_qla_host_t *vha, uint16_t dev, uint16_t adr, + dma_addr_t sfp_dma, uint8_t *sfp, uint16_t len, uint16_t opt) +{ + int rval; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); + + if (opt & BIT_0) + if (sfp) + len = *sfp; + + mcp->mb[0] = MBC_WRITE_SFP; + mcp->mb[1] = dev; + mcp->mb[2] = MSW(sfp_dma); + mcp->mb[3] = LSW(sfp_dma); + mcp->mb[6] = MSW(MSD(sfp_dma)); + mcp->mb[7] = LSW(MSD(sfp_dma)); + mcp->mb[8] = len; + mcp->mb[9] = adr; + mcp->mb[10] = opt; + mcp->out_mb = MBX_10|MBX_9|MBX_8|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0; + mcp->in_mb = MBX_0; + mcp->tov = MBX_TOV_SECONDS; + mcp->flags = 0; + rval = qla2x00_mailbox_command(vha, mcp); + + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__, + vha->host_no, rval, mcp->mb[0])); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no)); + } + + return rval; +} diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 785c61279e6..51716c7e300 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -359,7 +359,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost); struct qla_hw_data *ha = base_vha->hw; scsi_qla_host_t *vha; - struct scsi_host_template *sht = &qla24xx_driver_template; + struct scsi_host_template *sht = &qla2xxx_driver_template; struct Scsi_Host *host; vha = qla2x00_create_host(sht, ha); @@ -584,6 +584,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options, struct req_que *req = NULL; struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); uint16_t que_id = 0; + device_reg_t __iomem *reg; req = kzalloc(sizeof(struct req_que), GFP_KERNEL); if (req == NULL) { @@ -631,6 +632,9 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options, req->ring_index = 0; req->cnt = req->length; req->id = que_id; + reg = ISP_QUE_REG(ha, que_id); + req->req_q_in = ®->isp25mq.req_q_in; + req->req_q_out = ®->isp25mq.req_q_out; req->max_q_depth = ha->req_q_map[0]->max_q_depth; mutex_unlock(&ha->vport_lock); @@ -658,7 +662,8 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, int ret = 0; struct rsp_que *rsp = NULL; struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); - uint16_t que_id = 0;; + uint16_t que_id = 0; + device_reg_t __iomem *reg; rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); if (rsp == NULL) { @@ -706,6 +711,9 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, rsp->ring_ptr = rsp->ring; rsp->ring_index = 0; rsp->id = que_id; + reg = ISP_QUE_REG(ha, que_id); + rsp->rsp_q_in = ®->isp25mq.rsp_q_in; + rsp->rsp_q_out = ®->isp25mq.rsp_q_out; mutex_unlock(&ha->vport_lock); ret = qla25xx_request_irq(rsp); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 3ddfa889e94..e4fdcdad80d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -104,9 +104,7 @@ static int qla2xxx_slave_alloc(struct scsi_device *); static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); static void qla2xxx_scan_start(struct Scsi_Host *); static void qla2xxx_slave_destroy(struct scsi_device *); -static int qla2x00_queuecommand(struct scsi_cmnd *cmd, - void (*fn)(struct scsi_cmnd *)); -static int qla24xx_queuecommand(struct scsi_cmnd *cmd, +static int qla2xxx_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)); static int qla2xxx_eh_abort(struct scsi_cmnd *); static int qla2xxx_eh_device_reset(struct scsi_cmnd *); @@ -117,42 +115,10 @@ static int qla2xxx_eh_host_reset(struct scsi_cmnd *); static int qla2x00_change_queue_depth(struct scsi_device *, int); static int qla2x00_change_queue_type(struct scsi_device *, int); -static struct scsi_host_template qla2x00_driver_template = { +struct scsi_host_template qla2xxx_driver_template = { .module = THIS_MODULE, .name = QLA2XXX_DRIVER_NAME, - .queuecommand = qla2x00_queuecommand, - - .eh_abort_handler = qla2xxx_eh_abort, - .eh_device_reset_handler = qla2xxx_eh_device_reset, - .eh_target_reset_handler = qla2xxx_eh_target_reset, - .eh_bus_reset_handler = qla2xxx_eh_bus_reset, - .eh_host_reset_handler = qla2xxx_eh_host_reset, - - .slave_configure = qla2xxx_slave_configure, - - .slave_alloc = qla2xxx_slave_alloc, - .slave_destroy = qla2xxx_slave_destroy, - .scan_finished = qla2xxx_scan_finished, - .scan_start = qla2xxx_scan_start, - .change_queue_depth = qla2x00_change_queue_depth, - .change_queue_type = qla2x00_change_queue_type, - .this_id = -1, - .cmd_per_lun = 3, - .use_clustering = ENABLE_CLUSTERING, - .sg_tablesize = SG_ALL, - - /* - * The RISC allows for each command to transfer (2^32-1) bytes of data, - * which equates to 0x800000 sectors. - */ - .max_sectors = 0xFFFF, - .shost_attrs = qla2x00_host_attrs, -}; - -struct scsi_host_template qla24xx_driver_template = { - .module = THIS_MODULE, - .name = QLA2XXX_DRIVER_NAME, - .queuecommand = qla24xx_queuecommand, + .queuecommand = qla2xxx_queuecommand, .eh_abort_handler = qla2xxx_eh_abort, .eh_device_reset_handler = qla2xxx_eh_device_reset, @@ -430,73 +396,7 @@ qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport, } static int -qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) -{ - scsi_qla_host_t *vha = shost_priv(cmd->device->host); - fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; - struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); - struct qla_hw_data *ha = vha->hw; - srb_t *sp; - int rval; - - if (unlikely(pci_channel_offline(ha->pdev))) { - cmd->result = DID_REQUEUE << 16; - goto qc_fail_command; - } - - rval = fc_remote_port_chkready(rport); - if (rval) { - cmd->result = rval; - goto qc_fail_command; - } - - /* Close window on fcport/rport state-transitioning. */ - if (fcport->drport) - goto qc_target_busy; - - if (atomic_read(&fcport->state) != FCS_ONLINE) { - if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || - atomic_read(&vha->loop_state) == LOOP_DEAD) { - cmd->result = DID_NO_CONNECT << 16; - goto qc_fail_command; - } - goto qc_target_busy; - } - - spin_unlock_irq(vha->host->host_lock); - - sp = qla2x00_get_new_sp(vha, fcport, cmd, done); - if (!sp) - goto qc_host_busy_lock; - - rval = ha->isp_ops->start_scsi(sp); - if (rval != QLA_SUCCESS) - goto qc_host_busy_free_sp; - - spin_lock_irq(vha->host->host_lock); - - return 0; - -qc_host_busy_free_sp: - qla2x00_sp_free_dma(sp); - mempool_free(sp, ha->srb_mempool); - -qc_host_busy_lock: - spin_lock_irq(vha->host->host_lock); - return SCSI_MLQUEUE_HOST_BUSY; - -qc_target_busy: - return SCSI_MLQUEUE_TARGET_BUSY; - -qc_fail_command: - done(cmd); - - return 0; -} - - -static int -qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) +qla2xxx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { scsi_qla_host_t *vha = shost_priv(cmd->device->host); fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; @@ -507,7 +407,10 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) int rval; if (unlikely(pci_channel_offline(ha->pdev))) { - cmd->result = DID_REQUEUE << 16; + if (ha->pdev->error_state == pci_channel_io_frozen) + cmd->result = DID_REQUEUE << 16; + else + cmd->result = DID_NO_CONNECT << 16; goto qc24_fail_command; } @@ -635,6 +538,34 @@ qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) return (return_status); } +int +qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) +{ + int return_status; + unsigned long wait_reset; + struct qla_hw_data *ha = vha->hw; + scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); + + wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); + while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || + test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || + test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || + ha->dpc_active) && time_before(jiffies, wait_reset)) { + + msleep(1000); + + if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && + ha->flags.chip_reset_done) + break; + } + if (ha->flags.chip_reset_done) + return_status = QLA_SUCCESS; + else + return_status = QLA_FUNCTION_FAILED; + + return return_status; +} + /* * qla2x00_wait_for_loop_ready * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop @@ -1163,7 +1094,7 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) continue; for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { sp = req->outstanding_cmds[cnt]; - if (sp && sp->fcport->vha == vha) { + if (sp) { req->outstanding_cmds[cnt] = NULL; sp->cmd->result = res; qla2x00_sp_compl(ha, sp); @@ -1245,10 +1176,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha) /* Assume a 32bit DMA mask. */ ha->flags.enable_64bit_addressing = 0; - if (!dma_set_mask(&ha->pdev->dev, DMA_64BIT_MASK)) { + if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { /* Any upper-dword bits set? */ if (MSD(dma_get_required_mask(&ha->pdev->dev)) && - !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) { + !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { /* Ok, a 64bit DMA mask is applicable. */ ha->flags.enable_64bit_addressing = 1; ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; @@ -1257,8 +1188,8 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha) } } - dma_set_mask(&ha->pdev->dev, DMA_32BIT_MASK); - pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK); + dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); + pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); } static void @@ -1351,9 +1282,6 @@ static struct isp_operations qla2100_isp_ops = { .write_optrom = qla2x00_write_optrom_data, .get_flash_version = qla2x00_get_flash_version, .start_scsi = qla2x00_start_scsi, - .wrt_req_reg = NULL, - .wrt_rsp_reg = NULL, - .rd_req_reg = NULL, }; static struct isp_operations qla2300_isp_ops = { @@ -1389,9 +1317,6 @@ static struct isp_operations qla2300_isp_ops = { .write_optrom = qla2x00_write_optrom_data, .get_flash_version = qla2x00_get_flash_version, .start_scsi = qla2x00_start_scsi, - .wrt_req_reg = NULL, - .wrt_rsp_reg = NULL, - .rd_req_reg = NULL, }; static struct isp_operations qla24xx_isp_ops = { @@ -1427,9 +1352,6 @@ static struct isp_operations qla24xx_isp_ops = { .write_optrom = qla24xx_write_optrom_data, .get_flash_version = qla24xx_get_flash_version, .start_scsi = qla24xx_start_scsi, - .wrt_req_reg = qla24xx_wrt_req_reg, - .wrt_rsp_reg = qla24xx_wrt_rsp_reg, - .rd_req_reg = qla24xx_rd_req_reg, }; static struct isp_operations qla25xx_isp_ops = { @@ -1465,9 +1387,6 @@ static struct isp_operations qla25xx_isp_ops = { .write_optrom = qla24xx_write_optrom_data, .get_flash_version = qla24xx_get_flash_version, .start_scsi = qla24xx_start_scsi, - .wrt_req_reg = qla24xx_wrt_req_reg, - .wrt_rsp_reg = qla24xx_wrt_rsp_reg, - .rd_req_reg = qla24xx_rd_req_reg, }; static struct isp_operations qla81xx_isp_ops = { @@ -1493,8 +1412,8 @@ static struct isp_operations qla81xx_isp_ops = { .build_iocbs = NULL, .prep_ms_iocb = qla24xx_prep_ms_iocb, .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, - .read_nvram = qla25xx_read_nvram_data, - .write_nvram = qla25xx_write_nvram_data, + .read_nvram = NULL, + .write_nvram = NULL, .fw_dump = qla81xx_fw_dump, .beacon_on = qla24xx_beacon_on, .beacon_off = qla24xx_beacon_off, @@ -1503,9 +1422,6 @@ static struct isp_operations qla81xx_isp_ops = { .write_optrom = qla24xx_write_optrom_data, .get_flash_version = qla24xx_get_flash_version, .start_scsi = qla24xx_start_scsi, - .wrt_req_reg = qla24xx_wrt_req_reg, - .wrt_rsp_reg = qla24xx_wrt_rsp_reg, - .rd_req_reg = qla24xx_rd_req_reg, }; static inline void @@ -1727,7 +1643,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) struct rsp_que *rsp = NULL; bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); - sht = &qla2x00_driver_template; + sht = &qla2xxx_driver_template; if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || @@ -1736,7 +1652,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) { bars = pci_select_bars(pdev, IORESOURCE_MEM); - sht = &qla24xx_driver_template; mem_only = 1; } @@ -1927,10 +1842,16 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->rsp_q_map[0] = rsp; ha->req_q_map[0] = req; + /* FWI2-capable only. */ + req->req_q_in = &ha->iobase->isp24.req_q_in; + req->req_q_out = &ha->iobase->isp24.req_q_out; + rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; + rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; if (ha->mqenable) { - ha->isp_ops->wrt_req_reg = qla25xx_wrt_req_reg; - ha->isp_ops->wrt_rsp_reg = qla25xx_wrt_rsp_reg; - ha->isp_ops->rd_req_reg = qla25xx_rd_req_reg; + req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; + req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; + rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; + rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; } if (qla2x00_initialize_adapter(base_vha)) { @@ -2000,6 +1921,16 @@ probe_init_failed: ha->max_queues = 0; probe_failed: + if (base_vha->timer_active) + qla2x00_stop_timer(base_vha); + base_vha->flags.online = 0; + if (ha->dpc_thread) { + struct task_struct *t = ha->dpc_thread; + + ha->dpc_thread = NULL; + kthread_stop(t); + } + qla2x00_free_device(base_vha); scsi_host_put(base_vha->host); @@ -2033,10 +1964,30 @@ qla2x00_remove_one(struct pci_dev *pdev) set_bit(UNLOADING, &base_vha->dpc_flags); + qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); + qla2x00_dfs_remove(base_vha); qla84xx_put_chip(base_vha); + /* Disable timer */ + if (base_vha->timer_active) + qla2x00_stop_timer(base_vha); + + base_vha->flags.online = 0; + + /* Kill the kernel thread for this host */ + if (ha->dpc_thread) { + struct task_struct *t = ha->dpc_thread; + + /* + * qla2xxx_wake_dpc checks for ->dpc_thread + * so we need to zero it out. + */ + ha->dpc_thread = NULL; + kthread_stop(t); + } + qla2x00_free_sysfs_attr(base_vha); fc_remove_host(base_vha->host); @@ -2065,25 +2016,6 @@ static void qla2x00_free_device(scsi_qla_host_t *vha) { struct qla_hw_data *ha = vha->hw; - qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); - - /* Disable timer */ - if (vha->timer_active) - qla2x00_stop_timer(vha); - - vha->flags.online = 0; - - /* Kill the kernel thread for this host */ - if (ha->dpc_thread) { - struct task_struct *t = ha->dpc_thread; - - /* - * qla2xxx_wake_dpc checks for ->dpc_thread - * so we need to zero it out. - */ - ha->dpc_thread = NULL; - kthread_stop(t); - } if (ha->flags.fce_enabled) qla2x00_disable_fce_trace(vha, NULL, NULL); @@ -2313,9 +2245,19 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, } else ha->npiv_info = NULL; + /* Get consistent memory allocated for EX-INIT-CB. */ + if (IS_QLA81XX(ha)) { + ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, + &ha->ex_init_cb_dma); + if (!ha->ex_init_cb) + goto fail_ex_init_cb; + } + INIT_LIST_HEAD(&ha->vp_list); return 1; +fail_ex_init_cb: + kfree(ha->npiv_info); fail_npiv_info: dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * sizeof(response_t), (*rsp)->ring, (*rsp)->dma); @@ -2398,18 +2340,22 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->sfp_data) dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); + if (ha->edc_data) + dma_pool_free(ha->s_dma_pool, ha->edc_data, ha->edc_data_dma); + if (ha->ms_iocb) dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); + if (ha->ex_init_cb) + dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); + if (ha->s_dma_pool) dma_pool_destroy(ha->s_dma_pool); - if (ha->gid_list) dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list, ha->gid_list_dma); - if (ha->init_cb) dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, ha->init_cb_dma); @@ -2428,6 +2374,8 @@ qla2x00_mem_free(struct qla_hw_data *ha) ha->ms_iocb_dma = 0; ha->init_cb = NULL; ha->init_cb_dma = 0; + ha->ex_init_cb = NULL; + ha->ex_init_cb_dma = 0; ha->s_dma_pool = NULL; @@ -2914,19 +2862,11 @@ qla2x00_timer(scsi_qla_host_t *vha) spin_unlock_irqrestore(&ha->hardware_lock, cpu_flags); } - set_bit(ABORT_QUEUES_NEEDED, &vha->dpc_flags); start_dpc++; } /* if the loop has been down for 4 minutes, reinit adapter */ if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { - DEBUG(printk("scsi(%ld): Loop down exceed 4 mins - " - "restarting queues.\n", - vha->host_no)); - - set_bit(RESTART_QUEUES_NEEDED, &vha->dpc_flags); - start_dpc++; - if (!(vha->device_flags & DFLG_NO_CABLE) && !vha->vp_idx) { DEBUG(printk("scsi(%ld): Loop down - " @@ -3053,6 +2993,8 @@ qla2x00_release_firmware(void) static pci_ers_result_t qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { + scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); + switch (state) { case pci_channel_io_normal: return PCI_ERS_RESULT_CAN_RECOVER; @@ -3060,7 +3002,7 @@ qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) pci_disable_device(pdev); return PCI_ERS_RESULT_NEED_RESET; case pci_channel_io_perm_failure: - qla2x00_remove_one(pdev); + qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); return PCI_ERS_RESULT_DISCONNECT; } return PCI_ERS_RESULT_NEED_RESET; diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index 284827926ef..152ecfc26cd 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -612,8 +612,8 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) /* Good data. Use specified location. */ loc = locations[1]; - *start = le16_to_cpu(fltl->start_hi) << 16 | - le16_to_cpu(fltl->start_lo); + *start = (le16_to_cpu(fltl->start_hi) << 16 | + le16_to_cpu(fltl->start_lo)) >> 2; end: DEBUG2(qla_printk(KERN_DEBUG, ha, "FLTL[%s] = 0x%x.\n", loc, *start)); return QLA_SUCCESS; @@ -629,6 +629,14 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr) { FA_BOOT_CODE_ADDR, FA_BOOT_CODE_ADDR, FA_BOOT_CODE_ADDR_81 }; const uint32_t def_vpd_nvram[] = { FA_VPD_NVRAM_ADDR, FA_VPD_NVRAM_ADDR, FA_VPD_NVRAM_ADDR_81 }; + const uint32_t def_vpd0[] = + { 0, 0, FA_VPD0_ADDR_81 }; + const uint32_t def_vpd1[] = + { 0, 0, FA_VPD1_ADDR_81 }; + const uint32_t def_nvram0[] = + { 0, 0, FA_NVRAM0_ADDR_81 }; + const uint32_t def_nvram1[] = + { 0, 0, FA_NVRAM1_ADDR_81 }; const uint32_t def_fdt[] = { FA_FLASH_DESCR_ADDR_24, FA_FLASH_DESCR_ADDR, FA_FLASH_DESCR_ADDR_81 }; @@ -693,6 +701,20 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr) break; case FLT_REG_VPD_0: ha->flt_region_vpd_nvram = start; + if (!(PCI_FUNC(ha->pdev->devfn) & 1)) + ha->flt_region_vpd = start; + break; + case FLT_REG_VPD_1: + if (PCI_FUNC(ha->pdev->devfn) & 1) + ha->flt_region_vpd = start; + break; + case FLT_REG_NVRAM_0: + if (!(PCI_FUNC(ha->pdev->devfn) & 1)) + ha->flt_region_nvram = start; + break; + case FLT_REG_NVRAM_1: + if (PCI_FUNC(ha->pdev->devfn) & 1) + ha->flt_region_nvram = start; break; case FLT_REG_FDT: ha->flt_region_fdt = start; @@ -722,13 +744,18 @@ no_flash_data: ha->flt_region_fw = def_fw[def]; ha->flt_region_boot = def_boot[def]; ha->flt_region_vpd_nvram = def_vpd_nvram[def]; + ha->flt_region_vpd = !(PCI_FUNC(ha->pdev->devfn) & 1) ? + def_vpd0[def]: def_vpd1[def]; + ha->flt_region_nvram = !(PCI_FUNC(ha->pdev->devfn) & 1) ? + def_nvram0[def]: def_nvram1[def]; ha->flt_region_fdt = def_fdt[def]; ha->flt_region_npiv_conf = !(PCI_FUNC(ha->pdev->devfn) & 1) ? def_npiv_conf0[def]: def_npiv_conf1[def]; done: DEBUG2(qla_printk(KERN_DEBUG, ha, "FLT[%s]: boot=0x%x fw=0x%x " - "vpd_nvram=0x%x fdt=0x%x flt=0x%x npiv=0x%x.\n", loc, - ha->flt_region_boot, ha->flt_region_fw, ha->flt_region_vpd_nvram, + "vpd_nvram=0x%x vpd=0x%x nvram=0x%x fdt=0x%x flt=0x%x " + "npiv=0x%x.\n", loc, ha->flt_region_boot, ha->flt_region_fw, + ha->flt_region_vpd_nvram, ha->flt_region_vpd, ha->flt_region_nvram, ha->flt_region_fdt, ha->flt_region_flt, ha->flt_region_npiv_conf)); } @@ -931,31 +958,41 @@ done: ha->npiv_info = NULL; } -static void -qla24xx_unprotect_flash(struct qla_hw_data *ha) +static int +qla24xx_unprotect_flash(scsi_qla_host_t *vha) { + struct qla_hw_data *ha = vha->hw; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; + if (ha->flags.fac_supported) + return qla81xx_fac_do_write_enable(vha, 1); + /* Enable flash write. */ WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) | CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ if (!ha->fdt_wrt_disable) - return; + goto done; /* Disable flash write-protection, first clear SR protection bit */ qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); /* Then write zero again to clear remaining SR bits.*/ qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); +done: + return QLA_SUCCESS; } -static void -qla24xx_protect_flash(struct qla_hw_data *ha) +static int +qla24xx_protect_flash(scsi_qla_host_t *vha) { uint32_t cnt; + struct qla_hw_data *ha = vha->hw; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; + if (ha->flags.fac_supported) + return qla81xx_fac_do_write_enable(vha, 0); + if (!ha->fdt_wrt_disable) goto skip_wrt_protect; @@ -973,6 +1010,26 @@ skip_wrt_protect: WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ + + return QLA_SUCCESS; +} + +static int +qla24xx_erase_sector(scsi_qla_host_t *vha, uint32_t fdata) +{ + struct qla_hw_data *ha = vha->hw; + uint32_t start, finish; + + if (ha->flags.fac_supported) { + start = fdata >> 2; + finish = start + (ha->fdt_block_size >> 2) - 1; + return qla81xx_fac_erase_sector(vha, flash_data_addr(ha, + start), flash_data_addr(ha, finish)); + } + + return qla24xx_write_flash_dword(ha, ha->fdt_erase_cmd, + (fdata & 0xff00) | ((fdata << 16) & 0xff0000) | + ((fdata >> 16) & 0xff)); } static int @@ -987,8 +1044,6 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, void *optrom = NULL; struct qla_hw_data *ha = vha->hw; - ret = QLA_SUCCESS; - /* Prepare burst-capable write on supported ISPs. */ if ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && !(faddr & 0xfff) && dwords > OPTROM_BURST_DWORDS) { @@ -1004,7 +1059,12 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, rest_addr = (ha->fdt_block_size >> 2) - 1; sec_mask = ~rest_addr; - qla24xx_unprotect_flash(ha); + ret = qla24xx_unprotect_flash(vha); + if (ret != QLA_SUCCESS) { + qla_printk(KERN_WARNING, ha, + "Unable to unprotect flash for update.\n"); + goto done; + } for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { fdata = (faddr & sec_mask) << 2; @@ -1017,9 +1077,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, ha->fdt_unprotect_sec_cmd, (fdata & 0xff00) | ((fdata << 16) & 0xff0000) | ((fdata >> 16) & 0xff)); - ret = qla24xx_write_flash_dword(ha, ha->fdt_erase_cmd, - (fdata & 0xff00) |((fdata << 16) & - 0xff0000) | ((fdata >> 16) & 0xff)); + ret = qla24xx_erase_sector(vha, fdata); if (ret != QLA_SUCCESS) { DEBUG9(qla_printk("Unable to erase sector: " "address=%x.\n", faddr)); @@ -1073,8 +1131,11 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, 0xff0000) | ((fdata >> 16) & 0xff)); } - qla24xx_protect_flash(ha); - + ret = qla24xx_protect_flash(vha); + if (ret != QLA_SUCCESS) + qla_printk(KERN_WARNING, ha, + "Unable to protect flash after update.\n"); +done: if (optrom) dma_free_coherent(&ha->pdev->dev, OPTROM_BURST_SIZE, optrom, optrom_dma); @@ -1915,7 +1976,7 @@ qla2x00_resume_hba(struct scsi_qla_host *vha) clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); qla2xxx_wake_dpc(vha); - qla2x00_wait_for_hba_online(vha); + qla2x00_wait_for_chip_reset(vha); scsi_unblock_requests(vha->host); } @@ -2206,11 +2267,7 @@ qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, rval = qla24xx_write_flash_data(vha, (uint32_t *)buf, offset >> 2, length >> 2); - /* Resume HBA -- RISC reset needed. */ clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); - set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); - qla2xxx_wake_dpc(vha); - qla2x00_wait_for_hba_online(vha); scsi_unblock_requests(vha->host); return rval; @@ -2518,7 +2575,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) dcode = mbuf; /* Begin with first PCI expansion ROM header. */ - pcihdr = ha->flt_region_boot; + pcihdr = ha->flt_region_boot << 2; last_image = 1; do { /* Verify PCI expansion ROM header. */ diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index a772eab2f0e..19d1afc3a34 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h @@ -7,9 +7,9 @@ /* * Driver version */ -#define QLA2XXX_VERSION "8.03.00-k4" +#define QLA2XXX_VERSION "8.03.01-k1" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 3 -#define QLA_DRIVER_PATCH_VER 0 +#define QLA_DRIVER_PATCH_VER 1 #define QLA_DRIVER_BETA_VER 0 |