Commit aa5e18c0 authored by Sucheta Chakraborty's avatar Sucheta Chakraborty Committed by David S. Miller

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: default avatarSucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: default avatarAmit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0c39aa48
...@@ -958,8 +958,9 @@ struct qlcnic_adapter { ...@@ -958,8 +958,9 @@ struct qlcnic_adapter {
u8 dev_state; u8 dev_state;
u8 diag_test; u8 diag_test;
u8 diag_cnt; u8 diag_cnt;
u8 reset_ack_timeo;
u8 dev_init_timeo;
u8 rsrd1; u8 rsrd1;
u16 rsrd2;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
...@@ -1040,6 +1041,7 @@ int qlcnic_need_fw_reset(struct qlcnic_adapter *adapter); ...@@ -1040,6 +1041,7 @@ int qlcnic_need_fw_reset(struct qlcnic_adapter *adapter);
void qlcnic_request_firmware(struct qlcnic_adapter *adapter); void qlcnic_request_firmware(struct qlcnic_adapter *adapter);
void qlcnic_release_firmware(struct qlcnic_adapter *adapter); void qlcnic_release_firmware(struct qlcnic_adapter *adapter);
int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter); int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter);
void qlcnic_setup_idc_param(struct qlcnic_adapter *adapter);
int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp); int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp);
int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr,
......
...@@ -695,6 +695,8 @@ enum { ...@@ -695,6 +695,8 @@ enum {
#define QLCNIC_CRB_DRV_SCRATCH (QLCNIC_CAM_RAM(0x148)) #define QLCNIC_CRB_DRV_SCRATCH (QLCNIC_CAM_RAM(0x148))
#define QLCNIC_CRB_DEV_PARTITION_INFO (QLCNIC_CAM_RAM(0x14c)) #define QLCNIC_CRB_DEV_PARTITION_INFO (QLCNIC_CAM_RAM(0x14c))
#define QLCNIC_CRB_DRV_IDC_VER (QLCNIC_CAM_RAM(0x14c)) #define QLCNIC_CRB_DRV_IDC_VER (QLCNIC_CAM_RAM(0x14c))
#define QLCNIC_ROM_DEV_INIT_TIMEOUT (0x3e885c)
#define QLCNIC_ROM_DRV_RESET_TIMEOUT (0x3e8860)
/* Device State */ /* Device State */
#define QLCNIC_DEV_COLD 1 #define QLCNIC_DEV_COLD 1
......
...@@ -529,6 +529,22 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) ...@@ -529,6 +529,22 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
return 0; return 0;
} }
void
qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) {
int timeo;
if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DEV_INIT_TIMEOUT, &timeo))
timeo = 30;
adapter->dev_init_timeo = timeo;
if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DRV_RESET_TIMEOUT, &timeo))
timeo = 10;
adapter->reset_ack_timeo = timeo;
}
static int static int
qlcnic_has_mn(struct qlcnic_adapter *adapter) qlcnic_has_mn(struct qlcnic_adapter *adapter)
{ {
......
...@@ -649,7 +649,10 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter) ...@@ -649,7 +649,10 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter)
if (err) if (err)
return err; return err;
if (!qlcnic_can_start_firmware(adapter)) err = qlcnic_can_start_firmware(adapter);
if (err < 0)
return err;
else if (!err)
goto wait_init; goto wait_init;
first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc)); 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,6 +1141,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_iounmap; goto err_out_iounmap;
} }
qlcnic_setup_idc_param(adapter);
err = qlcnic_start_firmware(adapter); err = qlcnic_start_firmware(adapter);
if (err) if (err)
...@@ -2027,7 +2031,7 @@ static int ...@@ -2027,7 +2031,7 @@ static int
qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
{ {
u32 val, prev_state; u32 val, prev_state;
int cnt = 0; u8 dev_init_timeo = adapter->dev_init_timeo;
int portnum = adapter->portnum; int portnum = adapter->portnum;
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
...@@ -2072,12 +2076,13 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2072,12 +2076,13 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
} }
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
do {
msleep(1000); msleep(1000);
while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY) && } while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY)
++cnt < 20) && --dev_init_timeo);
msleep(1000);
if (cnt >= 20) if (!dev_init_timeo)
return -1; return -1;
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
...@@ -2099,12 +2104,10 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2099,12 +2104,10 @@ qlcnic_fwinit_work(struct work_struct *work)
struct qlcnic_adapter, fw_work.work); struct qlcnic_adapter, fw_work.work);
int dev_state; int dev_state;
if (++adapter->fw_wait_cnt > FW_POLL_THRESH)
goto err_ret;
if (test_bit(__QLCNIC_START_FW, &adapter->state)) { if (test_bit(__QLCNIC_START_FW, &adapter->state)) {
if (qlcnic_check_drv_state(adapter)) { if (qlcnic_check_drv_state(adapter) &&
(adapter->fw_wait_cnt++ < adapter->reset_ack_timeo)) {
qlcnic_schedule_work(adapter, qlcnic_schedule_work(adapter,
qlcnic_fwinit_work, FW_POLL_DELAY); qlcnic_fwinit_work, FW_POLL_DELAY);
return; return;
...@@ -2118,6 +2121,9 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2118,6 +2121,9 @@ qlcnic_fwinit_work(struct work_struct *work)
goto err_ret; goto err_ret;
} }
if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2))
goto err_ret;
dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
switch (dev_state) { switch (dev_state) {
case QLCNIC_DEV_READY: case QLCNIC_DEV_READY:
......
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