diff options
Diffstat (limited to 'drivers/scsi/mpt3sas/mpt3sas_base.c')
-rw-r--r-- | drivers/scsi/mpt3sas/mpt3sas_base.c | 259 |
1 files changed, 107 insertions, 152 deletions
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 750f82c339d4..a1a5ceb42ce6 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c | |||
@@ -98,7 +98,7 @@ MODULE_PARM_DESC(mpt3sas_fwfault_debug, | |||
98 | " enable detection of firmware fault and halt firmware - (default=0)"); | 98 | " enable detection of firmware fault and halt firmware - (default=0)"); |
99 | 99 | ||
100 | static int | 100 | static int |
101 | _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag); | 101 | _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * _scsih_set_fwfault_debug - global setting of ioc->fwfault_debug. | 104 | * _scsih_set_fwfault_debug - global setting of ioc->fwfault_debug. |
@@ -218,8 +218,7 @@ _base_fault_reset_work(struct work_struct *work) | |||
218 | ioc->non_operational_loop = 0; | 218 | ioc->non_operational_loop = 0; |
219 | 219 | ||
220 | if ((doorbell & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) { | 220 | if ((doorbell & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) { |
221 | rc = mpt3sas_base_hard_reset_handler(ioc, CAN_SLEEP, | 221 | rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); |
222 | FORCE_BIG_HAMMER); | ||
223 | pr_warn(MPT3SAS_FMT "%s: hard reset: %s\n", ioc->name, | 222 | pr_warn(MPT3SAS_FMT "%s: hard reset: %s\n", ioc->name, |
224 | __func__, (rc == 0) ? "success" : "failed"); | 223 | __func__, (rc == 0) ? "success" : "failed"); |
225 | doorbell = mpt3sas_base_get_iocstate(ioc, 0); | 224 | doorbell = mpt3sas_base_get_iocstate(ioc, 0); |
@@ -2040,7 +2039,7 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc) | |||
2040 | * mpt3sas_base_unmap_resources - free controller resources | 2039 | * mpt3sas_base_unmap_resources - free controller resources |
2041 | * @ioc: per adapter object | 2040 | * @ioc: per adapter object |
2042 | */ | 2041 | */ |
2043 | void | 2042 | static void |
2044 | mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc) | 2043 | mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc) |
2045 | { | 2044 | { |
2046 | struct pci_dev *pdev = ioc->pdev; | 2045 | struct pci_dev *pdev = ioc->pdev; |
@@ -2145,7 +2144,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) | |||
2145 | 2144 | ||
2146 | _base_mask_interrupts(ioc); | 2145 | _base_mask_interrupts(ioc); |
2147 | 2146 | ||
2148 | r = _base_get_ioc_facts(ioc, CAN_SLEEP); | 2147 | r = _base_get_ioc_facts(ioc); |
2149 | if (r) | 2148 | if (r) |
2150 | goto out_fail; | 2149 | goto out_fail; |
2151 | 2150 | ||
@@ -3183,12 +3182,11 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) | |||
3183 | /** | 3182 | /** |
3184 | * _base_allocate_memory_pools - allocate start of day memory pools | 3183 | * _base_allocate_memory_pools - allocate start of day memory pools |
3185 | * @ioc: per adapter object | 3184 | * @ioc: per adapter object |
3186 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3187 | * | 3185 | * |
3188 | * Returns 0 success, anything else error | 3186 | * Returns 0 success, anything else error |
3189 | */ | 3187 | */ |
3190 | static int | 3188 | static int |
3191 | _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 3189 | _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc) |
3192 | { | 3190 | { |
3193 | struct mpt3sas_facts *facts; | 3191 | struct mpt3sas_facts *facts; |
3194 | u16 max_sge_elements; | 3192 | u16 max_sge_elements; |
@@ -3658,29 +3656,25 @@ mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked) | |||
3658 | * _base_wait_on_iocstate - waiting on a particular ioc state | 3656 | * _base_wait_on_iocstate - waiting on a particular ioc state |
3659 | * @ioc_state: controller state { READY, OPERATIONAL, or RESET } | 3657 | * @ioc_state: controller state { READY, OPERATIONAL, or RESET } |
3660 | * @timeout: timeout in second | 3658 | * @timeout: timeout in second |
3661 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3662 | * | 3659 | * |
3663 | * Returns 0 for success, non-zero for failure. | 3660 | * Returns 0 for success, non-zero for failure. |
3664 | */ | 3661 | */ |
3665 | static int | 3662 | static int |
3666 | _base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc, u32 ioc_state, int timeout, | 3663 | _base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc, u32 ioc_state, int timeout) |
3667 | int sleep_flag) | ||
3668 | { | 3664 | { |
3669 | u32 count, cntdn; | 3665 | u32 count, cntdn; |
3670 | u32 current_state; | 3666 | u32 current_state; |
3671 | 3667 | ||
3672 | count = 0; | 3668 | count = 0; |
3673 | cntdn = (sleep_flag == CAN_SLEEP) ? 1000*timeout : 2000*timeout; | 3669 | cntdn = 1000 * timeout; |
3674 | do { | 3670 | do { |
3675 | current_state = mpt3sas_base_get_iocstate(ioc, 1); | 3671 | current_state = mpt3sas_base_get_iocstate(ioc, 1); |
3676 | if (current_state == ioc_state) | 3672 | if (current_state == ioc_state) |
3677 | return 0; | 3673 | return 0; |
3678 | if (count && current_state == MPI2_IOC_STATE_FAULT) | 3674 | if (count && current_state == MPI2_IOC_STATE_FAULT) |
3679 | break; | 3675 | break; |
3680 | if (sleep_flag == CAN_SLEEP) | 3676 | |
3681 | usleep_range(1000, 1500); | 3677 | usleep_range(1000, 1500); |
3682 | else | ||
3683 | udelay(500); | ||
3684 | count++; | 3678 | count++; |
3685 | } while (--cntdn); | 3679 | } while (--cntdn); |
3686 | 3680 | ||
@@ -3692,24 +3686,22 @@ _base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc, u32 ioc_state, int timeout, | |||
3692 | * a write to the doorbell) | 3686 | * a write to the doorbell) |
3693 | * @ioc: per adapter object | 3687 | * @ioc: per adapter object |
3694 | * @timeout: timeout in second | 3688 | * @timeout: timeout in second |
3695 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3696 | * | 3689 | * |
3697 | * Returns 0 for success, non-zero for failure. | 3690 | * Returns 0 for success, non-zero for failure. |
3698 | * | 3691 | * |
3699 | * Notes: MPI2_HIS_IOC2SYS_DB_STATUS - set to one when IOC writes to doorbell. | 3692 | * Notes: MPI2_HIS_IOC2SYS_DB_STATUS - set to one when IOC writes to doorbell. |
3700 | */ | 3693 | */ |
3701 | static int | 3694 | static int |
3702 | _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag); | 3695 | _base_diag_reset(struct MPT3SAS_ADAPTER *ioc); |
3703 | 3696 | ||
3704 | static int | 3697 | static int |
3705 | _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout, | 3698 | _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout) |
3706 | int sleep_flag) | ||
3707 | { | 3699 | { |
3708 | u32 cntdn, count; | 3700 | u32 cntdn, count; |
3709 | u32 int_status; | 3701 | u32 int_status; |
3710 | 3702 | ||
3711 | count = 0; | 3703 | count = 0; |
3712 | cntdn = (sleep_flag == CAN_SLEEP) ? 1000*timeout : 2000*timeout; | 3704 | cntdn = 1000 * timeout; |
3713 | do { | 3705 | do { |
3714 | int_status = readl(&ioc->chip->HostInterruptStatus); | 3706 | int_status = readl(&ioc->chip->HostInterruptStatus); |
3715 | if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) { | 3707 | if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) { |
@@ -3718,10 +3710,35 @@ _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3718 | ioc->name, __func__, count, timeout)); | 3710 | ioc->name, __func__, count, timeout)); |
3719 | return 0; | 3711 | return 0; |
3720 | } | 3712 | } |
3721 | if (sleep_flag == CAN_SLEEP) | 3713 | |
3722 | usleep_range(1000, 1500); | 3714 | usleep_range(1000, 1500); |
3723 | else | 3715 | count++; |
3724 | udelay(500); | 3716 | } while (--cntdn); |
3717 | |||
3718 | pr_err(MPT3SAS_FMT | ||
3719 | "%s: failed due to timeout count(%d), int_status(%x)!\n", | ||
3720 | ioc->name, __func__, count, int_status); | ||
3721 | return -EFAULT; | ||
3722 | } | ||
3723 | |||
3724 | static int | ||
3725 | _base_spin_on_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout) | ||
3726 | { | ||
3727 | u32 cntdn, count; | ||
3728 | u32 int_status; | ||
3729 | |||
3730 | count = 0; | ||
3731 | cntdn = 2000 * timeout; | ||
3732 | do { | ||
3733 | int_status = readl(&ioc->chip->HostInterruptStatus); | ||
3734 | if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) { | ||
3735 | dhsprintk(ioc, pr_info(MPT3SAS_FMT | ||
3736 | "%s: successful count(%d), timeout(%d)\n", | ||
3737 | ioc->name, __func__, count, timeout)); | ||
3738 | return 0; | ||
3739 | } | ||
3740 | |||
3741 | udelay(500); | ||
3725 | count++; | 3742 | count++; |
3726 | } while (--cntdn); | 3743 | } while (--cntdn); |
3727 | 3744 | ||
@@ -3729,13 +3746,13 @@ _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3729 | "%s: failed due to timeout count(%d), int_status(%x)!\n", | 3746 | "%s: failed due to timeout count(%d), int_status(%x)!\n", |
3730 | ioc->name, __func__, count, int_status); | 3747 | ioc->name, __func__, count, int_status); |
3731 | return -EFAULT; | 3748 | return -EFAULT; |
3749 | |||
3732 | } | 3750 | } |
3733 | 3751 | ||
3734 | /** | 3752 | /** |
3735 | * _base_wait_for_doorbell_ack - waiting for controller to read the doorbell. | 3753 | * _base_wait_for_doorbell_ack - waiting for controller to read the doorbell. |
3736 | * @ioc: per adapter object | 3754 | * @ioc: per adapter object |
3737 | * @timeout: timeout in second | 3755 | * @timeout: timeout in second |
3738 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3739 | * | 3756 | * |
3740 | * Returns 0 for success, non-zero for failure. | 3757 | * Returns 0 for success, non-zero for failure. |
3741 | * | 3758 | * |
@@ -3743,15 +3760,14 @@ _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3743 | * doorbell. | 3760 | * doorbell. |
3744 | */ | 3761 | */ |
3745 | static int | 3762 | static int |
3746 | _base_wait_for_doorbell_ack(struct MPT3SAS_ADAPTER *ioc, int timeout, | 3763 | _base_wait_for_doorbell_ack(struct MPT3SAS_ADAPTER *ioc, int timeout) |
3747 | int sleep_flag) | ||
3748 | { | 3764 | { |
3749 | u32 cntdn, count; | 3765 | u32 cntdn, count; |
3750 | u32 int_status; | 3766 | u32 int_status; |
3751 | u32 doorbell; | 3767 | u32 doorbell; |
3752 | 3768 | ||
3753 | count = 0; | 3769 | count = 0; |
3754 | cntdn = (sleep_flag == CAN_SLEEP) ? 1000*timeout : 2000*timeout; | 3770 | cntdn = 1000 * timeout; |
3755 | do { | 3771 | do { |
3756 | int_status = readl(&ioc->chip->HostInterruptStatus); | 3772 | int_status = readl(&ioc->chip->HostInterruptStatus); |
3757 | if (!(int_status & MPI2_HIS_SYS2IOC_DB_STATUS)) { | 3773 | if (!(int_status & MPI2_HIS_SYS2IOC_DB_STATUS)) { |
@@ -3769,10 +3785,7 @@ _base_wait_for_doorbell_ack(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3769 | } else if (int_status == 0xFFFFFFFF) | 3785 | } else if (int_status == 0xFFFFFFFF) |
3770 | goto out; | 3786 | goto out; |
3771 | 3787 | ||
3772 | if (sleep_flag == CAN_SLEEP) | 3788 | usleep_range(1000, 1500); |
3773 | usleep_range(1000, 1500); | ||
3774 | else | ||
3775 | udelay(500); | ||
3776 | count++; | 3789 | count++; |
3777 | } while (--cntdn); | 3790 | } while (--cntdn); |
3778 | 3791 | ||
@@ -3787,20 +3800,18 @@ _base_wait_for_doorbell_ack(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3787 | * _base_wait_for_doorbell_not_used - waiting for doorbell to not be in use | 3800 | * _base_wait_for_doorbell_not_used - waiting for doorbell to not be in use |
3788 | * @ioc: per adapter object | 3801 | * @ioc: per adapter object |
3789 | * @timeout: timeout in second | 3802 | * @timeout: timeout in second |
3790 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3791 | * | 3803 | * |
3792 | * Returns 0 for success, non-zero for failure. | 3804 | * Returns 0 for success, non-zero for failure. |
3793 | * | 3805 | * |
3794 | */ | 3806 | */ |
3795 | static int | 3807 | static int |
3796 | _base_wait_for_doorbell_not_used(struct MPT3SAS_ADAPTER *ioc, int timeout, | 3808 | _base_wait_for_doorbell_not_used(struct MPT3SAS_ADAPTER *ioc, int timeout) |
3797 | int sleep_flag) | ||
3798 | { | 3809 | { |
3799 | u32 cntdn, count; | 3810 | u32 cntdn, count; |
3800 | u32 doorbell_reg; | 3811 | u32 doorbell_reg; |
3801 | 3812 | ||
3802 | count = 0; | 3813 | count = 0; |
3803 | cntdn = (sleep_flag == CAN_SLEEP) ? 1000*timeout : 2000*timeout; | 3814 | cntdn = 1000 * timeout; |
3804 | do { | 3815 | do { |
3805 | doorbell_reg = readl(&ioc->chip->Doorbell); | 3816 | doorbell_reg = readl(&ioc->chip->Doorbell); |
3806 | if (!(doorbell_reg & MPI2_DOORBELL_USED)) { | 3817 | if (!(doorbell_reg & MPI2_DOORBELL_USED)) { |
@@ -3809,10 +3820,8 @@ _base_wait_for_doorbell_not_used(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3809 | ioc->name, __func__, count, timeout)); | 3820 | ioc->name, __func__, count, timeout)); |
3810 | return 0; | 3821 | return 0; |
3811 | } | 3822 | } |
3812 | if (sleep_flag == CAN_SLEEP) | 3823 | |
3813 | usleep_range(1000, 1500); | 3824 | usleep_range(1000, 1500); |
3814 | else | ||
3815 | udelay(500); | ||
3816 | count++; | 3825 | count++; |
3817 | } while (--cntdn); | 3826 | } while (--cntdn); |
3818 | 3827 | ||
@@ -3827,13 +3836,11 @@ _base_wait_for_doorbell_not_used(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
3827 | * @ioc: per adapter object | 3836 | * @ioc: per adapter object |
3828 | * @reset_type: currently only supports: MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET | 3837 | * @reset_type: currently only supports: MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET |
3829 | * @timeout: timeout in second | 3838 | * @timeout: timeout in second |
3830 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3831 | * | 3839 | * |
3832 | * Returns 0 for success, non-zero for failure. | 3840 | * Returns 0 for success, non-zero for failure. |
3833 | */ | 3841 | */ |
3834 | static int | 3842 | static int |
3835 | _base_send_ioc_reset(struct MPT3SAS_ADAPTER *ioc, u8 reset_type, int timeout, | 3843 | _base_send_ioc_reset(struct MPT3SAS_ADAPTER *ioc, u8 reset_type, int timeout) |
3836 | int sleep_flag) | ||
3837 | { | 3844 | { |
3838 | u32 ioc_state; | 3845 | u32 ioc_state; |
3839 | int r = 0; | 3846 | int r = 0; |
@@ -3852,12 +3859,11 @@ _base_send_ioc_reset(struct MPT3SAS_ADAPTER *ioc, u8 reset_type, int timeout, | |||
3852 | 3859 | ||
3853 | writel(reset_type << MPI2_DOORBELL_FUNCTION_SHIFT, | 3860 | writel(reset_type << MPI2_DOORBELL_FUNCTION_SHIFT, |
3854 | &ioc->chip->Doorbell); | 3861 | &ioc->chip->Doorbell); |
3855 | if ((_base_wait_for_doorbell_ack(ioc, 15, sleep_flag))) { | 3862 | if ((_base_wait_for_doorbell_ack(ioc, 15))) { |
3856 | r = -EFAULT; | 3863 | r = -EFAULT; |
3857 | goto out; | 3864 | goto out; |
3858 | } | 3865 | } |
3859 | ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, | 3866 | ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, timeout); |
3860 | timeout, sleep_flag); | ||
3861 | if (ioc_state) { | 3867 | if (ioc_state) { |
3862 | pr_err(MPT3SAS_FMT | 3868 | pr_err(MPT3SAS_FMT |
3863 | "%s: failed going to ready state (ioc_state=0x%x)\n", | 3869 | "%s: failed going to ready state (ioc_state=0x%x)\n", |
@@ -3879,18 +3885,16 @@ _base_send_ioc_reset(struct MPT3SAS_ADAPTER *ioc, u8 reset_type, int timeout, | |||
3879 | * @reply_bytes: reply length | 3885 | * @reply_bytes: reply length |
3880 | * @reply: pointer to reply payload | 3886 | * @reply: pointer to reply payload |
3881 | * @timeout: timeout in second | 3887 | * @timeout: timeout in second |
3882 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
3883 | * | 3888 | * |
3884 | * Returns 0 for success, non-zero for failure. | 3889 | * Returns 0 for success, non-zero for failure. |
3885 | */ | 3890 | */ |
3886 | static int | 3891 | static int |
3887 | _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | 3892 | _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, |
3888 | u32 *request, int reply_bytes, u16 *reply, int timeout, int sleep_flag) | 3893 | u32 *request, int reply_bytes, u16 *reply, int timeout) |
3889 | { | 3894 | { |
3890 | MPI2DefaultReply_t *default_reply = (MPI2DefaultReply_t *)reply; | 3895 | MPI2DefaultReply_t *default_reply = (MPI2DefaultReply_t *)reply; |
3891 | int i; | 3896 | int i; |
3892 | u8 failed; | 3897 | u8 failed; |
3893 | u16 dummy; | ||
3894 | __le32 *mfp; | 3898 | __le32 *mfp; |
3895 | 3899 | ||
3896 | /* make sure doorbell is not in use */ | 3900 | /* make sure doorbell is not in use */ |
@@ -3911,7 +3915,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | |||
3911 | ((request_bytes/4)<<MPI2_DOORBELL_ADD_DWORDS_SHIFT)), | 3915 | ((request_bytes/4)<<MPI2_DOORBELL_ADD_DWORDS_SHIFT)), |
3912 | &ioc->chip->Doorbell); | 3916 | &ioc->chip->Doorbell); |
3913 | 3917 | ||
3914 | if ((_base_wait_for_doorbell_int(ioc, 5, NO_SLEEP))) { | 3918 | if ((_base_spin_on_doorbell_int(ioc, 5))) { |
3915 | pr_err(MPT3SAS_FMT | 3919 | pr_err(MPT3SAS_FMT |
3916 | "doorbell handshake int failed (line=%d)\n", | 3920 | "doorbell handshake int failed (line=%d)\n", |
3917 | ioc->name, __LINE__); | 3921 | ioc->name, __LINE__); |
@@ -3919,7 +3923,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | |||
3919 | } | 3923 | } |
3920 | writel(0, &ioc->chip->HostInterruptStatus); | 3924 | writel(0, &ioc->chip->HostInterruptStatus); |
3921 | 3925 | ||
3922 | if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) { | 3926 | if ((_base_wait_for_doorbell_ack(ioc, 5))) { |
3923 | pr_err(MPT3SAS_FMT | 3927 | pr_err(MPT3SAS_FMT |
3924 | "doorbell handshake ack failed (line=%d)\n", | 3928 | "doorbell handshake ack failed (line=%d)\n", |
3925 | ioc->name, __LINE__); | 3929 | ioc->name, __LINE__); |
@@ -3929,7 +3933,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | |||
3929 | /* send message 32-bits at a time */ | 3933 | /* send message 32-bits at a time */ |
3930 | for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) { | 3934 | for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) { |
3931 | writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell); | 3935 | writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell); |
3932 | if ((_base_wait_for_doorbell_ack(ioc, 5, sleep_flag))) | 3936 | if ((_base_wait_for_doorbell_ack(ioc, 5))) |
3933 | failed = 1; | 3937 | failed = 1; |
3934 | } | 3938 | } |
3935 | 3939 | ||
@@ -3941,7 +3945,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | |||
3941 | } | 3945 | } |
3942 | 3946 | ||
3943 | /* now wait for the reply */ | 3947 | /* now wait for the reply */ |
3944 | if ((_base_wait_for_doorbell_int(ioc, timeout, sleep_flag))) { | 3948 | if ((_base_wait_for_doorbell_int(ioc, timeout))) { |
3945 | pr_err(MPT3SAS_FMT | 3949 | pr_err(MPT3SAS_FMT |
3946 | "doorbell handshake int failed (line=%d)\n", | 3950 | "doorbell handshake int failed (line=%d)\n", |
3947 | ioc->name, __LINE__); | 3951 | ioc->name, __LINE__); |
@@ -3952,7 +3956,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | |||
3952 | reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell) | 3956 | reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell) |
3953 | & MPI2_DOORBELL_DATA_MASK); | 3957 | & MPI2_DOORBELL_DATA_MASK); |
3954 | writel(0, &ioc->chip->HostInterruptStatus); | 3958 | writel(0, &ioc->chip->HostInterruptStatus); |
3955 | if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { | 3959 | if ((_base_wait_for_doorbell_int(ioc, 5))) { |
3956 | pr_err(MPT3SAS_FMT | 3960 | pr_err(MPT3SAS_FMT |
3957 | "doorbell handshake int failed (line=%d)\n", | 3961 | "doorbell handshake int failed (line=%d)\n", |
3958 | ioc->name, __LINE__); | 3962 | ioc->name, __LINE__); |
@@ -3963,22 +3967,22 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, | |||
3963 | writel(0, &ioc->chip->HostInterruptStatus); | 3967 | writel(0, &ioc->chip->HostInterruptStatus); |
3964 | 3968 | ||
3965 | for (i = 2; i < default_reply->MsgLength * 2; i++) { | 3969 | for (i = 2; i < default_reply->MsgLength * 2; i++) { |
3966 | if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { | 3970 | if ((_base_wait_for_doorbell_int(ioc, 5))) { |
3967 | pr_err(MPT3SAS_FMT | 3971 | pr_err(MPT3SAS_FMT |
3968 | "doorbell handshake int failed (line=%d)\n", | 3972 | "doorbell handshake int failed (line=%d)\n", |
3969 | ioc->name, __LINE__); | 3973 | ioc->name, __LINE__); |
3970 | return -EFAULT; | 3974 | return -EFAULT; |
3971 | } | 3975 | } |
3972 | if (i >= reply_bytes/2) /* overflow case */ | 3976 | if (i >= reply_bytes/2) /* overflow case */ |
3973 | dummy = readl(&ioc->chip->Doorbell); | 3977 | readl(&ioc->chip->Doorbell); |
3974 | else | 3978 | else |
3975 | reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell) | 3979 | reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell) |
3976 | & MPI2_DOORBELL_DATA_MASK); | 3980 | & MPI2_DOORBELL_DATA_MASK); |
3977 | writel(0, &ioc->chip->HostInterruptStatus); | 3981 | writel(0, &ioc->chip->HostInterruptStatus); |
3978 | } | 3982 | } |
3979 | 3983 | ||
3980 | _base_wait_for_doorbell_int(ioc, 5, sleep_flag); | 3984 | _base_wait_for_doorbell_int(ioc, 5); |
3981 | if (_base_wait_for_doorbell_not_used(ioc, 5, sleep_flag) != 0) { | 3985 | if (_base_wait_for_doorbell_not_used(ioc, 5) != 0) { |
3982 | dhsprintk(ioc, pr_info(MPT3SAS_FMT | 3986 | dhsprintk(ioc, pr_info(MPT3SAS_FMT |
3983 | "doorbell is in use (line=%d)\n", ioc->name, __LINE__)); | 3987 | "doorbell is in use (line=%d)\n", ioc->name, __LINE__)); |
3984 | } | 3988 | } |
@@ -4015,7 +4019,6 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, | |||
4015 | { | 4019 | { |
4016 | u16 smid; | 4020 | u16 smid; |
4017 | u32 ioc_state; | 4021 | u32 ioc_state; |
4018 | unsigned long timeleft; | ||
4019 | bool issue_reset = false; | 4022 | bool issue_reset = false; |
4020 | int rc; | 4023 | int rc; |
4021 | void *request; | 4024 | void *request; |
@@ -4068,7 +4071,7 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, | |||
4068 | ioc->ioc_link_reset_in_progress = 1; | 4071 | ioc->ioc_link_reset_in_progress = 1; |
4069 | init_completion(&ioc->base_cmds.done); | 4072 | init_completion(&ioc->base_cmds.done); |
4070 | mpt3sas_base_put_smid_default(ioc, smid); | 4073 | mpt3sas_base_put_smid_default(ioc, smid); |
4071 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, | 4074 | wait_for_completion_timeout(&ioc->base_cmds.done, |
4072 | msecs_to_jiffies(10000)); | 4075 | msecs_to_jiffies(10000)); |
4073 | if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || | 4076 | if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || |
4074 | mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET) && | 4077 | mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET) && |
@@ -4093,8 +4096,7 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, | |||
4093 | 4096 | ||
4094 | issue_host_reset: | 4097 | issue_host_reset: |
4095 | if (issue_reset) | 4098 | if (issue_reset) |
4096 | mpt3sas_base_hard_reset_handler(ioc, CAN_SLEEP, | 4099 | mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); |
4097 | FORCE_BIG_HAMMER); | ||
4098 | ioc->base_cmds.status = MPT3_CMD_NOT_USED; | 4100 | ioc->base_cmds.status = MPT3_CMD_NOT_USED; |
4099 | rc = -EFAULT; | 4101 | rc = -EFAULT; |
4100 | out: | 4102 | out: |
@@ -4119,7 +4121,6 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, | |||
4119 | { | 4121 | { |
4120 | u16 smid; | 4122 | u16 smid; |
4121 | u32 ioc_state; | 4123 | u32 ioc_state; |
4122 | unsigned long timeleft; | ||
4123 | bool issue_reset = false; | 4124 | bool issue_reset = false; |
4124 | int rc; | 4125 | int rc; |
4125 | void *request; | 4126 | void *request; |
@@ -4170,7 +4171,7 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, | |||
4170 | memcpy(request, mpi_request, sizeof(Mpi2SepReply_t)); | 4171 | memcpy(request, mpi_request, sizeof(Mpi2SepReply_t)); |
4171 | init_completion(&ioc->base_cmds.done); | 4172 | init_completion(&ioc->base_cmds.done); |
4172 | mpt3sas_base_put_smid_default(ioc, smid); | 4173 | mpt3sas_base_put_smid_default(ioc, smid); |
4173 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, | 4174 | wait_for_completion_timeout(&ioc->base_cmds.done, |
4174 | msecs_to_jiffies(10000)); | 4175 | msecs_to_jiffies(10000)); |
4175 | if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { | 4176 | if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { |
4176 | pr_err(MPT3SAS_FMT "%s: timeout\n", | 4177 | pr_err(MPT3SAS_FMT "%s: timeout\n", |
@@ -4191,8 +4192,7 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, | |||
4191 | 4192 | ||
4192 | issue_host_reset: | 4193 | issue_host_reset: |
4193 | if (issue_reset) | 4194 | if (issue_reset) |
4194 | mpt3sas_base_hard_reset_handler(ioc, CAN_SLEEP, | 4195 | mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); |
4195 | FORCE_BIG_HAMMER); | ||
4196 | ioc->base_cmds.status = MPT3_CMD_NOT_USED; | 4196 | ioc->base_cmds.status = MPT3_CMD_NOT_USED; |
4197 | rc = -EFAULT; | 4197 | rc = -EFAULT; |
4198 | out: | 4198 | out: |
@@ -4203,12 +4203,11 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, | |||
4203 | /** | 4203 | /** |
4204 | * _base_get_port_facts - obtain port facts reply and save in ioc | 4204 | * _base_get_port_facts - obtain port facts reply and save in ioc |
4205 | * @ioc: per adapter object | 4205 | * @ioc: per adapter object |
4206 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4207 | * | 4206 | * |
4208 | * Returns 0 for success, non-zero for failure. | 4207 | * Returns 0 for success, non-zero for failure. |
4209 | */ | 4208 | */ |
4210 | static int | 4209 | static int |
4211 | _base_get_port_facts(struct MPT3SAS_ADAPTER *ioc, int port, int sleep_flag) | 4210 | _base_get_port_facts(struct MPT3SAS_ADAPTER *ioc, int port) |
4212 | { | 4211 | { |
4213 | Mpi2PortFactsRequest_t mpi_request; | 4212 | Mpi2PortFactsRequest_t mpi_request; |
4214 | Mpi2PortFactsReply_t mpi_reply; | 4213 | Mpi2PortFactsReply_t mpi_reply; |
@@ -4224,7 +4223,7 @@ _base_get_port_facts(struct MPT3SAS_ADAPTER *ioc, int port, int sleep_flag) | |||
4224 | mpi_request.Function = MPI2_FUNCTION_PORT_FACTS; | 4223 | mpi_request.Function = MPI2_FUNCTION_PORT_FACTS; |
4225 | mpi_request.PortNumber = port; | 4224 | mpi_request.PortNumber = port; |
4226 | r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, | 4225 | r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, |
4227 | (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5, CAN_SLEEP); | 4226 | (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5); |
4228 | 4227 | ||
4229 | if (r != 0) { | 4228 | if (r != 0) { |
4230 | pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n", | 4229 | pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n", |
@@ -4247,13 +4246,11 @@ _base_get_port_facts(struct MPT3SAS_ADAPTER *ioc, int port, int sleep_flag) | |||
4247 | * _base_wait_for_iocstate - Wait until the card is in READY or OPERATIONAL | 4246 | * _base_wait_for_iocstate - Wait until the card is in READY or OPERATIONAL |
4248 | * @ioc: per adapter object | 4247 | * @ioc: per adapter object |
4249 | * @timeout: | 4248 | * @timeout: |
4250 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4251 | * | 4249 | * |
4252 | * Returns 0 for success, non-zero for failure. | 4250 | * Returns 0 for success, non-zero for failure. |
4253 | */ | 4251 | */ |
4254 | static int | 4252 | static int |
4255 | _base_wait_for_iocstate(struct MPT3SAS_ADAPTER *ioc, int timeout, | 4253 | _base_wait_for_iocstate(struct MPT3SAS_ADAPTER *ioc, int timeout) |
4256 | int sleep_flag) | ||
4257 | { | 4254 | { |
4258 | u32 ioc_state; | 4255 | u32 ioc_state; |
4259 | int rc; | 4256 | int rc; |
@@ -4287,8 +4284,7 @@ _base_wait_for_iocstate(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
4287 | goto issue_diag_reset; | 4284 | goto issue_diag_reset; |
4288 | } | 4285 | } |
4289 | 4286 | ||
4290 | ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, | 4287 | ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, timeout); |
4291 | timeout, sleep_flag); | ||
4292 | if (ioc_state) { | 4288 | if (ioc_state) { |
4293 | dfailprintk(ioc, printk(MPT3SAS_FMT | 4289 | dfailprintk(ioc, printk(MPT3SAS_FMT |
4294 | "%s: failed going to ready state (ioc_state=0x%x)\n", | 4290 | "%s: failed going to ready state (ioc_state=0x%x)\n", |
@@ -4297,19 +4293,18 @@ _base_wait_for_iocstate(struct MPT3SAS_ADAPTER *ioc, int timeout, | |||
4297 | } | 4293 | } |
4298 | 4294 | ||
4299 | issue_diag_reset: | 4295 | issue_diag_reset: |
4300 | rc = _base_diag_reset(ioc, sleep_flag); | 4296 | rc = _base_diag_reset(ioc); |
4301 | return rc; | 4297 | return rc; |
4302 | } | 4298 | } |
4303 | 4299 | ||
4304 | /** | 4300 | /** |
4305 | * _base_get_ioc_facts - obtain ioc facts reply and save in ioc | 4301 | * _base_get_ioc_facts - obtain ioc facts reply and save in ioc |
4306 | * @ioc: per adapter object | 4302 | * @ioc: per adapter object |
4307 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4308 | * | 4303 | * |
4309 | * Returns 0 for success, non-zero for failure. | 4304 | * Returns 0 for success, non-zero for failure. |
4310 | */ | 4305 | */ |
4311 | static int | 4306 | static int |
4312 | _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 4307 | _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc) |
4313 | { | 4308 | { |
4314 | Mpi2IOCFactsRequest_t mpi_request; | 4309 | Mpi2IOCFactsRequest_t mpi_request; |
4315 | Mpi2IOCFactsReply_t mpi_reply; | 4310 | Mpi2IOCFactsReply_t mpi_reply; |
@@ -4319,7 +4314,7 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4319 | dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, | 4314 | dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
4320 | __func__)); | 4315 | __func__)); |
4321 | 4316 | ||
4322 | r = _base_wait_for_iocstate(ioc, 10, sleep_flag); | 4317 | r = _base_wait_for_iocstate(ioc, 10); |
4323 | if (r) { | 4318 | if (r) { |
4324 | dfailprintk(ioc, printk(MPT3SAS_FMT | 4319 | dfailprintk(ioc, printk(MPT3SAS_FMT |
4325 | "%s: failed getting to correct state\n", | 4320 | "%s: failed getting to correct state\n", |
@@ -4331,7 +4326,7 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4331 | memset(&mpi_request, 0, mpi_request_sz); | 4326 | memset(&mpi_request, 0, mpi_request_sz); |
4332 | mpi_request.Function = MPI2_FUNCTION_IOC_FACTS; | 4327 | mpi_request.Function = MPI2_FUNCTION_IOC_FACTS; |
4333 | r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, | 4328 | r = _base_handshake_req_reply_wait(ioc, mpi_request_sz, |
4334 | (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5, CAN_SLEEP); | 4329 | (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5); |
4335 | 4330 | ||
4336 | if (r != 0) { | 4331 | if (r != 0) { |
4337 | pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n", | 4332 | pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n", |
@@ -4391,12 +4386,11 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4391 | /** | 4386 | /** |
4392 | * _base_send_ioc_init - send ioc_init to firmware | 4387 | * _base_send_ioc_init - send ioc_init to firmware |
4393 | * @ioc: per adapter object | 4388 | * @ioc: per adapter object |
4394 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4395 | * | 4389 | * |
4396 | * Returns 0 for success, non-zero for failure. | 4390 | * Returns 0 for success, non-zero for failure. |
4397 | */ | 4391 | */ |
4398 | static int | 4392 | static int |
4399 | _base_send_ioc_init(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 4393 | _base_send_ioc_init(struct MPT3SAS_ADAPTER *ioc) |
4400 | { | 4394 | { |
4401 | Mpi2IOCInitRequest_t mpi_request; | 4395 | Mpi2IOCInitRequest_t mpi_request; |
4402 | Mpi2IOCInitReply_t mpi_reply; | 4396 | Mpi2IOCInitReply_t mpi_reply; |
@@ -4479,8 +4473,7 @@ _base_send_ioc_init(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4479 | 4473 | ||
4480 | r = _base_handshake_req_reply_wait(ioc, | 4474 | r = _base_handshake_req_reply_wait(ioc, |
4481 | sizeof(Mpi2IOCInitRequest_t), (u32 *)&mpi_request, | 4475 | sizeof(Mpi2IOCInitRequest_t), (u32 *)&mpi_request, |
4482 | sizeof(Mpi2IOCInitReply_t), (u16 *)&mpi_reply, 10, | 4476 | sizeof(Mpi2IOCInitReply_t), (u16 *)&mpi_reply, 10); |
4483 | sleep_flag); | ||
4484 | 4477 | ||
4485 | if (r != 0) { | 4478 | if (r != 0) { |
4486 | pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n", | 4479 | pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n", |
@@ -4555,16 +4548,14 @@ mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, | |||
4555 | /** | 4548 | /** |
4556 | * _base_send_port_enable - send port_enable(discovery stuff) to firmware | 4549 | * _base_send_port_enable - send port_enable(discovery stuff) to firmware |
4557 | * @ioc: per adapter object | 4550 | * @ioc: per adapter object |
4558 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4559 | * | 4551 | * |
4560 | * Returns 0 for success, non-zero for failure. | 4552 | * Returns 0 for success, non-zero for failure. |
4561 | */ | 4553 | */ |
4562 | static int | 4554 | static int |
4563 | _base_send_port_enable(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 4555 | _base_send_port_enable(struct MPT3SAS_ADAPTER *ioc) |
4564 | { | 4556 | { |
4565 | Mpi2PortEnableRequest_t *mpi_request; | 4557 | Mpi2PortEnableRequest_t *mpi_request; |
4566 | Mpi2PortEnableReply_t *mpi_reply; | 4558 | Mpi2PortEnableReply_t *mpi_reply; |
4567 | unsigned long timeleft; | ||
4568 | int r = 0; | 4559 | int r = 0; |
4569 | u16 smid; | 4560 | u16 smid; |
4570 | u16 ioc_status; | 4561 | u16 ioc_status; |
@@ -4592,8 +4583,7 @@ _base_send_port_enable(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4592 | 4583 | ||
4593 | init_completion(&ioc->port_enable_cmds.done); | 4584 | init_completion(&ioc->port_enable_cmds.done); |
4594 | mpt3sas_base_put_smid_default(ioc, smid); | 4585 | mpt3sas_base_put_smid_default(ioc, smid); |
4595 | timeleft = wait_for_completion_timeout(&ioc->port_enable_cmds.done, | 4586 | wait_for_completion_timeout(&ioc->port_enable_cmds.done, 300*HZ); |
4596 | 300*HZ); | ||
4597 | if (!(ioc->port_enable_cmds.status & MPT3_CMD_COMPLETE)) { | 4587 | if (!(ioc->port_enable_cmds.status & MPT3_CMD_COMPLETE)) { |
4598 | pr_err(MPT3SAS_FMT "%s: timeout\n", | 4588 | pr_err(MPT3SAS_FMT "%s: timeout\n", |
4599 | ioc->name, __func__); | 4589 | ioc->name, __func__); |
@@ -4737,15 +4727,13 @@ _base_unmask_events(struct MPT3SAS_ADAPTER *ioc, u16 event) | |||
4737 | /** | 4727 | /** |
4738 | * _base_event_notification - send event notification | 4728 | * _base_event_notification - send event notification |
4739 | * @ioc: per adapter object | 4729 | * @ioc: per adapter object |
4740 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4741 | * | 4730 | * |
4742 | * Returns 0 for success, non-zero for failure. | 4731 | * Returns 0 for success, non-zero for failure. |
4743 | */ | 4732 | */ |
4744 | static int | 4733 | static int |
4745 | _base_event_notification(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 4734 | _base_event_notification(struct MPT3SAS_ADAPTER *ioc) |
4746 | { | 4735 | { |
4747 | Mpi2EventNotificationRequest_t *mpi_request; | 4736 | Mpi2EventNotificationRequest_t *mpi_request; |
4748 | unsigned long timeleft; | ||
4749 | u16 smid; | 4737 | u16 smid; |
4750 | int r = 0; | 4738 | int r = 0; |
4751 | int i; | 4739 | int i; |
@@ -4777,7 +4765,7 @@ _base_event_notification(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4777 | cpu_to_le32(ioc->event_masks[i]); | 4765 | cpu_to_le32(ioc->event_masks[i]); |
4778 | init_completion(&ioc->base_cmds.done); | 4766 | init_completion(&ioc->base_cmds.done); |
4779 | mpt3sas_base_put_smid_default(ioc, smid); | 4767 | mpt3sas_base_put_smid_default(ioc, smid); |
4780 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); | 4768 | wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); |
4781 | if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { | 4769 | if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) { |
4782 | pr_err(MPT3SAS_FMT "%s: timeout\n", | 4770 | pr_err(MPT3SAS_FMT "%s: timeout\n", |
4783 | ioc->name, __func__); | 4771 | ioc->name, __func__); |
@@ -4827,19 +4815,18 @@ mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc, u32 *event_type) | |||
4827 | return; | 4815 | return; |
4828 | 4816 | ||
4829 | mutex_lock(&ioc->base_cmds.mutex); | 4817 | mutex_lock(&ioc->base_cmds.mutex); |
4830 | _base_event_notification(ioc, CAN_SLEEP); | 4818 | _base_event_notification(ioc); |
4831 | mutex_unlock(&ioc->base_cmds.mutex); | 4819 | mutex_unlock(&ioc->base_cmds.mutex); |
4832 | } | 4820 | } |
4833 | 4821 | ||
4834 | /** | 4822 | /** |
4835 | * _base_diag_reset - the "big hammer" start of day reset | 4823 | * _base_diag_reset - the "big hammer" start of day reset |
4836 | * @ioc: per adapter object | 4824 | * @ioc: per adapter object |
4837 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4838 | * | 4825 | * |
4839 | * Returns 0 for success, non-zero for failure. | 4826 | * Returns 0 for success, non-zero for failure. |
4840 | */ | 4827 | */ |
4841 | static int | 4828 | static int |
4842 | _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 4829 | _base_diag_reset(struct MPT3SAS_ADAPTER *ioc) |
4843 | { | 4830 | { |
4844 | u32 host_diagnostic; | 4831 | u32 host_diagnostic; |
4845 | u32 ioc_state; | 4832 | u32 ioc_state; |
@@ -4867,10 +4854,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4867 | writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence); | 4854 | writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence); |
4868 | 4855 | ||
4869 | /* wait 100 msec */ | 4856 | /* wait 100 msec */ |
4870 | if (sleep_flag == CAN_SLEEP) | 4857 | msleep(100); |
4871 | msleep(100); | ||
4872 | else | ||
4873 | mdelay(100); | ||
4874 | 4858 | ||
4875 | if (count++ > 20) | 4859 | if (count++ > 20) |
4876 | goto out; | 4860 | goto out; |
@@ -4890,10 +4874,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4890 | &ioc->chip->HostDiagnostic); | 4874 | &ioc->chip->HostDiagnostic); |
4891 | 4875 | ||
4892 | /*This delay allows the chip PCIe hardware time to finish reset tasks*/ | 4876 | /*This delay allows the chip PCIe hardware time to finish reset tasks*/ |
4893 | if (sleep_flag == CAN_SLEEP) | 4877 | msleep(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000); |
4894 | msleep(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000); | ||
4895 | else | ||
4896 | mdelay(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000); | ||
4897 | 4878 | ||
4898 | /* Approximately 300 second max wait */ | 4879 | /* Approximately 300 second max wait */ |
4899 | for (count = 0; count < (300000000 / | 4880 | for (count = 0; count < (300000000 / |
@@ -4906,13 +4887,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4906 | if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER)) | 4887 | if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER)) |
4907 | break; | 4888 | break; |
4908 | 4889 | ||
4909 | /* Wait to pass the second read delay window */ | 4890 | msleep(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC / 1000); |
4910 | if (sleep_flag == CAN_SLEEP) | ||
4911 | msleep(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC | ||
4912 | / 1000); | ||
4913 | else | ||
4914 | mdelay(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC | ||
4915 | / 1000); | ||
4916 | } | 4891 | } |
4917 | 4892 | ||
4918 | if (host_diagnostic & MPI2_DIAG_HCB_MODE) { | 4893 | if (host_diagnostic & MPI2_DIAG_HCB_MODE) { |
@@ -4941,8 +4916,7 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4941 | 4916 | ||
4942 | drsprintk(ioc, pr_info(MPT3SAS_FMT | 4917 | drsprintk(ioc, pr_info(MPT3SAS_FMT |
4943 | "Wait for FW to go to the READY state\n", ioc->name)); | 4918 | "Wait for FW to go to the READY state\n", ioc->name)); |
4944 | ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20, | 4919 | ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20); |
4945 | sleep_flag); | ||
4946 | if (ioc_state) { | 4920 | if (ioc_state) { |
4947 | pr_err(MPT3SAS_FMT | 4921 | pr_err(MPT3SAS_FMT |
4948 | "%s: failed going to ready state (ioc_state=0x%x)\n", | 4922 | "%s: failed going to ready state (ioc_state=0x%x)\n", |
@@ -4961,14 +4935,12 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
4961 | /** | 4935 | /** |
4962 | * _base_make_ioc_ready - put controller in READY state | 4936 | * _base_make_ioc_ready - put controller in READY state |
4963 | * @ioc: per adapter object | 4937 | * @ioc: per adapter object |
4964 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
4965 | * @type: FORCE_BIG_HAMMER or SOFT_RESET | 4938 | * @type: FORCE_BIG_HAMMER or SOFT_RESET |
4966 | * | 4939 | * |
4967 | * Returns 0 for success, non-zero for failure. | 4940 | * Returns 0 for success, non-zero for failure. |
4968 | */ | 4941 | */ |
4969 | static int | 4942 | static int |
4970 | _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | 4943 | _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, enum reset_type type) |
4971 | enum reset_type type) | ||
4972 | { | 4944 | { |
4973 | u32 ioc_state; | 4945 | u32 ioc_state; |
4974 | int rc; | 4946 | int rc; |
@@ -4995,10 +4967,7 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
4995 | ioc->name, __func__, ioc_state); | 4967 | ioc->name, __func__, ioc_state); |
4996 | return -EFAULT; | 4968 | return -EFAULT; |
4997 | } | 4969 | } |
4998 | if (sleep_flag == CAN_SLEEP) | 4970 | ssleep(1); |
4999 | ssleep(1); | ||
5000 | else | ||
5001 | mdelay(1000); | ||
5002 | ioc_state = mpt3sas_base_get_iocstate(ioc, 0); | 4971 | ioc_state = mpt3sas_base_get_iocstate(ioc, 0); |
5003 | } | 4972 | } |
5004 | } | 4973 | } |
@@ -5024,24 +4993,23 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
5024 | 4993 | ||
5025 | if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_OPERATIONAL) | 4994 | if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_OPERATIONAL) |
5026 | if (!(_base_send_ioc_reset(ioc, | 4995 | if (!(_base_send_ioc_reset(ioc, |
5027 | MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET, 15, CAN_SLEEP))) { | 4996 | MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET, 15))) { |
5028 | return 0; | 4997 | return 0; |
5029 | } | 4998 | } |
5030 | 4999 | ||
5031 | issue_diag_reset: | 5000 | issue_diag_reset: |
5032 | rc = _base_diag_reset(ioc, CAN_SLEEP); | 5001 | rc = _base_diag_reset(ioc); |
5033 | return rc; | 5002 | return rc; |
5034 | } | 5003 | } |
5035 | 5004 | ||
5036 | /** | 5005 | /** |
5037 | * _base_make_ioc_operational - put controller in OPERATIONAL state | 5006 | * _base_make_ioc_operational - put controller in OPERATIONAL state |
5038 | * @ioc: per adapter object | 5007 | * @ioc: per adapter object |
5039 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
5040 | * | 5008 | * |
5041 | * Returns 0 for success, non-zero for failure. | 5009 | * Returns 0 for success, non-zero for failure. |
5042 | */ | 5010 | */ |
5043 | static int | 5011 | static int |
5044 | _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 5012 | _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc) |
5045 | { | 5013 | { |
5046 | int r, i, index; | 5014 | int r, i, index; |
5047 | unsigned long flags; | 5015 | unsigned long flags; |
@@ -5160,7 +5128,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
5160 | } | 5128 | } |
5161 | skip_init_reply_post_free_queue: | 5129 | skip_init_reply_post_free_queue: |
5162 | 5130 | ||
5163 | r = _base_send_ioc_init(ioc, sleep_flag); | 5131 | r = _base_send_ioc_init(ioc); |
5164 | if (r) | 5132 | if (r) |
5165 | return r; | 5133 | return r; |
5166 | 5134 | ||
@@ -5186,13 +5154,11 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
5186 | skip_init_reply_post_host_index: | 5154 | skip_init_reply_post_host_index: |
5187 | 5155 | ||
5188 | _base_unmask_interrupts(ioc); | 5156 | _base_unmask_interrupts(ioc); |
5189 | r = _base_event_notification(ioc, sleep_flag); | 5157 | r = _base_event_notification(ioc); |
5190 | if (r) | 5158 | if (r) |
5191 | return r; | 5159 | return r; |
5192 | 5160 | ||
5193 | if (sleep_flag == CAN_SLEEP) | 5161 | _base_static_config_pages(ioc); |
5194 | _base_static_config_pages(ioc); | ||
5195 | |||
5196 | 5162 | ||
5197 | if (ioc->is_driver_loading) { | 5163 | if (ioc->is_driver_loading) { |
5198 | 5164 | ||
@@ -5211,7 +5177,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
5211 | return r; /* scan_start and scan_finished support */ | 5177 | return r; /* scan_start and scan_finished support */ |
5212 | } | 5178 | } |
5213 | 5179 | ||
5214 | r = _base_send_port_enable(ioc, sleep_flag); | 5180 | r = _base_send_port_enable(ioc); |
5215 | if (r) | 5181 | if (r) |
5216 | return r; | 5182 | return r; |
5217 | 5183 | ||
@@ -5235,7 +5201,7 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc) | |||
5235 | if (ioc->chip_phys && ioc->chip) { | 5201 | if (ioc->chip_phys && ioc->chip) { |
5236 | _base_mask_interrupts(ioc); | 5202 | _base_mask_interrupts(ioc); |
5237 | ioc->shost_recovery = 1; | 5203 | ioc->shost_recovery = 1; |
5238 | _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); | 5204 | _base_make_ioc_ready(ioc, SOFT_RESET); |
5239 | ioc->shost_recovery = 0; | 5205 | ioc->shost_recovery = 0; |
5240 | } | 5206 | } |
5241 | 5207 | ||
@@ -5292,7 +5258,7 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) | |||
5292 | goto out_free_resources; | 5258 | goto out_free_resources; |
5293 | 5259 | ||
5294 | pci_set_drvdata(ioc->pdev, ioc->shost); | 5260 | pci_set_drvdata(ioc->pdev, ioc->shost); |
5295 | r = _base_get_ioc_facts(ioc, CAN_SLEEP); | 5261 | r = _base_get_ioc_facts(ioc); |
5296 | if (r) | 5262 | if (r) |
5297 | goto out_free_resources; | 5263 | goto out_free_resources; |
5298 | 5264 | ||
@@ -5326,7 +5292,7 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) | |||
5326 | ioc->build_sg_mpi = &_base_build_sg; | 5292 | ioc->build_sg_mpi = &_base_build_sg; |
5327 | ioc->build_zero_len_sge_mpi = &_base_build_zero_len_sge; | 5293 | ioc->build_zero_len_sge_mpi = &_base_build_zero_len_sge; |
5328 | 5294 | ||
5329 | r = _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); | 5295 | r = _base_make_ioc_ready(ioc, SOFT_RESET); |
5330 | if (r) | 5296 | if (r) |
5331 | goto out_free_resources; | 5297 | goto out_free_resources; |
5332 | 5298 | ||
@@ -5338,12 +5304,12 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) | |||
5338 | } | 5304 | } |
5339 | 5305 | ||
5340 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { | 5306 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { |
5341 | r = _base_get_port_facts(ioc, i, CAN_SLEEP); | 5307 | r = _base_get_port_facts(ioc, i); |
5342 | if (r) | 5308 | if (r) |
5343 | goto out_free_resources; | 5309 | goto out_free_resources; |
5344 | } | 5310 | } |
5345 | 5311 | ||
5346 | r = _base_allocate_memory_pools(ioc, CAN_SLEEP); | 5312 | r = _base_allocate_memory_pools(ioc); |
5347 | if (r) | 5313 | if (r) |
5348 | goto out_free_resources; | 5314 | goto out_free_resources; |
5349 | 5315 | ||
@@ -5429,7 +5395,7 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) | |||
5429 | if (ioc->hba_mpi_version_belonged == MPI26_VERSION) | 5395 | if (ioc->hba_mpi_version_belonged == MPI26_VERSION) |
5430 | _base_unmask_events(ioc, MPI2_EVENT_ACTIVE_CABLE_EXCEPTION); | 5396 | _base_unmask_events(ioc, MPI2_EVENT_ACTIVE_CABLE_EXCEPTION); |
5431 | 5397 | ||
5432 | r = _base_make_ioc_operational(ioc, CAN_SLEEP); | 5398 | r = _base_make_ioc_operational(ioc); |
5433 | if (r) | 5399 | if (r) |
5434 | goto out_free_resources; | 5400 | goto out_free_resources; |
5435 | 5401 | ||
@@ -5565,21 +5531,18 @@ _base_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase) | |||
5565 | /** | 5531 | /** |
5566 | * _wait_for_commands_to_complete - reset controller | 5532 | * _wait_for_commands_to_complete - reset controller |
5567 | * @ioc: Pointer to MPT_ADAPTER structure | 5533 | * @ioc: Pointer to MPT_ADAPTER structure |
5568 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
5569 | * | 5534 | * |
5570 | * This function waiting(3s) for all pending commands to complete | 5535 | * This function waiting(3s) for all pending commands to complete |
5571 | * prior to putting controller in reset. | 5536 | * prior to putting controller in reset. |
5572 | */ | 5537 | */ |
5573 | static void | 5538 | static void |
5574 | _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | 5539 | _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) |
5575 | { | 5540 | { |
5576 | u32 ioc_state; | 5541 | u32 ioc_state; |
5577 | unsigned long flags; | 5542 | unsigned long flags; |
5578 | u16 i; | 5543 | u16 i; |
5579 | 5544 | ||
5580 | ioc->pending_io_count = 0; | 5545 | ioc->pending_io_count = 0; |
5581 | if (sleep_flag != CAN_SLEEP) | ||
5582 | return; | ||
5583 | 5546 | ||
5584 | ioc_state = mpt3sas_base_get_iocstate(ioc, 0); | 5547 | ioc_state = mpt3sas_base_get_iocstate(ioc, 0); |
5585 | if ((ioc_state & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) | 5548 | if ((ioc_state & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) |
@@ -5602,13 +5565,12 @@ _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) | |||
5602 | /** | 5565 | /** |
5603 | * mpt3sas_base_hard_reset_handler - reset controller | 5566 | * mpt3sas_base_hard_reset_handler - reset controller |
5604 | * @ioc: Pointer to MPT_ADAPTER structure | 5567 | * @ioc: Pointer to MPT_ADAPTER structure |
5605 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | ||
5606 | * @type: FORCE_BIG_HAMMER or SOFT_RESET | 5568 | * @type: FORCE_BIG_HAMMER or SOFT_RESET |
5607 | * | 5569 | * |
5608 | * Returns 0 for success, non-zero for failure. | 5570 | * Returns 0 for success, non-zero for failure. |
5609 | */ | 5571 | */ |
5610 | int | 5572 | int |
5611 | mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | 5573 | mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, |
5612 | enum reset_type type) | 5574 | enum reset_type type) |
5613 | { | 5575 | { |
5614 | int r; | 5576 | int r; |
@@ -5629,13 +5591,6 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
5629 | if (mpt3sas_fwfault_debug) | 5591 | if (mpt3sas_fwfault_debug) |
5630 | mpt3sas_halt_firmware(ioc); | 5592 | mpt3sas_halt_firmware(ioc); |
5631 | 5593 | ||
5632 | /* TODO - What we really should be doing is pulling | ||
5633 | * out all the code associated with NO_SLEEP; its never used. | ||
5634 | * That is legacy code from mpt fusion driver, ported over. | ||
5635 | * I will leave this BUG_ON here for now till its been resolved. | ||
5636 | */ | ||
5637 | BUG_ON(sleep_flag == NO_SLEEP); | ||
5638 | |||
5639 | /* wait for an active reset in progress to complete */ | 5594 | /* wait for an active reset in progress to complete */ |
5640 | if (!mutex_trylock(&ioc->reset_in_progress_mutex)) { | 5595 | if (!mutex_trylock(&ioc->reset_in_progress_mutex)) { |
5641 | do { | 5596 | do { |
@@ -5660,9 +5615,9 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
5660 | is_fault = 1; | 5615 | is_fault = 1; |
5661 | } | 5616 | } |
5662 | _base_reset_handler(ioc, MPT3_IOC_PRE_RESET); | 5617 | _base_reset_handler(ioc, MPT3_IOC_PRE_RESET); |
5663 | _wait_for_commands_to_complete(ioc, sleep_flag); | 5618 | _wait_for_commands_to_complete(ioc); |
5664 | _base_mask_interrupts(ioc); | 5619 | _base_mask_interrupts(ioc); |
5665 | r = _base_make_ioc_ready(ioc, sleep_flag, type); | 5620 | r = _base_make_ioc_ready(ioc, type); |
5666 | if (r) | 5621 | if (r) |
5667 | goto out; | 5622 | goto out; |
5668 | _base_reset_handler(ioc, MPT3_IOC_AFTER_RESET); | 5623 | _base_reset_handler(ioc, MPT3_IOC_AFTER_RESET); |
@@ -5675,7 +5630,7 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
5675 | r = -EFAULT; | 5630 | r = -EFAULT; |
5676 | goto out; | 5631 | goto out; |
5677 | } | 5632 | } |
5678 | r = _base_get_ioc_facts(ioc, CAN_SLEEP); | 5633 | r = _base_get_ioc_facts(ioc); |
5679 | if (r) | 5634 | if (r) |
5680 | goto out; | 5635 | goto out; |
5681 | 5636 | ||
@@ -5684,7 +5639,7 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, int sleep_flag, | |||
5684 | "Please reboot the system and ensure that the correct" | 5639 | "Please reboot the system and ensure that the correct" |
5685 | " firmware version is running\n", ioc->name); | 5640 | " firmware version is running\n", ioc->name); |
5686 | 5641 | ||
5687 | r = _base_make_ioc_operational(ioc, sleep_flag); | 5642 | r = _base_make_ioc_operational(ioc); |
5688 | if (!r) | 5643 | if (!r) |
5689 | _base_reset_handler(ioc, MPT3_IOC_DONE_RESET); | 5644 | _base_reset_handler(ioc, MPT3_IOC_DONE_RESET); |
5690 | 5645 | ||