Commit 3695310e authored by Joe Carnuccio's avatar Joe Carnuccio Committed by Martin K. Petersen

scsi: qla2xxx: Update flash read/write routine

This patch makes following changes to flash access routines:

- update return type for read_optrom
- use void instead of uint32_t * for buffer parameter in read
  and write optrom routines
- fix flash/nvram addressing
Signed-off-by: default avatarJoe Carnuccio <joe.carnuccio@cavium.com>
Signed-off-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a28d9e4e
...@@ -223,9 +223,9 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, ...@@ -223,9 +223,9 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,
} }
/* Write NVRAM. */ /* Write NVRAM. */
ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count); ha->isp_ops->write_nvram(vha, buf, ha->nvram_base, count);
ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base, ha->isp_ops->read_nvram(vha, ha->nvram, ha->nvram_base,
count); count);
mutex_unlock(&ha->optrom_mutex); mutex_unlock(&ha->optrom_mutex);
ql_dbg(ql_dbg_user, vha, 0x7060, ql_dbg(ql_dbg_user, vha, 0x7060,
...@@ -511,22 +511,24 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, ...@@ -511,22 +511,24 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EINVAL; return -EINVAL;
if (IS_NOCACHE_VPD_TYPE(ha)) { if (IS_NOCACHE_VPD_TYPE(ha))
faddr = ha->flt_region_vpd << 2; goto skip;
if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) && faddr = ha->flt_region_vpd << 2;
qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE)
faddr = ha->flt_region_vpd_sec << 2;
mutex_lock(&ha->optrom_mutex); if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
if (qla2x00_chip_is_down(vha)) { qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE)
mutex_unlock(&ha->optrom_mutex); faddr = ha->flt_region_vpd_sec << 2;
return -EAGAIN;
} mutex_lock(&ha->optrom_mutex);
ha->isp_ops->read_optrom(vha, ha->vpd, faddr, if (qla2x00_chip_is_down(vha)) {
ha->vpd_size);
mutex_unlock(&ha->optrom_mutex); mutex_unlock(&ha->optrom_mutex);
return -EAGAIN;
} }
ha->isp_ops->read_optrom(vha, ha->vpd, faddr, ha->vpd_size);
mutex_unlock(&ha->optrom_mutex);
skip:
return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size); return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
} }
...@@ -563,8 +565,8 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, ...@@ -563,8 +565,8 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj,
} }
/* Write NVRAM. */ /* Write NVRAM. */
ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count); ha->isp_ops->write_nvram(vha, buf, ha->vpd_base, count);
ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count); ha->isp_ops->read_nvram(vha, ha->vpd, ha->vpd_base, count);
/* Update flash version information for 4Gb & above. */ /* Update flash version information for 4Gb & above. */
if (!IS_FWI2_CAPABLE(ha)) { if (!IS_FWI2_CAPABLE(ha)) {
...@@ -934,7 +936,7 @@ static struct bin_attribute sysfs_dcbx_tlv_attr = { ...@@ -934,7 +936,7 @@ static struct bin_attribute sysfs_dcbx_tlv_attr = {
static struct sysfs_entry { static struct sysfs_entry {
char *name; char *name;
struct bin_attribute *attr; struct bin_attribute *attr;
int is4GBp_only; int type;
} bin_file_entries[] = { } bin_file_entries[] = {
{ "fw_dump", &sysfs_fw_dump_attr, }, { "fw_dump", &sysfs_fw_dump_attr, },
{ "nvram", &sysfs_nvram_attr, }, { "nvram", &sysfs_nvram_attr, },
...@@ -957,11 +959,11 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha) ...@@ -957,11 +959,11 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha)
int ret; int ret;
for (iter = bin_file_entries; iter->name; iter++) { for (iter = bin_file_entries; iter->name; iter++) {
if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw)) if (iter->type && !IS_FWI2_CAPABLE(vha->hw))
continue; continue;
if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw)) if (iter->type == 2 && !IS_QLA25XX(vha->hw))
continue; continue;
if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw))) if (iter->type == 3 && !(IS_CNA_CAPABLE(vha->hw)))
continue; continue;
ret = sysfs_create_bin_file(&host->shost_gendev.kobj, ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
...@@ -985,14 +987,14 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon) ...@@ -985,14 +987,14 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon)
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
for (iter = bin_file_entries; iter->name; iter++) { for (iter = bin_file_entries; iter->name; iter++) {
if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha)) if (iter->type && !IS_FWI2_CAPABLE(ha))
continue; continue;
if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha)) if (iter->type == 2 && !IS_QLA25XX(ha))
continue; continue;
if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw))) if (iter->type == 3 && !(IS_CNA_CAPABLE(ha)))
continue; continue;
if (iter->is4GBp_only == 0x27 && if (iter->type == 0x27 &&
(!IS_QLA27XX(vha->hw) || !IS_QLA28XX(ha))) (!IS_QLA27XX(ha) || !IS_QLA28XX(ha)))
continue; continue;
sysfs_remove_bin_file(&host->shost_gendev.kobj, sysfs_remove_bin_file(&host->shost_gendev.kobj,
...@@ -1360,19 +1362,20 @@ qla24xx_84xx_fw_version_show(struct device *dev, ...@@ -1360,19 +1362,20 @@ qla24xx_84xx_fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int rval = QLA_SUCCESS; int rval = QLA_SUCCESS;
uint16_t status[2] = {0, 0}; uint16_t status[2] = { 0 };
scsi_qla_host_t *vha = shost_priv(class_to_shost(dev)); scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
if (!IS_QLA84XX(ha)) if (!IS_QLA84XX(ha))
return scnprintf(buf, PAGE_SIZE, "\n"); return scnprintf(buf, PAGE_SIZE, "\n");
if (ha->cs84xx->op_fw_version == 0) if (!ha->cs84xx->op_fw_version) {
rval = qla84xx_verify_chip(vha, status); rval = qla84xx_verify_chip(vha, status);
if ((rval == QLA_SUCCESS) && (status[0] == 0)) if (!rval && !status[0])
return scnprintf(buf, PAGE_SIZE, "%u\n", return scnprintf(buf, PAGE_SIZE, "%u\n",
(uint32_t)ha->cs84xx->op_fw_version); (uint32_t)ha->cs84xx->op_fw_version);
}
return scnprintf(buf, PAGE_SIZE, "\n"); return scnprintf(buf, PAGE_SIZE, "\n");
} }
......
...@@ -3161,9 +3161,9 @@ struct isp_operations { ...@@ -3161,9 +3161,9 @@ struct isp_operations {
void *(*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t, void *(*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t,
uint32_t); uint32_t);
uint8_t *(*read_nvram) (struct scsi_qla_host *, uint8_t *, uint8_t *(*read_nvram)(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
int (*write_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t, int (*write_nvram)(struct scsi_qla_host *, void *, uint32_t,
uint32_t); uint32_t);
void (*fw_dump) (struct scsi_qla_host *, int); void (*fw_dump) (struct scsi_qla_host *, int);
...@@ -3172,9 +3172,9 @@ struct isp_operations { ...@@ -3172,9 +3172,9 @@ struct isp_operations {
int (*beacon_off) (struct scsi_qla_host *); int (*beacon_off) (struct scsi_qla_host *);
void (*beacon_blink) (struct scsi_qla_host *); void (*beacon_blink) (struct scsi_qla_host *);
uint8_t * (*read_optrom) (struct scsi_qla_host *, uint8_t *, void *(*read_optrom)(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
int (*write_optrom) (struct scsi_qla_host *, uint8_t *, uint32_t, int (*write_optrom)(struct scsi_qla_host *, void *, uint32_t,
uint32_t); uint32_t);
int (*get_flash_version) (struct scsi_qla_host *, void *); int (*get_flash_version) (struct scsi_qla_host *, void *);
......
...@@ -543,19 +543,20 @@ fc_port_t *qla2x00_find_fcport_by_nportid(scsi_qla_host_t *, port_id_t *, u8); ...@@ -543,19 +543,20 @@ fc_port_t *qla2x00_find_fcport_by_nportid(scsi_qla_host_t *, port_id_t *, u8);
*/ */
extern void qla2x00_release_nvram_protection(scsi_qla_host_t *); extern void qla2x00_release_nvram_protection(scsi_qla_host_t *);
extern uint32_t *qla24xx_read_flash_data(scsi_qla_host_t *, uint32_t *, extern uint32_t *qla24xx_read_flash_data(scsi_qla_host_t *, uint32_t *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern uint8_t *qla2x00_read_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, extern uint8_t *qla2x00_read_nvram_data(scsi_qla_host_t *, void *, uint32_t,
uint32_t); uint32_t);
extern uint8_t *qla24xx_read_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, extern uint8_t *qla24xx_read_nvram_data(scsi_qla_host_t *, void *, uint32_t,
uint32_t); uint32_t);
extern int qla2x00_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, extern int qla2x00_write_nvram_data(scsi_qla_host_t *, void *, uint32_t,
uint32_t); uint32_t);
extern int qla24xx_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, extern int qla24xx_write_nvram_data(scsi_qla_host_t *, void *, uint32_t,
uint32_t); uint32_t);
extern uint8_t *qla25xx_read_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, extern uint8_t *qla25xx_read_nvram_data(scsi_qla_host_t *, void *, uint32_t,
uint32_t); uint32_t);
extern int qla25xx_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, extern int qla25xx_write_nvram_data(scsi_qla_host_t *, void *, uint32_t,
uint32_t); uint32_t);
extern int qla2x00_is_a_vp_did(scsi_qla_host_t *, uint32_t); extern int qla2x00_is_a_vp_did(scsi_qla_host_t *, uint32_t);
bool qla2x00_check_reg32_for_disconnect(scsi_qla_host_t *, uint32_t); bool qla2x00_check_reg32_for_disconnect(scsi_qla_host_t *, uint32_t);
bool qla2x00_check_reg16_for_disconnect(scsi_qla_host_t *, uint16_t); bool qla2x00_check_reg16_for_disconnect(scsi_qla_host_t *, uint16_t);
...@@ -575,18 +576,18 @@ extern int qla83xx_restart_nic_firmware(scsi_qla_host_t *); ...@@ -575,18 +576,18 @@ extern int qla83xx_restart_nic_firmware(scsi_qla_host_t *);
extern int qla83xx_access_control(scsi_qla_host_t *, uint16_t, uint32_t, extern int qla83xx_access_control(scsi_qla_host_t *, uint16_t, uint32_t,
uint32_t, uint16_t *); uint32_t, uint16_t *);
extern uint8_t *qla2x00_read_optrom_data(struct scsi_qla_host *, uint8_t *, extern void *qla2x00_read_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern int qla2x00_write_optrom_data(struct scsi_qla_host *, uint8_t *, extern int qla2x00_write_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern uint8_t *qla24xx_read_optrom_data(struct scsi_qla_host *, uint8_t *, extern void *qla24xx_read_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern int qla24xx_write_optrom_data(struct scsi_qla_host *, uint8_t *, extern int qla24xx_write_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern uint8_t *qla25xx_read_optrom_data(struct scsi_qla_host *, uint8_t *, extern void *qla25xx_read_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern uint8_t *qla8044_read_optrom_data(struct scsi_qla_host *, extern void *qla8044_read_optrom_data(struct scsi_qla_host *,
uint8_t *, uint32_t, uint32_t); void *, uint32_t, uint32_t);
extern void qla8044_watchdog(struct scsi_qla_host *vha); extern void qla8044_watchdog(struct scsi_qla_host *vha);
extern int qla2x00_get_flash_version(scsi_qla_host_t *, void *); extern int qla2x00_get_flash_version(scsi_qla_host_t *, void *);
...@@ -766,9 +767,9 @@ extern int qla82xx_start_firmware(scsi_qla_host_t *); ...@@ -766,9 +767,9 @@ extern int qla82xx_start_firmware(scsi_qla_host_t *);
/* Firmware and flash related functions */ /* Firmware and flash related functions */
extern int qla82xx_load_risc(scsi_qla_host_t *, uint32_t *); extern int qla82xx_load_risc(scsi_qla_host_t *, uint32_t *);
extern uint8_t *qla82xx_read_optrom_data(struct scsi_qla_host *, uint8_t *, extern void *qla82xx_read_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern int qla82xx_write_optrom_data(struct scsi_qla_host *, uint8_t *, extern int qla82xx_write_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
/* Mailbox related functions */ /* Mailbox related functions */
...@@ -864,7 +865,7 @@ extern void qla8044_clear_drv_active(struct qla_hw_data *); ...@@ -864,7 +865,7 @@ extern void qla8044_clear_drv_active(struct qla_hw_data *);
void qla8044_get_minidump(struct scsi_qla_host *vha); void qla8044_get_minidump(struct scsi_qla_host *vha);
int qla8044_collect_md_data(struct scsi_qla_host *vha); int qla8044_collect_md_data(struct scsi_qla_host *vha);
extern int qla8044_md_get_template(scsi_qla_host_t *); extern int qla8044_md_get_template(scsi_qla_host_t *);
extern int qla8044_write_optrom_data(struct scsi_qla_host *, uint8_t *, extern int qla8044_write_optrom_data(struct scsi_qla_host *, void *,
uint32_t, uint32_t); uint32_t, uint32_t);
extern irqreturn_t qla8044_intr_handler(int, void *); extern irqreturn_t qla8044_intr_handler(int, void *);
extern void qla82xx_mbx_completion(scsi_qla_host_t *, uint16_t); extern void qla82xx_mbx_completion(scsi_qla_host_t *, uint16_t);
......
...@@ -4419,9 +4419,8 @@ qla2x00_nvram_config(scsi_qla_host_t *vha) ...@@ -4419,9 +4419,8 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
nv->nvram_version < 1) { nv->nvram_version < 1) {
/* Reset NVRAM data. */ /* Reset NVRAM data. */
ql_log(ql_log_warn, vha, 0x0064, ql_log(ql_log_warn, vha, 0x0064,
"Inconsistent NVRAM " "Inconsistent NVRAM detected: checksum=%#x id=%.4s version=%#x.\n",
"detected: checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id, nv->nvram_version);
chksum, nv->id[0], nv->nvram_version);
ql_log(ql_log_warn, vha, 0x0065, ql_log(ql_log_warn, vha, 0x0065,
"Falling back to " "Falling back to "
"functioning (yet invalid -- WWPN) defaults.\n"); "functioning (yet invalid -- WWPN) defaults.\n");
...@@ -7007,13 +7006,12 @@ qla24xx_nvram_config(scsi_qla_host_t *vha) ...@@ -7007,13 +7006,12 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
/* Get VPD data into cache */ /* Get VPD data into cache */
ha->vpd = ha->nvram + VPD_OFFSET; ha->vpd = ha->nvram + VPD_OFFSET;
ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->isp_ops->read_nvram(vha, ha->vpd,
ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4);
/* Get NVRAM data into cache and calculate checksum. */ /* Get NVRAM data into cache and calculate checksum. */
dptr = (uint32_t *)nv; dptr = (uint32_t *)nv;
ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base, ha->isp_ops->read_nvram(vha, dptr, ha->nvram_base, ha->nvram_size);
ha->nvram_size);
for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++) for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++)
chksum += le32_to_cpu(*dptr); chksum += le32_to_cpu(*dptr);
...@@ -7027,9 +7025,9 @@ qla24xx_nvram_config(scsi_qla_host_t *vha) ...@@ -7027,9 +7025,9 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
le16_to_cpu(nv->nvram_version) < ICB_VERSION) { le16_to_cpu(nv->nvram_version) < ICB_VERSION) {
/* Reset NVRAM data. */ /* Reset NVRAM data. */
ql_log(ql_log_warn, vha, 0x006b, ql_log(ql_log_warn, vha, 0x006b,
"Inconsistent NVRAM detected: checksum=0x%x id=%c " "Inconsistent NVRAM checksum=%#x id=%.4s version=%#x.\n",
"version=0x%x.\n", chksum, nv->id[0], nv->nvram_version); chksum, nv->id, nv->nvram_version);
ql_dump_buffer(ql_dbg_init, vha, 0x006b, nv, 32); ql_dump_buffer(ql_dbg_init, vha, 0x006b, nv, sizeof(*nv));
ql_log(ql_log_warn, vha, 0x006c, ql_log(ql_log_warn, vha, 0x006c,
"Falling back to functioning (yet invalid -- WWPN) " "Falling back to functioning (yet invalid -- WWPN) "
"defaults.\n"); "defaults.\n");
...@@ -7418,6 +7416,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, ...@@ -7418,6 +7416,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr,
fwdt->template = NULL; fwdt->template = NULL;
fwdt->length = 0; fwdt->length = 0;
dcode = (void *)req->ring;
qla24xx_read_flash_data(vha, dcode, faddr, 7); qla24xx_read_flash_data(vha, dcode, faddr, 7);
risc_size = be32_to_cpu(dcode[2]); risc_size = be32_to_cpu(dcode[2]);
ql_dbg(ql_dbg_init, vha, 0x0161, ql_dbg(ql_dbg_init, vha, 0x0161,
...@@ -8020,10 +8019,9 @@ qla81xx_nvram_config(scsi_qla_host_t *vha) ...@@ -8020,10 +8019,9 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
le16_to_cpu(nv->nvram_version) < ICB_VERSION) { le16_to_cpu(nv->nvram_version) < ICB_VERSION) {
/* Reset NVRAM data. */ /* Reset NVRAM data. */
ql_log(ql_log_info, vha, 0x0073, ql_log(ql_log_info, vha, 0x0073,
"Inconsistent NVRAM detected: checksum=0x%x id=%c " "Inconsistent NVRAM checksum=%#x id=%.4s version=%#x.\n",
"version=0x%x.\n", chksum, nv->id[0], chksum, nv->id, le16_to_cpu(nv->nvram_version));
le16_to_cpu(nv->nvram_version)); ql_dump_buffer(ql_dbg_init, vha, 0x0073, nv, sizeof(*nv));
ql_dump_buffer(ql_dbg_init, vha, 0x0073, nv, 32);
ql_log(ql_log_info, vha, 0x0074, ql_log(ql_log_info, vha, 0x0074,
"Falling back to functioning (yet invalid -- WWPN) " "Falling back to functioning (yet invalid -- WWPN) "
"defaults.\n"); "defaults.\n");
......
...@@ -2658,8 +2658,8 @@ qla82xx_erase_sector(struct qla_hw_data *ha, int addr) ...@@ -2658,8 +2658,8 @@ qla82xx_erase_sector(struct qla_hw_data *ha, int addr)
/* /*
* Address and length are byte address * Address and length are byte address
*/ */
uint8_t * void *
qla82xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla82xx_read_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
scsi_block_requests(vha->host); scsi_block_requests(vha->host);
...@@ -2767,15 +2767,14 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr, ...@@ -2767,15 +2767,14 @@ qla82xx_write_flash_data(struct scsi_qla_host *vha, uint32_t *dwptr,
} }
int int
qla82xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla82xx_write_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
int rval; int rval;
/* Suspend HBA. */ /* Suspend HBA. */
scsi_block_requests(vha->host); scsi_block_requests(vha->host);
rval = qla82xx_write_flash_data(vha, (uint32_t *)buf, offset, rval = qla82xx_write_flash_data(vha, buf, offset, length >> 2);
length >> 2);
scsi_unblock_requests(vha->host); scsi_unblock_requests(vha->host);
/* Convert return ISP82xx to generic */ /* Convert return ISP82xx to generic */
...@@ -3699,8 +3698,8 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha) ...@@ -3699,8 +3698,8 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha)
spin_unlock_irqrestore(&ha->hardware_lock, flags); spin_unlock_irqrestore(&ha->hardware_lock, flags);
/* Wait for pending cmds (physical and virtual) to complete */ /* Wait for pending cmds (physical and virtual) to complete */
if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, if (!qla2x00_eh_wait_for_pending_commands(vha, 0, 0,
WAIT_HOST)) { WAIT_HOST) == QLA_SUCCESS) {
ql_dbg(ql_dbg_init, vha, 0x00b3, ql_dbg(ql_dbg_init, vha, 0x00b3,
"Done wait for " "Done wait for "
"pending commands.\n"); "pending commands.\n");
......
...@@ -559,12 +559,12 @@ qla8044_read_flash_data(scsi_qla_host_t *vha, uint8_t *p_data, ...@@ -559,12 +559,12 @@ qla8044_read_flash_data(scsi_qla_host_t *vha, uint8_t *p_data,
/* /*
* Address and length are byte address * Address and length are byte address
*/ */
uint8_t * void *
qla8044_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla8044_read_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
scsi_block_requests(vha->host); scsi_block_requests(vha->host);
if (qla8044_read_flash_data(vha, (uint8_t *)buf, offset, length / 4) if (qla8044_read_flash_data(vha, buf, offset, length / 4)
!= QLA_SUCCESS) { != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0xb08d, ql_log(ql_log_warn, vha, 0xb08d,
"%s: Failed to read from flash\n", "%s: Failed to read from flash\n",
...@@ -3797,7 +3797,7 @@ qla8044_write_flash_dword_mode(scsi_qla_host_t *vha, uint32_t *dwptr, ...@@ -3797,7 +3797,7 @@ qla8044_write_flash_dword_mode(scsi_qla_host_t *vha, uint32_t *dwptr,
} }
int int
qla8044_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla8044_write_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
int rval = QLA_FUNCTION_FAILED, i, burst_iter_count; int rval = QLA_FUNCTION_FAILED, i, burst_iter_count;
......
...@@ -429,66 +429,64 @@ qla2x00_set_nvram_protection(struct qla_hw_data *ha, int stat) ...@@ -429,66 +429,64 @@ qla2x00_set_nvram_protection(struct qla_hw_data *ha, int stat)
static inline uint32_t static inline uint32_t
flash_conf_addr(struct qla_hw_data *ha, uint32_t faddr) flash_conf_addr(struct qla_hw_data *ha, uint32_t faddr)
{ {
return ha->flash_conf_off | faddr; return ha->flash_conf_off + faddr;
} }
static inline uint32_t static inline uint32_t
flash_data_addr(struct qla_hw_data *ha, uint32_t faddr) flash_data_addr(struct qla_hw_data *ha, uint32_t faddr)
{ {
return ha->flash_data_off | faddr; return ha->flash_data_off + faddr;
} }
static inline uint32_t static inline uint32_t
nvram_conf_addr(struct qla_hw_data *ha, uint32_t naddr) nvram_conf_addr(struct qla_hw_data *ha, uint32_t naddr)
{ {
return ha->nvram_conf_off | naddr; return ha->nvram_conf_off + naddr;
} }
static inline uint32_t static inline uint32_t
nvram_data_addr(struct qla_hw_data *ha, uint32_t naddr) nvram_data_addr(struct qla_hw_data *ha, uint32_t naddr)
{ {
return ha->nvram_data_off | naddr; return ha->nvram_data_off + naddr;
} }
static uint32_t static int
qla24xx_read_flash_dword(struct qla_hw_data *ha, uint32_t addr) qla24xx_read_flash_dword(struct qla_hw_data *ha, uint32_t addr, uint32_t *data)
{ {
int rval;
uint32_t cnt, data;
struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
ulong cnt = 30000;
WRT_REG_DWORD(&reg->flash_addr, addr & ~FARX_DATA_FLAG); WRT_REG_DWORD(&reg->flash_addr, addr & ~FARX_DATA_FLAG);
/* Wait for READ cycle to complete. */
rval = QLA_SUCCESS; while (cnt--) {
for (cnt = 3000; if (RD_REG_DWORD(&reg->flash_addr) & FARX_DATA_FLAG) {
(RD_REG_DWORD(&reg->flash_addr) & FARX_DATA_FLAG) == 0 && *data = RD_REG_DWORD(&reg->flash_data);
rval == QLA_SUCCESS; cnt--) { return QLA_SUCCESS;
if (cnt) }
udelay(10); udelay(10);
else
rval = QLA_FUNCTION_TIMEOUT;
cond_resched(); cond_resched();
} }
/* TODO: What happens if we time out? */ ql_log(ql_log_warn, pci_get_drvdata(ha->pdev), 0x7090,
data = 0xDEADDEAD; "Flash read dword at %x timeout.\n", addr);
if (rval == QLA_SUCCESS) *data = 0xDEADDEAD;
data = RD_REG_DWORD(&reg->flash_data); return QLA_FUNCTION_TIMEOUT;
return data;
} }
uint32_t * uint32_t *
qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
uint32_t dwords) uint32_t dwords)
{ {
uint32_t i; ulong i;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
/* Dword reads to flash. */ /* Dword reads to flash. */
for (i = 0; i < dwords; i++, faddr++) faddr = flash_data_addr(ha, faddr);
dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, for (i = 0; i < dwords; i++, faddr++, dwptr++) {
flash_data_addr(ha, faddr))); if (qla24xx_read_flash_dword(ha, faddr, dwptr))
break;
cpu_to_le32s(dwptr);
}
return dwptr; return dwptr;
} }
...@@ -496,35 +494,37 @@ qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, ...@@ -496,35 +494,37 @@ qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
static int static int
qla24xx_write_flash_dword(struct qla_hw_data *ha, uint32_t addr, uint32_t data) qla24xx_write_flash_dword(struct qla_hw_data *ha, uint32_t addr, uint32_t data)
{ {
int rval;
uint32_t cnt;
struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
ulong cnt = 500000;
WRT_REG_DWORD(&reg->flash_data, data); WRT_REG_DWORD(&reg->flash_data, data);
RD_REG_DWORD(&reg->flash_data); /* PCI Posting. */
WRT_REG_DWORD(&reg->flash_addr, addr | FARX_DATA_FLAG); WRT_REG_DWORD(&reg->flash_addr, addr | FARX_DATA_FLAG);
/* Wait for Write cycle to complete. */
rval = QLA_SUCCESS; while (cnt--) {
for (cnt = 500000; (RD_REG_DWORD(&reg->flash_addr) & FARX_DATA_FLAG) && if (!(RD_REG_DWORD(&reg->flash_addr) & FARX_DATA_FLAG))
rval == QLA_SUCCESS; cnt--) { return QLA_SUCCESS;
if (cnt) udelay(10);
udelay(10);
else
rval = QLA_FUNCTION_TIMEOUT;
cond_resched(); cond_resched();
} }
return rval;
ql_log(ql_log_warn, pci_get_drvdata(ha->pdev), 0x7090,
"Flash write dword at %x timeout.\n", addr);
return QLA_FUNCTION_TIMEOUT;
} }
static void static void
qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id, qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id,
uint8_t *flash_id) uint8_t *flash_id)
{ {
uint32_t ids; uint32_t faddr, ids = 0;
ids = qla24xx_read_flash_dword(ha, flash_conf_addr(ha, 0x03ab)); *man_id = *flash_id = 0;
*man_id = LSB(ids);
*flash_id = MSB(ids); faddr = flash_conf_addr(ha, 0x03ab);
if (!qla24xx_read_flash_dword(ha, faddr, &ids)) {
*man_id = LSB(ids);
*flash_id = MSB(ids);
}
/* Check if man_id and flash_id are valid. */ /* Check if man_id and flash_id are valid. */
if (ids != 0xDEADDEAD && (*man_id == 0 || *flash_id == 0)) { if (ids != 0xDEADDEAD && (*man_id == 0 || *flash_id == 0)) {
...@@ -534,9 +534,11 @@ qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id, ...@@ -534,9 +534,11 @@ qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id,
* Example: ATMEL 0x00 01 45 1F * Example: ATMEL 0x00 01 45 1F
* Extract MFG and Dev ID from last two bytes. * Extract MFG and Dev ID from last two bytes.
*/ */
ids = qla24xx_read_flash_dword(ha, flash_conf_addr(ha, 0x009f)); faddr = flash_conf_addr(ha, 0x009f);
*man_id = LSB(ids); if (!qla24xx_read_flash_dword(ha, faddr, &ids)) {
*flash_id = MSB(ids); *man_id = LSB(ids);
*flash_id = MSB(ids);
}
} }
} }
...@@ -545,12 +547,12 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) ...@@ -545,12 +547,12 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start)
{ {
const char *loc, *locations[] = { "DEF", "PCI" }; const char *loc, *locations[] = { "DEF", "PCI" };
uint32_t pcihdr, pcids; uint32_t pcihdr, pcids;
uint32_t *dcode;
uint8_t *buf, *bcode, last_image;
uint16_t cnt, chksum, *wptr; uint16_t cnt, chksum, *wptr;
struct qla_flt_location *fltl;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
struct req_que *req = ha->req_q_map[0]; struct req_que *req = ha->req_q_map[0];
struct qla_flt_location *fltl = (void *)req->ring;
uint32_t *dcode = (void *)req->ring;
uint8_t *buf = (void *)req->ring, *bcode, last_image;
/* /*
* FLT-location structure resides after the last PCI region. * FLT-location structure resides after the last PCI region.
...@@ -575,11 +577,9 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) ...@@ -575,11 +577,9 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start)
*start = FA_FLASH_LAYOUT_ADDR_28; *start = FA_FLASH_LAYOUT_ADDR_28;
goto end; goto end;
} }
/* Begin with first PCI expansion ROM header. */ /* Begin with first PCI expansion ROM header. */
buf = (uint8_t *)req->ring;
dcode = (uint32_t *)req->ring;
pcihdr = 0; pcihdr = 0;
last_image = 1;
do { do {
/* Verify PCI expansion ROM header. */ /* Verify PCI expansion ROM header. */
qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20);
...@@ -604,15 +604,12 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) ...@@ -604,15 +604,12 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start)
} while (!last_image); } while (!last_image);
/* Now verify FLT-location structure. */ /* Now verify FLT-location structure. */
fltl = (struct qla_flt_location *)req->ring; qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, sizeof(*fltl) >> 2);
qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, if (memcmp(fltl->sig, "QFLT", 4))
sizeof(struct qla_flt_location) >> 2);
if (fltl->sig[0] != 'Q' || fltl->sig[1] != 'F' ||
fltl->sig[2] != 'L' || fltl->sig[3] != 'T')
goto end; goto end;
wptr = (uint16_t *)req->ring; wptr = (void *)req->ring;
cnt = sizeof(struct qla_flt_location) >> 1; cnt = sizeof(*fltl) / sizeof(*wptr);
for (chksum = 0; cnt--; wptr++) for (chksum = 0; cnt--; wptr++)
chksum += le16_to_cpu(*wptr); chksum += le16_to_cpu(*wptr);
if (chksum) { if (chksum) {
...@@ -915,22 +912,19 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *vha) ...@@ -915,22 +912,19 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *vha)
#define FLASH_BLK_SIZE_32K 0x8000 #define FLASH_BLK_SIZE_32K 0x8000
#define FLASH_BLK_SIZE_64K 0x10000 #define FLASH_BLK_SIZE_64K 0x10000
const char *loc, *locations[] = { "MID", "FDT" }; const char *loc, *locations[] = { "MID", "FDT" };
struct qla_hw_data *ha = vha->hw;
struct req_que *req = ha->req_q_map[0];
uint16_t cnt, chksum; uint16_t cnt, chksum;
uint16_t *wptr; uint16_t *wptr = (void *)req->ring;
struct qla_fdt_layout *fdt; struct qla_fdt_layout *fdt = (void *)req->ring;
uint8_t man_id, flash_id; uint8_t man_id, flash_id;
uint16_t mid = 0, fid = 0; uint16_t mid = 0, fid = 0;
struct qla_hw_data *ha = vha->hw;
struct req_que *req = ha->req_q_map[0];
wptr = (uint16_t *)req->ring; qla24xx_read_flash_data(vha, (void *)fdt, ha->flt_region_fdt,
fdt = (struct qla_fdt_layout *)req->ring; OPTROM_BURST_DWORDS);
ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring, if (le16_to_cpu(*wptr) == 0xffff)
ha->flt_region_fdt << 2, OPTROM_BURST_SIZE);
if (*wptr == cpu_to_le16(0xffff))
goto no_flash_data; goto no_flash_data;
if (fdt->sig[0] != 'Q' || fdt->sig[1] != 'L' || fdt->sig[2] != 'I' || if (memcmp(fdt->sig, "QLID", 4))
fdt->sig[3] != 'D')
goto no_flash_data; goto no_flash_data;
for (cnt = 0, chksum = 0; cnt < sizeof(*fdt) >> 1; cnt++, wptr++) for (cnt = 0, chksum = 0; cnt < sizeof(*fdt) >> 1; cnt++, wptr++)
...@@ -1022,8 +1016,7 @@ qla2xxx_get_idc_param(scsi_qla_host_t *vha) ...@@ -1022,8 +1016,7 @@ qla2xxx_get_idc_param(scsi_qla_host_t *vha)
return; return;
wptr = (uint32_t *)req->ring; wptr = (uint32_t *)req->ring;
ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring, ha->isp_ops->read_optrom(vha, req->ring, QLA82XX_IDC_PARAM_ADDR, 8);
QLA82XX_IDC_PARAM_ADDR , 8);
if (*wptr == cpu_to_le32(0xffffffff)) { if (*wptr == cpu_to_le32(0xffffffff)) {
ha->fcoe_dev_init_timeout = QLA82XX_ROM_DEV_INIT_TIMEOUT; ha->fcoe_dev_init_timeout = QLA82XX_ROM_DEV_INIT_TIMEOUT;
...@@ -1085,8 +1078,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha) ...@@ -1085,8 +1078,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
if (IS_QLA8044(ha)) if (IS_QLA8044(ha))
return; return;
ha->isp_ops->read_optrom(vha, (uint8_t *)&hdr, ha->isp_ops->read_optrom(vha, &hdr, ha->flt_region_npiv_conf << 2,
ha->flt_region_npiv_conf << 2, sizeof(struct qla_npiv_header)); sizeof(struct qla_npiv_header));
if (hdr.version == cpu_to_le16(0xffff)) if (hdr.version == cpu_to_le16(0xffff))
return; return;
if (hdr.version != cpu_to_le16(1)) { if (hdr.version != cpu_to_le16(1)) {
...@@ -1105,8 +1098,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha) ...@@ -1105,8 +1098,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
return; return;
} }
ha->isp_ops->read_optrom(vha, (uint8_t *)data, ha->isp_ops->read_optrom(vha, data, ha->flt_region_npiv_conf << 2,
ha->flt_region_npiv_conf << 2, NPIV_CONFIG_SIZE); NPIV_CONFIG_SIZE);
cnt = (sizeof(hdr) + le16_to_cpu(hdr.entries) * sizeof(*entry)) >> 1; cnt = (sizeof(hdr) + le16_to_cpu(hdr.entries) * sizeof(*entry)) >> 1;
for (wptr = data, chksum = 0; cnt--; wptr++) for (wptr = data, chksum = 0; cnt--; wptr++)
...@@ -1143,10 +1136,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha) ...@@ -1143,10 +1136,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
vid.node_name = wwn_to_u64(entry->node_name); vid.node_name = wwn_to_u64(entry->node_name);
ql_dbg(ql_dbg_user, vha, 0x7093, ql_dbg(ql_dbg_user, vha, 0x7093,
"NPIV[%02x]: wwpn=%llx " "NPIV[%02x]: wwpn=%llx wwnn=%llx vf_id=%#x Q_qos=%#x F_qos=%#x.\n",
"wwnn=%llx vf_id=0x%x Q_qos=0x%x F_qos=0x%x.\n", cnt, cnt, vid.port_name, vid.node_name,
(unsigned long long)vid.port_name,
(unsigned long long)vid.node_name,
le16_to_cpu(entry->vf_id), le16_to_cpu(entry->vf_id),
entry->q_qos, entry->f_qos); entry->q_qos, entry->f_qos);
...@@ -1154,10 +1145,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha) ...@@ -1154,10 +1145,8 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
vport = fc_vport_create(vha->host, 0, &vid); vport = fc_vport_create(vha->host, 0, &vid);
if (!vport) if (!vport)
ql_log(ql_log_warn, vha, 0x7094, ql_log(ql_log_warn, vha, 0x7094,
"NPIV-Config Failed to create vport [%02x]: " "NPIV-Config Failed to create vport [%02x]: wwpn=%llx wwnn=%llx.\n",
"wwpn=%llx wwnn=%llx.\n", cnt, cnt, vid.port_name, vid.node_name);
(unsigned long long)vid.port_name,
(unsigned long long)vid.node_name);
} }
} }
done: done:
...@@ -1192,9 +1181,10 @@ qla24xx_unprotect_flash(scsi_qla_host_t *vha) ...@@ -1192,9 +1181,10 @@ qla24xx_unprotect_flash(scsi_qla_host_t *vha)
static int static int
qla24xx_protect_flash(scsi_qla_host_t *vha) qla24xx_protect_flash(scsi_qla_host_t *vha)
{ {
uint32_t cnt;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
ulong cnt = 300;
uint32_t faddr, dword;
if (ha->flags.fac_supported) if (ha->flags.fac_supported)
return qla81xx_fac_do_write_enable(vha, 0); return qla81xx_fac_do_write_enable(vha, 0);
...@@ -1203,11 +1193,14 @@ qla24xx_protect_flash(scsi_qla_host_t *vha) ...@@ -1203,11 +1193,14 @@ qla24xx_protect_flash(scsi_qla_host_t *vha)
goto skip_wrt_protect; goto skip_wrt_protect;
/* Enable flash write-protection and wait for completion. */ /* Enable flash write-protection and wait for completion. */
qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), faddr = flash_conf_addr(ha, 0x101);
ha->fdt_wrt_disable); qla24xx_write_flash_dword(ha, faddr, ha->fdt_wrt_disable);
for (cnt = 300; cnt && faddr = flash_conf_addr(ha, 0x5);
qla24xx_read_flash_dword(ha, flash_conf_addr(ha, 0x005)) & BIT_0; while (cnt--) {
cnt--) { if (!qla24xx_read_flash_dword(ha, faddr, &dword)) {
if (!(dword & BIT_0))
break;
}
udelay(10); udelay(10);
} }
...@@ -1215,7 +1208,6 @@ qla24xx_protect_flash(scsi_qla_host_t *vha) ...@@ -1215,7 +1208,6 @@ qla24xx_protect_flash(scsi_qla_host_t *vha)
/* Disable flash write. */ /* Disable flash write. */
WRT_REG_DWORD(&reg->ctrl_status, WRT_REG_DWORD(&reg->ctrl_status,
RD_REG_DWORD(&reg->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(&reg->ctrl_status) & ~CSRX_FLASH_ENABLE);
RD_REG_DWORD(&reg->ctrl_status); /* PCI Posting. */
return QLA_SUCCESS; return QLA_SUCCESS;
} }
...@@ -1243,107 +1235,103 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, ...@@ -1243,107 +1235,103 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
uint32_t dwords) uint32_t dwords)
{ {
int ret; int ret;
uint32_t liter; ulong liter;
uint32_t sec_mask, rest_addr; ulong dburst = OPTROM_BURST_DWORDS; /* burst size in dwords */
uint32_t fdata; uint32_t sec_mask, rest_addr, fdata;
dma_addr_t optrom_dma; dma_addr_t optrom_dma;
void *optrom = NULL; void *optrom = NULL;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
/* Prepare burst-capable write on supported ISPs. */ if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
if ((IS_QLA25XX(ha) || IS_QLA81XX(ha) || IS_QLA83XX(ha) || !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
IS_QLA27XX(ha) || IS_QLA28XX(ha)) && goto next;
!(faddr & 0xfff) && dwords > OPTROM_BURST_DWORDS) {
optrom = dma_alloc_coherent(&ha->pdev->dev, OPTROM_BURST_SIZE,
&optrom_dma, GFP_KERNEL);
if (!optrom) {
ql_log(ql_log_warn, vha, 0x7095,
"Unable to allocate "
"memory for optrom burst write (%x KB).\n",
OPTROM_BURST_SIZE / 1024);
}
}
rest_addr = (ha->fdt_block_size >> 2) - 1; /* Allocate dma buffer for burst write */
sec_mask = ~rest_addr; optrom = dma_alloc_coherent(&ha->pdev->dev, OPTROM_BURST_SIZE,
&optrom_dma, GFP_KERNEL);
if (!optrom) {
ql_log(ql_log_warn, vha, 0x7095,
"Failed allocate burst (%x bytes)\n", OPTROM_BURST_SIZE);
}
next:
ql_log(ql_log_warn + ql_dbg_verbose, vha, 0x7095,
"Unprotect flash...\n");
ret = qla24xx_unprotect_flash(vha); ret = qla24xx_unprotect_flash(vha);
if (ret != QLA_SUCCESS) { if (ret) {
ql_log(ql_log_warn, vha, 0x7096, ql_log(ql_log_warn, vha, 0x7096,
"Unable to unprotect flash for update.\n"); "Failed to unprotect flash.\n");
goto done; goto done;
} }
rest_addr = (ha->fdt_block_size >> 2) - 1;
sec_mask = ~rest_addr;
for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) {
fdata = (faddr & sec_mask) << 2; fdata = (faddr & sec_mask) << 2;
/* Are we at the beginning of a sector? */ /* Are we at the beginning of a sector? */
if ((faddr & rest_addr) == 0) { if (!(faddr & rest_addr)) {
/* Do sector unprotect. */ ql_log(ql_log_warn + ql_dbg_verbose, vha, 0x7095,
if (ha->fdt_unprotect_sec_cmd) "Erase sector %#x...\n", faddr);
qla24xx_write_flash_dword(ha,
ha->fdt_unprotect_sec_cmd,
(fdata & 0xff00) | ((fdata << 16) &
0xff0000) | ((fdata >> 16) & 0xff));
ret = qla24xx_erase_sector(vha, fdata); ret = qla24xx_erase_sector(vha, fdata);
if (ret != QLA_SUCCESS) { if (ret) {
ql_dbg(ql_dbg_user, vha, 0x7007, ql_dbg(ql_dbg_user, vha, 0x7007,
"Unable to erase erase sector: address=%x.\n", "Failed to erase sector %x.\n", faddr);
faddr);
break; break;
} }
} }
/* Go with burst-write. */ if (optrom) {
if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { /* If smaller than a burst remaining */
/* Copy data to DMA'ble buffer. */ if (dwords - liter < dburst)
memcpy(optrom, dwptr, OPTROM_BURST_SIZE); dburst = dwords - liter;
/* Copy to dma buffer */
memcpy(optrom, dwptr, dburst << 2);
/* Burst write */
ql_log(ql_log_warn + ql_dbg_verbose, vha, 0x7095,
"Write burst (%#lx dwords)...\n", dburst);
ret = qla2x00_load_ram(vha, optrom_dma, ret = qla2x00_load_ram(vha, optrom_dma,
flash_data_addr(ha, faddr), flash_data_addr(ha, faddr), dburst);
OPTROM_BURST_DWORDS); if (!ret) {
if (ret != QLA_SUCCESS) { liter += dburst - 1;
ql_log(ql_log_warn, vha, 0x7097, faddr += dburst - 1;
"Unable to burst-write optrom segment " dwptr += dburst - 1;
"(%x/%x/%llx).\n", ret,
flash_data_addr(ha, faddr),
(unsigned long long)optrom_dma);
ql_log(ql_log_warn, vha, 0x7098,
"Reverting to slow-write.\n");
dma_free_coherent(&ha->pdev->dev,
OPTROM_BURST_SIZE, optrom, optrom_dma);
optrom = NULL;
} else {
liter += OPTROM_BURST_DWORDS - 1;
faddr += OPTROM_BURST_DWORDS - 1;
dwptr += OPTROM_BURST_DWORDS - 1;
continue; continue;
} }
ql_log(ql_log_warn, vha, 0x7097,
"Failed burst-write at %x (%p/%#llx)....\n",
flash_data_addr(ha, faddr), optrom,
(u64)optrom_dma);
dma_free_coherent(&ha->pdev->dev,
OPTROM_BURST_SIZE, optrom, optrom_dma);
optrom = NULL;
if (IS_QLA27XX(ha) || IS_QLA28XX(ha))
break;
ql_log(ql_log_warn, vha, 0x7098,
"Reverting to slow write...\n");
} }
/* Slow write */
ret = qla24xx_write_flash_dword(ha, ret = qla24xx_write_flash_dword(ha,
flash_data_addr(ha, faddr), cpu_to_le32(*dwptr)); flash_data_addr(ha, faddr), cpu_to_le32(*dwptr));
if (ret != QLA_SUCCESS) { if (ret) {
ql_dbg(ql_dbg_user, vha, 0x7006, ql_dbg(ql_dbg_user, vha, 0x7006,
"Unable to program flash address=%x data=%x.\n", "Failed slopw write %x (%x)\n", faddr, *dwptr);
faddr, *dwptr);
break; break;
} }
/* Do sector protect. */
if (ha->fdt_unprotect_sec_cmd &&
((faddr & rest_addr) == rest_addr))
qla24xx_write_flash_dword(ha,
ha->fdt_protect_sec_cmd,
(fdata & 0xff00) | ((fdata << 16) &
0xff0000) | ((fdata >> 16) & 0xff));
} }
ql_log(ql_log_warn + ql_dbg_verbose, vha, 0x7095,
"Protect flash...\n");
ret = qla24xx_protect_flash(vha); ret = qla24xx_protect_flash(vha);
if (ret != QLA_SUCCESS) if (ret)
ql_log(ql_log_warn, vha, 0x7099, ql_log(ql_log_warn, vha, 0x7099,
"Unable to protect flash after update.\n"); "Failed to protect flash\n");
done: done:
if (optrom) if (optrom)
dma_free_coherent(&ha->pdev->dev, dma_free_coherent(&ha->pdev->dev,
...@@ -1353,7 +1341,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, ...@@ -1353,7 +1341,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
} }
uint8_t * uint8_t *
qla2x00_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, qla2x00_read_nvram_data(scsi_qla_host_t *vha, void *buf, uint32_t naddr,
uint32_t bytes) uint32_t bytes)
{ {
uint32_t i; uint32_t i;
...@@ -1372,27 +1360,30 @@ qla2x00_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, ...@@ -1372,27 +1360,30 @@ qla2x00_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
} }
uint8_t * uint8_t *
qla24xx_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, qla24xx_read_nvram_data(scsi_qla_host_t *vha, void *buf, uint32_t naddr,
uint32_t bytes) uint32_t bytes)
{ {
uint32_t i;
uint32_t *dwptr;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
uint32_t *dwptr = buf;
uint32_t i;
if (IS_P3P_TYPE(ha)) if (IS_P3P_TYPE(ha))
return buf; return buf;
/* Dword reads to flash. */ /* Dword reads to flash. */
dwptr = (uint32_t *)buf; naddr = nvram_data_addr(ha, naddr);
for (i = 0; i < bytes >> 2; i++, naddr++) bytes >>= 2;
dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, for (i = 0; i < bytes; i++, naddr++, dwptr++) {
nvram_data_addr(ha, naddr))); if (qla24xx_read_flash_dword(ha, naddr, dwptr))
break;
cpu_to_le32s(dwptr);
}
return buf; return buf;
} }
int int
qla2x00_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, qla2x00_write_nvram_data(scsi_qla_host_t *vha, void *buf, uint32_t naddr,
uint32_t bytes) uint32_t bytes)
{ {
int ret, stat; int ret, stat;
...@@ -1426,14 +1417,14 @@ qla2x00_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, ...@@ -1426,14 +1417,14 @@ qla2x00_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
} }
int int
qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, qla24xx_write_nvram_data(scsi_qla_host_t *vha, void *buf, uint32_t naddr,
uint32_t bytes) uint32_t bytes)
{ {
int ret;
uint32_t i;
uint32_t *dwptr;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
uint32_t *dwptr = buf;
uint32_t i;
int ret;
ret = QLA_SUCCESS; ret = QLA_SUCCESS;
...@@ -1450,11 +1441,10 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, ...@@ -1450,11 +1441,10 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
qla24xx_write_flash_dword(ha, nvram_conf_addr(ha, 0x101), 0); qla24xx_write_flash_dword(ha, nvram_conf_addr(ha, 0x101), 0);
/* Dword writes to flash. */ /* Dword writes to flash. */
dwptr = (uint32_t *)buf; naddr = nvram_data_addr(ha, naddr);
for (i = 0; i < bytes >> 2; i++, naddr++, dwptr++) { bytes >>= 2;
ret = qla24xx_write_flash_dword(ha, for (i = 0; i < bytes; i++, naddr++, dwptr++) {
nvram_data_addr(ha, naddr), cpu_to_le32(*dwptr)); if (qla24xx_write_flash_dword(ha, naddr, cpu_to_le32(*dwptr))) {
if (ret != QLA_SUCCESS) {
ql_dbg(ql_dbg_user, vha, 0x709a, ql_dbg(ql_dbg_user, vha, 0x709a,
"Unable to program nvram address=%x data=%x.\n", "Unable to program nvram address=%x data=%x.\n",
naddr, *dwptr); naddr, *dwptr);
...@@ -1474,31 +1464,34 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, ...@@ -1474,31 +1464,34 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
} }
uint8_t * uint8_t *
qla25xx_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, qla25xx_read_nvram_data(scsi_qla_host_t *vha, void *buf, uint32_t naddr,
uint32_t bytes) uint32_t bytes)
{ {
uint32_t i;
uint32_t *dwptr;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
uint32_t *dwptr = buf;
uint32_t i;
/* Dword reads to flash. */ /* Dword reads to flash. */
dwptr = (uint32_t *)buf; naddr = flash_data_addr(ha, ha->flt_region_vpd_nvram | naddr);
for (i = 0; i < bytes >> 2; i++, naddr++) bytes >>= 2;
dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, for (i = 0; i < bytes; i++, naddr++, dwptr++) {
flash_data_addr(ha, ha->flt_region_vpd_nvram | naddr))); if (qla24xx_read_flash_dword(ha, naddr, dwptr))
break;
cpu_to_le32s(dwptr);
}
return buf; return buf;
} }
#define RMW_BUFFER_SIZE (64 * 1024)
int int
qla25xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr, qla25xx_write_nvram_data(scsi_qla_host_t *vha, void *buf, uint32_t naddr,
uint32_t bytes) uint32_t bytes)
{ {
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
#define RMW_BUFFER_SIZE (64 * 1024) uint8_t *dbuf = vmalloc(RMW_BUFFER_SIZE);
uint8_t *dbuf;
dbuf = vmalloc(RMW_BUFFER_SIZE);
if (!dbuf) if (!dbuf)
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
ha->isp_ops->read_optrom(vha, dbuf, ha->flt_region_vpd_nvram << 2, ha->isp_ops->read_optrom(vha, dbuf, ha->flt_region_vpd_nvram << 2,
...@@ -2319,8 +2312,8 @@ qla2x00_resume_hba(struct scsi_qla_host *vha) ...@@ -2319,8 +2312,8 @@ qla2x00_resume_hba(struct scsi_qla_host *vha)
scsi_unblock_requests(vha->host); scsi_unblock_requests(vha->host);
} }
uint8_t * void *
qla2x00_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla2x00_read_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
uint32_t addr, midpoint; uint32_t addr, midpoint;
...@@ -2354,12 +2347,12 @@ qla2x00_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2354,12 +2347,12 @@ qla2x00_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
} }
int int
qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla2x00_write_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
int rval; int rval;
uint8_t man_id, flash_id, sec_number, data; uint8_t man_id, flash_id, sec_number, *data;
uint16_t wd; uint16_t wd;
uint32_t addr, liter, sec_mask, rest_addr; uint32_t addr, liter, sec_mask, rest_addr;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
...@@ -2488,7 +2481,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2488,7 +2481,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
for (addr = offset, liter = 0; liter < length; liter++, for (addr = offset, liter = 0; liter < length; liter++,
addr++) { addr++) {
data = buf[liter]; data = buf + liter;
/* Are we at the beginning of a sector? */ /* Are we at the beginning of a sector? */
if ((addr & rest_addr) == 0) { if ((addr & rest_addr) == 0) {
if (IS_QLA2322(ha) || IS_QLA6322(ha)) { if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
...@@ -2556,7 +2549,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2556,7 +2549,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
} }
} }
if (qla2x00_program_flash_address(ha, addr, data, if (qla2x00_program_flash_address(ha, addr, *data,
man_id, flash_id)) { man_id, flash_id)) {
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
break; break;
...@@ -2572,8 +2565,8 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2572,8 +2565,8 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
return rval; return rval;
} }
uint8_t * void *
qla24xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla24xx_read_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
...@@ -2583,7 +2576,7 @@ qla24xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2583,7 +2576,7 @@ qla24xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
/* Go with read. */ /* Go with read. */
qla24xx_read_flash_data(vha, (uint32_t *)buf, offset >> 2, length >> 2); qla24xx_read_flash_data(vha, (void *)buf, offset >> 2, length >> 2);
/* Resume HBA. */ /* Resume HBA. */
clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
...@@ -2593,7 +2586,7 @@ qla24xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2593,7 +2586,7 @@ qla24xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
} }
int int
qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla24xx_write_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
int rval; int rval;
...@@ -2604,7 +2597,7 @@ qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2604,7 +2597,7 @@ qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
/* Go with write. */ /* Go with write. */
rval = qla24xx_write_flash_data(vha, (uint32_t *)buf, offset >> 2, rval = qla24xx_write_flash_data(vha, buf, offset >> 2,
length >> 2); length >> 2);
clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
...@@ -2613,8 +2606,8 @@ qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, ...@@ -2613,8 +2606,8 @@ qla24xx_write_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
return rval; return rval;
} }
uint8_t * void *
qla25xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf, qla25xx_read_optrom_data(struct scsi_qla_host *vha, void *buf,
uint32_t offset, uint32_t length) uint32_t offset, uint32_t length)
{ {
int rval; int rval;
...@@ -2881,7 +2874,7 @@ qla2x00_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -2881,7 +2874,7 @@ qla2x00_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
"Dumping fw " "Dumping fw "
"ver from flash:.\n"); "ver from flash:.\n");
ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x010b, ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x010b,
dbyte, 8); dbyte, 32);
if ((dcode[0] == 0xffff && dcode[1] == 0xffff && if ((dcode[0] == 0xffff && dcode[1] == 0xffff &&
dcode[2] == 0xffff && dcode[3] == 0xffff) || dcode[2] == 0xffff && dcode[3] == 0xffff) ||
...@@ -2912,8 +2905,8 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -2912,8 +2905,8 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
{ {
int ret = QLA_SUCCESS; int ret = QLA_SUCCESS;
uint32_t pcihdr, pcids; uint32_t pcihdr, pcids;
uint32_t *dcode; uint32_t *dcode = mbuf;
uint8_t *bcode; uint8_t *bcode = mbuf;
uint8_t code_type, last_image; uint8_t code_type, last_image;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
...@@ -2925,17 +2918,14 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -2925,17 +2918,14 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
memset(ha->fcode_revision, 0, sizeof(ha->fcode_revision)); memset(ha->fcode_revision, 0, sizeof(ha->fcode_revision));
memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); memset(ha->fw_revision, 0, sizeof(ha->fw_revision));
dcode = mbuf;
/* Begin with first PCI expansion ROM header. */ /* Begin with first PCI expansion ROM header. */
pcihdr = ha->flt_region_boot << 2; pcihdr = ha->flt_region_boot << 2;
last_image = 1; last_image = 1;
do { do {
/* Verify PCI expansion ROM header. */ /* Verify PCI expansion ROM header. */
ha->isp_ops->read_optrom(vha, (uint8_t *)dcode, pcihdr, ha->isp_ops->read_optrom(vha, dcode, pcihdr, 0x20 * 4);
0x20 * 4);
bcode = mbuf + (pcihdr % 4); bcode = mbuf + (pcihdr % 4);
if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa) { if (memcmp(bcode, "\x55\xaa", 2)) {
/* No signature */ /* No signature */
ql_log(ql_log_fatal, vha, 0x0154, ql_log(ql_log_fatal, vha, 0x0154,
"No matching ROM signature.\n"); "No matching ROM signature.\n");
...@@ -2946,13 +2936,11 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -2946,13 +2936,11 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
/* Locate PCI data structure. */ /* Locate PCI data structure. */
pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]); pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]);
ha->isp_ops->read_optrom(vha, (uint8_t *)dcode, pcids, ha->isp_ops->read_optrom(vha, dcode, pcids, 0x20 * 4);
0x20 * 4);
bcode = mbuf + (pcihdr % 4); bcode = mbuf + (pcihdr % 4);
/* Validate signature of PCI data structure. */ /* Validate signature of PCI data structure. */
if (bcode[0x0] != 'P' || bcode[0x1] != 'C' || if (memcmp(bcode, "PCIR", 4)) {
bcode[0x2] != 'I' || bcode[0x3] != 'R') {
/* Incorrect header. */ /* Incorrect header. */
ql_log(ql_log_fatal, vha, 0x0155, ql_log(ql_log_fatal, vha, 0x0155,
"PCI data struct not found pcir_adr=%x.\n", pcids); "PCI data struct not found pcir_adr=%x.\n", pcids);
...@@ -3003,8 +2991,7 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -3003,8 +2991,7 @@ qla82xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
/* Read firmware image information. */ /* Read firmware image information. */
memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); memset(ha->fw_revision, 0, sizeof(ha->fw_revision));
dcode = mbuf; dcode = mbuf;
ha->isp_ops->read_optrom(vha, (uint8_t *)dcode, ha->flt_region_fw << 2, ha->isp_ops->read_optrom(vha, dcode, ha->flt_region_fw << 2, 0x20);
0x20);
bcode = mbuf + (pcihdr % 4); bcode = mbuf + (pcihdr % 4);
/* Validate signature of PCI data structure. */ /* Validate signature of PCI data structure. */
...@@ -3026,16 +3013,14 @@ int ...@@ -3026,16 +3013,14 @@ int
qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
{ {
int ret = QLA_SUCCESS; int ret = QLA_SUCCESS;
uint32_t pcihdr, pcids; uint32_t pcihdr = 0, pcids = 0;
uint32_t *dcode; uint32_t *dcode = mbuf;
uint8_t *bcode; uint8_t *bcode = mbuf;
uint8_t code_type, last_image; uint8_t code_type, last_image;
int i; int i;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
uint32_t faddr = 0; uint32_t faddr = 0;
pcihdr = pcids = 0;
if (IS_P3P_TYPE(ha)) if (IS_P3P_TYPE(ha))
return ret; return ret;
...@@ -3047,18 +3032,16 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -3047,18 +3032,16 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
memset(ha->fcode_revision, 0, sizeof(ha->fcode_revision)); memset(ha->fcode_revision, 0, sizeof(ha->fcode_revision));
memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); memset(ha->fw_revision, 0, sizeof(ha->fw_revision));
dcode = mbuf;
pcihdr = ha->flt_region_boot << 2; pcihdr = ha->flt_region_boot << 2;
if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) && if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE) qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE)
pcihdr = ha->flt_region_boot_sec << 2; pcihdr = ha->flt_region_boot_sec << 2;
last_image = 1;
do { do {
/* Verify PCI expansion ROM header. */ /* Verify PCI expansion ROM header. */
qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20);
bcode = mbuf + (pcihdr % 4); bcode = mbuf + (pcihdr % 4);
if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa) { if (memcmp(bcode, "\x55\xaa", 2)) {
/* No signature */ /* No signature */
ql_log(ql_log_fatal, vha, 0x0059, ql_log(ql_log_fatal, vha, 0x0059,
"No matching ROM signature.\n"); "No matching ROM signature.\n");
...@@ -3073,11 +3056,11 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -3073,11 +3056,11 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
bcode = mbuf + (pcihdr % 4); bcode = mbuf + (pcihdr % 4);
/* Validate signature of PCI data structure. */ /* Validate signature of PCI data structure. */
if (bcode[0x0] != 'P' || bcode[0x1] != 'C' || if (memcmp(bcode, "PCIR", 4)) {
bcode[0x2] != 'I' || bcode[0x3] != 'R') {
/* Incorrect header. */ /* Incorrect header. */
ql_log(ql_log_fatal, vha, 0x005a, ql_log(ql_log_fatal, vha, 0x005a,
"PCI data struct not found pcir_adr=%x.\n", pcids); "PCI data struct not found pcir_adr=%x.\n", pcids);
ql_dump_buffer(ql_dbg_init, vha, 0x0059, dcode, 32);
ret = QLA_FUNCTION_FAILED; ret = QLA_FUNCTION_FAILED;
break; break;
} }
...@@ -3124,7 +3107,6 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -3124,7 +3107,6 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
/* Read firmware image information. */ /* Read firmware image information. */
memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); memset(ha->fw_revision, 0, sizeof(ha->fw_revision));
dcode = mbuf;
faddr = ha->flt_region_fw; faddr = ha->flt_region_fw;
if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) && if ((IS_QLA27XX(ha) || IS_QLA28XX(ha)) &&
qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE) qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE)
...@@ -3135,11 +3117,12 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -3135,11 +3117,12 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
ql_log(ql_log_warn, vha, 0x005f, ql_log(ql_log_warn, vha, 0x005f,
"Unrecognized fw revision at %x.\n", "Unrecognized fw revision at %x.\n",
ha->flt_region_fw * 4); ha->flt_region_fw * 4);
ql_dump_buffer(ql_dbg_init, vha, 0x005f, dcode, 32);
} else { } else {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
ha->fw_revision[i] = be32_to_cpu(dcode[4+i]); ha->fw_revision[i] = be32_to_cpu(dcode[4+i]);
ql_dbg(ql_dbg_init, vha, 0x0060, ql_dbg(ql_dbg_init, vha, 0x0060,
"Firmware revision (flash) %d.%d.%d (%x).\n", "Firmware revision (flash) %u.%u.%u (%x).\n",
ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[0], ha->fw_revision[1],
ha->fw_revision[2], ha->fw_revision[3]); ha->fw_revision[2], ha->fw_revision[3]);
} }
...@@ -3151,12 +3134,12 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) ...@@ -3151,12 +3134,12 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
} }
memset(ha->gold_fw_version, 0, sizeof(ha->gold_fw_version)); memset(ha->gold_fw_version, 0, sizeof(ha->gold_fw_version));
dcode = mbuf; faddr = ha->flt_region_gold_fw;
qla24xx_read_flash_data(vha, dcode, ha->flt_region_gold_fw, 8); qla24xx_read_flash_data(vha, (void *)dcode, ha->flt_region_gold_fw, 8);
if (qla24xx_risc_firmware_invalid(dcode)) { if (qla24xx_risc_firmware_invalid(dcode)) {
ql_log(ql_log_warn, vha, 0x0056, ql_log(ql_log_warn, vha, 0x0056,
"Unrecognized golden fw at 0x%x.\n", "Unrecognized golden fw at %#x.\n", faddr);
ha->flt_region_gold_fw * 4); ql_dump_buffer(ql_dbg_init, vha, 0x0056, dcode, 32);
return ret; return ret;
} }
...@@ -3233,7 +3216,7 @@ qla24xx_read_fcp_prio_cfg(scsi_qla_host_t *vha) ...@@ -3233,7 +3216,7 @@ qla24xx_read_fcp_prio_cfg(scsi_qla_host_t *vha)
fcp_prio_addr = ha->flt_region_fcp_prio; fcp_prio_addr = ha->flt_region_fcp_prio;
/* first read the fcp priority data header from flash */ /* first read the fcp priority data header from flash */
ha->isp_ops->read_optrom(vha, (uint8_t *)ha->fcp_prio_cfg, ha->isp_ops->read_optrom(vha, ha->fcp_prio_cfg,
fcp_prio_addr << 2, FCP_PRIO_CFG_HDR_SIZE); fcp_prio_addr << 2, FCP_PRIO_CFG_HDR_SIZE);
if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 0)) if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 0))
...@@ -3244,7 +3227,7 @@ qla24xx_read_fcp_prio_cfg(scsi_qla_host_t *vha) ...@@ -3244,7 +3227,7 @@ qla24xx_read_fcp_prio_cfg(scsi_qla_host_t *vha)
len = ha->fcp_prio_cfg->num_entries * FCP_PRIO_CFG_ENTRY_SIZE; len = ha->fcp_prio_cfg->num_entries * FCP_PRIO_CFG_ENTRY_SIZE;
max_len = FCP_PRIO_CFG_SIZE - FCP_PRIO_CFG_HDR_SIZE; max_len = FCP_PRIO_CFG_SIZE - FCP_PRIO_CFG_HDR_SIZE;
ha->isp_ops->read_optrom(vha, (uint8_t *)&ha->fcp_prio_cfg->entry[0], ha->isp_ops->read_optrom(vha, &ha->fcp_prio_cfg->entry[0],
fcp_prio_addr << 2, (len < max_len ? len : max_len)); fcp_prio_addr << 2, (len < max_len ? len : max_len));
/* revalidate the entire FCP priority config data, including entries */ /* revalidate the entire FCP priority config data, including entries */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment