[SCSI] megaraid_sas: FW transition and q size changes

This patch has the following enhancements :
a. handles new transition states of FW to support controller hotplug.
b. It reduces by 1 the maximum cmds that the driver may send to FW.
c. Sends "Stop Processing" cmd to FW before returning failure from reset routine
d. Adds print in megasas_transition routine
e. Sends "RESET" flag to FW to do a soft reset of controller
to move from Operational to Ready state.
f. Sending correct pointer (cmd->sense) to pci_pool_free

Signed-off-by: Sumant Patro <Sumant.Patro@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Sumant Patro and committed by James Bottomley e3bbff9f 65935ff9

+38 -8
+29 -6
drivers/scsi/megaraid/megaraid_sas.c
··· 832 } 833 834 if (atomic_read(&instance->fw_outstanding)) { 835 instance->hw_crit_error = 1; 836 return FAILED; 837 } ··· 1235 1236 fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK; 1237 1238 while (fw_state != MFI_STATE_READY) { 1239 1240 - printk(KERN_INFO "megasas: Waiting for FW to come to ready" 1241 - " state\n"); 1242 switch (fw_state) { 1243 1244 case MFI_STATE_FAULT: ··· 1252 /* 1253 * Set the CLR bit in inbound doorbell 1254 */ 1255 - writel(MFI_INIT_CLEAR_HANDSHAKE, 1256 &instance->reg_set->inbound_doorbell); 1257 1258 max_wait = 2; 1259 cur_state = MFI_STATE_WAIT_HANDSHAKE; 1260 break; 1261 1262 case MFI_STATE_OPERATIONAL: 1263 /* 1264 - * Bring it to READY state; assuming max wait 2 secs 1265 */ 1266 megasas_disable_intr(instance); 1267 - writel(MFI_INIT_READY, &instance->reg_set->inbound_doorbell); 1268 1269 max_wait = 10; 1270 cur_state = MFI_STATE_OPERATIONAL; ··· 1339 return -ENODEV; 1340 } 1341 }; 1342 1343 return 0; 1344 } ··· 1369 cmd->frame_phys_addr); 1370 1371 if (cmd->sense) 1372 - pci_pool_free(instance->sense_dma_pool, cmd->frame, 1373 cmd->sense_phys_addr); 1374 } 1375 ··· 1707 * Get various operational parameters from status register 1708 */ 1709 instance->max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF; 1710 instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >> 1711 0x10; 1712 /*
··· 832 } 833 834 if (atomic_read(&instance->fw_outstanding)) { 835 + /* 836 + * Send signal to FW to stop processing any pending cmds. 837 + * The controller will be taken offline by the OS now. 838 + */ 839 + writel(MFI_STOP_ADP, 840 + &instance->reg_set->inbound_doorbell); 841 instance->hw_crit_error = 1; 842 return FAILED; 843 } ··· 1229 1230 fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK; 1231 1232 + if (fw_state != MFI_STATE_READY) 1233 + printk(KERN_INFO "megasas: Waiting for FW to come to ready" 1234 + " state\n"); 1235 + 1236 while (fw_state != MFI_STATE_READY) { 1237 1238 switch (fw_state) { 1239 1240 case MFI_STATE_FAULT: ··· 1244 /* 1245 * Set the CLR bit in inbound doorbell 1246 */ 1247 + writel(MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG, 1248 &instance->reg_set->inbound_doorbell); 1249 1250 max_wait = 2; 1251 cur_state = MFI_STATE_WAIT_HANDSHAKE; 1252 break; 1253 1254 + case MFI_STATE_BOOT_MESSAGE_PENDING: 1255 + writel(MFI_INIT_HOTPLUG, 1256 + &instance->reg_set->inbound_doorbell); 1257 + 1258 + max_wait = 10; 1259 + cur_state = MFI_STATE_BOOT_MESSAGE_PENDING; 1260 + break; 1261 + 1262 case MFI_STATE_OPERATIONAL: 1263 /* 1264 + * Bring it to READY state; assuming max wait 10 secs 1265 */ 1266 megasas_disable_intr(instance); 1267 + writel(MFI_RESET_FLAGS, &instance->reg_set->inbound_doorbell); 1268 1269 max_wait = 10; 1270 cur_state = MFI_STATE_OPERATIONAL; ··· 1323 return -ENODEV; 1324 } 1325 }; 1326 + printk(KERN_INFO "megasas: FW now in Ready state\n"); 1327 1328 return 0; 1329 } ··· 1352 cmd->frame_phys_addr); 1353 1354 if (cmd->sense) 1355 + pci_pool_free(instance->sense_dma_pool, cmd->sense, 1356 cmd->sense_phys_addr); 1357 } 1358 ··· 1690 * Get various operational parameters from status register 1691 */ 1692 instance->max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF; 1693 + /* 1694 + * Reduce the max supported cmds by 1. This is to ensure that the 1695 + * reply_q_sz (1 more than the max cmd that driver may send) 1696 + * does not exceed max cmds that the FW can support 1697 + */ 1698 + instance->max_fw_cmds = instance->max_fw_cmds-1; 1699 instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >> 1700 0x10; 1701 /*
+9 -2
drivers/scsi/megaraid/megaraid_sas.h
··· 50 #define MFI_STATE_WAIT_HANDSHAKE 0x60000000 51 #define MFI_STATE_FW_INIT_2 0x70000000 52 #define MFI_STATE_DEVICE_SCAN 0x80000000 53 #define MFI_STATE_FLUSH_CACHE 0xA0000000 54 #define MFI_STATE_READY 0xB0000000 55 #define MFI_STATE_OPERATIONAL 0xC0000000 ··· 65 * READY : Move from OPERATIONAL to READY state; discard queue info 66 * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??) 67 * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver 68 */ 69 - #define MFI_INIT_ABORT 0x00000000 70 #define MFI_INIT_READY 0x00000002 71 #define MFI_INIT_MFIMODE 0x00000004 72 #define MFI_INIT_CLEAR_HANDSHAKE 0x00000008 73 - #define MFI_RESET_FLAGS MFI_INIT_READY|MFI_INIT_MFIMODE 74 75 /** 76 * MFI frame flags
··· 50 #define MFI_STATE_WAIT_HANDSHAKE 0x60000000 51 #define MFI_STATE_FW_INIT_2 0x70000000 52 #define MFI_STATE_DEVICE_SCAN 0x80000000 53 + #define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000 54 #define MFI_STATE_FLUSH_CACHE 0xA0000000 55 #define MFI_STATE_READY 0xB0000000 56 #define MFI_STATE_OPERATIONAL 0xC0000000 ··· 64 * READY : Move from OPERATIONAL to READY state; discard queue info 65 * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??) 66 * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver 67 + * HOTPLUG : Resume from Hotplug 68 + * MFI_STOP_ADP : Send signal to FW to stop processing 69 */ 70 + #define MFI_INIT_ABORT 0x00000001 71 #define MFI_INIT_READY 0x00000002 72 #define MFI_INIT_MFIMODE 0x00000004 73 #define MFI_INIT_CLEAR_HANDSHAKE 0x00000008 74 + #define MFI_INIT_HOTPLUG 0x00000010 75 + #define MFI_STOP_ADP 0x00000020 76 + #define MFI_RESET_FLAGS MFI_INIT_READY| \ 77 + MFI_INIT_MFIMODE| \ 78 + MFI_INIT_ABORT 79 80 /** 81 * MFI frame flags