aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSucheta Chakraborty <sucheta.chakraborty@qlogic.com>2010-04-01 15:01:32 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-03 17:19:14 -0400
commitaa5e18c04af8706251768e6aba83465e31de7810 (patch)
tree8a766de994e5a9313b5019cca67400375a6a7220
parent0c39aa4819fab75dcce0b1a9d99dcac0d85274f6 (diff)
qlcnic: use IDC defined timeout value
o USE/Read IDC defined timeout value from ROM. o While resetting chip, don't wait for other pci-func to respond, more than reset_ack_timeo seconds, Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/qlcnic/qlcnic.h4
-rw-r--r--drivers/net/qlcnic/qlcnic_hdr.h2
-rw-r--r--drivers/net/qlcnic/qlcnic_init.c16
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c26
4 files changed, 37 insertions, 11 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index 8a3446df4e90..87cd1a7ef9ca 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -958,8 +958,9 @@ struct qlcnic_adapter {
958 u8 dev_state; 958 u8 dev_state;
959 u8 diag_test; 959 u8 diag_test;
960 u8 diag_cnt; 960 u8 diag_cnt;
961 u8 reset_ack_timeo;
962 u8 dev_init_timeo;
961 u8 rsrd1; 963 u8 rsrd1;
962 u16 rsrd2;
963 964
964 u8 mac_addr[ETH_ALEN]; 965 u8 mac_addr[ETH_ALEN];
965 966
@@ -1040,6 +1041,7 @@ int qlcnic_need_fw_reset(struct qlcnic_adapter *adapter);
1040void qlcnic_request_firmware(struct qlcnic_adapter *adapter); 1041void qlcnic_request_firmware(struct qlcnic_adapter *adapter);
1041void qlcnic_release_firmware(struct qlcnic_adapter *adapter); 1042void qlcnic_release_firmware(struct qlcnic_adapter *adapter);
1042int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter); 1043int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter);
1044void qlcnic_setup_idc_param(struct qlcnic_adapter *adapter);
1043 1045
1044int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp); 1046int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp);
1045int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, 1047int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr,
diff --git a/drivers/net/qlcnic/qlcnic_hdr.h b/drivers/net/qlcnic/qlcnic_hdr.h
index e9fb692d83ab..51fa3fbcf58a 100644
--- a/drivers/net/qlcnic/qlcnic_hdr.h
+++ b/drivers/net/qlcnic/qlcnic_hdr.h
@@ -695,6 +695,8 @@ enum {
695#define QLCNIC_CRB_DRV_SCRATCH (QLCNIC_CAM_RAM(0x148)) 695#define QLCNIC_CRB_DRV_SCRATCH (QLCNIC_CAM_RAM(0x148))
696#define QLCNIC_CRB_DEV_PARTITION_INFO (QLCNIC_CAM_RAM(0x14c)) 696#define QLCNIC_CRB_DEV_PARTITION_INFO (QLCNIC_CAM_RAM(0x14c))
697#define QLCNIC_CRB_DRV_IDC_VER (QLCNIC_CAM_RAM(0x14c)) 697#define QLCNIC_CRB_DRV_IDC_VER (QLCNIC_CAM_RAM(0x14c))
698#define QLCNIC_ROM_DEV_INIT_TIMEOUT (0x3e885c)
699#define QLCNIC_ROM_DRV_RESET_TIMEOUT (0x3e8860)
698 700
699 /* Device State */ 701 /* Device State */
700#define QLCNIC_DEV_COLD 1 702#define QLCNIC_DEV_COLD 1
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index 0a424e038cff..ccd24f49b6dd 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -529,6 +529,22 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
529 return 0; 529 return 0;
530} 530}
531 531
532void
533qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) {
534
535 int timeo;
536
537 if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DEV_INIT_TIMEOUT, &timeo))
538 timeo = 30;
539
540 adapter->dev_init_timeo = timeo;
541
542 if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DRV_RESET_TIMEOUT, &timeo))
543 timeo = 10;
544
545 adapter->reset_ack_timeo = timeo;
546}
547
532static int 548static int
533qlcnic_has_mn(struct qlcnic_adapter *adapter) 549qlcnic_has_mn(struct qlcnic_adapter *adapter)
534{ 550{
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index a2346229312e..38e082969253 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -649,7 +649,10 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter)
649 if (err) 649 if (err)
650 return err; 650 return err;
651 651
652 if (!qlcnic_can_start_firmware(adapter)) 652 err = qlcnic_can_start_firmware(adapter);
653 if (err < 0)
654 return err;
655 else if (!err)
653 goto wait_init; 656 goto wait_init;
654 657
655 first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc)); 658 first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc));
@@ -1138,6 +1141,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1138 goto err_out_iounmap; 1141 goto err_out_iounmap;
1139 } 1142 }
1140 1143
1144 qlcnic_setup_idc_param(adapter);
1141 1145
1142 err = qlcnic_start_firmware(adapter); 1146 err = qlcnic_start_firmware(adapter);
1143 if (err) 1147 if (err)
@@ -2027,7 +2031,7 @@ static int
2027qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) 2031qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
2028{ 2032{
2029 u32 val, prev_state; 2033 u32 val, prev_state;
2030 int cnt = 0; 2034 u8 dev_init_timeo = adapter->dev_init_timeo;
2031 int portnum = adapter->portnum; 2035 int portnum = adapter->portnum;
2032 2036
2033 if (qlcnic_api_lock(adapter)) 2037 if (qlcnic_api_lock(adapter))
@@ -2072,12 +2076,13 @@ start_fw:
2072 } 2076 }
2073 2077
2074 qlcnic_api_unlock(adapter); 2078 qlcnic_api_unlock(adapter);
2075 msleep(1000); 2079
2076 while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY) && 2080 do {
2077 ++cnt < 20)
2078 msleep(1000); 2081 msleep(1000);
2082 } while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY)
2083 && --dev_init_timeo);
2079 2084
2080 if (cnt >= 20) 2085 if (!dev_init_timeo)
2081 return -1; 2086 return -1;
2082 2087
2083 if (qlcnic_api_lock(adapter)) 2088 if (qlcnic_api_lock(adapter))
@@ -2099,12 +2104,10 @@ qlcnic_fwinit_work(struct work_struct *work)
2099 struct qlcnic_adapter, fw_work.work); 2104 struct qlcnic_adapter, fw_work.work);
2100 int dev_state; 2105 int dev_state;
2101 2106
2102 if (++adapter->fw_wait_cnt > FW_POLL_THRESH)
2103 goto err_ret;
2104
2105 if (test_bit(__QLCNIC_START_FW, &adapter->state)) { 2107 if (test_bit(__QLCNIC_START_FW, &adapter->state)) {
2106 2108
2107 if (qlcnic_check_drv_state(adapter)) { 2109 if (qlcnic_check_drv_state(adapter) &&
2110 (adapter->fw_wait_cnt++ < adapter->reset_ack_timeo)) {
2108 qlcnic_schedule_work(adapter, 2111 qlcnic_schedule_work(adapter,
2109 qlcnic_fwinit_work, FW_POLL_DELAY); 2112 qlcnic_fwinit_work, FW_POLL_DELAY);
2110 return; 2113 return;
@@ -2118,6 +2121,9 @@ qlcnic_fwinit_work(struct work_struct *work)
2118 goto err_ret; 2121 goto err_ret;
2119 } 2122 }
2120 2123
2124 if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2))
2125 goto err_ret;
2126
2121 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2127 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2122 switch (dev_state) { 2128 switch (dev_state) {
2123 case QLCNIC_DEV_READY: 2129 case QLCNIC_DEV_READY: