Commit 8a01a41d authored by Sumit Saxena's avatar Sumit Saxena Committed by Martin K. Petersen

megaraid_sas: Make adprecovery variable atomic

Make instance->adprecovery variable atomic and removes hba_lock spinlock
while accessing instance->adprecovery.
Signed-off-by: default avatarSumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: default avatarKashyap Desai <kashyap.desai@avagotech.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 52b62ac7
...@@ -2101,7 +2101,7 @@ struct megasas_instance { ...@@ -2101,7 +2101,7 @@ struct megasas_instance {
u16 drv_supported_vd_count; u16 drv_supported_vd_count;
u16 drv_supported_pd_count; u16 drv_supported_pd_count;
u8 adprecovery; atomic_t adprecovery;
unsigned long last_time; unsigned long last_time;
u32 mfiStatus; u32 mfiStatus;
u32 last_seq_num; u32 last_seq_num;
......
...@@ -483,7 +483,7 @@ static int ...@@ -483,7 +483,7 @@ static int
megasas_check_reset_xscale(struct megasas_instance *instance, megasas_check_reset_xscale(struct megasas_instance *instance,
struct megasas_register_set __iomem *regs) struct megasas_register_set __iomem *regs)
{ {
if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) && if ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) &&
(le32_to_cpu(*instance->consumer) == (le32_to_cpu(*instance->consumer) ==
MEGASAS_ADPRESET_INPROG_SIGN)) MEGASAS_ADPRESET_INPROG_SIGN))
return 1; return 1;
...@@ -619,7 +619,7 @@ static int ...@@ -619,7 +619,7 @@ static int
megasas_check_reset_ppc(struct megasas_instance *instance, megasas_check_reset_ppc(struct megasas_instance *instance,
struct megasas_register_set __iomem *regs) struct megasas_register_set __iomem *regs)
{ {
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)
return 1; return 1;
return 0; return 0;
...@@ -756,7 +756,7 @@ static int ...@@ -756,7 +756,7 @@ static int
megasas_check_reset_skinny(struct megasas_instance *instance, megasas_check_reset_skinny(struct megasas_instance *instance,
struct megasas_register_set __iomem *regs) struct megasas_register_set __iomem *regs)
{ {
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)
return 1; return 1;
return 0; return 0;
...@@ -950,9 +950,8 @@ static int ...@@ -950,9 +950,8 @@ static int
megasas_check_reset_gen2(struct megasas_instance *instance, megasas_check_reset_gen2(struct megasas_instance *instance,
struct megasas_register_set __iomem *regs) struct megasas_register_set __iomem *regs)
{ {
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)
return 1; return 1;
}
return 0; return 0;
} }
...@@ -998,7 +997,7 @@ megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd) ...@@ -998,7 +997,7 @@ megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd)
frame_hdr->cmd_status = MFI_STAT_INVALID_STATUS; frame_hdr->cmd_status = MFI_STAT_INVALID_STATUS;
frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE); frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) || if ((atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) ||
(instance->instancet->issue_dcmd(instance, cmd))) { (instance->instancet->issue_dcmd(instance, cmd))) {
dev_err(&instance->pdev->dev, "Failed from %s %d\n", dev_err(&instance->pdev->dev, "Failed from %s %d\n",
__func__, __LINE__); __func__, __LINE__);
...@@ -1026,7 +1025,7 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance, ...@@ -1026,7 +1025,7 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance,
int ret = 0; int ret = 0;
cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) || if ((atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) ||
(instance->instancet->issue_dcmd(instance, cmd))) { (instance->instancet->issue_dcmd(instance, cmd))) {
dev_err(&instance->pdev->dev, "Failed from %s %d\n", dev_err(&instance->pdev->dev, "Failed from %s %d\n",
__func__, __LINE__); __func__, __LINE__);
...@@ -1090,7 +1089,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, ...@@ -1090,7 +1089,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
cmd->sync_cmd = 1; cmd->sync_cmd = 1;
cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) || if ((atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) ||
(instance->instancet->issue_dcmd(instance, cmd))) { (instance->instancet->issue_dcmd(instance, cmd))) {
dev_err(&instance->pdev->dev, "Failed from %s %d\n", dev_err(&instance->pdev->dev, "Failed from %s %d\n",
__func__, __LINE__); __func__, __LINE__);
...@@ -1653,7 +1652,6 @@ static int ...@@ -1653,7 +1652,6 @@ static int
megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
{ {
struct megasas_instance *instance; struct megasas_instance *instance;
unsigned long flags;
struct MR_PRIV_DEVICE *mr_device_priv_data; struct MR_PRIV_DEVICE *mr_device_priv_data;
instance = (struct megasas_instance *) instance = (struct megasas_instance *)
...@@ -1668,24 +1666,20 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) ...@@ -1668,24 +1666,20 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
if (instance->issuepend_done == 0) if (instance->issuepend_done == 0)
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
spin_lock_irqsave(&instance->hba_lock, flags);
/* Check for an mpio path and adjust behavior */ /* Check for an mpio path and adjust behavior */
if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) { if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) {
if (megasas_check_mpio_paths(instance, scmd) == if (megasas_check_mpio_paths(instance, scmd) ==
(DID_RESET << 16)) { (DID_RESET << 16)) {
spin_unlock_irqrestore(&instance->hba_lock, flags);
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} else { } else {
spin_unlock_irqrestore(&instance->hba_lock, flags);
scmd->result = DID_NO_CONNECT << 16; scmd->result = DID_NO_CONNECT << 16;
scmd->scsi_done(scmd); scmd->scsi_done(scmd);
return 0; return 0;
} }
} }
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
spin_unlock_irqrestore(&instance->hba_lock, flags);
scmd->result = DID_NO_CONNECT << 16; scmd->result = DID_NO_CONNECT << 16;
scmd->scsi_done(scmd); scmd->scsi_done(scmd);
return 0; return 0;
...@@ -1693,23 +1687,17 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) ...@@ -1693,23 +1687,17 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
mr_device_priv_data = scmd->device->hostdata; mr_device_priv_data = scmd->device->hostdata;
if (!mr_device_priv_data) { if (!mr_device_priv_data) {
spin_unlock_irqrestore(&instance->hba_lock, flags);
scmd->result = DID_NO_CONNECT << 16; scmd->result = DID_NO_CONNECT << 16;
scmd->scsi_done(scmd); scmd->scsi_done(scmd);
return 0; return 0;
} }
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)
spin_unlock_irqrestore(&instance->hba_lock, flags);
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
}
if (mr_device_priv_data->tm_busy) { if (mr_device_priv_data->tm_busy)
spin_unlock_irqrestore(&instance->hba_lock, flags);
return SCSI_MLQUEUE_DEVICE_BUSY; return SCSI_MLQUEUE_DEVICE_BUSY;
}
spin_unlock_irqrestore(&instance->hba_lock, flags);
scmd->result = 0; scmd->result = 0;
...@@ -1942,7 +1930,7 @@ static void megasas_complete_outstanding_ioctls(struct megasas_instance *instanc ...@@ -1942,7 +1930,7 @@ static void megasas_complete_outstanding_ioctls(struct megasas_instance *instanc
void megaraid_sas_kill_hba(struct megasas_instance *instance) void megaraid_sas_kill_hba(struct megasas_instance *instance)
{ {
/* Set critical error to block I/O & ioctls in case caller didn't */ /* Set critical error to block I/O & ioctls in case caller didn't */
instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);
/* Wait 1 second to ensure IO or ioctls in build have posted */ /* Wait 1 second to ensure IO or ioctls in build have posted */
msleep(1000); msleep(1000);
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
...@@ -2002,7 +1990,7 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr) ...@@ -2002,7 +1990,7 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
unsigned long flags; unsigned long flags;
/* If we have already declared adapter dead, donot complete cmds */ /* If we have already declared adapter dead, donot complete cmds */
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
return; return;
spin_lock_irqsave(&instance->completion_lock, flags); spin_lock_irqsave(&instance->completion_lock, flags);
...@@ -2071,7 +2059,7 @@ void megasas_do_ocr(struct megasas_instance *instance) ...@@ -2071,7 +2059,7 @@ void megasas_do_ocr(struct megasas_instance *instance)
*instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN); *instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN);
} }
instance->instancet->disable_intr(instance); instance->instancet->disable_intr(instance);
instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT);
instance->issuepend_done = 0; instance->issuepend_done = 0;
atomic_set(&instance->fw_outstanding, 0); atomic_set(&instance->fw_outstanding, 0);
...@@ -2470,18 +2458,14 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) ...@@ -2470,18 +2458,14 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
int i; int i;
u32 reset_index; u32 reset_index;
u32 wait_time = MEGASAS_RESET_WAIT_TIME; u32 wait_time = MEGASAS_RESET_WAIT_TIME;
u8 adprecovery;
unsigned long flags; unsigned long flags;
struct list_head clist_local; struct list_head clist_local;
struct megasas_cmd *reset_cmd; struct megasas_cmd *reset_cmd;
u32 fw_state; u32 fw_state;
u8 kill_adapter_flag; u8 kill_adapter_flag;
spin_lock_irqsave(&instance->hba_lock, flags);
adprecovery = instance->adprecovery;
spin_unlock_irqrestore(&instance->hba_lock, flags);
if (adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
INIT_LIST_HEAD(&clist_local); INIT_LIST_HEAD(&clist_local);
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
...@@ -2492,18 +2476,13 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) ...@@ -2492,18 +2476,13 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
dev_notice(&instance->pdev->dev, "HBA reset wait ...\n"); dev_notice(&instance->pdev->dev, "HBA reset wait ...\n");
for (i = 0; i < wait_time; i++) { for (i = 0; i < wait_time; i++) {
msleep(1000); msleep(1000);
spin_lock_irqsave(&instance->hba_lock, flags); if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL)
adprecovery = instance->adprecovery;
spin_unlock_irqrestore(&instance->hba_lock, flags);
if (adprecovery == MEGASAS_HBA_OPERATIONAL)
break; break;
} }
if (adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n"); dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n");
spin_lock_irqsave(&instance->hba_lock, flags); atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);
instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR;
spin_unlock_irqrestore(&instance->hba_lock, flags);
return FAILED; return FAILED;
} }
...@@ -2612,9 +2591,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) ...@@ -2612,9 +2591,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
&instance->reg_set->inbound_doorbell); &instance->reg_set->inbound_doorbell);
} }
megasas_dump_pending_frames(instance); megasas_dump_pending_frames(instance);
spin_lock_irqsave(&instance->hba_lock, flags); atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);
instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR;
spin_unlock_irqrestore(&instance->hba_lock, flags);
return FAILED; return FAILED;
} }
...@@ -2641,7 +2618,7 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd) ...@@ -2641,7 +2618,7 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n", scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n",
scmd->cmnd[0], scmd->retries); scmd->cmnd[0], scmd->retries);
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n"); dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n");
return FAILED; return FAILED;
} }
...@@ -3385,13 +3362,13 @@ process_fw_state_change_wq(struct work_struct *work) ...@@ -3385,13 +3362,13 @@ process_fw_state_change_wq(struct work_struct *work)
u32 wait; u32 wait;
unsigned long flags; unsigned long flags;
if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) { if (atomic_read(&instance->adprecovery) != MEGASAS_ADPRESET_SM_INFAULT) {
dev_notice(&instance->pdev->dev, "error, recovery st %x\n", dev_notice(&instance->pdev->dev, "error, recovery st %x\n",
instance->adprecovery); atomic_read(&instance->adprecovery));
return ; return ;
} }
if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) { if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) {
dev_notice(&instance->pdev->dev, "FW detected to be in fault" dev_notice(&instance->pdev->dev, "FW detected to be in fault"
"state, restarting it...\n"); "state, restarting it...\n");
...@@ -3434,7 +3411,7 @@ process_fw_state_change_wq(struct work_struct *work) ...@@ -3434,7 +3411,7 @@ process_fw_state_change_wq(struct work_struct *work)
megasas_issue_init_mfi(instance); megasas_issue_init_mfi(instance);
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
instance->adprecovery = MEGASAS_HBA_OPERATIONAL; atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
spin_unlock_irqrestore(&instance->hba_lock, flags); spin_unlock_irqrestore(&instance->hba_lock, flags);
instance->instancet->enable_intr(instance); instance->instancet->enable_intr(instance);
...@@ -3499,14 +3476,14 @@ megasas_deplete_reply_queue(struct megasas_instance *instance, ...@@ -3499,14 +3476,14 @@ megasas_deplete_reply_queue(struct megasas_instance *instance,
instance->instancet->disable_intr(instance); instance->instancet->disable_intr(instance);
instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT);
instance->issuepend_done = 0; instance->issuepend_done = 0;
atomic_set(&instance->fw_outstanding, 0); atomic_set(&instance->fw_outstanding, 0);
megasas_internal_reset_defer_cmds(instance); megasas_internal_reset_defer_cmds(instance);
dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n", dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n",
fw_state, instance->adprecovery); fw_state, atomic_read(&instance->adprecovery));
schedule_work(&instance->work_init); schedule_work(&instance->work_init);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -5795,7 +5772,7 @@ static int megasas_probe_one(struct pci_dev *pdev, ...@@ -5795,7 +5772,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
instance->flag_ieee = 0; instance->flag_ieee = 0;
instance->ev = NULL; instance->ev = NULL;
instance->issuepend_done = 1; instance->issuepend_done = 1;
instance->adprecovery = MEGASAS_HBA_OPERATIONAL; atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
instance->is_imr = 0; instance->is_imr = 0;
instance->evt_detail = pci_alloc_consistent(pdev, instance->evt_detail = pci_alloc_consistent(pdev,
...@@ -5974,7 +5951,7 @@ static void megasas_flush_cache(struct megasas_instance *instance) ...@@ -5974,7 +5951,7 @@ static void megasas_flush_cache(struct megasas_instance *instance)
struct megasas_cmd *cmd; struct megasas_cmd *cmd;
struct megasas_dcmd_frame *dcmd; struct megasas_dcmd_frame *dcmd;
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
return; return;
cmd = megasas_get_cmd(instance); cmd = megasas_get_cmd(instance);
...@@ -6017,7 +5994,7 @@ static void megasas_shutdown_controller(struct megasas_instance *instance, ...@@ -6017,7 +5994,7 @@ static void megasas_shutdown_controller(struct megasas_instance *instance,
struct megasas_cmd *cmd; struct megasas_cmd *cmd;
struct megasas_dcmd_frame *dcmd; struct megasas_dcmd_frame *dcmd;
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
return; return;
cmd = megasas_get_cmd(instance); cmd = megasas_get_cmd(instance);
...@@ -6462,7 +6439,7 @@ static int megasas_set_crash_dump_params_ioctl(struct megasas_cmd *cmd) ...@@ -6462,7 +6439,7 @@ static int megasas_set_crash_dump_params_ioctl(struct megasas_cmd *cmd)
for (i = 0; i < megasas_mgmt_info.max_index; i++) { for (i = 0; i < megasas_mgmt_info.max_index; i++) {
local_instance = megasas_mgmt_info.instance[i]; local_instance = megasas_mgmt_info.instance[i];
if (local_instance && local_instance->crash_dump_drv_support) { if (local_instance && local_instance->crash_dump_drv_support) {
if ((local_instance->adprecovery == if ((atomic_read(&local_instance->adprecovery) ==
MEGASAS_HBA_OPERATIONAL) && MEGASAS_HBA_OPERATIONAL) &&
!megasas_set_crash_dump_params(local_instance, !megasas_set_crash_dump_params(local_instance,
crash_support)) { crash_support)) {
...@@ -6710,7 +6687,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) ...@@ -6710,7 +6687,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
goto out_kfree_ioc; goto out_kfree_ioc;
} }
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
dev_err(&instance->pdev->dev, "Controller in crit error\n"); dev_err(&instance->pdev->dev, "Controller in crit error\n");
error = -ENODEV; error = -ENODEV;
goto out_kfree_ioc; goto out_kfree_ioc;
...@@ -6729,7 +6706,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) ...@@ -6729,7 +6706,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
for (i = 0; i < wait_time; i++) { for (i = 0; i < wait_time; i++) {
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, flags); spin_unlock_irqrestore(&instance->hba_lock, flags);
break; break;
} }
...@@ -6744,7 +6721,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) ...@@ -6744,7 +6721,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
} }
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, flags); spin_unlock_irqrestore(&instance->hba_lock, flags);
dev_err(&instance->pdev->dev, "timed out while" dev_err(&instance->pdev->dev, "timed out while"
...@@ -6786,7 +6763,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) ...@@ -6786,7 +6763,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
if (!instance) if (!instance)
return -ENODEV; return -ENODEV;
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
return -ENODEV; return -ENODEV;
} }
...@@ -6797,7 +6774,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) ...@@ -6797,7 +6774,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
for (i = 0; i < wait_time; i++) { for (i = 0; i < wait_time; i++) {
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, spin_unlock_irqrestore(&instance->hba_lock,
flags); flags);
break; break;
...@@ -6814,7 +6791,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) ...@@ -6814,7 +6791,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
} }
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
spin_unlock_irqrestore(&instance->hba_lock, flags); spin_unlock_irqrestore(&instance->hba_lock, flags);
dev_err(&instance->pdev->dev, "timed out while waiting" dev_err(&instance->pdev->dev, "timed out while waiting"
"for HBA to recover\n"); "for HBA to recover\n");
......
...@@ -2246,7 +2246,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) ...@@ -2246,7 +2246,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
fusion = instance->ctrl_context; fusion = instance->ctrl_context;
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
return IRQ_HANDLED; return IRQ_HANDLED;
desc = fusion->reply_frames_desc[MSIxIndex] + desc = fusion->reply_frames_desc[MSIxIndex] +
...@@ -2413,7 +2413,7 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) ...@@ -2413,7 +2413,7 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr)
/* If we have already declared adapter dead, donot complete cmds */ /* If we have already declared adapter dead, donot complete cmds */
spin_lock_irqsave(&instance->hba_lock, flags); spin_lock_irqsave(&instance->hba_lock, flags);
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
spin_unlock_irqrestore(&instance->hba_lock, flags); spin_unlock_irqrestore(&instance->hba_lock, flags);
return; return;
} }
...@@ -3197,7 +3197,7 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd) ...@@ -3197,7 +3197,7 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd)
instance = (struct megasas_instance *)scmd->device->host->hostdata; instance = (struct megasas_instance *)scmd->device->host->hostdata;
fusion = instance->ctrl_context; fusion = instance->ctrl_context;
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL,"
"SCSI host:%d\n", instance->host->host_no); "SCSI host:%d\n", instance->host->host_no);
ret = FAILED; ret = FAILED;
...@@ -3277,7 +3277,7 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd) ...@@ -3277,7 +3277,7 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
instance = (struct megasas_instance *)scmd->device->host->hostdata; instance = (struct megasas_instance *)scmd->device->host->hostdata;
fusion = instance->ctrl_context; fusion = instance->ctrl_context;
if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL,"
"SCSI host:%d\n", instance->host->host_no); "SCSI host:%d\n", instance->host->host_no);
ret = FAILED; ret = FAILED;
...@@ -3366,7 +3366,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3366,7 +3366,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
mutex_lock(&instance->reset_mutex); mutex_lock(&instance->reset_mutex);
if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
dev_warn(&instance->pdev->dev, "Hardware critical error, " dev_warn(&instance->pdev->dev, "Hardware critical error, "
"returning FAILED for scsi%d.\n", "returning FAILED for scsi%d.\n",
instance->host->host_no); instance->host->host_no);
...@@ -3381,7 +3381,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3381,7 +3381,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
instance->crash_dump_app_support && reason) { instance->crash_dump_app_support && reason) {
dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, " dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, "
"forcibly FAULT Firmware\n"); "forcibly FAULT Firmware\n");
instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT);
status_reg = readl(&instance->reg_set->doorbell); status_reg = readl(&instance->reg_set->doorbell);
writel(status_reg | MFI_STATE_FORCE_OCR, writel(status_reg | MFI_STATE_FORCE_OCR,
&instance->reg_set->doorbell); &instance->reg_set->doorbell);
...@@ -3393,10 +3393,10 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3393,10 +3393,10 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
dev_dbg(&instance->pdev->dev, "waiting for [%d] " dev_dbg(&instance->pdev->dev, "waiting for [%d] "
"seconds for crash dump collection and OCR " "seconds for crash dump collection and OCR "
"to be done\n", (io_timeout_in_crash_mode * 3)); "to be done\n", (io_timeout_in_crash_mode * 3));
} while ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) && } while ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) &&
(io_timeout_in_crash_mode < 80)); (io_timeout_in_crash_mode < 80));
if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) {
dev_info(&instance->pdev->dev, "OCR done for IO " dev_info(&instance->pdev->dev, "OCR done for IO "
"timeout case\n"); "timeout case\n");
retval = SUCCESS; retval = SUCCESS;
...@@ -3413,14 +3413,14 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3413,14 +3413,14 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
if (instance->requestorId && !instance->skip_heartbeat_timer_del) if (instance->requestorId && !instance->skip_heartbeat_timer_del)
del_timer_sync(&instance->sriov_heartbeat_timer); del_timer_sync(&instance->sriov_heartbeat_timer);
set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);
instance->adprecovery = MEGASAS_ADPRESET_SM_POLLING; atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_POLLING);
instance->instancet->disable_intr(instance); instance->instancet->disable_intr(instance);
msleep(1000); msleep(1000);
/* First try waiting for commands to complete */ /* First try waiting for commands to complete */
if (megasas_wait_for_outstanding_fusion(instance, reason, if (megasas_wait_for_outstanding_fusion(instance, reason,
&convert)) { &convert)) {
instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT);
dev_warn(&instance->pdev->dev, "resetting fusion " dev_warn(&instance->pdev->dev, "resetting fusion "
"adapter scsi%d.\n", instance->host->host_no); "adapter scsi%d.\n", instance->host->host_no);
if (convert) if (convert)
...@@ -3503,8 +3503,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3503,8 +3503,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
status_reg); status_reg);
megaraid_sas_kill_hba(instance); megaraid_sas_kill_hba(instance);
instance->skip_heartbeat_timer_del = 1; instance->skip_heartbeat_timer_del = 1;
instance->adprecovery = atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);
MEGASAS_HW_CRITICAL_ERROR;
retval = FAILED; retval = FAILED;
goto out; goto out;
} }
...@@ -3563,7 +3562,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3563,7 +3562,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
clear_bit(MEGASAS_FUSION_IN_RESET, clear_bit(MEGASAS_FUSION_IN_RESET,
&instance->reset_flags); &instance->reset_flags);
instance->instancet->enable_intr(instance); instance->instancet->enable_intr(instance);
instance->adprecovery = MEGASAS_HBA_OPERATIONAL; atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
/* Restart SR-IOV heartbeat */ /* Restart SR-IOV heartbeat */
if (instance->requestorId) { if (instance->requestorId) {
...@@ -3608,7 +3607,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) ...@@ -3608,7 +3607,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
} }
clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);
instance->instancet->enable_intr(instance); instance->instancet->enable_intr(instance);
instance->adprecovery = MEGASAS_HBA_OPERATIONAL; atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
} }
out: out:
clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);
......
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