]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
qla4xxx: Set IDC version in correct way
authorVikas Chaudhary <vikas.chaudhary@qlogic.com>
Wed, 22 Aug 2012 11:55:06 +0000 (07:55 -0400)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Mon, 12 Nov 2012 10:51:22 +0000 (02:51 -0800)
Issue:
   Device can go to READY state from COLD and skip INITIALIZATION,
   In this case driver will never set IDC version from function
   qla4_8xxx_device_bootstrap().

Fix:
1. Set IDC version at start of function qla4_82xx_need_reset_handler().
2. Set IDC version only if we are 1st driver to load.
3. Added new function qla4_8xxx_update_idc_reg() to set all idc reg at one
   place.

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
(cherry picked from commit aaeef189498373e5d2a34d88002c0bd3308ccda2)

drivers/scsi/qla4xxx/ql4_nx.c

index 8b77a6f00179d0a16f246d5b5c00a45bd39bf46a..ccf6eedec31f33a69ba97012bce7fd2cc41a1b79 100644 (file)
@@ -2356,10 +2356,6 @@ dev_initialize:
        qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
                            QLA8XXX_DEV_INITIALIZING);
 
-       /* Driver that sets device state to initializating sets IDC version */
-       qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DRV_IDC_VERSION,
-                           QLA82XX_IDC_VERSION);
-
        ha->isp_ops->idc_unlock(ha);
        if (ql4xenablemd && test_bit(AF_FW_RECOVERY, &ha->flags) &&
            !test_and_set_bit(AF_82XX_FW_DUMPED, &ha->flags)) {
@@ -2482,6 +2478,38 @@ qla4_8xxx_need_qsnt_handler(struct scsi_qla_host *ha)
        ha->isp_ops->idc_unlock(ha);
 }
 
+static void qla4_82xx_set_idc_ver(struct scsi_qla_host *ha)
+{
+       int idc_ver;
+       uint32_t drv_active;
+
+       drv_active = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DRV_ACTIVE);
+       if (drv_active == (1 << (ha->func_num * 4))) {
+               qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DRV_IDC_VERSION,
+                                   QLA82XX_IDC_VERSION);
+               ql4_printk(KERN_INFO, ha,
+                          "%s: IDC version updated to %d\n", __func__,
+                          QLA82XX_IDC_VERSION);
+       } else {
+               idc_ver = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DRV_IDC_VERSION);
+               if (QLA82XX_IDC_VERSION != idc_ver) {
+                       ql4_printk(KERN_INFO, ha,
+                                  "%s: qla4xxx driver IDC version %d is not compatible with IDC version %d of other drivers!\n",
+                                  __func__, QLA82XX_IDC_VERSION, idc_ver);
+               }
+       }
+}
+
+static void qla4_8xxx_update_idc_reg(struct scsi_qla_host *ha)
+{
+       if (!test_bit(AF_INIT_DONE, &ha->flags)) {
+               ha->isp_ops->idc_lock(ha);
+               qla4_8xxx_set_drv_active(ha);
+               qla4_82xx_set_idc_ver(ha);
+               ha->isp_ops->idc_unlock(ha);
+       }
+}
+
 /**
  * qla4_8xxx_device_state_handler - Adapter state machine
  * @ha: pointer to host adapter structure.
@@ -2494,11 +2522,7 @@ int qla4_8xxx_device_state_handler(struct scsi_qla_host *ha)
        int rval = QLA_SUCCESS;
        unsigned long dev_init_timeout;
 
-       if (!test_bit(AF_INIT_DONE, &ha->flags)) {
-               ha->isp_ops->idc_lock(ha);
-               qla4_8xxx_set_drv_active(ha);
-               ha->isp_ops->idc_unlock(ha);
-       }
+       qla4_8xxx_update_idc_reg(ha);
 
        dev_state = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE);
        DEBUG2(ql4_printk(KERN_INFO, ha, "Device state is 0x%x = %s\n",