aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla4xxx/ql4_nx.c
diff options
context:
space:
mode:
authorNilesh Javali <nilesh.javali@qlogic.com>2011-12-02 01:42:11 -0500
committerJames Bottomley <JBottomley@Parallels.com>2011-12-15 01:57:42 -0500
commite3f37d1636b7142527704ff62bf6f695a2887501 (patch)
tree7d4b91ff1c2a89cdf8e924d97e7fc879d0fa1231 /drivers/scsi/qla4xxx/ql4_nx.c
parentce505f9d1d9701f02b124ba1ee6caec21c2100e2 (diff)
[SCSI] qla4xxx: Fix the IDC locking mechanism
This ensures the transition of dev_state from COLD to INITIALIZING is within lock and atomic. Signed-off-by: Nilesh Javali <nilesh.javali@qlogic.com> 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>
Diffstat (limited to 'drivers/scsi/qla4xxx/ql4_nx.c')
-rw-r--r--drivers/scsi/qla4xxx/ql4_nx.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 7fc29c6ff57e..8d6bc1b2ff17 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -1792,8 +1792,11 @@ int qla4_8xxx_device_state_handler(struct scsi_qla_host *ha)
1792 int rval = QLA_SUCCESS; 1792 int rval = QLA_SUCCESS;
1793 unsigned long dev_init_timeout; 1793 unsigned long dev_init_timeout;
1794 1794
1795 if (!test_bit(AF_INIT_DONE, &ha->flags)) 1795 if (!test_bit(AF_INIT_DONE, &ha->flags)) {
1796 qla4_8xxx_idc_lock(ha);
1796 qla4_8xxx_set_drv_active(ha); 1797 qla4_8xxx_set_drv_active(ha);
1798 qla4_8xxx_idc_unlock(ha);
1799 }
1797 1800
1798 dev_state = qla4_8xxx_rd_32(ha, QLA82XX_CRB_DEV_STATE); 1801 dev_state = qla4_8xxx_rd_32(ha, QLA82XX_CRB_DEV_STATE);
1799 ql4_printk(KERN_INFO, ha, "1:Device state is 0x%x = %s\n", dev_state, 1802 ql4_printk(KERN_INFO, ha, "1:Device state is 0x%x = %s\n", dev_state,
@@ -1802,8 +1805,8 @@ int qla4_8xxx_device_state_handler(struct scsi_qla_host *ha)
1802 /* wait for 30 seconds for device to go ready */ 1805 /* wait for 30 seconds for device to go ready */
1803 dev_init_timeout = jiffies + (ha->nx_dev_init_timeout * HZ); 1806 dev_init_timeout = jiffies + (ha->nx_dev_init_timeout * HZ);
1804 1807
1808 qla4_8xxx_idc_lock(ha);
1805 while (1) { 1809 while (1) {
1806 qla4_8xxx_idc_lock(ha);
1807 1810
1808 if (time_after_eq(jiffies, dev_init_timeout)) { 1811 if (time_after_eq(jiffies, dev_init_timeout)) {
1809 ql4_printk(KERN_WARNING, ha, "Device init failed!\n"); 1812 ql4_printk(KERN_WARNING, ha, "Device init failed!\n");
@@ -1819,15 +1822,14 @@ int qla4_8xxx_device_state_handler(struct scsi_qla_host *ha)
1819 /* NOTE: Make sure idc unlocked upon exit of switch statement */ 1822 /* NOTE: Make sure idc unlocked upon exit of switch statement */
1820 switch (dev_state) { 1823 switch (dev_state) {
1821 case QLA82XX_DEV_READY: 1824 case QLA82XX_DEV_READY:
1822 qla4_8xxx_idc_unlock(ha);
1823 goto exit; 1825 goto exit;
1824 case QLA82XX_DEV_COLD: 1826 case QLA82XX_DEV_COLD:
1825 rval = qla4_8xxx_device_bootstrap(ha); 1827 rval = qla4_8xxx_device_bootstrap(ha);
1826 qla4_8xxx_idc_unlock(ha);
1827 goto exit; 1828 goto exit;
1828 case QLA82XX_DEV_INITIALIZING: 1829 case QLA82XX_DEV_INITIALIZING:
1829 qla4_8xxx_idc_unlock(ha); 1830 qla4_8xxx_idc_unlock(ha);
1830 msleep(1000); 1831 msleep(1000);
1832 qla4_8xxx_idc_lock(ha);
1831 break; 1833 break;
1832 case QLA82XX_DEV_NEED_RESET: 1834 case QLA82XX_DEV_NEED_RESET:
1833 if (!ql4xdontresethba) { 1835 if (!ql4xdontresethba) {
@@ -1841,31 +1843,32 @@ int qla4_8xxx_device_state_handler(struct scsi_qla_host *ha)
1841 msleep(1000); 1843 msleep(1000);
1842 qla4_8xxx_idc_lock(ha); 1844 qla4_8xxx_idc_lock(ha);
1843 } 1845 }
1844 qla4_8xxx_idc_unlock(ha);
1845 break; 1846 break;
1846 case QLA82XX_DEV_NEED_QUIESCENT: 1847 case QLA82XX_DEV_NEED_QUIESCENT:
1847 qla4_8xxx_idc_unlock(ha);
1848 /* idc locked/unlocked in handler */ 1848 /* idc locked/unlocked in handler */
1849 qla4_8xxx_need_qsnt_handler(ha); 1849 qla4_8xxx_need_qsnt_handler(ha);
1850 qla4_8xxx_idc_lock(ha); 1850 break;
1851 /* fall thru needs idc_locked */
1852 case QLA82XX_DEV_QUIESCENT: 1851 case QLA82XX_DEV_QUIESCENT:
1853 qla4_8xxx_idc_unlock(ha); 1852 qla4_8xxx_idc_unlock(ha);
1854 msleep(1000); 1853 msleep(1000);
1854 qla4_8xxx_idc_lock(ha);
1855 break; 1855 break;
1856 case QLA82XX_DEV_FAILED: 1856 case QLA82XX_DEV_FAILED:
1857 qla4_8xxx_idc_unlock(ha); 1857 qla4_8xxx_idc_unlock(ha);
1858 qla4xxx_dead_adapter_cleanup(ha); 1858 qla4xxx_dead_adapter_cleanup(ha);
1859 rval = QLA_ERROR; 1859 rval = QLA_ERROR;
1860 qla4_8xxx_idc_lock(ha);
1860 goto exit; 1861 goto exit;
1861 default: 1862 default:
1862 qla4_8xxx_idc_unlock(ha); 1863 qla4_8xxx_idc_unlock(ha);
1863 qla4xxx_dead_adapter_cleanup(ha); 1864 qla4xxx_dead_adapter_cleanup(ha);
1864 rval = QLA_ERROR; 1865 rval = QLA_ERROR;
1866 qla4_8xxx_idc_lock(ha);
1865 goto exit; 1867 goto exit;
1866 } 1868 }
1867 } 1869 }
1868exit: 1870exit:
1871 qla4_8xxx_idc_unlock(ha);
1869 return rval; 1872 return rval;
1870} 1873}
1871 1874