diff options
author | Sumit Saxena <sumit.saxena@avagotech.com> | 2016-01-28 10:34:32 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-02-23 21:27:02 -0500 |
commit | 8a01a41d864771fbc3cfc80a9629e06189479cce (patch) | |
tree | 00519c8d33a5a6a6160c39bedf76aab5f5ed8f79 /drivers/scsi | |
parent | 52b62ac7c66e1a11eb8b3e3b0212847749af3b2d (diff) |
megaraid_sas: Make adprecovery variable atomic
Make instance->adprecovery variable atomic and removes hba_lock spinlock
while accessing instance->adprecovery.
Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.h | 2 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_base.c | 95 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_fusion.c | 27 |
3 files changed, 50 insertions, 74 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index c8d25a739d38..3e92f20b3d62 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h | |||
@@ -2101,7 +2101,7 @@ struct megasas_instance { | |||
2101 | u16 drv_supported_vd_count; | 2101 | u16 drv_supported_vd_count; |
2102 | u16 drv_supported_pd_count; | 2102 | u16 drv_supported_pd_count; |
2103 | 2103 | ||
2104 | u8 adprecovery; | 2104 | atomic_t adprecovery; |
2105 | unsigned long last_time; | 2105 | unsigned long last_time; |
2106 | u32 mfiStatus; | 2106 | u32 mfiStatus; |
2107 | u32 last_seq_num; | 2107 | u32 last_seq_num; |
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 961c024d11ca..1bd5da49b897 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
@@ -483,7 +483,7 @@ static int | |||
483 | megasas_check_reset_xscale(struct megasas_instance *instance, | 483 | megasas_check_reset_xscale(struct megasas_instance *instance, |
484 | struct megasas_register_set __iomem *regs) | 484 | struct megasas_register_set __iomem *regs) |
485 | { | 485 | { |
486 | if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) && | 486 | if ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) && |
487 | (le32_to_cpu(*instance->consumer) == | 487 | (le32_to_cpu(*instance->consumer) == |
488 | MEGASAS_ADPRESET_INPROG_SIGN)) | 488 | MEGASAS_ADPRESET_INPROG_SIGN)) |
489 | return 1; | 489 | return 1; |
@@ -619,7 +619,7 @@ static int | |||
619 | megasas_check_reset_ppc(struct megasas_instance *instance, | 619 | megasas_check_reset_ppc(struct megasas_instance *instance, |
620 | struct megasas_register_set __iomem *regs) | 620 | struct megasas_register_set __iomem *regs) |
621 | { | 621 | { |
622 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) | 622 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) |
623 | return 1; | 623 | return 1; |
624 | 624 | ||
625 | return 0; | 625 | return 0; |
@@ -756,7 +756,7 @@ static int | |||
756 | megasas_check_reset_skinny(struct megasas_instance *instance, | 756 | megasas_check_reset_skinny(struct megasas_instance *instance, |
757 | struct megasas_register_set __iomem *regs) | 757 | struct megasas_register_set __iomem *regs) |
758 | { | 758 | { |
759 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) | 759 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) |
760 | return 1; | 760 | return 1; |
761 | 761 | ||
762 | return 0; | 762 | return 0; |
@@ -950,9 +950,8 @@ static int | |||
950 | megasas_check_reset_gen2(struct megasas_instance *instance, | 950 | megasas_check_reset_gen2(struct megasas_instance *instance, |
951 | struct megasas_register_set __iomem *regs) | 951 | struct megasas_register_set __iomem *regs) |
952 | { | 952 | { |
953 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { | 953 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) |
954 | return 1; | 954 | return 1; |
955 | } | ||
956 | 955 | ||
957 | return 0; | 956 | return 0; |
958 | } | 957 | } |
@@ -998,7 +997,7 @@ megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd) | |||
998 | frame_hdr->cmd_status = MFI_STAT_INVALID_STATUS; | 997 | frame_hdr->cmd_status = MFI_STAT_INVALID_STATUS; |
999 | frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE); | 998 | frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE); |
1000 | 999 | ||
1001 | if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) || | 1000 | if ((atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) || |
1002 | (instance->instancet->issue_dcmd(instance, cmd))) { | 1001 | (instance->instancet->issue_dcmd(instance, cmd))) { |
1003 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", | 1002 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", |
1004 | __func__, __LINE__); | 1003 | __func__, __LINE__); |
@@ -1026,7 +1025,7 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance, | |||
1026 | int ret = 0; | 1025 | int ret = 0; |
1027 | cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; | 1026 | cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; |
1028 | 1027 | ||
1029 | if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) || | 1028 | if ((atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) || |
1030 | (instance->instancet->issue_dcmd(instance, cmd))) { | 1029 | (instance->instancet->issue_dcmd(instance, cmd))) { |
1031 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", | 1030 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", |
1032 | __func__, __LINE__); | 1031 | __func__, __LINE__); |
@@ -1090,7 +1089,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance, | |||
1090 | cmd->sync_cmd = 1; | 1089 | cmd->sync_cmd = 1; |
1091 | cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; | 1090 | cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS; |
1092 | 1091 | ||
1093 | if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) || | 1092 | if ((atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) || |
1094 | (instance->instancet->issue_dcmd(instance, cmd))) { | 1093 | (instance->instancet->issue_dcmd(instance, cmd))) { |
1095 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", | 1094 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", |
1096 | __func__, __LINE__); | 1095 | __func__, __LINE__); |
@@ -1653,7 +1652,6 @@ static int | |||
1653 | megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) | 1652 | megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) |
1654 | { | 1653 | { |
1655 | struct megasas_instance *instance; | 1654 | struct megasas_instance *instance; |
1656 | unsigned long flags; | ||
1657 | struct MR_PRIV_DEVICE *mr_device_priv_data; | 1655 | struct MR_PRIV_DEVICE *mr_device_priv_data; |
1658 | 1656 | ||
1659 | instance = (struct megasas_instance *) | 1657 | instance = (struct megasas_instance *) |
@@ -1668,24 +1666,20 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) | |||
1668 | if (instance->issuepend_done == 0) | 1666 | if (instance->issuepend_done == 0) |
1669 | return SCSI_MLQUEUE_HOST_BUSY; | 1667 | return SCSI_MLQUEUE_HOST_BUSY; |
1670 | 1668 | ||
1671 | spin_lock_irqsave(&instance->hba_lock, flags); | ||
1672 | 1669 | ||
1673 | /* Check for an mpio path and adjust behavior */ | 1670 | /* Check for an mpio path and adjust behavior */ |
1674 | if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) { | 1671 | if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) { |
1675 | if (megasas_check_mpio_paths(instance, scmd) == | 1672 | if (megasas_check_mpio_paths(instance, scmd) == |
1676 | (DID_RESET << 16)) { | 1673 | (DID_RESET << 16)) { |
1677 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1678 | return SCSI_MLQUEUE_HOST_BUSY; | 1674 | return SCSI_MLQUEUE_HOST_BUSY; |
1679 | } else { | 1675 | } else { |
1680 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1681 | scmd->result = DID_NO_CONNECT << 16; | 1676 | scmd->result = DID_NO_CONNECT << 16; |
1682 | scmd->scsi_done(scmd); | 1677 | scmd->scsi_done(scmd); |
1683 | return 0; | 1678 | return 0; |
1684 | } | 1679 | } |
1685 | } | 1680 | } |
1686 | 1681 | ||
1687 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { | 1682 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { |
1688 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1689 | scmd->result = DID_NO_CONNECT << 16; | 1683 | scmd->result = DID_NO_CONNECT << 16; |
1690 | scmd->scsi_done(scmd); | 1684 | scmd->scsi_done(scmd); |
1691 | return 0; | 1685 | return 0; |
@@ -1693,23 +1687,17 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) | |||
1693 | 1687 | ||
1694 | mr_device_priv_data = scmd->device->hostdata; | 1688 | mr_device_priv_data = scmd->device->hostdata; |
1695 | if (!mr_device_priv_data) { | 1689 | if (!mr_device_priv_data) { |
1696 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1697 | scmd->result = DID_NO_CONNECT << 16; | 1690 | scmd->result = DID_NO_CONNECT << 16; |
1698 | scmd->scsi_done(scmd); | 1691 | scmd->scsi_done(scmd); |
1699 | return 0; | 1692 | return 0; |
1700 | } | 1693 | } |
1701 | 1694 | ||
1702 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { | 1695 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) |
1703 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1704 | return SCSI_MLQUEUE_HOST_BUSY; | 1696 | return SCSI_MLQUEUE_HOST_BUSY; |
1705 | } | ||
1706 | 1697 | ||
1707 | if (mr_device_priv_data->tm_busy) { | 1698 | if (mr_device_priv_data->tm_busy) |
1708 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1709 | return SCSI_MLQUEUE_DEVICE_BUSY; | 1699 | return SCSI_MLQUEUE_DEVICE_BUSY; |
1710 | } | ||
1711 | 1700 | ||
1712 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
1713 | 1701 | ||
1714 | scmd->result = 0; | 1702 | scmd->result = 0; |
1715 | 1703 | ||
@@ -1942,7 +1930,7 @@ static void megasas_complete_outstanding_ioctls(struct megasas_instance *instanc | |||
1942 | void megaraid_sas_kill_hba(struct megasas_instance *instance) | 1930 | void megaraid_sas_kill_hba(struct megasas_instance *instance) |
1943 | { | 1931 | { |
1944 | /* Set critical error to block I/O & ioctls in case caller didn't */ | 1932 | /* Set critical error to block I/O & ioctls in case caller didn't */ |
1945 | instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; | 1933 | atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); |
1946 | /* Wait 1 second to ensure IO or ioctls in build have posted */ | 1934 | /* Wait 1 second to ensure IO or ioctls in build have posted */ |
1947 | msleep(1000); | 1935 | msleep(1000); |
1948 | if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || | 1936 | if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || |
@@ -2002,7 +1990,7 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr) | |||
2002 | unsigned long flags; | 1990 | unsigned long flags; |
2003 | 1991 | ||
2004 | /* If we have already declared adapter dead, donot complete cmds */ | 1992 | /* If we have already declared adapter dead, donot complete cmds */ |
2005 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) | 1993 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) |
2006 | return; | 1994 | return; |
2007 | 1995 | ||
2008 | spin_lock_irqsave(&instance->completion_lock, flags); | 1996 | spin_lock_irqsave(&instance->completion_lock, flags); |
@@ -2071,7 +2059,7 @@ void megasas_do_ocr(struct megasas_instance *instance) | |||
2071 | *instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN); | 2059 | *instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN); |
2072 | } | 2060 | } |
2073 | instance->instancet->disable_intr(instance); | 2061 | instance->instancet->disable_intr(instance); |
2074 | instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; | 2062 | atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); |
2075 | instance->issuepend_done = 0; | 2063 | instance->issuepend_done = 0; |
2076 | 2064 | ||
2077 | atomic_set(&instance->fw_outstanding, 0); | 2065 | atomic_set(&instance->fw_outstanding, 0); |
@@ -2470,18 +2458,14 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) | |||
2470 | int i; | 2458 | int i; |
2471 | u32 reset_index; | 2459 | u32 reset_index; |
2472 | u32 wait_time = MEGASAS_RESET_WAIT_TIME; | 2460 | u32 wait_time = MEGASAS_RESET_WAIT_TIME; |
2473 | u8 adprecovery; | ||
2474 | unsigned long flags; | 2461 | unsigned long flags; |
2475 | struct list_head clist_local; | 2462 | struct list_head clist_local; |
2476 | struct megasas_cmd *reset_cmd; | 2463 | struct megasas_cmd *reset_cmd; |
2477 | u32 fw_state; | 2464 | u32 fw_state; |
2478 | u8 kill_adapter_flag; | 2465 | u8 kill_adapter_flag; |
2479 | 2466 | ||
2480 | spin_lock_irqsave(&instance->hba_lock, flags); | ||
2481 | adprecovery = instance->adprecovery; | ||
2482 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
2483 | 2467 | ||
2484 | if (adprecovery != MEGASAS_HBA_OPERATIONAL) { | 2468 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { |
2485 | 2469 | ||
2486 | INIT_LIST_HEAD(&clist_local); | 2470 | INIT_LIST_HEAD(&clist_local); |
2487 | spin_lock_irqsave(&instance->hba_lock, flags); | 2471 | spin_lock_irqsave(&instance->hba_lock, flags); |
@@ -2492,18 +2476,13 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) | |||
2492 | dev_notice(&instance->pdev->dev, "HBA reset wait ...\n"); | 2476 | dev_notice(&instance->pdev->dev, "HBA reset wait ...\n"); |
2493 | for (i = 0; i < wait_time; i++) { | 2477 | for (i = 0; i < wait_time; i++) { |
2494 | msleep(1000); | 2478 | msleep(1000); |
2495 | spin_lock_irqsave(&instance->hba_lock, flags); | 2479 | if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) |
2496 | adprecovery = instance->adprecovery; | ||
2497 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
2498 | if (adprecovery == MEGASAS_HBA_OPERATIONAL) | ||
2499 | break; | 2480 | break; |
2500 | } | 2481 | } |
2501 | 2482 | ||
2502 | if (adprecovery != MEGASAS_HBA_OPERATIONAL) { | 2483 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { |
2503 | dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n"); | 2484 | dev_notice(&instance->pdev->dev, "reset: Stopping HBA.\n"); |
2504 | spin_lock_irqsave(&instance->hba_lock, flags); | 2485 | atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); |
2505 | instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; | ||
2506 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
2507 | return FAILED; | 2486 | return FAILED; |
2508 | } | 2487 | } |
2509 | 2488 | ||
@@ -2612,9 +2591,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) | |||
2612 | &instance->reg_set->inbound_doorbell); | 2591 | &instance->reg_set->inbound_doorbell); |
2613 | } | 2592 | } |
2614 | megasas_dump_pending_frames(instance); | 2593 | megasas_dump_pending_frames(instance); |
2615 | spin_lock_irqsave(&instance->hba_lock, flags); | 2594 | atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); |
2616 | instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR; | ||
2617 | spin_unlock_irqrestore(&instance->hba_lock, flags); | ||
2618 | return FAILED; | 2595 | return FAILED; |
2619 | } | 2596 | } |
2620 | 2597 | ||
@@ -2641,7 +2618,7 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd) | |||
2641 | scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n", | 2618 | scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n", |
2642 | scmd->cmnd[0], scmd->retries); | 2619 | scmd->cmnd[0], scmd->retries); |
2643 | 2620 | ||
2644 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { | 2621 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { |
2645 | dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n"); | 2622 | dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n"); |
2646 | return FAILED; | 2623 | return FAILED; |
2647 | } | 2624 | } |
@@ -3385,13 +3362,13 @@ process_fw_state_change_wq(struct work_struct *work) | |||
3385 | u32 wait; | 3362 | u32 wait; |
3386 | unsigned long flags; | 3363 | unsigned long flags; |
3387 | 3364 | ||
3388 | if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) { | 3365 | if (atomic_read(&instance->adprecovery) != MEGASAS_ADPRESET_SM_INFAULT) { |
3389 | dev_notice(&instance->pdev->dev, "error, recovery st %x\n", | 3366 | dev_notice(&instance->pdev->dev, "error, recovery st %x\n", |
3390 | instance->adprecovery); | 3367 | atomic_read(&instance->adprecovery)); |
3391 | return ; | 3368 | return ; |
3392 | } | 3369 | } |
3393 | 3370 | ||
3394 | if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) { | 3371 | if (atomic_read(&instance->adprecovery) == MEGASAS_ADPRESET_SM_INFAULT) { |
3395 | dev_notice(&instance->pdev->dev, "FW detected to be in fault" | 3372 | dev_notice(&instance->pdev->dev, "FW detected to be in fault" |
3396 | "state, restarting it...\n"); | 3373 | "state, restarting it...\n"); |
3397 | 3374 | ||
@@ -3434,7 +3411,7 @@ process_fw_state_change_wq(struct work_struct *work) | |||
3434 | megasas_issue_init_mfi(instance); | 3411 | megasas_issue_init_mfi(instance); |
3435 | 3412 | ||
3436 | spin_lock_irqsave(&instance->hba_lock, flags); | 3413 | spin_lock_irqsave(&instance->hba_lock, flags); |
3437 | instance->adprecovery = MEGASAS_HBA_OPERATIONAL; | 3414 | atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); |
3438 | spin_unlock_irqrestore(&instance->hba_lock, flags); | 3415 | spin_unlock_irqrestore(&instance->hba_lock, flags); |
3439 | instance->instancet->enable_intr(instance); | 3416 | instance->instancet->enable_intr(instance); |
3440 | 3417 | ||
@@ -3499,14 +3476,14 @@ megasas_deplete_reply_queue(struct megasas_instance *instance, | |||
3499 | 3476 | ||
3500 | 3477 | ||
3501 | instance->instancet->disable_intr(instance); | 3478 | instance->instancet->disable_intr(instance); |
3502 | instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; | 3479 | atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); |
3503 | instance->issuepend_done = 0; | 3480 | instance->issuepend_done = 0; |
3504 | 3481 | ||
3505 | atomic_set(&instance->fw_outstanding, 0); | 3482 | atomic_set(&instance->fw_outstanding, 0); |
3506 | megasas_internal_reset_defer_cmds(instance); | 3483 | megasas_internal_reset_defer_cmds(instance); |
3507 | 3484 | ||
3508 | dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n", | 3485 | dev_notice(&instance->pdev->dev, "fwState=%x, stage:%d\n", |
3509 | fw_state, instance->adprecovery); | 3486 | fw_state, atomic_read(&instance->adprecovery)); |
3510 | 3487 | ||
3511 | schedule_work(&instance->work_init); | 3488 | schedule_work(&instance->work_init); |
3512 | return IRQ_HANDLED; | 3489 | return IRQ_HANDLED; |
@@ -5795,7 +5772,7 @@ static int megasas_probe_one(struct pci_dev *pdev, | |||
5795 | instance->flag_ieee = 0; | 5772 | instance->flag_ieee = 0; |
5796 | instance->ev = NULL; | 5773 | instance->ev = NULL; |
5797 | instance->issuepend_done = 1; | 5774 | instance->issuepend_done = 1; |
5798 | instance->adprecovery = MEGASAS_HBA_OPERATIONAL; | 5775 | atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); |
5799 | instance->is_imr = 0; | 5776 | instance->is_imr = 0; |
5800 | 5777 | ||
5801 | instance->evt_detail = pci_alloc_consistent(pdev, | 5778 | instance->evt_detail = pci_alloc_consistent(pdev, |
@@ -5974,7 +5951,7 @@ static void megasas_flush_cache(struct megasas_instance *instance) | |||
5974 | struct megasas_cmd *cmd; | 5951 | struct megasas_cmd *cmd; |
5975 | struct megasas_dcmd_frame *dcmd; | 5952 | struct megasas_dcmd_frame *dcmd; |
5976 | 5953 | ||
5977 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) | 5954 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) |
5978 | return; | 5955 | return; |
5979 | 5956 | ||
5980 | cmd = megasas_get_cmd(instance); | 5957 | cmd = megasas_get_cmd(instance); |
@@ -6017,7 +5994,7 @@ static void megasas_shutdown_controller(struct megasas_instance *instance, | |||
6017 | struct megasas_cmd *cmd; | 5994 | struct megasas_cmd *cmd; |
6018 | struct megasas_dcmd_frame *dcmd; | 5995 | struct megasas_dcmd_frame *dcmd; |
6019 | 5996 | ||
6020 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) | 5997 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) |
6021 | return; | 5998 | return; |
6022 | 5999 | ||
6023 | cmd = megasas_get_cmd(instance); | 6000 | cmd = megasas_get_cmd(instance); |
@@ -6462,7 +6439,7 @@ static int megasas_set_crash_dump_params_ioctl(struct megasas_cmd *cmd) | |||
6462 | for (i = 0; i < megasas_mgmt_info.max_index; i++) { | 6439 | for (i = 0; i < megasas_mgmt_info.max_index; i++) { |
6463 | local_instance = megasas_mgmt_info.instance[i]; | 6440 | local_instance = megasas_mgmt_info.instance[i]; |
6464 | if (local_instance && local_instance->crash_dump_drv_support) { | 6441 | if (local_instance && local_instance->crash_dump_drv_support) { |
6465 | if ((local_instance->adprecovery == | 6442 | if ((atomic_read(&local_instance->adprecovery) == |
6466 | MEGASAS_HBA_OPERATIONAL) && | 6443 | MEGASAS_HBA_OPERATIONAL) && |
6467 | !megasas_set_crash_dump_params(local_instance, | 6444 | !megasas_set_crash_dump_params(local_instance, |
6468 | crash_support)) { | 6445 | crash_support)) { |
@@ -6710,7 +6687,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) | |||
6710 | goto out_kfree_ioc; | 6687 | goto out_kfree_ioc; |
6711 | } | 6688 | } |
6712 | 6689 | ||
6713 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { | 6690 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { |
6714 | dev_err(&instance->pdev->dev, "Controller in crit error\n"); | 6691 | dev_err(&instance->pdev->dev, "Controller in crit error\n"); |
6715 | error = -ENODEV; | 6692 | error = -ENODEV; |
6716 | goto out_kfree_ioc; | 6693 | goto out_kfree_ioc; |
@@ -6729,7 +6706,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) | |||
6729 | for (i = 0; i < wait_time; i++) { | 6706 | for (i = 0; i < wait_time; i++) { |
6730 | 6707 | ||
6731 | spin_lock_irqsave(&instance->hba_lock, flags); | 6708 | spin_lock_irqsave(&instance->hba_lock, flags); |
6732 | if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { | 6709 | if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { |
6733 | spin_unlock_irqrestore(&instance->hba_lock, flags); | 6710 | spin_unlock_irqrestore(&instance->hba_lock, flags); |
6734 | break; | 6711 | break; |
6735 | } | 6712 | } |
@@ -6744,7 +6721,7 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg) | |||
6744 | } | 6721 | } |
6745 | 6722 | ||
6746 | spin_lock_irqsave(&instance->hba_lock, flags); | 6723 | spin_lock_irqsave(&instance->hba_lock, flags); |
6747 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { | 6724 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { |
6748 | spin_unlock_irqrestore(&instance->hba_lock, flags); | 6725 | spin_unlock_irqrestore(&instance->hba_lock, flags); |
6749 | 6726 | ||
6750 | dev_err(&instance->pdev->dev, "timed out while" | 6727 | 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 | if (!instance) | 6763 | if (!instance) |
6787 | return -ENODEV; | 6764 | return -ENODEV; |
6788 | 6765 | ||
6789 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { | 6766 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { |
6790 | return -ENODEV; | 6767 | return -ENODEV; |
6791 | } | 6768 | } |
6792 | 6769 | ||
@@ -6797,7 +6774,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) | |||
6797 | for (i = 0; i < wait_time; i++) { | 6774 | for (i = 0; i < wait_time; i++) { |
6798 | 6775 | ||
6799 | spin_lock_irqsave(&instance->hba_lock, flags); | 6776 | spin_lock_irqsave(&instance->hba_lock, flags); |
6800 | if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { | 6777 | if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { |
6801 | spin_unlock_irqrestore(&instance->hba_lock, | 6778 | spin_unlock_irqrestore(&instance->hba_lock, |
6802 | flags); | 6779 | flags); |
6803 | break; | 6780 | break; |
@@ -6814,7 +6791,7 @@ static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg) | |||
6814 | } | 6791 | } |
6815 | 6792 | ||
6816 | spin_lock_irqsave(&instance->hba_lock, flags); | 6793 | spin_lock_irqsave(&instance->hba_lock, flags); |
6817 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { | 6794 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { |
6818 | spin_unlock_irqrestore(&instance->hba_lock, flags); | 6795 | spin_unlock_irqrestore(&instance->hba_lock, flags); |
6819 | dev_err(&instance->pdev->dev, "timed out while waiting" | 6796 | dev_err(&instance->pdev->dev, "timed out while waiting" |
6820 | "for HBA to recover\n"); | 6797 | "for HBA to recover\n"); |
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 2c4912f68225..64926f7ef119 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c | |||
@@ -2246,7 +2246,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex) | |||
2246 | 2246 | ||
2247 | fusion = instance->ctrl_context; | 2247 | fusion = instance->ctrl_context; |
2248 | 2248 | ||
2249 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) | 2249 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) |
2250 | return IRQ_HANDLED; | 2250 | return IRQ_HANDLED; |
2251 | 2251 | ||
2252 | desc = fusion->reply_frames_desc[MSIxIndex] + | 2252 | desc = fusion->reply_frames_desc[MSIxIndex] + |
@@ -2413,7 +2413,7 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) | |||
2413 | 2413 | ||
2414 | /* If we have already declared adapter dead, donot complete cmds */ | 2414 | /* If we have already declared adapter dead, donot complete cmds */ |
2415 | spin_lock_irqsave(&instance->hba_lock, flags); | 2415 | spin_lock_irqsave(&instance->hba_lock, flags); |
2416 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { | 2416 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { |
2417 | spin_unlock_irqrestore(&instance->hba_lock, flags); | 2417 | spin_unlock_irqrestore(&instance->hba_lock, flags); |
2418 | return; | 2418 | return; |
2419 | } | 2419 | } |
@@ -3197,7 +3197,7 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd) | |||
3197 | instance = (struct megasas_instance *)scmd->device->host->hostdata; | 3197 | instance = (struct megasas_instance *)scmd->device->host->hostdata; |
3198 | fusion = instance->ctrl_context; | 3198 | fusion = instance->ctrl_context; |
3199 | 3199 | ||
3200 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { | 3200 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { |
3201 | dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," | 3201 | dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," |
3202 | "SCSI host:%d\n", instance->host->host_no); | 3202 | "SCSI host:%d\n", instance->host->host_no); |
3203 | ret = FAILED; | 3203 | ret = FAILED; |
@@ -3277,7 +3277,7 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd) | |||
3277 | instance = (struct megasas_instance *)scmd->device->host->hostdata; | 3277 | instance = (struct megasas_instance *)scmd->device->host->hostdata; |
3278 | fusion = instance->ctrl_context; | 3278 | fusion = instance->ctrl_context; |
3279 | 3279 | ||
3280 | if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) { | 3280 | if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) { |
3281 | dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," | 3281 | dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL," |
3282 | "SCSI host:%d\n", instance->host->host_no); | 3282 | "SCSI host:%d\n", instance->host->host_no); |
3283 | ret = FAILED; | 3283 | ret = FAILED; |
@@ -3366,7 +3366,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3366 | 3366 | ||
3367 | mutex_lock(&instance->reset_mutex); | 3367 | mutex_lock(&instance->reset_mutex); |
3368 | 3368 | ||
3369 | if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) { | 3369 | if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) { |
3370 | dev_warn(&instance->pdev->dev, "Hardware critical error, " | 3370 | dev_warn(&instance->pdev->dev, "Hardware critical error, " |
3371 | "returning FAILED for scsi%d.\n", | 3371 | "returning FAILED for scsi%d.\n", |
3372 | instance->host->host_no); | 3372 | instance->host->host_no); |
@@ -3381,7 +3381,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3381 | instance->crash_dump_app_support && reason) { | 3381 | instance->crash_dump_app_support && reason) { |
3382 | dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, " | 3382 | dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, " |
3383 | "forcibly FAULT Firmware\n"); | 3383 | "forcibly FAULT Firmware\n"); |
3384 | instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; | 3384 | atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); |
3385 | status_reg = readl(&instance->reg_set->doorbell); | 3385 | status_reg = readl(&instance->reg_set->doorbell); |
3386 | writel(status_reg | MFI_STATE_FORCE_OCR, | 3386 | writel(status_reg | MFI_STATE_FORCE_OCR, |
3387 | &instance->reg_set->doorbell); | 3387 | &instance->reg_set->doorbell); |
@@ -3393,10 +3393,10 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3393 | dev_dbg(&instance->pdev->dev, "waiting for [%d] " | 3393 | dev_dbg(&instance->pdev->dev, "waiting for [%d] " |
3394 | "seconds for crash dump collection and OCR " | 3394 | "seconds for crash dump collection and OCR " |
3395 | "to be done\n", (io_timeout_in_crash_mode * 3)); | 3395 | "to be done\n", (io_timeout_in_crash_mode * 3)); |
3396 | } while ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) && | 3396 | } while ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) && |
3397 | (io_timeout_in_crash_mode < 80)); | 3397 | (io_timeout_in_crash_mode < 80)); |
3398 | 3398 | ||
3399 | if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) { | 3399 | if (atomic_read(&instance->adprecovery) == MEGASAS_HBA_OPERATIONAL) { |
3400 | dev_info(&instance->pdev->dev, "OCR done for IO " | 3400 | dev_info(&instance->pdev->dev, "OCR done for IO " |
3401 | "timeout case\n"); | 3401 | "timeout case\n"); |
3402 | retval = SUCCESS; | 3402 | retval = SUCCESS; |
@@ -3413,14 +3413,14 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3413 | if (instance->requestorId && !instance->skip_heartbeat_timer_del) | 3413 | if (instance->requestorId && !instance->skip_heartbeat_timer_del) |
3414 | del_timer_sync(&instance->sriov_heartbeat_timer); | 3414 | del_timer_sync(&instance->sriov_heartbeat_timer); |
3415 | set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); | 3415 | set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); |
3416 | instance->adprecovery = MEGASAS_ADPRESET_SM_POLLING; | 3416 | atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_POLLING); |
3417 | instance->instancet->disable_intr(instance); | 3417 | instance->instancet->disable_intr(instance); |
3418 | msleep(1000); | 3418 | msleep(1000); |
3419 | 3419 | ||
3420 | /* First try waiting for commands to complete */ | 3420 | /* First try waiting for commands to complete */ |
3421 | if (megasas_wait_for_outstanding_fusion(instance, reason, | 3421 | if (megasas_wait_for_outstanding_fusion(instance, reason, |
3422 | &convert)) { | 3422 | &convert)) { |
3423 | instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT; | 3423 | atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT); |
3424 | dev_warn(&instance->pdev->dev, "resetting fusion " | 3424 | dev_warn(&instance->pdev->dev, "resetting fusion " |
3425 | "adapter scsi%d.\n", instance->host->host_no); | 3425 | "adapter scsi%d.\n", instance->host->host_no); |
3426 | if (convert) | 3426 | if (convert) |
@@ -3503,8 +3503,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3503 | status_reg); | 3503 | status_reg); |
3504 | megaraid_sas_kill_hba(instance); | 3504 | megaraid_sas_kill_hba(instance); |
3505 | instance->skip_heartbeat_timer_del = 1; | 3505 | instance->skip_heartbeat_timer_del = 1; |
3506 | instance->adprecovery = | 3506 | atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR); |
3507 | MEGASAS_HW_CRITICAL_ERROR; | ||
3508 | retval = FAILED; | 3507 | retval = FAILED; |
3509 | goto out; | 3508 | goto out; |
3510 | } | 3509 | } |
@@ -3563,7 +3562,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3563 | clear_bit(MEGASAS_FUSION_IN_RESET, | 3562 | clear_bit(MEGASAS_FUSION_IN_RESET, |
3564 | &instance->reset_flags); | 3563 | &instance->reset_flags); |
3565 | instance->instancet->enable_intr(instance); | 3564 | instance->instancet->enable_intr(instance); |
3566 | instance->adprecovery = MEGASAS_HBA_OPERATIONAL; | 3565 | atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); |
3567 | 3566 | ||
3568 | /* Restart SR-IOV heartbeat */ | 3567 | /* Restart SR-IOV heartbeat */ |
3569 | if (instance->requestorId) { | 3568 | if (instance->requestorId) { |
@@ -3608,7 +3607,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) | |||
3608 | } | 3607 | } |
3609 | clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); | 3608 | clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); |
3610 | instance->instancet->enable_intr(instance); | 3609 | instance->instancet->enable_intr(instance); |
3611 | instance->adprecovery = MEGASAS_HBA_OPERATIONAL; | 3610 | atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); |
3612 | } | 3611 | } |
3613 | out: | 3612 | out: |
3614 | clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); | 3613 | clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); |