From f581a3f79cc7c00c1a416356011c2e274dbf6571 Mon Sep 17 00:00:00 2001 From: Vikas Chaudhary Date: Wed, 6 Oct 2010 22:47:48 -0700 Subject: [SCSI] qla4xxx: Trivial cleanup * cleanup function qla4xxx_recovery_timeout - No need to wakeup dpc thread from function qla4xxx_recovery_timeout() as we are not doing anything in do_dpc() thread when wakeup from qla4xxx_recovery_timeout() * cleanup function qla4xxx_wait_for_hba_online - Remove hard coded value from qla4xxx_wait_for_hba_online(). * cleanup function qla4xxx_start_firmware_from_flash - display seconds * cleanup function qla4_8xxx_load_risc - Remove redundant code. * cleanup function qla4xxx_get_firmware_status - update debug statement * cleanup function qla4_8xxx_try_start_fw - update return status Signed-off-by: Vikas Chaudhary Signed-off-by: Ravi Anand Reviewed-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/qla4xxx/ql4_nx.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/qla4xxx/ql4_nx.c') diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index 449256f2c5f..b311a96acf1 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c @@ -1540,10 +1540,12 @@ qla4_8xxx_try_start_fw(struct scsi_qla_host *ha) ql4_printk(KERN_INFO, ha, "FW: Attempting to load firmware from flash...\n"); rval = qla4_8xxx_start_firmware(ha, ha->hw.flt_region_fw); - if (rval == QLA_SUCCESS) - return rval; - ql4_printk(KERN_ERR, ha, "FW: Load firmware from flash FAILED...\n"); + if (rval != QLA_SUCCESS) { + ql4_printk(KERN_ERR, ha, "FW: Load firmware from flash" + " FAILED...\n"); + return rval; + } return rval; } @@ -1764,20 +1766,9 @@ int qla4_8xxx_load_risc(struct scsi_qla_host *ha) int retval; retval = qla4_8xxx_device_state_handler(ha); - if (retval == QLA_SUCCESS && - !test_bit(AF_INIT_DONE, &ha->flags)) { + if (retval == QLA_SUCCESS && !test_bit(AF_INIT_DONE, &ha->flags)) retval = qla4xxx_request_irqs(ha); - if (retval != QLA_SUCCESS) { - ql4_printk(KERN_WARNING, ha, - "Failed to reserve interrupt %d already in use.\n", - ha->pdev->irq); - } else { - set_bit(AF_IRQ_ATTACHED, &ha->flags); - ha->host->irq = ha->pdev->irq; - ql4_printk(KERN_INFO, ha, "%s: irq %d attached\n", - __func__, ha->pdev->irq); - } - } + return retval; } -- cgit v1.2.3-70-g09d2 From b25ee66f2d4e5f14e69d75a7363e55889e9aff92 Mon Sep 17 00:00:00 2001 From: Shyam Sundar Date: Wed, 6 Oct 2010 22:50:51 -0700 Subject: [SCSI] qla4xxx: Clear the rom lock if the firmware died while holding it. There is a possibility that the firmware dies while the rom lock is held. The only way to recover from this condition is to forcefully unlock. Signed-off-by: Shyam Sundar Signed-off-by: Vikas Chaudhary Signed-off-by: Ravi Anand Reviewed-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/qla4xxx/ql4_nx.c | 49 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/qla4xxx/ql4_nx.c') diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index b311a96acf1..74582cb46a2 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c @@ -839,8 +839,11 @@ qla4_8xxx_rom_lock(struct scsi_qla_host *ha) done = qla4_8xxx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM2_LOCK)); if (done == 1) break; - if (timeout >= qla4_8xxx_rom_lock_timeout) + if (timeout >= qla4_8xxx_rom_lock_timeout) { + ql4_printk(KERN_WARNING, ha, + "%s: Failed to acquire rom lock", __func__); return -1; + } timeout++; @@ -1550,6 +1553,21 @@ qla4_8xxx_try_start_fw(struct scsi_qla_host *ha) return rval; } +static void qla4_8xxx_rom_lock_recovery(struct scsi_qla_host *ha) +{ + if (qla4_8xxx_rom_lock(ha)) { + /* Someone else is holding the lock. */ + dev_info(&ha->pdev->dev, "Resetting rom_lock\n"); + } + + /* + * Either we got the lock, or someone + * else died while holding it. + * In either case, unlock. + */ + qla4_8xxx_rom_unlock(ha); +} + /** * qla4_8xxx_device_bootstrap - Initialize device, set DEV_READY, start fw * @ha: pointer to adapter structure @@ -1559,11 +1577,12 @@ qla4_8xxx_try_start_fw(struct scsi_qla_host *ha) static int qla4_8xxx_device_bootstrap(struct scsi_qla_host *ha) { - int rval, i, timeout; + int rval = QLA_ERROR; + int i, timeout; uint32_t old_count, count; + int need_reset = 0, peg_stuck = 1; - if (qla4_8xxx_need_reset(ha)) - goto dev_initialize; + need_reset = qla4_8xxx_need_reset(ha); old_count = qla4_8xxx_rd_32(ha, QLA82XX_PEG_ALIVE_COUNTER); @@ -1572,12 +1591,30 @@ qla4_8xxx_device_bootstrap(struct scsi_qla_host *ha) if (timeout) { qla4_8xxx_wr_32(ha, QLA82XX_CRB_DEV_STATE, QLA82XX_DEV_FAILED); - return QLA_ERROR; + return rval; } count = qla4_8xxx_rd_32(ha, QLA82XX_PEG_ALIVE_COUNTER); if (count != old_count) + peg_stuck = 0; + } + + if (need_reset) { + /* We are trying to perform a recovery here. */ + if (peg_stuck) + qla4_8xxx_rom_lock_recovery(ha); + goto dev_initialize; + } else { + /* Start of day for this ha context. */ + if (peg_stuck) { + /* Either we are the first or recovery in progress. */ + qla4_8xxx_rom_lock_recovery(ha); + goto dev_initialize; + } else { + /* Firmware already running. */ + rval = QLA_SUCCESS; goto dev_ready; + } } dev_initialize: @@ -1603,7 +1640,7 @@ dev_ready: ql4_printk(KERN_INFO, ha, "HW State: READY\n"); qla4_8xxx_wr_32(ha, QLA82XX_CRB_DEV_STATE, QLA82XX_DEV_READY); - return QLA_SUCCESS; + return rval; } /** -- cgit v1.2.3-70-g09d2 From d64eab764aaf1455d4cd790e3651a2d65b69e661 Mon Sep 17 00:00:00 2001 From: Vikas Chaudhary Date: Wed, 6 Oct 2010 22:51:09 -0700 Subject: [SCSI] qla4xxx: remove unwanted check for bad spd Signed-off-by: Vikas Chaudhary Signed-off-by: Saurav Kashyap Signed-off-by: Ravi Anand Reviewed-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/qla4xxx/ql4_nx.c | 17 ----------------- drivers/scsi/qla4xxx/ql4_nx.h | 3 --- 2 files changed, 20 deletions(-) (limited to 'drivers/scsi/qla4xxx/ql4_nx.c') diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index 74582cb46a2..474b10d7136 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c @@ -1081,21 +1081,6 @@ qla4_8xxx_pinit_from_rom(struct scsi_qla_host *ha, int verbose) return 0; } -static int qla4_8xxx_check_for_bad_spd(struct scsi_qla_host *ha) -{ - u32 val = 0; - val = qla4_8xxx_rd_32(ha, BOOT_LOADER_DIMM_STATUS) ; - val &= QLA82XX_BOOT_LOADER_MN_ISSUE; - if (val & QLA82XX_PEG_TUNE_MN_SPD_ZEROED) { - printk("Memory DIMM SPD not programmed. Assumed valid.\n"); - return 1; - } else if (val) { - printk("Memory DIMM type incorrect. Info:%08X.\n", val); - return 2; - } - return 0; -} - static int qla4_8xxx_load_from_flash(struct scsi_qla_host *ha, uint32_t image_start) { @@ -1380,8 +1365,6 @@ static int qla4_8xxx_cmdpeg_ready(struct scsi_qla_host *ha, int pegtune_val) } while (--retries); - qla4_8xxx_check_for_bad_spd(ha); - if (!retries) { pegtune_val = qla4_8xxx_rd_32(ha, QLA82XX_ROMUSB_GLB_PEGTUNE_DONE); diff --git a/drivers/scsi/qla4xxx/ql4_nx.h b/drivers/scsi/qla4xxx/ql4_nx.h index 95f3060ad02..ff689bf5300 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.h +++ b/drivers/scsi/qla4xxx/ql4_nx.h @@ -24,7 +24,6 @@ #define CRB_CMDPEG_STATE QLA82XX_REG(0x50) #define CRB_RCVPEG_STATE QLA82XX_REG(0x13c) -#define BOOT_LOADER_DIMM_STATUS QLA82XX_REG(0x54) #define CRB_DMA_SHIFT QLA82XX_REG(0xcc) #define QLA82XX_HW_H0_CH_HUB_ADR 0x05 @@ -529,8 +528,6 @@ # define QLA82XX_CAM_RAM_BASE (QLA82XX_CRB_CAM + 0x02000) # define QLA82XX_CAM_RAM(reg) (QLA82XX_CAM_RAM_BASE + (reg)) -#define QLA82XX_PEG_TUNE_MN_SPD_ZEROED 0x80000000 -#define QLA82XX_BOOT_LOADER_MN_ISSUE 0xff00ffff #define QLA82XX_PORT_MODE_ADDR (QLA82XX_CAM_RAM(0x24)) #define QLA82XX_PEG_HALT_STATUS1 (QLA82XX_CAM_RAM(0xa8)) #define QLA82XX_PEG_HALT_STATUS2 (QLA82XX_CAM_RAM(0xac)) -- cgit v1.2.3-70-g09d2