Commit 7218df69 authored by Yang, Bo's avatar Yang, Bo Committed by James Bottomley

[SCSI] megaraid_sas: use the firmware boot timeout when waiting for commands

use the constant MEGASAS_RESET_WAIT_TIME when waiting for firmware
commands to complete (currently 3 minutes).

Signed-off-by Bo Yang<bo.yang@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 7b2519af
...@@ -1820,6 +1820,7 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1820,6 +1820,7 @@ megasas_transition_to_ready(struct megasas_instance* instance)
u8 max_wait; u8 max_wait;
u32 fw_state; u32 fw_state;
u32 cur_state; u32 cur_state;
u32 abs_state, curr_abs_state;
fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK; fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK;
...@@ -1829,6 +1830,9 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1829,6 +1830,9 @@ megasas_transition_to_ready(struct megasas_instance* instance)
while (fw_state != MFI_STATE_READY) { while (fw_state != MFI_STATE_READY) {
abs_state =
instance->instancet->read_fw_status_reg(instance->reg_set);
switch (fw_state) { switch (fw_state) {
case MFI_STATE_FAULT: case MFI_STATE_FAULT:
...@@ -1854,7 +1858,7 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1854,7 +1858,7 @@ megasas_transition_to_ready(struct megasas_instance* instance)
&instance->reg_set->inbound_doorbell); &instance->reg_set->inbound_doorbell);
} }
max_wait = 2; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_WAIT_HANDSHAKE; cur_state = MFI_STATE_WAIT_HANDSHAKE;
break; break;
...@@ -1869,7 +1873,7 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1869,7 +1873,7 @@ megasas_transition_to_ready(struct megasas_instance* instance)
writel(MFI_INIT_HOTPLUG, writel(MFI_INIT_HOTPLUG,
&instance->reg_set->inbound_doorbell); &instance->reg_set->inbound_doorbell);
max_wait = 10; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_BOOT_MESSAGE_PENDING; cur_state = MFI_STATE_BOOT_MESSAGE_PENDING;
break; break;
...@@ -1888,7 +1892,7 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1888,7 +1892,7 @@ megasas_transition_to_ready(struct megasas_instance* instance)
writel(MFI_RESET_FLAGS, writel(MFI_RESET_FLAGS,
&instance->reg_set->inbound_doorbell); &instance->reg_set->inbound_doorbell);
max_wait = 60; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_OPERATIONAL; cur_state = MFI_STATE_OPERATIONAL;
break; break;
...@@ -1896,32 +1900,32 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1896,32 +1900,32 @@ megasas_transition_to_ready(struct megasas_instance* instance)
/* /*
* This state should not last for more than 2 seconds * This state should not last for more than 2 seconds
*/ */
max_wait = 2; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_UNDEFINED; cur_state = MFI_STATE_UNDEFINED;
break; break;
case MFI_STATE_BB_INIT: case MFI_STATE_BB_INIT:
max_wait = 2; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_BB_INIT; cur_state = MFI_STATE_BB_INIT;
break; break;
case MFI_STATE_FW_INIT: case MFI_STATE_FW_INIT:
max_wait = 20; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_FW_INIT; cur_state = MFI_STATE_FW_INIT;
break; break;
case MFI_STATE_FW_INIT_2: case MFI_STATE_FW_INIT_2:
max_wait = 20; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_FW_INIT_2; cur_state = MFI_STATE_FW_INIT_2;
break; break;
case MFI_STATE_DEVICE_SCAN: case MFI_STATE_DEVICE_SCAN:
max_wait = 20; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_DEVICE_SCAN; cur_state = MFI_STATE_DEVICE_SCAN;
break; break;
case MFI_STATE_FLUSH_CACHE: case MFI_STATE_FLUSH_CACHE:
max_wait = 20; max_wait = MEGASAS_RESET_WAIT_TIME;
cur_state = MFI_STATE_FLUSH_CACHE; cur_state = MFI_STATE_FLUSH_CACHE;
break; break;
...@@ -1937,8 +1941,10 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1937,8 +1941,10 @@ megasas_transition_to_ready(struct megasas_instance* instance)
for (i = 0; i < (max_wait * 1000); i++) { for (i = 0; i < (max_wait * 1000); i++) {
fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) &
MFI_STATE_MASK ; MFI_STATE_MASK ;
curr_abs_state =
instance->instancet->read_fw_status_reg(instance->reg_set);
if (fw_state == cur_state) { if (abs_state == curr_abs_state) {
msleep(1); msleep(1);
} else } else
break; break;
...@@ -1947,7 +1953,7 @@ megasas_transition_to_ready(struct megasas_instance* instance) ...@@ -1947,7 +1953,7 @@ megasas_transition_to_ready(struct megasas_instance* instance)
/* /*
* Return error if fw_state hasn't changed after max_wait * Return error if fw_state hasn't changed after max_wait
*/ */
if (fw_state == cur_state) { if (curr_abs_state == abs_state) {
printk(KERN_DEBUG "FW state [%d] hasn't changed " printk(KERN_DEBUG "FW state [%d] hasn't changed "
"in %d secs\n", fw_state, max_wait); "in %d secs\n", fw_state, max_wait);
return -ENODEV; return -ENODEV;
......
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