diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-03-26 19:30:35 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:00:36 -0400 |
commit | 068b2c03635bf50c9b408b21435e23e7a0b89b0f (patch) | |
tree | ecdea391b5c13cfeab84747ec4960a881a9316eb | |
parent | f942f32ea05eff727c41e1a1112cab305b836377 (diff) |
isci: kill some long macros
Delete some macros that are longer to type than the open coded operation
that they perform.
scic_sds_phy_get_base_state_machine
scic_sds_phy_get_starting_substate_machine
scic_sds_port_get_base_state_machine
scic_sds_port_get_ready_substate_machine
scic_sds_remote_device_get_base_state_machine
scic_sds_remote_device_get_ready_substate_machine
scic_sds_remote_node_context_set_remote_node_index
scic_sds_controller_get_base_state_machine
Also performs some collateral cleanups like killing casts that assume
structure member ordering, and consolidating a lot of duplicated default
handler code (the primary callers of the *_get_base_state_machine macros) via
a helper.
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_controller.c | 259 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_controller.h | 9 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.c | 400 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.h | 48 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port.c | 424 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port.h | 16 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_remote_device.c | 508 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_remote_device.h | 16 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_remote_node_context.h | 3 |
9 files changed, 389 insertions, 1294 deletions
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c index eaaa4cc89a85..7d25a0aafb66 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.c +++ b/drivers/scsi/isci/core/scic_sds_controller.c | |||
@@ -739,9 +739,8 @@ static void scic_sds_controller_transition_to_ready( | |||
739 | * We move into the ready state, because some of the phys/ports | 739 | * We move into the ready state, because some of the phys/ports |
740 | * may be up and operational. | 740 | * may be up and operational. |
741 | */ | 741 | */ |
742 | sci_base_state_machine_change_state( | 742 | sci_base_state_machine_change_state(&scic->parent.state_machine, |
743 | scic_sds_controller_get_base_state_machine(scic), | 743 | SCI_BASE_CONTROLLER_STATE_READY); |
744 | SCI_BASE_CONTROLLER_STATE_READY); | ||
745 | 744 | ||
746 | isci_host_start_complete(ihost, status); | 745 | isci_host_start_complete(ihost, status); |
747 | } | 746 | } |
@@ -751,18 +750,12 @@ void scic_sds_controller_timeout_handler(void *_scic) | |||
751 | { | 750 | { |
752 | struct scic_sds_controller *scic = _scic; | 751 | struct scic_sds_controller *scic = _scic; |
753 | struct isci_host *ihost = sci_object_get_association(scic); | 752 | struct isci_host *ihost = sci_object_get_association(scic); |
754 | enum sci_base_controller_states current_state; | 753 | struct sci_base_state_machine *sm = &scic->parent.state_machine; |
755 | |||
756 | current_state = sci_base_state_machine_get_state( | ||
757 | scic_sds_controller_get_base_state_machine(scic)); | ||
758 | 754 | ||
759 | if (current_state == SCI_BASE_CONTROLLER_STATE_STARTING) { | 755 | if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING) |
760 | scic_sds_controller_transition_to_ready( | 756 | scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT); |
761 | scic, SCI_FAILURE_TIMEOUT); | 757 | else if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STOPPING) { |
762 | } else if (current_state == SCI_BASE_CONTROLLER_STATE_STOPPING) { | 758 | sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_FAILED); |
763 | sci_base_state_machine_change_state( | ||
764 | scic_sds_controller_get_base_state_machine(scic), | ||
765 | SCI_BASE_CONTROLLER_STATE_FAILED); | ||
766 | isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT); | 759 | isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT); |
767 | } else /* / @todo Now what do we want to do in this case? */ | 760 | } else /* / @todo Now what do we want to do in this case? */ |
768 | dev_err(scic_to_dev(scic), | 761 | dev_err(scic_to_dev(scic), |
@@ -1619,16 +1612,15 @@ void scic_sds_controller_error_handler(struct scic_sds_controller *scic) | |||
1619 | dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__, | 1612 | dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__, |
1620 | interrupt_status); | 1613 | interrupt_status); |
1621 | 1614 | ||
1622 | sci_base_state_machine_change_state( | 1615 | sci_base_state_machine_change_state(&scic->parent.state_machine, |
1623 | scic_sds_controller_get_base_state_machine(scic), | 1616 | SCI_BASE_CONTROLLER_STATE_FAILED); |
1624 | SCI_BASE_CONTROLLER_STATE_FAILED); | ||
1625 | 1617 | ||
1626 | return; | 1618 | return; |
1627 | } | 1619 | } |
1628 | 1620 | ||
1629 | /* | 1621 | /* If we dont process any completions I am not sure that we want to do this. |
1630 | * If we dont process any completions I am not sure that we want to do this. | 1622 | * We are in the middle of a hardware fault and should probably be reset. |
1631 | * We are in the middle of a hardware fault and should probably be reset. */ | 1623 | */ |
1632 | SMU_IMR_WRITE(scic, 0x00000000); | 1624 | SMU_IMR_WRITE(scic, 0x00000000); |
1633 | } | 1625 | } |
1634 | 1626 | ||
@@ -1655,12 +1647,8 @@ void scic_sds_controller_link_up( | |||
1655 | else | 1647 | else |
1656 | dev_dbg(scic_to_dev(scic), | 1648 | dev_dbg(scic_to_dev(scic), |
1657 | "%s: SCIC Controller linkup event from phy %d in " | 1649 | "%s: SCIC Controller linkup event from phy %d in " |
1658 | "unexpected state %d\n", | 1650 | "unexpected state %d\n", __func__, sci_phy->phy_index, |
1659 | __func__, | 1651 | state); |
1660 | sci_phy->phy_index, | ||
1661 | sci_base_state_machine_get_state( | ||
1662 | scic_sds_controller_get_base_state_machine( | ||
1663 | scic))); | ||
1664 | } | 1652 | } |
1665 | 1653 | ||
1666 | 1654 | ||
@@ -2125,11 +2113,7 @@ enum sci_status scic_controller_initialize( | |||
2125 | else | 2113 | else |
2126 | dev_warn(scic_to_dev(scic), | 2114 | dev_warn(scic_to_dev(scic), |
2127 | "%s: SCIC Controller initialize operation requested " | 2115 | "%s: SCIC Controller initialize operation requested " |
2128 | "in invalid state %d\n", | 2116 | "in invalid state %d\n", __func__, state); |
2129 | __func__, | ||
2130 | sci_base_state_machine_get_state( | ||
2131 | scic_sds_controller_get_base_state_machine( | ||
2132 | scic))); | ||
2133 | 2117 | ||
2134 | return status; | 2118 | return status; |
2135 | } | 2119 | } |
@@ -2180,11 +2164,7 @@ enum sci_status scic_controller_start( | |||
2180 | else | 2164 | else |
2181 | dev_warn(scic_to_dev(scic), | 2165 | dev_warn(scic_to_dev(scic), |
2182 | "%s: SCIC Controller start operation requested in " | 2166 | "%s: SCIC Controller start operation requested in " |
2183 | "invalid state %d\n", | 2167 | "invalid state %d\n", __func__, state); |
2184 | __func__, | ||
2185 | sci_base_state_machine_get_state( | ||
2186 | scic_sds_controller_get_base_state_machine( | ||
2187 | scic))); | ||
2188 | 2168 | ||
2189 | return status; | 2169 | return status; |
2190 | } | 2170 | } |
@@ -2207,11 +2187,7 @@ enum sci_status scic_controller_stop( | |||
2207 | else | 2187 | else |
2208 | dev_warn(scic_to_dev(scic), | 2188 | dev_warn(scic_to_dev(scic), |
2209 | "%s: SCIC Controller stop operation requested in " | 2189 | "%s: SCIC Controller stop operation requested in " |
2210 | "invalid state %d\n", | 2190 | "invalid state %d\n", __func__, state); |
2211 | __func__, | ||
2212 | sci_base_state_machine_get_state( | ||
2213 | scic_sds_controller_get_base_state_machine( | ||
2214 | scic))); | ||
2215 | 2191 | ||
2216 | return status; | 2192 | return status; |
2217 | } | 2193 | } |
@@ -2233,11 +2209,7 @@ enum sci_status scic_controller_reset( | |||
2233 | else | 2209 | else |
2234 | dev_warn(scic_to_dev(scic), | 2210 | dev_warn(scic_to_dev(scic), |
2235 | "%s: SCIC Controller reset operation requested in " | 2211 | "%s: SCIC Controller reset operation requested in " |
2236 | "invalid state %d\n", | 2212 | "invalid state %d\n", __func__, state); |
2237 | __func__, | ||
2238 | sci_base_state_machine_get_state( | ||
2239 | scic_sds_controller_get_base_state_machine( | ||
2240 | scic))); | ||
2241 | 2213 | ||
2242 | return status; | 2214 | return status; |
2243 | } | 2215 | } |
@@ -2765,128 +2737,57 @@ struct scic_sds_controller *scic_controller_alloc(struct device *dev) | |||
2765 | return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL); | 2737 | return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL); |
2766 | } | 2738 | } |
2767 | 2739 | ||
2768 | /* | 2740 | static enum sci_status default_controller_handler(struct sci_base_controller *base_scic, |
2769 | * ***************************************************************************** | 2741 | const char *func) |
2770 | * * DEFAULT STATE HANDLERS | 2742 | { |
2771 | * ***************************************************************************** */ | 2743 | struct scic_sds_controller *scic = container_of(base_scic, typeof(*scic), parent); |
2744 | u32 state = base_scic->state_machine.current_state_id; | ||
2745 | |||
2746 | dev_warn(scic_to_dev(scic), "%s: invalid state %d\n", func, state); | ||
2747 | |||
2748 | return SCI_FAILURE_INVALID_STATE; | ||
2749 | } | ||
2772 | 2750 | ||
2773 | /** | ||
2774 | * | ||
2775 | * @controller: This is struct sci_base_controller object which is cast into a | ||
2776 | * struct scic_sds_controller object. | ||
2777 | * @remote_device: This is struct sci_base_remote_device which, if it was used, would | ||
2778 | * be cast to a struct scic_sds_remote_device. | ||
2779 | * @io_request: This is the struct sci_base_request which, if it was used, would be | ||
2780 | * cast to a SCIC_SDS_IO_REQUEST. | ||
2781 | * @io_tag: This is the IO tag to be assigned to the IO request or | ||
2782 | * SCI_CONTROLLER_INVALID_IO_TAG. | ||
2783 | * | ||
2784 | * This method is called when the struct scic_sds_controller default start io/task | ||
2785 | * handler is in place. - Issue a warning message enum sci_status | ||
2786 | * SCI_FAILURE_INVALID_STATE | ||
2787 | */ | ||
2788 | static enum sci_status scic_sds_controller_default_start_operation_handler( | 2751 | static enum sci_status scic_sds_controller_default_start_operation_handler( |
2789 | struct sci_base_controller *controller, | 2752 | struct sci_base_controller *base_scic, |
2790 | struct sci_base_remote_device *remote_device, | 2753 | struct sci_base_remote_device *remote_device, |
2791 | struct sci_base_request *io_request, | 2754 | struct sci_base_request *io_request, |
2792 | u16 io_tag) | 2755 | u16 io_tag) |
2793 | { | 2756 | { |
2794 | struct scic_sds_controller *this_controller; | 2757 | return default_controller_handler(base_scic, __func__); |
2795 | |||
2796 | this_controller = (struct scic_sds_controller *)controller; | ||
2797 | |||
2798 | dev_warn(scic_to_dev(this_controller), | ||
2799 | "%s: SCIC Controller requested to start an io/task from " | ||
2800 | "invalid state %d\n", | ||
2801 | __func__, | ||
2802 | sci_base_state_machine_get_state( | ||
2803 | scic_sds_controller_get_base_state_machine( | ||
2804 | this_controller))); | ||
2805 | |||
2806 | return SCI_FAILURE_INVALID_STATE; | ||
2807 | } | 2758 | } |
2808 | 2759 | ||
2809 | /** | ||
2810 | * | ||
2811 | * @controller: This is struct sci_base_controller object which is cast into a | ||
2812 | * struct scic_sds_controller object. | ||
2813 | * @remote_device: This is struct sci_base_remote_device which, if it was used, would | ||
2814 | * be cast to a struct scic_sds_remote_device. | ||
2815 | * @io_request: This is the struct sci_base_request which, if it was used, would be | ||
2816 | * cast to a SCIC_SDS_IO_REQUEST. | ||
2817 | * | ||
2818 | * This method is called when the struct scic_sds_controller default request handler | ||
2819 | * is in place. - Issue a warning message enum sci_status SCI_FAILURE_INVALID_STATE | ||
2820 | */ | ||
2821 | static enum sci_status scic_sds_controller_default_request_handler( | 2760 | static enum sci_status scic_sds_controller_default_request_handler( |
2822 | struct sci_base_controller *controller, | 2761 | struct sci_base_controller *base_scic, |
2823 | struct sci_base_remote_device *remote_device, | 2762 | struct sci_base_remote_device *remote_device, |
2824 | struct sci_base_request *io_request) | 2763 | struct sci_base_request *io_request) |
2825 | { | 2764 | { |
2826 | struct scic_sds_controller *this_controller; | 2765 | return default_controller_handler(base_scic, __func__); |
2827 | |||
2828 | this_controller = (struct scic_sds_controller *)controller; | ||
2829 | |||
2830 | dev_warn(scic_to_dev(this_controller), | ||
2831 | "%s: SCIC Controller request operation from invalid state %d\n", | ||
2832 | __func__, | ||
2833 | sci_base_state_machine_get_state( | ||
2834 | scic_sds_controller_get_base_state_machine( | ||
2835 | this_controller))); | ||
2836 | |||
2837 | return SCI_FAILURE_INVALID_STATE; | ||
2838 | } | 2766 | } |
2839 | 2767 | ||
2840 | /* | 2768 | static enum sci_status scic_sds_controller_general_reset_handler(struct sci_base_controller *base_scic) |
2841 | * ***************************************************************************** | ||
2842 | * * GENERAL (COMMON) STATE HANDLERS | ||
2843 | * ***************************************************************************** */ | ||
2844 | |||
2845 | /** | ||
2846 | * | ||
2847 | * @controller: The struct sci_base_controller object which is cast into a | ||
2848 | * struct scic_sds_controller object. | ||
2849 | * | ||
2850 | * This method is called when the struct scic_sds_controller is in the ready state | ||
2851 | * reset handler is in place. - Transition to | ||
2852 | * SCI_BASE_CONTROLLER_STATE_RESETTING enum sci_status SCI_SUCCESS | ||
2853 | */ | ||
2854 | static enum sci_status scic_sds_controller_general_reset_handler( | ||
2855 | struct sci_base_controller *controller) | ||
2856 | { | 2769 | { |
2857 | struct scic_sds_controller *this_controller; | 2770 | /* The reset operation is not a graceful cleanup just perform the state |
2858 | 2771 | * transition. | |
2859 | this_controller = (struct scic_sds_controller *)controller; | 2772 | */ |
2860 | 2773 | sci_base_state_machine_change_state(&base_scic->state_machine, | |
2861 | /* | 2774 | SCI_BASE_CONTROLLER_STATE_RESETTING); |
2862 | * The reset operation is not a graceful cleanup just perform the state | ||
2863 | * transition. */ | ||
2864 | sci_base_state_machine_change_state( | ||
2865 | scic_sds_controller_get_base_state_machine(this_controller), | ||
2866 | SCI_BASE_CONTROLLER_STATE_RESETTING | ||
2867 | ); | ||
2868 | 2775 | ||
2869 | return SCI_SUCCESS; | 2776 | return SCI_SUCCESS; |
2870 | } | 2777 | } |
2871 | 2778 | ||
2872 | /* | ||
2873 | * ***************************************************************************** | ||
2874 | * * RESET STATE HANDLERS | ||
2875 | * ***************************************************************************** */ | ||
2876 | |||
2877 | static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic) | 2779 | static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic) |
2878 | { | 2780 | { |
2781 | struct sci_base_state_machine *sm = &base_scic->state_machine; | ||
2879 | enum sci_status result = SCI_SUCCESS; | 2782 | enum sci_status result = SCI_SUCCESS; |
2880 | struct scic_sds_controller *scic; | 2783 | struct scic_sds_controller *scic; |
2881 | struct isci_host *ihost; | 2784 | struct isci_host *ihost; |
2882 | u32 index; | 2785 | u32 index, state; |
2883 | 2786 | ||
2884 | scic = container_of(base_scic, typeof(*scic), parent); | 2787 | scic = container_of(base_scic, typeof(*scic), parent); |
2885 | ihost = sci_object_get_association(scic); | 2788 | ihost = sci_object_get_association(scic); |
2886 | 2789 | ||
2887 | sci_base_state_machine_change_state( | 2790 | sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING); |
2888 | scic_sds_controller_get_base_state_machine(scic), | ||
2889 | SCI_BASE_CONTROLLER_STATE_INITIALIZING); | ||
2890 | 2791 | ||
2891 | scic->timeout_timer = isci_timer_create(ihost, | 2792 | scic->timeout_timer = isci_timer_create(ihost, |
2892 | scic, | 2793 | scic, |
@@ -3028,13 +2929,10 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct | |||
3028 | 2929 | ||
3029 | /* Advance the controller state machine */ | 2930 | /* Advance the controller state machine */ |
3030 | if (result == SCI_SUCCESS) | 2931 | if (result == SCI_SUCCESS) |
3031 | sci_base_state_machine_change_state( | 2932 | state = SCI_BASE_CONTROLLER_STATE_INITIALIZED; |
3032 | scic_sds_controller_get_base_state_machine(scic), | ||
3033 | SCI_BASE_CONTROLLER_STATE_INITIALIZED); | ||
3034 | else | 2933 | else |
3035 | sci_base_state_machine_change_state( | 2934 | state = SCI_BASE_CONTROLLER_STATE_FAILED; |
3036 | scic_sds_controller_get_base_state_machine(scic), | 2935 | sci_base_state_machine_change_state(sm, state); |
3037 | SCI_BASE_CONTROLLER_STATE_FAILED); | ||
3038 | 2936 | ||
3039 | return result; | 2937 | return result; |
3040 | } | 2938 | } |
@@ -3065,14 +2963,14 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct | |||
3065 | * descriptor fields is invalid. | 2963 | * descriptor fields is invalid. |
3066 | */ | 2964 | */ |
3067 | static enum sci_status scic_sds_controller_initialized_state_start_handler( | 2965 | static enum sci_status scic_sds_controller_initialized_state_start_handler( |
3068 | struct sci_base_controller *controller, | 2966 | struct sci_base_controller *base_scic, |
3069 | u32 timeout) | 2967 | u32 timeout) |
3070 | { | 2968 | { |
3071 | u16 index; | 2969 | u16 index; |
3072 | enum sci_status result; | 2970 | enum sci_status result; |
3073 | struct scic_sds_controller *scic; | 2971 | struct scic_sds_controller *scic; |
3074 | 2972 | ||
3075 | scic = (struct scic_sds_controller *)controller; | 2973 | scic = container_of(base_scic, typeof(*scic), parent); |
3076 | 2974 | ||
3077 | /* | 2975 | /* |
3078 | * Make sure that the SCI User filled in the memory descriptor | 2976 | * Make sure that the SCI User filled in the memory descriptor |
@@ -3135,9 +3033,8 @@ static enum sci_status scic_sds_controller_initialized_state_start_handler( | |||
3135 | 3033 | ||
3136 | isci_timer_start(scic->timeout_timer, timeout); | 3034 | isci_timer_start(scic->timeout_timer, timeout); |
3137 | 3035 | ||
3138 | sci_base_state_machine_change_state( | 3036 | sci_base_state_machine_change_state(&base_scic->state_machine, |
3139 | scic_sds_controller_get_base_state_machine(scic), | 3037 | SCI_BASE_CONTROLLER_STATE_STARTING); |
3140 | SCI_BASE_CONTROLLER_STATE_STARTING); | ||
3141 | } | 3038 | } |
3142 | 3039 | ||
3143 | return result; | 3040 | return result; |
@@ -3197,33 +3094,15 @@ static void scic_sds_controller_starting_state_link_down_handler( | |||
3197 | /* scic_sds_port_link_down(port, phy); */ | 3094 | /* scic_sds_port_link_down(port, phy); */ |
3198 | } | 3095 | } |
3199 | 3096 | ||
3200 | /* | 3097 | static enum sci_status scic_sds_controller_ready_state_stop_handler(struct sci_base_controller *base_scic, |
3201 | * ***************************************************************************** | 3098 | u32 timeout) |
3202 | * * READY STATE HANDLERS | ||
3203 | * ***************************************************************************** */ | ||
3204 | |||
3205 | /** | ||
3206 | * | ||
3207 | * @controller: The struct sci_base_controller object which is cast into a | ||
3208 | * struct scic_sds_controller object. | ||
3209 | * @timeout: The timeout for when the stop operation should report a failure. | ||
3210 | * | ||
3211 | * This method is called when the struct scic_sds_controller is in the ready state | ||
3212 | * stop handler is called. - Start the timeout timer - Transition to | ||
3213 | * SCI_BASE_CONTROLLER_STATE_STOPPING. enum sci_status SCI_SUCCESS | ||
3214 | */ | ||
3215 | static enum sci_status scic_sds_controller_ready_state_stop_handler( | ||
3216 | struct sci_base_controller *controller, | ||
3217 | u32 timeout) | ||
3218 | { | 3099 | { |
3219 | struct scic_sds_controller *scic = | 3100 | struct scic_sds_controller *scic; |
3220 | (struct scic_sds_controller *)controller; | ||
3221 | 3101 | ||
3102 | scic = container_of(base_scic, typeof(*scic), parent); | ||
3222 | isci_timer_start(scic->timeout_timer, timeout); | 3103 | isci_timer_start(scic->timeout_timer, timeout); |
3223 | 3104 | sci_base_state_machine_change_state(&base_scic->state_machine, | |
3224 | sci_base_state_machine_change_state( | 3105 | SCI_BASE_CONTROLLER_STATE_STOPPING); |
3225 | scic_sds_controller_get_base_state_machine(scic), | ||
3226 | SCI_BASE_CONTROLLER_STATE_STOPPING); | ||
3227 | 3106 | ||
3228 | return SCI_SUCCESS; | 3107 | return SCI_SUCCESS; |
3229 | } | 3108 | } |
@@ -3749,33 +3628,16 @@ static inline void scic_sds_controller_stopping_state_exit( | |||
3749 | isci_timer_stop(scic->timeout_timer); | 3628 | isci_timer_stop(scic->timeout_timer); |
3750 | } | 3629 | } |
3751 | 3630 | ||
3752 | /** | 3631 | static void scic_sds_controller_resetting_state_enter(struct sci_base_object *object) |
3753 | * | ||
3754 | * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller | ||
3755 | * object. | ||
3756 | * | ||
3757 | * This method implements the actions taken by the struct scic_sds_controller on entry | ||
3758 | * to the SCI_BASE_CONTROLLER_STATE_RESETTING. - Set the state handlers to the | ||
3759 | * controllers resetting state. - Write to the SCU hardware reset register to | ||
3760 | * force a reset - Transition to the SCI_BASE_CONTROLLER_STATE_RESET none | ||
3761 | */ | ||
3762 | static void scic_sds_controller_resetting_state_enter( | ||
3763 | struct sci_base_object *object) | ||
3764 | { | 3632 | { |
3765 | struct scic_sds_controller *this_controller; | 3633 | struct scic_sds_controller *scic; |
3766 | |||
3767 | this_controller = (struct scic_sds_controller *)object; | ||
3768 | |||
3769 | scic_sds_controller_reset_hardware(this_controller); | ||
3770 | 3634 | ||
3771 | sci_base_state_machine_change_state( | 3635 | scic = container_of(object, typeof(*scic), parent.parent); |
3772 | scic_sds_controller_get_base_state_machine(this_controller), | 3636 | scic_sds_controller_reset_hardware(scic); |
3773 | SCI_BASE_CONTROLLER_STATE_RESET | 3637 | sci_base_state_machine_change_state(&scic->parent.state_machine, |
3774 | ); | 3638 | SCI_BASE_CONTROLLER_STATE_RESET); |
3775 | } | 3639 | } |
3776 | 3640 | ||
3777 | /* --------------------------------------------------------------------------- */ | ||
3778 | |||
3779 | const struct sci_base_state scic_sds_controller_state_table[] = { | 3641 | const struct sci_base_state scic_sds_controller_state_table[] = { |
3780 | [SCI_BASE_CONTROLLER_STATE_INITIAL] = { | 3642 | [SCI_BASE_CONTROLLER_STATE_INITIAL] = { |
3781 | .enter_state = scic_sds_controller_initial_state_enter, | 3643 | .enter_state = scic_sds_controller_initial_state_enter, |
@@ -3800,4 +3662,3 @@ const struct sci_base_state scic_sds_controller_state_table[] = { | |||
3800 | [SCI_BASE_CONTROLLER_STATE_STOPPED] = {}, | 3662 | [SCI_BASE_CONTROLLER_STATE_STOPPED] = {}, |
3801 | [SCI_BASE_CONTROLLER_STATE_FAILED] = {} | 3663 | [SCI_BASE_CONTROLLER_STATE_FAILED] = {} |
3802 | }; | 3664 | }; |
3803 | |||
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h index f426324bf3a9..aa2698bb7ca1 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.h +++ b/drivers/scsi/isci/core/scic_sds_controller.h | |||
@@ -421,15 +421,6 @@ extern const struct sci_base_state scic_sds_controller_state_table[]; | |||
421 | } | 421 | } |
422 | 422 | ||
423 | /** | 423 | /** |
424 | * scic_sds_controller_get_base_state_machine() - | ||
425 | * | ||
426 | * This is a helper macro that gets the base state machine for the controller | ||
427 | * object | ||
428 | */ | ||
429 | #define scic_sds_controller_get_base_state_machine(this_controller) \ | ||
430 | (&(this_controller)->parent.state_machine) | ||
431 | |||
432 | /** | ||
433 | * scic_sds_controller_get_port_configuration_agent() - | 424 | * scic_sds_controller_get_port_configuration_agent() - |
434 | * | 425 | * |
435 | * This is a helper macro to get the port configuration agent from the | 426 | * This is a helper macro to get the port configuration agent from the |
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c index 225e67a9e7b1..e546e20f1ffd 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.c +++ b/drivers/scsi/isci/core/scic_sds_phy.c | |||
@@ -246,7 +246,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, | |||
246 | 0x1F4); | 246 | 0x1F4); |
247 | 247 | ||
248 | /* We can exit the initial state to the stopped state */ | 248 | /* We can exit the initial state to the stopped state */ |
249 | sci_base_state_machine_change_state(scic_sds_phy_get_base_state_machine(sci_phy), | 249 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
250 | SCI_BASE_PHY_STATE_STOPPED); | 250 | SCI_BASE_PHY_STATE_STOPPED); |
251 | 251 | ||
252 | return SCI_SUCCESS; | 252 | return SCI_SUCCESS; |
@@ -267,13 +267,10 @@ void scic_sds_phy_sata_timeout(void *phy) | |||
267 | __func__, | 267 | __func__, |
268 | sci_phy); | 268 | sci_phy); |
269 | 269 | ||
270 | sci_base_state_machine_stop( | 270 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); |
271 | scic_sds_phy_get_starting_substate_machine(sci_phy)); | ||
272 | 271 | ||
273 | sci_base_state_machine_change_state( | 272 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
274 | scic_sds_phy_get_base_state_machine(sci_phy), | 273 | SCI_BASE_PHY_STATE_STARTING); |
275 | SCI_BASE_PHY_STATE_STARTING | ||
276 | ); | ||
277 | } | 274 | } |
278 | 275 | ||
279 | /** | 276 | /** |
@@ -390,9 +387,8 @@ enum sci_status scic_sds_phy_initialize( | |||
390 | /* | 387 | /* |
391 | * There is nothing that needs to be done in this state just | 388 | * There is nothing that needs to be done in this state just |
392 | * transition to the stopped state. */ | 389 | * transition to the stopped state. */ |
393 | sci_base_state_machine_change_state( | 390 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
394 | scic_sds_phy_get_base_state_machine(sci_phy), | 391 | SCI_BASE_PHY_STATE_STOPPED); |
395 | SCI_BASE_PHY_STATE_STOPPED); | ||
396 | 392 | ||
397 | return SCI_SUCCESS; | 393 | return SCI_SUCCESS; |
398 | } | 394 | } |
@@ -716,9 +712,9 @@ static void scic_sds_phy_start_sata_link_training( | |||
716 | } | 712 | } |
717 | 713 | ||
718 | /** | 714 | /** |
719 | * This method performs processing common to all protocols upon completion of | 715 | * scic_sds_phy_complete_link_training - perform processing common to |
720 | * link training. | 716 | * all protocols upon completion of link training. |
721 | * @this_phy: This parameter specifies the phy object for which link training | 717 | * @sci_phy: This parameter specifies the phy object for which link training |
722 | * has completed. | 718 | * has completed. |
723 | * @max_link_rate: This parameter specifies the maximum link rate to be | 719 | * @max_link_rate: This parameter specifies the maximum link rate to be |
724 | * associated with this phy. | 720 | * associated with this phy. |
@@ -727,37 +723,25 @@ static void scic_sds_phy_start_sata_link_training( | |||
727 | * | 723 | * |
728 | */ | 724 | */ |
729 | static void scic_sds_phy_complete_link_training( | 725 | static void scic_sds_phy_complete_link_training( |
730 | struct scic_sds_phy *this_phy, | 726 | struct scic_sds_phy *sci_phy, |
731 | enum sci_sas_link_rate max_link_rate, | 727 | enum sci_sas_link_rate max_link_rate, |
732 | u32 next_state) | 728 | u32 next_state) |
733 | { | 729 | { |
734 | this_phy->max_negotiated_speed = max_link_rate; | 730 | sci_phy->max_negotiated_speed = max_link_rate; |
735 | 731 | ||
736 | sci_base_state_machine_change_state( | 732 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
737 | scic_sds_phy_get_starting_substate_machine(this_phy), next_state | 733 | next_state); |
738 | ); | ||
739 | } | 734 | } |
740 | 735 | ||
741 | /** | ||
742 | * | ||
743 | * @this_phy: The struct scic_sds_phy object to restart. | ||
744 | * | ||
745 | * This method restarts the struct scic_sds_phy objects base state machine in the | ||
746 | * starting state from any starting substate. none | ||
747 | */ | ||
748 | static void scic_sds_phy_restart_starting_state( | 736 | static void scic_sds_phy_restart_starting_state( |
749 | struct scic_sds_phy *this_phy) | 737 | struct scic_sds_phy *sci_phy) |
750 | { | 738 | { |
751 | /* Stop the current substate machine */ | 739 | /* Stop the current substate machine */ |
752 | sci_base_state_machine_stop( | 740 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); |
753 | scic_sds_phy_get_starting_substate_machine(this_phy) | ||
754 | ); | ||
755 | 741 | ||
756 | /* Re-enter the base state machine starting state */ | 742 | /* Re-enter the base state machine starting state */ |
757 | sci_base_state_machine_change_state( | 743 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
758 | scic_sds_phy_get_base_state_machine(this_phy), | 744 | SCI_BASE_PHY_STATE_STARTING); |
759 | SCI_BASE_PHY_STATE_STARTING | ||
760 | ); | ||
761 | } | 745 | } |
762 | 746 | ||
763 | /* **************************************************************************** | 747 | /* **************************************************************************** |
@@ -1041,7 +1025,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_han | |||
1041 | } | 1025 | } |
1042 | 1026 | ||
1043 | /** | 1027 | /** |
1044 | * | 1028 | * scic_sds_phy_starting_substate_await_sata_phy_event_handler - |
1045 | * @phy: This struct scic_sds_phy object which has received an event. | 1029 | * @phy: This struct scic_sds_phy object which has received an event. |
1046 | * @event_code: This is the event code which the phy object is to decode. | 1030 | * @event_code: This is the event code which the phy object is to decode. |
1047 | * | 1031 | * |
@@ -1054,42 +1038,39 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_han | |||
1054 | * failure event SCI_FAILURE on any unexpected event notifation | 1038 | * failure event SCI_FAILURE on any unexpected event notifation |
1055 | */ | 1039 | */ |
1056 | static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler( | 1040 | static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler( |
1057 | struct scic_sds_phy *this_phy, | 1041 | struct scic_sds_phy *sci_phy, u32 event_code) |
1058 | u32 event_code) | ||
1059 | { | 1042 | { |
1060 | u32 result = SCI_SUCCESS; | 1043 | u32 result = SCI_SUCCESS; |
1061 | 1044 | ||
1062 | switch (scu_get_event_code(event_code)) { | 1045 | switch (scu_get_event_code(event_code)) { |
1063 | case SCU_EVENT_LINK_FAILURE: | 1046 | case SCU_EVENT_LINK_FAILURE: |
1064 | /* Link failure change state back to the starting state */ | 1047 | /* Link failure change state back to the starting state */ |
1065 | scic_sds_phy_restart_starting_state(this_phy); | 1048 | scic_sds_phy_restart_starting_state(sci_phy); |
1066 | break; | 1049 | break; |
1067 | 1050 | ||
1068 | case SCU_EVENT_SATA_SPINUP_HOLD: | 1051 | case SCU_EVENT_SATA_SPINUP_HOLD: |
1069 | /* | 1052 | /* These events might be received since we dont know how many may be in |
1070 | * These events might be received since we dont know how many may be in | 1053 | * the completion queue while waiting for power |
1071 | * the completion queue while waiting for power */ | 1054 | */ |
1072 | break; | 1055 | break; |
1073 | 1056 | ||
1074 | case SCU_EVENT_SATA_PHY_DETECTED: | 1057 | case SCU_EVENT_SATA_PHY_DETECTED: |
1075 | this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; | 1058 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; |
1076 | 1059 | ||
1077 | /* We have received the SATA PHY notification change state */ | 1060 | /* We have received the SATA PHY notification change state */ |
1078 | sci_base_state_machine_change_state( | 1061 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
1079 | scic_sds_phy_get_starting_substate_machine(this_phy), | 1062 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); |
1080 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN | ||
1081 | ); | ||
1082 | break; | 1063 | break; |
1083 | 1064 | ||
1084 | case SCU_EVENT_SAS_PHY_DETECTED: | 1065 | case SCU_EVENT_SAS_PHY_DETECTED: |
1085 | /* | 1066 | /* There has been a change in the phy type before OOB/SN for the |
1086 | * There has been a change in the phy type before OOB/SN for the | 1067 | * SATA finished start down the SAS link traning path. |
1087 | * SATA finished start down the SAS link traning path. */ | 1068 | */ |
1088 | scic_sds_phy_start_sas_link_training(this_phy); | 1069 | scic_sds_phy_start_sas_link_training(sci_phy); |
1089 | break; | 1070 | break; |
1090 | 1071 | ||
1091 | default: | 1072 | default: |
1092 | dev_warn(sciphy_to_dev(this_phy), | 1073 | dev_warn(sciphy_to_dev(sci_phy), |
1093 | "%s: PHY starting substate machine received " | 1074 | "%s: PHY starting substate machine received " |
1094 | "unexpected event_code %x\n", | 1075 | "unexpected event_code %x\n", |
1095 | __func__, | 1076 | __func__, |
@@ -1182,7 +1163,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_han | |||
1182 | } | 1163 | } |
1183 | 1164 | ||
1184 | /** | 1165 | /** |
1185 | * | 1166 | * scic_sds_phy_starting_substate_await_sig_fis_event_handler - |
1186 | * @phy: This struct scic_sds_phy object which has received an event. | 1167 | * @phy: This struct scic_sds_phy object which has received an event. |
1187 | * @event_code: This is the event code which the phy object is to decode. | 1168 | * @event_code: This is the event code which the phy object is to decode. |
1188 | * | 1169 | * |
@@ -1196,27 +1177,24 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_han | |||
1196 | * unexpected event notifation | 1177 | * unexpected event notifation |
1197 | */ | 1178 | */ |
1198 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler( | 1179 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler( |
1199 | struct scic_sds_phy *this_phy, | 1180 | struct scic_sds_phy *sci_phy, u32 event_code) |
1200 | u32 event_code) | ||
1201 | { | 1181 | { |
1202 | u32 result = SCI_SUCCESS; | 1182 | u32 result = SCI_SUCCESS; |
1203 | 1183 | ||
1204 | switch (scu_get_event_code(event_code)) { | 1184 | switch (scu_get_event_code(event_code)) { |
1205 | case SCU_EVENT_SATA_PHY_DETECTED: | 1185 | case SCU_EVENT_SATA_PHY_DETECTED: |
1206 | /* Backup the state machine */ | 1186 | /* Backup the state machine */ |
1207 | sci_base_state_machine_change_state( | 1187 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
1208 | scic_sds_phy_get_starting_substate_machine(this_phy), | 1188 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); |
1209 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN | ||
1210 | ); | ||
1211 | break; | 1189 | break; |
1212 | 1190 | ||
1213 | case SCU_EVENT_LINK_FAILURE: | 1191 | case SCU_EVENT_LINK_FAILURE: |
1214 | /* Link failure change state back to the starting state */ | 1192 | /* Link failure change state back to the starting state */ |
1215 | scic_sds_phy_restart_starting_state(this_phy); | 1193 | scic_sds_phy_restart_starting_state(sci_phy); |
1216 | break; | 1194 | break; |
1217 | 1195 | ||
1218 | default: | 1196 | default: |
1219 | dev_warn(sciphy_to_dev(this_phy), | 1197 | dev_warn(sciphy_to_dev(sci_phy), |
1220 | "%s: PHY starting substate machine received " | 1198 | "%s: PHY starting substate machine received " |
1221 | "unexpected event_code %x\n", | 1199 | "unexpected event_code %x\n", |
1222 | __func__, | 1200 | __func__, |
@@ -1249,15 +1227,14 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handle | |||
1249 | * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS | 1227 | * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS |
1250 | */ | 1228 | */ |
1251 | static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler( | 1229 | static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler( |
1252 | struct scic_sds_phy *this_phy, | 1230 | struct scic_sds_phy *sci_phy, u32 frame_index) |
1253 | u32 frame_index) | ||
1254 | { | 1231 | { |
1255 | enum sci_status result; | 1232 | enum sci_status result; |
1256 | u32 *frame_words; | 1233 | u32 *frame_words; |
1257 | struct sci_sas_identify_address_frame *identify_frame; | 1234 | struct sci_sas_identify_address_frame *identify_frame; |
1258 | 1235 | ||
1259 | result = scic_sds_unsolicited_frame_control_get_header( | 1236 | result = scic_sds_unsolicited_frame_control_get_header( |
1260 | &(scic_sds_phy_get_controller(this_phy)->uf_control), | 1237 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), |
1261 | frame_index, | 1238 | frame_index, |
1262 | (void **)&frame_words); | 1239 | (void **)&frame_words); |
1263 | 1240 | ||
@@ -1269,49 +1246,43 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler | |||
1269 | identify_frame = (struct sci_sas_identify_address_frame *)frame_words; | 1246 | identify_frame = (struct sci_sas_identify_address_frame *)frame_words; |
1270 | 1247 | ||
1271 | if (identify_frame->address_frame_type == 0) { | 1248 | if (identify_frame->address_frame_type == 0) { |
1272 | /* | 1249 | u32 state; |
1273 | * Byte swap the rest of the frame so we can make | 1250 | |
1274 | * a copy of the buffer */ | 1251 | /* Byte swap the rest of the frame so we can make |
1252 | * a copy of the buffer | ||
1253 | */ | ||
1275 | frame_words[1] = SCIC_SWAP_DWORD(frame_words[1]); | 1254 | frame_words[1] = SCIC_SWAP_DWORD(frame_words[1]); |
1276 | frame_words[2] = SCIC_SWAP_DWORD(frame_words[2]); | 1255 | frame_words[2] = SCIC_SWAP_DWORD(frame_words[2]); |
1277 | frame_words[3] = SCIC_SWAP_DWORD(frame_words[3]); | 1256 | frame_words[3] = SCIC_SWAP_DWORD(frame_words[3]); |
1278 | frame_words[4] = SCIC_SWAP_DWORD(frame_words[4]); | 1257 | frame_words[4] = SCIC_SWAP_DWORD(frame_words[4]); |
1279 | frame_words[5] = SCIC_SWAP_DWORD(frame_words[5]); | 1258 | frame_words[5] = SCIC_SWAP_DWORD(frame_words[5]); |
1280 | 1259 | ||
1281 | memcpy( | 1260 | memcpy(&sci_phy->phy_type.sas.identify_address_frame_buffer, |
1282 | &this_phy->phy_type.sas.identify_address_frame_buffer, | ||
1283 | identify_frame, | 1261 | identify_frame, |
1284 | sizeof(struct sci_sas_identify_address_frame) | 1262 | sizeof(struct sci_sas_identify_address_frame)); |
1285 | ); | ||
1286 | 1263 | ||
1287 | if (identify_frame->protocols.u.bits.smp_target) { | 1264 | if (identify_frame->protocols.u.bits.smp_target) { |
1288 | /* | 1265 | /* We got the IAF for an expander PHY go to the final state since |
1289 | * We got the IAF for an expander PHY go to the final state since | 1266 | * there are no power requirements for expander phys. |
1290 | * there are no power requirements for expander phys. */ | 1267 | */ |
1291 | sci_base_state_machine_change_state( | 1268 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL; |
1292 | scic_sds_phy_get_starting_substate_machine(this_phy), | ||
1293 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL | ||
1294 | ); | ||
1295 | } else { | 1269 | } else { |
1296 | /* We got the IAF we can now go to the await spinup semaphore state */ | 1270 | /* We got the IAF we can now go to the await spinup semaphore state */ |
1297 | sci_base_state_machine_change_state( | 1271 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER; |
1298 | scic_sds_phy_get_starting_substate_machine(this_phy), | ||
1299 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER | ||
1300 | ); | ||
1301 | } | 1272 | } |
1302 | 1273 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | |
1274 | state); | ||
1303 | result = SCI_SUCCESS; | 1275 | result = SCI_SUCCESS; |
1304 | } else | 1276 | } else |
1305 | dev_warn(sciphy_to_dev(this_phy), | 1277 | dev_warn(sciphy_to_dev(sci_phy), |
1306 | "%s: PHY starting substate machine received " | 1278 | "%s: PHY starting substate machine received " |
1307 | "unexpected frame id %x\n", | 1279 | "unexpected frame id %x\n", |
1308 | __func__, | 1280 | __func__, |
1309 | frame_index); | 1281 | frame_index); |
1310 | 1282 | ||
1311 | /* Regardless of the result release this frame since we are done with it */ | 1283 | /* Regardless of the result release this frame since we are done with it */ |
1312 | scic_sds_controller_release_frame( | 1284 | scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy), |
1313 | scic_sds_phy_get_controller(this_phy), frame_index | 1285 | frame_index); |
1314 | ); | ||
1315 | 1286 | ||
1316 | return result; | 1287 | return result; |
1317 | } | 1288 | } |
@@ -1331,7 +1302,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler | |||
1331 | * data | 1302 | * data |
1332 | */ | 1303 | */ |
1333 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler( | 1304 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler( |
1334 | struct scic_sds_phy *this_phy, | 1305 | struct scic_sds_phy *sci_phy, |
1335 | u32 frame_index) | 1306 | u32 frame_index) |
1336 | { | 1307 | { |
1337 | enum sci_status result; | 1308 | enum sci_status result; |
@@ -1340,7 +1311,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle | |||
1340 | u32 *fis_frame_data; | 1311 | u32 *fis_frame_data; |
1341 | 1312 | ||
1342 | result = scic_sds_unsolicited_frame_control_get_header( | 1313 | result = scic_sds_unsolicited_frame_control_get_header( |
1343 | &(scic_sds_phy_get_controller(this_phy)->uf_control), | 1314 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), |
1344 | frame_index, | 1315 | frame_index, |
1345 | (void **)&frame_words); | 1316 | (void **)&frame_words); |
1346 | 1317 | ||
@@ -1350,40 +1321,33 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle | |||
1350 | 1321 | ||
1351 | fis_frame_header = (struct sata_fis_header *)frame_words; | 1322 | fis_frame_header = (struct sata_fis_header *)frame_words; |
1352 | 1323 | ||
1353 | if ( | 1324 | if ((fis_frame_header->fis_type == SATA_FIS_TYPE_REGD2H) && |
1354 | (fis_frame_header->fis_type == SATA_FIS_TYPE_REGD2H) | 1325 | !(fis_frame_header->status & ATA_STATUS_REG_BSY_BIT)) { |
1355 | && !(fis_frame_header->status & ATA_STATUS_REG_BSY_BIT) | ||
1356 | ) { | ||
1357 | scic_sds_unsolicited_frame_control_get_buffer( | 1326 | scic_sds_unsolicited_frame_control_get_buffer( |
1358 | &(scic_sds_phy_get_controller(this_phy)->uf_control), | 1327 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), |
1359 | frame_index, | 1328 | frame_index, |
1360 | (void **)&fis_frame_data | 1329 | (void **)&fis_frame_data); |
1361 | ); | ||
1362 | 1330 | ||
1363 | scic_sds_controller_copy_sata_response( | 1331 | scic_sds_controller_copy_sata_response( |
1364 | &this_phy->phy_type.sata.signature_fis_buffer, | 1332 | &sci_phy->phy_type.sata.signature_fis_buffer, |
1365 | frame_words, | 1333 | frame_words, |
1366 | fis_frame_data | 1334 | fis_frame_data); |
1367 | ); | ||
1368 | 1335 | ||
1369 | /* We got the IAF we can now go to the await spinup semaphore state */ | 1336 | /* We got the IAF we can now go to the await spinup semaphore state */ |
1370 | sci_base_state_machine_change_state( | 1337 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
1371 | scic_sds_phy_get_starting_substate_machine(this_phy), | 1338 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); |
1372 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL | ||
1373 | ); | ||
1374 | 1339 | ||
1375 | result = SCI_SUCCESS; | 1340 | result = SCI_SUCCESS; |
1376 | } else | 1341 | } else |
1377 | dev_warn(sciphy_to_dev(this_phy), | 1342 | dev_warn(sciphy_to_dev(sci_phy), |
1378 | "%s: PHY starting substate machine received " | 1343 | "%s: PHY starting substate machine received " |
1379 | "unexpected frame id %x\n", | 1344 | "unexpected frame id %x\n", |
1380 | __func__, | 1345 | __func__, |
1381 | frame_index); | 1346 | frame_index); |
1382 | 1347 | ||
1383 | /* Regardless of the result release this frame since we are done with it */ | 1348 | /* Regardless of the result release this frame since we are done with it */ |
1384 | scic_sds_controller_release_frame( | 1349 | scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy), |
1385 | scic_sds_phy_get_controller(this_phy), frame_index | 1350 | frame_index); |
1386 | ); | ||
1387 | 1351 | ||
1388 | return result; | 1352 | return result; |
1389 | } | 1353 | } |
@@ -1394,7 +1358,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle | |||
1394 | * ***************************************************************************** */ | 1358 | * ***************************************************************************** */ |
1395 | 1359 | ||
1396 | /** | 1360 | /** |
1397 | * | 1361 | * scic_sds_phy_starting_substate_await_sas_power_consume_power_handler - |
1398 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy | 1362 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy |
1399 | * object. | 1363 | * object. |
1400 | * | 1364 | * |
@@ -1404,19 +1368,17 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle | |||
1404 | * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS | 1368 | * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS |
1405 | */ | 1369 | */ |
1406 | static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler( | 1370 | static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler( |
1407 | struct scic_sds_phy *this_phy) | 1371 | struct scic_sds_phy *sci_phy) |
1408 | { | 1372 | { |
1409 | u32 enable_spinup; | 1373 | u32 enable_spinup; |
1410 | 1374 | ||
1411 | enable_spinup = SCU_SAS_ENSPINUP_READ(this_phy); | 1375 | enable_spinup = SCU_SAS_ENSPINUP_READ(sci_phy); |
1412 | enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); | 1376 | enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); |
1413 | SCU_SAS_ENSPINUP_WRITE(this_phy, enable_spinup); | 1377 | SCU_SAS_ENSPINUP_WRITE(sci_phy, enable_spinup); |
1414 | 1378 | ||
1415 | /* Change state to the final state this substate machine has run to completion */ | 1379 | /* Change state to the final state this substate machine has run to completion */ |
1416 | sci_base_state_machine_change_state( | 1380 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
1417 | scic_sds_phy_get_starting_substate_machine(this_phy), | 1381 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); |
1418 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL | ||
1419 | ); | ||
1420 | 1382 | ||
1421 | return SCI_SUCCESS; | 1383 | return SCI_SUCCESS; |
1422 | } | 1384 | } |
@@ -1431,27 +1393,25 @@ static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_po | |||
1431 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS | 1393 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS |
1432 | */ | 1394 | */ |
1433 | static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler( | 1395 | static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler( |
1434 | struct scic_sds_phy *this_phy) | 1396 | struct scic_sds_phy *sci_phy) |
1435 | { | 1397 | { |
1436 | u32 scu_sas_pcfg_value; | 1398 | u32 scu_sas_pcfg_value; |
1437 | 1399 | ||
1438 | /* Release the spinup hold state and reset the OOB state machine */ | 1400 | /* Release the spinup hold state and reset the OOB state machine */ |
1439 | scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy); | 1401 | scu_sas_pcfg_value = SCU_SAS_PCFG_READ(sci_phy); |
1440 | scu_sas_pcfg_value &= | 1402 | scu_sas_pcfg_value &= |
1441 | ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); | 1403 | ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); |
1442 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | 1404 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); |
1443 | SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value); | 1405 | SCU_SAS_PCFG_WRITE(sci_phy, scu_sas_pcfg_value); |
1444 | 1406 | ||
1445 | /* Now restart the OOB operation */ | 1407 | /* Now restart the OOB operation */ |
1446 | scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | 1408 | scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); |
1447 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | 1409 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); |
1448 | SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value); | 1410 | SCU_SAS_PCFG_WRITE(sci_phy, scu_sas_pcfg_value); |
1449 | 1411 | ||
1450 | /* Change state to the final state this substate machine has run to completion */ | 1412 | /* Change state to the final state this substate machine has run to completion */ |
1451 | sci_base_state_machine_change_state( | 1413 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
1452 | scic_sds_phy_get_starting_substate_machine(this_phy), | 1414 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); |
1453 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN | ||
1454 | ); | ||
1455 | 1415 | ||
1456 | return SCI_SUCCESS; | 1416 | return SCI_SUCCESS; |
1457 | } | 1417 | } |
@@ -1566,7 +1526,7 @@ const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_t | |||
1566 | * **************************************************************************** */ | 1526 | * **************************************************************************** */ |
1567 | 1527 | ||
1568 | /** | 1528 | /** |
1569 | * | 1529 | * scic_sds_phy_starting_initial_substate_enter - |
1570 | * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. | 1530 | * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. |
1571 | * | 1531 | * |
1572 | * This method will perform the actions required by the struct scic_sds_phy on | 1532 | * This method will perform the actions required by the struct scic_sds_phy on |
@@ -1574,21 +1534,18 @@ const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_t | |||
1574 | * handlers are put in place for the struct scic_sds_phy object. - The state is | 1534 | * handlers are put in place for the struct scic_sds_phy object. - The state is |
1575 | * changed to the wait phy type event notification. none | 1535 | * changed to the wait phy type event notification. none |
1576 | */ | 1536 | */ |
1577 | static void scic_sds_phy_starting_initial_substate_enter( | 1537 | static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_object *object) |
1578 | struct sci_base_object *object) | ||
1579 | { | 1538 | { |
1580 | struct scic_sds_phy *this_phy; | 1539 | struct scic_sds_phy *sci_phy; |
1581 | 1540 | ||
1582 | this_phy = (struct scic_sds_phy *)object; | 1541 | sci_phy = (struct scic_sds_phy *)object; |
1583 | 1542 | ||
1584 | scic_sds_phy_set_starting_substate_handlers( | 1543 | scic_sds_phy_set_starting_substate_handlers( |
1585 | this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | 1544 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); |
1586 | 1545 | ||
1587 | /* This is just an temporary state go off to the starting state */ | 1546 | /* This is just an temporary state go off to the starting state */ |
1588 | sci_base_state_machine_change_state( | 1547 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, |
1589 | scic_sds_phy_get_starting_substate_machine(this_phy), | 1548 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); |
1590 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN | ||
1591 | ); | ||
1592 | } | 1549 | } |
1593 | 1550 | ||
1594 | /** | 1551 | /** |
@@ -1892,23 +1849,20 @@ static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit( | |||
1892 | * object state handlers for this state. - Change base state machine to the | 1849 | * object state handlers for this state. - Change base state machine to the |
1893 | * ready state. none | 1850 | * ready state. none |
1894 | */ | 1851 | */ |
1895 | static void scic_sds_phy_starting_final_substate_enter( | 1852 | static void scic_sds_phy_starting_final_substate_enter(struct sci_base_object *object) |
1896 | struct sci_base_object *object) | ||
1897 | { | 1853 | { |
1898 | struct scic_sds_phy *this_phy; | 1854 | struct scic_sds_phy *sci_phy; |
1899 | 1855 | ||
1900 | this_phy = (struct scic_sds_phy *)object; | 1856 | sci_phy = container_of(object, typeof(*sci_phy), parent.parent); |
1901 | 1857 | ||
1902 | scic_sds_phy_set_starting_substate_handlers( | 1858 | scic_sds_phy_set_starting_substate_handlers(sci_phy, |
1903 | this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL | 1859 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); |
1904 | ); | ||
1905 | 1860 | ||
1906 | /* | 1861 | /* State machine has run to completion so exit out and change |
1907 | * State machine has run to completion so exit out and change | 1862 | * the base state machine to the ready state |
1908 | * the base state machine to the ready state */ | 1863 | */ |
1909 | sci_base_state_machine_change_state( | 1864 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
1910 | scic_sds_phy_get_base_state_machine(this_phy), | 1865 | SCI_BASE_PHY_STATE_READY); |
1911 | SCI_BASE_PHY_STATE_READY); | ||
1912 | } | 1866 | } |
1913 | 1867 | ||
1914 | /* --------------------------------------------------------------------------- */ | 1868 | /* --------------------------------------------------------------------------- */ |
@@ -2150,153 +2104,85 @@ enum sci_status scic_sds_phy_default_consume_power_handler( | |||
2150 | * attempts to start it. - The phy state machine is transitioned to the | 2104 | * attempts to start it. - The phy state machine is transitioned to the |
2151 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS | 2105 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS |
2152 | */ | 2106 | */ |
2153 | static enum sci_status scic_sds_phy_stopped_state_start_handler( | 2107 | static enum sci_status scic_sds_phy_stopped_state_start_handler(struct sci_base_phy *base_phy) |
2154 | struct sci_base_phy *phy) | ||
2155 | { | 2108 | { |
2156 | struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)phy; | 2109 | struct isci_host *ihost; |
2157 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | 2110 | struct scic_sds_phy *sci_phy; |
2158 | struct isci_host *ihost = sci_object_get_association(scic); | 2111 | struct scic_sds_controller *scic; |
2112 | |||
2113 | sci_phy = container_of(base_phy, typeof(*sci_phy), parent); | ||
2114 | scic = scic_sds_phy_get_controller(sci_phy), | ||
2115 | ihost = sci_object_get_association(scic); | ||
2159 | 2116 | ||
2160 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | 2117 | /* Create the SIGNATURE FIS Timeout timer for this phy */ |
2161 | sci_phy->sata_timeout_timer = | 2118 | sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy, |
2162 | isci_timer_create( | 2119 | scic_sds_phy_sata_timeout); |
2163 | ihost, | ||
2164 | sci_phy, | ||
2165 | scic_sds_phy_sata_timeout); | ||
2166 | 2120 | ||
2167 | if (sci_phy->sata_timeout_timer != NULL) { | 2121 | if (sci_phy->sata_timeout_timer) |
2168 | sci_base_state_machine_change_state( | 2122 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
2169 | scic_sds_phy_get_base_state_machine(sci_phy), | 2123 | SCI_BASE_PHY_STATE_STARTING); |
2170 | SCI_BASE_PHY_STATE_STARTING); | ||
2171 | } | ||
2172 | 2124 | ||
2173 | return SCI_SUCCESS; | 2125 | return SCI_SUCCESS; |
2174 | } | 2126 | } |
2175 | 2127 | ||
2176 | /** | 2128 | static enum sci_status scic_sds_phy_stopped_state_destroy_handler(struct sci_base_phy *base_phy) |
2177 | * | ||
2178 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy | ||
2179 | * object. | ||
2180 | * | ||
2181 | * This method takes the struct scic_sds_phy from a stopped state and destroys it. - | ||
2182 | * This function takes no action. Shouldnt this function transition the | ||
2183 | * struct sci_base_phy::state_machine to the SCI_BASE_PHY_STATE_FINAL? enum sci_status | ||
2184 | * SCI_SUCCESS | ||
2185 | */ | ||
2186 | static enum sci_status scic_sds_phy_stopped_state_destroy_handler( | ||
2187 | struct sci_base_phy *phy) | ||
2188 | { | 2129 | { |
2189 | struct scic_sds_phy *this_phy; | ||
2190 | |||
2191 | this_phy = (struct scic_sds_phy *)phy; | ||
2192 | |||
2193 | /* @todo what do we actually need to do here? */ | ||
2194 | return SCI_SUCCESS; | 2130 | return SCI_SUCCESS; |
2195 | } | 2131 | } |
2196 | 2132 | ||
2197 | /* | 2133 | static enum sci_status scic_sds_phy_ready_state_stop_handler(struct sci_base_phy *base_phy) |
2198 | * ****************************************************************************** | ||
2199 | * * PHY STARTING STATE HANDLERS | ||
2200 | * ****************************************************************************** */ | ||
2201 | |||
2202 | /* All of these state handlers are mapped to the starting sub-state machine */ | ||
2203 | |||
2204 | /* | ||
2205 | * ****************************************************************************** | ||
2206 | * * PHY READY STATE HANDLERS | ||
2207 | * ****************************************************************************** */ | ||
2208 | |||
2209 | /** | ||
2210 | * | ||
2211 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy | ||
2212 | * object. | ||
2213 | * | ||
2214 | * This method takes the struct scic_sds_phy from a ready state and attempts to stop | ||
2215 | * it. - The phy state machine is transitioned to the | ||
2216 | * SCI_BASE_PHY_STATE_STOPPED. enum sci_status SCI_SUCCESS | ||
2217 | */ | ||
2218 | static enum sci_status scic_sds_phy_ready_state_stop_handler( | ||
2219 | struct sci_base_phy *phy) | ||
2220 | { | 2134 | { |
2221 | struct scic_sds_phy *this_phy; | 2135 | sci_base_state_machine_change_state(&base_phy->state_machine, |
2222 | 2136 | SCI_BASE_PHY_STATE_STOPPED); | |
2223 | this_phy = (struct scic_sds_phy *)phy; | ||
2224 | |||
2225 | sci_base_state_machine_change_state( | ||
2226 | scic_sds_phy_get_base_state_machine(this_phy), | ||
2227 | SCI_BASE_PHY_STATE_STOPPED | ||
2228 | ); | ||
2229 | 2137 | ||
2230 | return SCI_SUCCESS; | 2138 | return SCI_SUCCESS; |
2231 | } | 2139 | } |
2232 | 2140 | ||
2233 | /** | 2141 | static enum sci_status scic_sds_phy_ready_state_reset_handler(struct sci_base_phy *base_phy) |
2234 | * | ||
2235 | * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy | ||
2236 | * object. | ||
2237 | * | ||
2238 | * This method takes the struct scic_sds_phy from a ready state and attempts to reset | ||
2239 | * it. - The phy state machine is transitioned to the | ||
2240 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS | ||
2241 | */ | ||
2242 | static enum sci_status scic_sds_phy_ready_state_reset_handler( | ||
2243 | struct sci_base_phy *phy) | ||
2244 | { | 2142 | { |
2245 | struct scic_sds_phy *this_phy; | 2143 | sci_base_state_machine_change_state(&base_phy->state_machine, |
2246 | 2144 | SCI_BASE_PHY_STATE_RESETTING); | |
2247 | this_phy = (struct scic_sds_phy *)phy; | ||
2248 | |||
2249 | sci_base_state_machine_change_state( | ||
2250 | scic_sds_phy_get_base_state_machine(this_phy), | ||
2251 | SCI_BASE_PHY_STATE_RESETTING | ||
2252 | ); | ||
2253 | 2145 | ||
2254 | return SCI_SUCCESS; | 2146 | return SCI_SUCCESS; |
2255 | } | 2147 | } |
2256 | 2148 | ||
2257 | /** | 2149 | /** |
2258 | * | 2150 | * scic_sds_phy_ready_state_event_handler - |
2259 | * @phy: This is the struct scic_sds_phy object which has received the event. | 2151 | * @phy: This is the struct scic_sds_phy object which has received the event. |
2260 | * | 2152 | * |
2261 | * This method request the struct scic_sds_phy handle the received event. The only | 2153 | * This method request the struct scic_sds_phy handle the received event. The only |
2262 | * event that we are interested in while in the ready state is the link failure | 2154 | * event that we are interested in while in the ready state is the link failure |
2263 | * event. - decoded event is a link failure - transition the struct scic_sds_phy back | 2155 | * event. - decoded event is a link failure - transition the struct scic_sds_phy back |
2264 | * to the SCI_BASE_PHY_STATE_STARTING state. - any other event recived will | 2156 | * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will |
2265 | * report a warning message enum sci_status SCI_SUCCESS if the event received is a | 2157 | * report a warning message enum sci_status SCI_SUCCESS if the event received is a |
2266 | * link failure SCI_FAILURE_INVALID_STATE for any other event received. | 2158 | * link failure SCI_FAILURE_INVALID_STATE for any other event received. |
2267 | */ | 2159 | */ |
2268 | static enum sci_status scic_sds_phy_ready_state_event_handler( | 2160 | static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy, |
2269 | struct scic_sds_phy *this_phy, | 2161 | u32 event_code) |
2270 | u32 event_code) | ||
2271 | { | 2162 | { |
2272 | enum sci_status result = SCI_FAILURE; | 2163 | enum sci_status result = SCI_FAILURE; |
2273 | 2164 | ||
2274 | switch (scu_get_event_code(event_code)) { | 2165 | switch (scu_get_event_code(event_code)) { |
2275 | case SCU_EVENT_LINK_FAILURE: | 2166 | case SCU_EVENT_LINK_FAILURE: |
2276 | /* Link failure change state back to the starting state */ | 2167 | /* Link failure change state back to the starting state */ |
2277 | sci_base_state_machine_change_state( | 2168 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
2278 | scic_sds_phy_get_base_state_machine(this_phy), | 2169 | SCI_BASE_PHY_STATE_STARTING); |
2279 | SCI_BASE_PHY_STATE_STARTING | ||
2280 | ); | ||
2281 | |||
2282 | result = SCI_SUCCESS; | 2170 | result = SCI_SUCCESS; |
2283 | break; | 2171 | break; |
2284 | 2172 | ||
2285 | case SCU_EVENT_BROADCAST_CHANGE: | 2173 | case SCU_EVENT_BROADCAST_CHANGE: |
2286 | /* Broadcast change received. Notify the port. */ | 2174 | /* Broadcast change received. Notify the port. */ |
2287 | if (scic_sds_phy_get_port(this_phy) != NULL) | 2175 | if (scic_sds_phy_get_port(sci_phy) != NULL) |
2288 | scic_sds_port_broadcast_change_received(this_phy->owning_port, this_phy); | 2176 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); |
2289 | else | 2177 | else |
2290 | this_phy->bcn_received_while_port_unassigned = true; | 2178 | sci_phy->bcn_received_while_port_unassigned = true; |
2291 | break; | 2179 | break; |
2292 | 2180 | ||
2293 | default: | 2181 | default: |
2294 | dev_warn(sciphy_to_dev(this_phy), | 2182 | dev_warn(sciphy_to_dev(sci_phy), |
2295 | "%sP SCIC PHY 0x%p ready state machine received " | 2183 | "%sP SCIC PHY 0x%p ready state machine received " |
2296 | "unexpected event_code %x\n", | 2184 | "unexpected event_code %x\n", |
2297 | __func__, | 2185 | __func__, sci_phy, event_code); |
2298 | this_phy, | ||
2299 | event_code); | ||
2300 | 2186 | ||
2301 | result = SCI_FAILURE_INVALID_STATE; | 2187 | result = SCI_FAILURE_INVALID_STATE; |
2302 | break; | 2188 | break; |
@@ -2305,40 +2191,24 @@ static enum sci_status scic_sds_phy_ready_state_event_handler( | |||
2305 | return result; | 2191 | return result; |
2306 | } | 2192 | } |
2307 | 2193 | ||
2308 | /* --------------------------------------------------------------------------- */ | 2194 | static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy, |
2309 | 2195 | u32 event_code) | |
2310 | /** | ||
2311 | * | ||
2312 | * @this_phy: This is the struct scic_sds_phy object which is receiving the event. | ||
2313 | * @event_code: This is the event code to be processed. | ||
2314 | * | ||
2315 | * This is the resetting state event handler. enum sci_status | ||
2316 | * SCI_FAILURE_INVALID_STATE | ||
2317 | */ | ||
2318 | static enum sci_status scic_sds_phy_resetting_state_event_handler( | ||
2319 | struct scic_sds_phy *this_phy, | ||
2320 | u32 event_code) | ||
2321 | { | 2196 | { |
2322 | enum sci_status result = SCI_FAILURE; | 2197 | enum sci_status result = SCI_FAILURE; |
2323 | 2198 | ||
2324 | switch (scu_get_event_code(event_code)) { | 2199 | switch (scu_get_event_code(event_code)) { |
2325 | case SCU_EVENT_HARD_RESET_TRANSMITTED: | 2200 | case SCU_EVENT_HARD_RESET_TRANSMITTED: |
2326 | /* Link failure change state back to the starting state */ | 2201 | /* Link failure change state back to the starting state */ |
2327 | sci_base_state_machine_change_state( | 2202 | sci_base_state_machine_change_state(&sci_phy->parent.state_machine, |
2328 | scic_sds_phy_get_base_state_machine(this_phy), | 2203 | SCI_BASE_PHY_STATE_STARTING); |
2329 | SCI_BASE_PHY_STATE_STARTING | ||
2330 | ); | ||
2331 | |||
2332 | result = SCI_SUCCESS; | 2204 | result = SCI_SUCCESS; |
2333 | break; | 2205 | break; |
2334 | 2206 | ||
2335 | default: | 2207 | default: |
2336 | dev_warn(sciphy_to_dev(this_phy), | 2208 | dev_warn(sciphy_to_dev(sci_phy), |
2337 | "%s: SCIC PHY 0x%p resetting state machine received " | 2209 | "%s: SCIC PHY 0x%p resetting state machine received " |
2338 | "unexpected event_code %x\n", | 2210 | "unexpected event_code %x\n", |
2339 | __func__, | 2211 | __func__, sci_phy, event_code); |
2340 | this_phy, | ||
2341 | event_code); | ||
2342 | 2212 | ||
2343 | result = SCI_FAILURE_INVALID_STATE; | 2213 | result = SCI_FAILURE_INVALID_STATE; |
2344 | break; | 2214 | break; |
diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h index b611e33180b2..af9e24c30945 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.h +++ b/drivers/scsi/isci/core/scic_sds_phy.h | |||
@@ -317,24 +317,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha | |||
317 | (scic_sds_port_get_controller((phy)->owning_port)) | 317 | (scic_sds_port_get_controller((phy)->owning_port)) |
318 | 318 | ||
319 | /** | 319 | /** |
320 | * scic_sds_phy_get_base_state_machine() - This macro returns the state machine | ||
321 | * for the base phy | ||
322 | * | ||
323 | * | ||
324 | */ | ||
325 | #define scic_sds_phy_get_base_state_machine(phy) \ | ||
326 | (&(phy)->parent.state_machine) | ||
327 | |||
328 | /** | ||
329 | * scic_sds_phy_get_starting_substate_machine() - This macro returns the | ||
330 | * starting substate machine for this phy | ||
331 | * | ||
332 | * | ||
333 | */ | ||
334 | #define scic_sds_phy_get_starting_substate_machine(phy) \ | ||
335 | (&(phy)->starting_substate_machine) | ||
336 | |||
337 | /** | ||
338 | * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for | 320 | * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for |
339 | * this phy object | 321 | * this phy object |
340 | * | 322 | * |
@@ -354,27 +336,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha | |||
354 | &scic_sds_phy_state_handler_table[(state_id)] \ | 336 | &scic_sds_phy_state_handler_table[(state_id)] \ |
355 | ) | 337 | ) |
356 | 338 | ||
357 | /** | ||
358 | * scic_sds_phy_is_ready() - | ||
359 | * | ||
360 | * This macro returns true if the current base state for this phy is | ||
361 | * SCI_BASE_PHY_STATE_READY | ||
362 | */ | ||
363 | #define scic_sds_phy_is_ready(phy) \ | ||
364 | (\ | ||
365 | SCI_BASE_PHY_STATE_READY \ | ||
366 | == sci_base_state_machine_get_state(\ | ||
367 | scic_sds_phy_get_base_state_machine(phy) \ | ||
368 | ) \ | ||
369 | ) | ||
370 | |||
371 | /* --------------------------------------------------------------------------- */ | ||
372 | |||
373 | |||
374 | |||
375 | |||
376 | /* --------------------------------------------------------------------------- */ | ||
377 | |||
378 | void scic_sds_phy_construct( | 339 | void scic_sds_phy_construct( |
379 | struct scic_sds_phy *this_phy, | 340 | struct scic_sds_phy *this_phy, |
380 | struct scic_sds_port *owning_port, | 341 | struct scic_sds_port *owning_port, |
@@ -404,8 +365,6 @@ enum sci_status scic_sds_phy_reset( | |||
404 | void scic_sds_phy_sata_timeout( | 365 | void scic_sds_phy_sata_timeout( |
405 | void *cookie); | 366 | void *cookie); |
406 | 367 | ||
407 | /* --------------------------------------------------------------------------- */ | ||
408 | |||
409 | void scic_sds_phy_suspend( | 368 | void scic_sds_phy_suspend( |
410 | struct scic_sds_phy *this_phy); | 369 | struct scic_sds_phy *this_phy); |
411 | 370 | ||
@@ -416,8 +375,6 @@ void scic_sds_phy_setup_transport( | |||
416 | struct scic_sds_phy *this_phy, | 375 | struct scic_sds_phy *this_phy, |
417 | u32 device_id); | 376 | u32 device_id); |
418 | 377 | ||
419 | /* --------------------------------------------------------------------------- */ | ||
420 | |||
421 | enum sci_status scic_sds_phy_event_handler( | 378 | enum sci_status scic_sds_phy_event_handler( |
422 | struct scic_sds_phy *this_phy, | 379 | struct scic_sds_phy *this_phy, |
423 | u32 event_code); | 380 | u32 event_code); |
@@ -445,11 +402,6 @@ void scic_sds_phy_get_attached_phy_protocols( | |||
445 | struct scic_sds_phy *this_phy, | 402 | struct scic_sds_phy *this_phy, |
446 | struct sci_sas_identify_address_frame_protocols *protocols); | 403 | struct sci_sas_identify_address_frame_protocols *protocols); |
447 | 404 | ||
448 | /* | ||
449 | * ****************************************************************************- | ||
450 | * * SCIC SDS PHY Handler Methods | ||
451 | * ****************************************************************************- */ | ||
452 | |||
453 | enum sci_status scic_sds_phy_default_start_handler( | 405 | enum sci_status scic_sds_phy_default_start_handler( |
454 | struct sci_base_phy *phy); | 406 | struct sci_base_phy *phy); |
455 | 407 | ||
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c index 3ae0f0d80f1f..72b815ef98ca 100644 --- a/drivers/scsi/isci/core/scic_sds_port.c +++ b/drivers/scsi/isci/core/scic_sds_port.c | |||
@@ -576,12 +576,10 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index, | |||
576 | 576 | ||
577 | sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table); | 577 | sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table); |
578 | 578 | ||
579 | sci_base_state_machine_construct( | 579 | sci_base_state_machine_construct(&sci_port->ready_substate_machine, |
580 | scic_sds_port_get_ready_substate_machine(sci_port), | 580 | &sci_port->parent.parent, |
581 | &sci_port->parent.parent, | 581 | scic_sds_port_ready_substate_table, |
582 | scic_sds_port_ready_substate_table, | 582 | SCIC_SDS_PORT_READY_SUBSTATE_WAITING); |
583 | SCIC_SDS_PORT_READY_SUBSTATE_WAITING | ||
584 | ); | ||
585 | 583 | ||
586 | sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT; | 584 | sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT; |
587 | sci_port->physical_port_index = port_index; | 585 | sci_port->physical_port_index = port_index; |
@@ -1339,9 +1337,9 @@ static void scic_sds_port_ready_operational_substate_link_up_handler( | |||
1339 | 1337 | ||
1340 | /** | 1338 | /** |
1341 | * scic_sds_port_ready_operational_substate_link_down_handler() - | 1339 | * scic_sds_port_ready_operational_substate_link_down_handler() - |
1342 | * @this_port: This is the struct scic_sds_port object that which has a phy that has | 1340 | * @sci_port: This is the struct scic_sds_port object that which has a phy that has |
1343 | * gone link down. | 1341 | * gone link down. |
1344 | * @the_phy: This is the struct scic_sds_phy object that has gone link down. | 1342 | * @sci_phy: This is the struct scic_sds_phy object that has gone link down. |
1345 | * | 1343 | * |
1346 | * This method is the ready operational substate link down handler for the | 1344 | * This method is the ready operational substate link down handler for the |
1347 | * struct scic_sds_port object. This function notifies the SCI User that the phy has | 1345 | * struct scic_sds_port object. This function notifies the SCI User that the phy has |
@@ -1349,21 +1347,18 @@ static void scic_sds_port_ready_operational_substate_link_up_handler( | |||
1349 | * state to the ready waiting substate. none | 1347 | * state to the ready waiting substate. none |
1350 | */ | 1348 | */ |
1351 | static void scic_sds_port_ready_operational_substate_link_down_handler( | 1349 | static void scic_sds_port_ready_operational_substate_link_down_handler( |
1352 | struct scic_sds_port *this_port, | 1350 | struct scic_sds_port *sci_port, |
1353 | struct scic_sds_phy *the_phy) | 1351 | struct scic_sds_phy *sci_phy) |
1354 | { | 1352 | { |
1355 | scic_sds_port_deactivate_phy(this_port, the_phy, true); | 1353 | scic_sds_port_deactivate_phy(sci_port, sci_phy, true); |
1356 | 1354 | ||
1357 | /* | 1355 | /* |
1358 | * If there are no active phys left in the port, then transition | 1356 | * If there are no active phys left in the port, then transition |
1359 | * the port to the WAITING state until such time as a phy goes | 1357 | * the port to the WAITING state until such time as a phy goes |
1360 | * link up. */ | 1358 | * link up. */ |
1361 | if (this_port->active_phy_mask == 0) { | 1359 | if (sci_port->active_phy_mask == 0) |
1362 | sci_base_state_machine_change_state( | 1360 | sci_base_state_machine_change_state(&sci_port->ready_substate_machine, |
1363 | scic_sds_port_get_ready_substate_machine(this_port), | 1361 | SCIC_SDS_PORT_READY_SUBSTATE_WAITING); |
1364 | SCIC_SDS_PORT_READY_SUBSTATE_WAITING | ||
1365 | ); | ||
1366 | } | ||
1367 | } | 1362 | } |
1368 | 1363 | ||
1369 | /** | 1364 | /** |
@@ -1820,169 +1815,52 @@ const struct sci_base_state scic_sds_port_ready_substate_table[] = { | |||
1820 | }, | 1815 | }, |
1821 | }; | 1816 | }; |
1822 | 1817 | ||
1823 | /* | 1818 | static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func) |
1824 | * *************************************************************************** | ||
1825 | * * DEFAULT HANDLERS | ||
1826 | * *************************************************************************** */ | ||
1827 | |||
1828 | /** | ||
1829 | * | ||
1830 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1831 | * object. | ||
1832 | * | ||
1833 | * This is the default method for port a start request. It will report a | ||
1834 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1835 | */ | ||
1836 | enum sci_status scic_sds_port_default_start_handler( | ||
1837 | struct sci_base_port *port) | ||
1838 | { | 1819 | { |
1839 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | 1820 | struct scic_sds_port *sci_port; |
1840 | 1821 | ||
1822 | sci_port = container_of(base_port, typeof(*sci_port), parent); | ||
1841 | dev_warn(sciport_to_dev(sci_port), | 1823 | dev_warn(sciport_to_dev(sci_port), |
1842 | "%s: SCIC Port 0x%p requested to start while in invalid " | 1824 | "%s: in wrong state: %d\n", func, |
1843 | "state %d\n", | 1825 | sci_base_state_machine_get_state(&base_port->state_machine)); |
1844 | __func__, | ||
1845 | port, | ||
1846 | sci_base_state_machine_get_state( | ||
1847 | scic_sds_port_get_base_state_machine( | ||
1848 | (struct scic_sds_port *)port))); | ||
1849 | |||
1850 | return SCI_FAILURE_INVALID_STATE; | 1826 | return SCI_FAILURE_INVALID_STATE; |
1851 | } | 1827 | } |
1852 | 1828 | ||
1853 | /** | 1829 | enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port) |
1854 | * | ||
1855 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1856 | * object. | ||
1857 | * | ||
1858 | * This is the default method for a port stop request. It will report a | ||
1859 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1860 | */ | ||
1861 | static enum sci_status scic_sds_port_default_stop_handler( | ||
1862 | struct sci_base_port *port) | ||
1863 | { | 1830 | { |
1864 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | 1831 | return default_port_handler(base_port, __func__); |
1865 | |||
1866 | dev_warn(sciport_to_dev(sci_port), | ||
1867 | "%s: SCIC Port 0x%p requested to stop while in invalid " | ||
1868 | "state %d\n", | ||
1869 | __func__, | ||
1870 | port, | ||
1871 | sci_base_state_machine_get_state( | ||
1872 | scic_sds_port_get_base_state_machine( | ||
1873 | (struct scic_sds_port *)port))); | ||
1874 | |||
1875 | return SCI_FAILURE_INVALID_STATE; | ||
1876 | } | 1832 | } |
1877 | 1833 | ||
1878 | /** | 1834 | static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port) |
1879 | * | ||
1880 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1881 | * object. | ||
1882 | * | ||
1883 | * This is the default method for a port destruct request. It will report a | ||
1884 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1885 | */ | ||
1886 | enum sci_status scic_sds_port_default_destruct_handler( | ||
1887 | struct sci_base_port *port) | ||
1888 | { | 1835 | { |
1889 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | 1836 | return default_port_handler(base_port, __func__); |
1890 | |||
1891 | dev_warn(sciport_to_dev(sci_port), | ||
1892 | "%s: SCIC Port 0x%p requested to destruct while in invalid " | ||
1893 | "state %d\n", | ||
1894 | __func__, | ||
1895 | port, | ||
1896 | sci_base_state_machine_get_state( | ||
1897 | scic_sds_port_get_base_state_machine( | ||
1898 | (struct scic_sds_port *)port))); | ||
1899 | |||
1900 | return SCI_FAILURE_INVALID_STATE; | ||
1901 | } | 1837 | } |
1902 | 1838 | ||
1903 | /** | 1839 | enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port) |
1904 | * | ||
1905 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1906 | * object. | ||
1907 | * @timeout: This is the timeout for the reset request to complete. | ||
1908 | * | ||
1909 | * This is the default method for a port reset request. It will report a | ||
1910 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1911 | */ | ||
1912 | enum sci_status scic_sds_port_default_reset_handler( | ||
1913 | struct sci_base_port *port, | ||
1914 | u32 timeout) | ||
1915 | { | 1840 | { |
1916 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | 1841 | return default_port_handler(base_port, __func__); |
1917 | |||
1918 | dev_warn(sciport_to_dev(sci_port), | ||
1919 | "%s: SCIC Port 0x%p requested to reset while in invalid " | ||
1920 | "state %d\n", | ||
1921 | __func__, | ||
1922 | port, | ||
1923 | sci_base_state_machine_get_state( | ||
1924 | scic_sds_port_get_base_state_machine( | ||
1925 | (struct scic_sds_port *)port))); | ||
1926 | |||
1927 | return SCI_FAILURE_INVALID_STATE; | ||
1928 | } | 1842 | } |
1929 | 1843 | ||
1930 | /** | 1844 | enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port, |
1931 | * | 1845 | u32 timeout) |
1932 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1933 | * object. | ||
1934 | * | ||
1935 | * This is the default method for a port add phy request. It will report a | ||
1936 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1937 | */ | ||
1938 | static enum sci_status scic_sds_port_default_add_phy_handler( | ||
1939 | struct sci_base_port *port, | ||
1940 | struct sci_base_phy *phy) | ||
1941 | { | 1846 | { |
1942 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | 1847 | return default_port_handler(base_port, __func__); |
1943 | |||
1944 | dev_warn(sciport_to_dev(sci_port), | ||
1945 | "%s: SCIC Port 0x%p requested to add phy 0x%p while in " | ||
1946 | "invalid state %d\n", | ||
1947 | __func__, | ||
1948 | port, | ||
1949 | phy, | ||
1950 | sci_base_state_machine_get_state( | ||
1951 | scic_sds_port_get_base_state_machine( | ||
1952 | (struct scic_sds_port *)port))); | ||
1953 | |||
1954 | return SCI_FAILURE_INVALID_STATE; | ||
1955 | } | 1848 | } |
1956 | 1849 | ||
1957 | /** | 1850 | static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port, |
1958 | * | 1851 | struct sci_base_phy *base_phy) |
1959 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
1960 | * object. | ||
1961 | * | ||
1962 | * This is the default method for a port remove phy request. It will report a | ||
1963 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1964 | */ | ||
1965 | enum sci_status scic_sds_port_default_remove_phy_handler( | ||
1966 | struct sci_base_port *port, | ||
1967 | struct sci_base_phy *phy) | ||
1968 | { | 1852 | { |
1969 | struct scic_sds_port *sci_port = (struct scic_sds_port *)port; | 1853 | return default_port_handler(base_port, __func__); |
1970 | 1854 | } | |
1971 | dev_warn(sciport_to_dev(sci_port), | ||
1972 | "%s: SCIC Port 0x%p requested to remove phy 0x%p while in " | ||
1973 | "invalid state %d\n", | ||
1974 | __func__, | ||
1975 | port, | ||
1976 | phy, | ||
1977 | sci_base_state_machine_get_state( | ||
1978 | scic_sds_port_get_base_state_machine( | ||
1979 | (struct scic_sds_port *)port))); | ||
1980 | 1855 | ||
1981 | return SCI_FAILURE_INVALID_STATE; | 1856 | enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port, |
1857 | struct sci_base_phy *base_phy) | ||
1858 | { | ||
1859 | return default_port_handler(base_port, __func__); | ||
1982 | } | 1860 | } |
1983 | 1861 | ||
1984 | /** | 1862 | /** |
1985 | * | 1863 | * scic_sds_port_default_frame_handler |
1986 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | 1864 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port |
1987 | * object. | 1865 | * object. |
1988 | * | 1866 | * |
@@ -1991,149 +1869,48 @@ enum sci_status scic_sds_port_default_remove_phy_handler( | |||
1991 | * possible to receive an unsolicited frame directed to a port object? It | 1869 | * possible to receive an unsolicited frame directed to a port object? It |
1992 | * seems possible if we implementing virtual functions but until then? | 1870 | * seems possible if we implementing virtual functions but until then? |
1993 | */ | 1871 | */ |
1994 | enum sci_status scic_sds_port_default_frame_handler( | 1872 | enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port, |
1995 | struct scic_sds_port *port, | 1873 | u32 frame_index) |
1996 | u32 frame_index) | 1874 | { |
1997 | { | 1875 | struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port); |
1998 | dev_warn(sciport_to_dev(port), | ||
1999 | "%s: SCIC Port 0x%p requested to process frame %d while in " | ||
2000 | "invalid state %d\n", | ||
2001 | __func__, | ||
2002 | port, | ||
2003 | frame_index, | ||
2004 | sci_base_state_machine_get_state( | ||
2005 | scic_sds_port_get_base_state_machine(port))); | ||
2006 | |||
2007 | scic_sds_controller_release_frame( | ||
2008 | scic_sds_port_get_controller(port), frame_index | ||
2009 | ); | ||
2010 | |||
2011 | return SCI_FAILURE_INVALID_STATE; | ||
2012 | } | ||
2013 | 1876 | ||
2014 | /** | 1877 | default_port_handler(&sci_port->parent, __func__); |
2015 | * | 1878 | scic_sds_controller_release_frame(scic, frame_index); |
2016 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2017 | * object. | ||
2018 | * | ||
2019 | * This is the default method for a port event request. It will report a | ||
2020 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
2021 | */ | ||
2022 | enum sci_status scic_sds_port_default_event_handler( | ||
2023 | struct scic_sds_port *port, | ||
2024 | u32 event_code) | ||
2025 | { | ||
2026 | dev_warn(sciport_to_dev(port), | ||
2027 | "%s: SCIC Port 0x%p requested to process event 0x%x while " | ||
2028 | "in invalid state %d\n", | ||
2029 | __func__, | ||
2030 | port, | ||
2031 | event_code, | ||
2032 | sci_base_state_machine_get_state( | ||
2033 | scic_sds_port_get_base_state_machine( | ||
2034 | (struct scic_sds_port *)port))); | ||
2035 | 1879 | ||
2036 | return SCI_FAILURE_INVALID_STATE; | 1880 | return SCI_FAILURE_INVALID_STATE; |
2037 | } | 1881 | } |
2038 | 1882 | ||
2039 | /** | 1883 | enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port, |
2040 | * | 1884 | u32 event_code) |
2041 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2042 | * object. | ||
2043 | * | ||
2044 | * This is the default method for a port link up notification. It will report | ||
2045 | * a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
2046 | */ | ||
2047 | void scic_sds_port_default_link_up_handler( | ||
2048 | struct scic_sds_port *this_port, | ||
2049 | struct scic_sds_phy *phy) | ||
2050 | { | 1885 | { |
2051 | dev_warn(sciport_to_dev(this_port), | 1886 | return default_port_handler(&sci_port->parent, __func__); |
2052 | "%s: SCIC Port 0x%p received link_up notification from phy " | ||
2053 | "0x%p while in invalid state %d\n", | ||
2054 | __func__, | ||
2055 | this_port, | ||
2056 | phy, | ||
2057 | sci_base_state_machine_get_state( | ||
2058 | scic_sds_port_get_base_state_machine(this_port))); | ||
2059 | } | 1887 | } |
2060 | 1888 | ||
2061 | /** | 1889 | void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port, |
2062 | * | 1890 | struct scic_sds_phy *sci_phy) |
2063 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2064 | * object. | ||
2065 | * | ||
2066 | * This is the default method for a port link down notification. It will | ||
2067 | * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
2068 | */ | ||
2069 | void scic_sds_port_default_link_down_handler( | ||
2070 | struct scic_sds_port *this_port, | ||
2071 | struct scic_sds_phy *phy) | ||
2072 | { | 1891 | { |
2073 | dev_warn(sciport_to_dev(this_port), | 1892 | default_port_handler(&sci_port->parent, __func__); |
2074 | "%s: SCIC Port 0x%p received link down notification from " | ||
2075 | "phy 0x%p while in invalid state %d\n", | ||
2076 | __func__, | ||
2077 | this_port, | ||
2078 | phy, | ||
2079 | sci_base_state_machine_get_state( | ||
2080 | scic_sds_port_get_base_state_machine(this_port))); | ||
2081 | } | 1893 | } |
2082 | 1894 | ||
2083 | /** | 1895 | void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port, |
2084 | * | 1896 | struct scic_sds_phy *sci_phy) |
2085 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | ||
2086 | * object. | ||
2087 | * | ||
2088 | * This is the default method for a port start io request. It will report a | ||
2089 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
2090 | */ | ||
2091 | enum sci_status scic_sds_port_default_start_io_handler( | ||
2092 | struct scic_sds_port *this_port, | ||
2093 | struct scic_sds_remote_device *device, | ||
2094 | struct scic_sds_request *io_request) | ||
2095 | { | 1897 | { |
2096 | dev_warn(sciport_to_dev(this_port), | 1898 | default_port_handler(&sci_port->parent, __func__); |
2097 | "%s: SCIC Port 0x%p requested to start io request 0x%p " | ||
2098 | "while in invalid state %d\n", | ||
2099 | __func__, | ||
2100 | this_port, | ||
2101 | io_request, | ||
2102 | sci_base_state_machine_get_state( | ||
2103 | scic_sds_port_get_base_state_machine(this_port))); | ||
2104 | |||
2105 | return SCI_FAILURE_INVALID_STATE; | ||
2106 | } | 1899 | } |
2107 | 1900 | ||
2108 | /** | 1901 | enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port, |
2109 | * | 1902 | struct scic_sds_remote_device *sci_dev, |
2110 | * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port | 1903 | struct scic_sds_request *sci_req) |
2111 | * object. | ||
2112 | * | ||
2113 | * This is the default method for a port complete io request. It will report a | ||
2114 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
2115 | */ | ||
2116 | static enum sci_status scic_sds_port_default_complete_io_handler( | ||
2117 | struct scic_sds_port *this_port, | ||
2118 | struct scic_sds_remote_device *device, | ||
2119 | struct scic_sds_request *io_request) | ||
2120 | { | 1904 | { |
2121 | dev_warn(sciport_to_dev(this_port), | 1905 | return default_port_handler(&sci_port->parent, __func__); |
2122 | "%s: SCIC Port 0x%p requested to complete io request 0x%p " | ||
2123 | "while in invalid state %d\n", | ||
2124 | __func__, | ||
2125 | this_port, | ||
2126 | io_request, | ||
2127 | sci_base_state_machine_get_state( | ||
2128 | scic_sds_port_get_base_state_machine(this_port))); | ||
2129 | |||
2130 | return SCI_FAILURE_INVALID_STATE; | ||
2131 | } | 1906 | } |
2132 | 1907 | ||
2133 | /* | 1908 | static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port, |
2134 | * **************************************************************************** | 1909 | struct scic_sds_remote_device *sci_dev, |
2135 | * * GENERAL STATE HANDLERS | 1910 | struct scic_sds_request *sci_req) |
2136 | * **************************************************************************** */ | 1911 | { |
1912 | return default_port_handler(&sci_port->parent, __func__); | ||
1913 | } | ||
2137 | 1914 | ||
2138 | /** | 1915 | /** |
2139 | * | 1916 | * |
@@ -2160,11 +1937,6 @@ static enum sci_status scic_sds_port_general_complete_io_handler( | |||
2160 | return SCI_SUCCESS; | 1937 | return SCI_SUCCESS; |
2161 | } | 1938 | } |
2162 | 1939 | ||
2163 | /* | ||
2164 | * **************************************************************************** | ||
2165 | * * STOPPED STATE HANDLERS | ||
2166 | * **************************************************************************** */ | ||
2167 | |||
2168 | /** | 1940 | /** |
2169 | * scic_sds_port_stopped_state_start_handler() - stop a port from "started" | 1941 | * scic_sds_port_stopped_state_start_handler() - stop a port from "started" |
2170 | * | 1942 | * |
@@ -2242,9 +2014,8 @@ scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port) | |||
2242 | * silicon. | 2014 | * silicon. |
2243 | */ | 2015 | */ |
2244 | if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { | 2016 | if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { |
2245 | sci_base_state_machine_change_state( | 2017 | sci_base_state_machine_change_state(&base_port->state_machine, |
2246 | scic_sds_port_get_base_state_machine(sci_port), | 2018 | SCI_BASE_PORT_STATE_READY); |
2247 | SCI_BASE_PORT_STATE_READY); | ||
2248 | 2019 | ||
2249 | return SCI_SUCCESS; | 2020 | return SCI_SUCCESS; |
2250 | } else | 2021 | } else |
@@ -2390,19 +2161,15 @@ static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( | |||
2390 | * object will transition to the stopped state. enum sci_status SCI_SUCCESS | 2161 | * object will transition to the stopped state. enum sci_status SCI_SUCCESS |
2391 | */ | 2162 | */ |
2392 | static enum sci_status scic_sds_port_stopping_state_complete_io_handler( | 2163 | static enum sci_status scic_sds_port_stopping_state_complete_io_handler( |
2393 | struct scic_sds_port *port, | 2164 | struct scic_sds_port *sci_port, |
2394 | struct scic_sds_remote_device *device, | 2165 | struct scic_sds_remote_device *device, |
2395 | struct scic_sds_request *io_request) | 2166 | struct scic_sds_request *io_request) |
2396 | { | 2167 | { |
2397 | struct scic_sds_port *this_port = (struct scic_sds_port *)port; | 2168 | scic_sds_port_decrement_request_count(sci_port); |
2398 | |||
2399 | scic_sds_port_decrement_request_count(this_port); | ||
2400 | 2169 | ||
2401 | if (this_port->started_request_count == 0) { | 2170 | if (sci_port->started_request_count == 0) { |
2402 | sci_base_state_machine_change_state( | 2171 | sci_base_state_machine_change_state(&sci_port->parent.state_machine, |
2403 | scic_sds_port_get_base_state_machine(this_port), | 2172 | SCI_BASE_PORT_STATE_STOPPED); |
2404 | SCI_BASE_PORT_STATE_STOPPED | ||
2405 | ); | ||
2406 | } | 2173 | } |
2407 | 2174 | ||
2408 | return SCI_SUCCESS; | 2175 | return SCI_SUCCESS; |
@@ -2727,9 +2494,8 @@ static void scic_sds_port_stopped_state_exit( | |||
2727 | } | 2494 | } |
2728 | 2495 | ||
2729 | /** | 2496 | /** |
2730 | * | 2497 | * scic_sds_port_ready_state_enter - |
2731 | * @object: This is the struct sci_base_object which is cast to a | 2498 | * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. |
2732 | * struct scic_sds_port object. | ||
2733 | * | 2499 | * |
2734 | * This method will perform the actions required by the struct scic_sds_port on | 2500 | * This method will perform the actions required by the struct scic_sds_port on |
2735 | * entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state | 2501 | * entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state |
@@ -2738,50 +2504,40 @@ static void scic_sds_port_stopped_state_exit( | |||
2738 | */ | 2504 | */ |
2739 | static void scic_sds_port_ready_state_enter(struct sci_base_object *object) | 2505 | static void scic_sds_port_ready_state_enter(struct sci_base_object *object) |
2740 | { | 2506 | { |
2741 | struct scic_sds_port *sci_port = (struct scic_sds_port *)object; | 2507 | struct scic_sds_controller *scic; |
2742 | struct isci_port *iport = sci_object_get_association(sci_port); | 2508 | struct scic_sds_port *sci_port; |
2743 | struct scic_sds_controller *scic = | 2509 | struct isci_port *iport; |
2744 | scic_sds_port_get_controller(sci_port); | 2510 | struct isci_host *ihost; |
2745 | struct isci_host *ihost = sci_object_get_association(scic); | 2511 | u32 prev_state; |
2746 | 2512 | ||
2747 | /* | 2513 | sci_port = container_of(object, typeof(*sci_port), parent.parent); |
2748 | * Put the ready state handlers in place though they will not be | 2514 | scic = scic_sds_port_get_controller(sci_port); |
2749 | * there long | 2515 | ihost = sci_object_get_association(scic); |
2750 | */ | 2516 | iport = sci_object_get_association(sci_port); |
2751 | scic_sds_port_set_base_state_handlers(sci_port, | ||
2752 | SCI_BASE_PORT_STATE_READY); | ||
2753 | 2517 | ||
2754 | if (sci_port->parent.state_machine.previous_state_id == | 2518 | /* Put the ready state handlers in place though they will not be there long */ |
2755 | SCI_BASE_PORT_STATE_RESETTING) | 2519 | scic_sds_port_set_base_state_handlers(sci_port, SCI_BASE_PORT_STATE_READY); |
2520 | |||
2521 | prev_state = sci_port->parent.state_machine.previous_state_id; | ||
2522 | if (prev_state == SCI_BASE_PORT_STATE_RESETTING) | ||
2756 | isci_port_hard_reset_complete(iport, SCI_SUCCESS); | 2523 | isci_port_hard_reset_complete(iport, SCI_SUCCESS); |
2757 | else /* Notify the caller that the port is not yet ready */ | 2524 | else |
2758 | isci_port_not_ready(ihost, iport); | 2525 | isci_port_not_ready(ihost, iport); |
2759 | 2526 | ||
2760 | /* Post and suspend the dummy remote node context for this port. */ | 2527 | /* Post and suspend the dummy remote node context for this port. */ |
2761 | scic_sds_port_post_dummy_remote_node(sci_port); | 2528 | scic_sds_port_post_dummy_remote_node(sci_port); |
2762 | 2529 | ||
2763 | /* Start the ready substate machine */ | 2530 | /* Start the ready substate machine */ |
2764 | sci_base_state_machine_start( | 2531 | sci_base_state_machine_start(&sci_port->ready_substate_machine); |
2765 | scic_sds_port_get_ready_substate_machine(sci_port)); | ||
2766 | } | 2532 | } |
2767 | 2533 | ||
2768 | /** | 2534 | static void scic_sds_port_ready_state_exit(struct sci_base_object *object) |
2769 | * | ||
2770 | * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. | ||
2771 | * | ||
2772 | * This method will perform the actions required by the struct scic_sds_port on | ||
2773 | * exiting the SCI_BASE_STATE_READY. This function does nothing. none | ||
2774 | */ | ||
2775 | static void scic_sds_port_ready_state_exit( | ||
2776 | struct sci_base_object *object) | ||
2777 | { | 2535 | { |
2778 | struct scic_sds_port *this_port; | 2536 | struct scic_sds_port *sci_port; |
2779 | |||
2780 | this_port = (struct scic_sds_port *)object; | ||
2781 | |||
2782 | sci_base_state_machine_stop(&this_port->ready_substate_machine); | ||
2783 | 2537 | ||
2784 | scic_sds_port_invalidate_dummy_remote_node(this_port); | 2538 | sci_port = container_of(object, typeof(*sci_port), parent.parent); |
2539 | sci_base_state_machine_stop(&sci_port->ready_substate_machine); | ||
2540 | scic_sds_port_invalidate_dummy_remote_node(sci_port); | ||
2785 | } | 2541 | } |
2786 | 2542 | ||
2787 | /** | 2543 | /** |
diff --git a/drivers/scsi/isci/core/scic_sds_port.h b/drivers/scsi/isci/core/scic_sds_port.h index c98caefa7cf2..ac81a92c348a 100644 --- a/drivers/scsi/isci/core/scic_sds_port.h +++ b/drivers/scsi/isci/core/scic_sds_port.h | |||
@@ -251,14 +251,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t | |||
251 | ((this_port)->owning_controller) | 251 | ((this_port)->owning_controller) |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * scic_sds_port_get_base_state_machine() - | ||
255 | * | ||
256 | * Helper macro to get the base state machine for this port | ||
257 | */ | ||
258 | #define scic_sds_port_get_base_state_machine(this_port) \ | ||
259 | (&(this_port)->parent.state_machine) | ||
260 | |||
261 | /** | ||
262 | * scic_sds_port_set_base_state_handlers() - | 254 | * scic_sds_port_set_base_state_handlers() - |
263 | * | 255 | * |
264 | * This macro will change the state handlers to those of the specified state id | 256 | * This macro will change the state handlers to those of the specified state id |
@@ -268,14 +260,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t | |||
268 | (this_port), &scic_sds_port_state_handler_table[(state_id)]) | 260 | (this_port), &scic_sds_port_state_handler_table[(state_id)]) |
269 | 261 | ||
270 | /** | 262 | /** |
271 | * scic_sds_port_get_ready_substate_machine() - | ||
272 | * | ||
273 | * Helper macro to get the ready substate machine for this port | ||
274 | */ | ||
275 | #define scic_sds_port_get_ready_substate_machine(this_port) \ | ||
276 | (&(this_port)->ready_substate_machine) | ||
277 | |||
278 | /** | ||
279 | * scic_sds_port_set_state_handlers() - | 263 | * scic_sds_port_set_state_handlers() - |
280 | * | 264 | * |
281 | * Helper macro to set the port object state handlers | 265 | * Helper macro to set the port object state handlers |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.c b/drivers/scsi/isci/core/scic_sds_remote_device.c index f722678eed8e..05599d178caa 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_device.c +++ b/drivers/scsi/isci/core/scic_sds_remote_device.c | |||
@@ -135,8 +135,7 @@ enum sci_status scic_remote_device_da_construct( | |||
135 | &remote_node_index); | 135 | &remote_node_index); |
136 | 136 | ||
137 | if (status == SCI_SUCCESS) { | 137 | if (status == SCI_SUCCESS) { |
138 | scic_sds_remote_node_context_set_remote_node_index( | 138 | sci_dev->rnc->remote_node_index = remote_node_index; |
139 | sci_dev->rnc, remote_node_index); | ||
140 | 139 | ||
141 | scic_sds_port_get_attached_sas_address( | 140 | scic_sds_port_get_attached_sas_address( |
142 | sci_dev->owning_port, &sci_dev->device_address); | 141 | sci_dev->owning_port, &sci_dev->device_address); |
@@ -510,16 +509,14 @@ bool scic_sds_remote_device_is_atapi( | |||
510 | static void scic_sds_cb_remote_device_rnc_destruct_complete( | 509 | static void scic_sds_cb_remote_device_rnc_destruct_complete( |
511 | void *user_parameter) | 510 | void *user_parameter) |
512 | { | 511 | { |
513 | struct scic_sds_remote_device *this_device; | 512 | struct scic_sds_remote_device *sci_dev; |
514 | 513 | ||
515 | this_device = (struct scic_sds_remote_device *)user_parameter; | 514 | sci_dev = (struct scic_sds_remote_device *)user_parameter; |
516 | 515 | ||
517 | BUG_ON(this_device->started_request_count != 0); | 516 | BUG_ON(sci_dev->started_request_count != 0); |
518 | 517 | ||
519 | sci_base_state_machine_change_state( | 518 | sci_base_state_machine_change_state(&sci_dev->parent.state_machine, |
520 | scic_sds_remote_device_get_base_state_machine(this_device), | 519 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); |
521 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED | ||
522 | ); | ||
523 | } | 520 | } |
524 | 521 | ||
525 | /** | 522 | /** |
@@ -649,206 +646,64 @@ static enum sci_status scic_sds_remote_device_terminate_requests( | |||
649 | return status; | 646 | return status; |
650 | } | 647 | } |
651 | 648 | ||
652 | /* | 649 | static enum sci_status default_device_handler(struct sci_base_remote_device *base_dev, |
653 | * ***************************************************************************** | 650 | const char *func) |
654 | * * DEFAULT STATE HANDLERS | ||
655 | * ***************************************************************************** */ | ||
656 | |||
657 | /** | ||
658 | * | ||
659 | * @device: The struct sci_base_remote_device which is then cast into a | ||
660 | * struct scic_sds_remote_device. | ||
661 | * | ||
662 | * This method is the default start handler. It logs a warning and returns a | ||
663 | * failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
664 | */ | ||
665 | enum sci_status scic_sds_remote_device_default_start_handler( | ||
666 | struct sci_base_remote_device *device) | ||
667 | { | 651 | { |
668 | struct scic_sds_remote_device *sds_device = | 652 | struct scic_sds_remote_device *sci_dev; |
669 | (struct scic_sds_remote_device *)device; | ||
670 | |||
671 | dev_warn(scirdev_to_dev(sds_device), | ||
672 | "%s: SCIC Remote Device requested to start while in wrong " | ||
673 | "state %d\n", | ||
674 | __func__, | ||
675 | sci_base_state_machine_get_state( | ||
676 | scic_sds_remote_device_get_base_state_machine( | ||
677 | sds_device))); | ||
678 | 653 | ||
654 | sci_dev = container_of(base_dev, typeof(*sci_dev), parent); | ||
655 | dev_warn(scirdev_to_dev(sci_dev), | ||
656 | "%s: in wrong state: %d\n", func, | ||
657 | sci_base_state_machine_get_state(&base_dev->state_machine)); | ||
679 | return SCI_FAILURE_INVALID_STATE; | 658 | return SCI_FAILURE_INVALID_STATE; |
680 | } | 659 | } |
681 | 660 | ||
682 | /** | 661 | enum sci_status scic_sds_remote_device_default_start_handler( |
683 | * | 662 | struct sci_base_remote_device *base_dev) |
684 | * @device: The struct sci_base_remote_device which is then cast into a | ||
685 | * struct scic_sds_remote_device. | ||
686 | * | ||
687 | * This method is the default stop handler. It logs a warning and returns a | ||
688 | * failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
689 | */ | ||
690 | static enum sci_status scic_sds_remote_device_default_stop_handler( | ||
691 | struct sci_base_remote_device *device) | ||
692 | { | 663 | { |
693 | struct scic_sds_remote_device *sds_device = | 664 | return default_device_handler(base_dev, __func__); |
694 | (struct scic_sds_remote_device *)device; | 665 | } |
695 | |||
696 | dev_warn(scirdev_to_dev(sds_device), | ||
697 | "%s: SCIC Remote Device requested to stop while in wrong " | ||
698 | "state %d\n", | ||
699 | __func__, | ||
700 | sci_base_state_machine_get_state( | ||
701 | scic_sds_remote_device_get_base_state_machine( | ||
702 | sds_device))); | ||
703 | 666 | ||
704 | return SCI_FAILURE_INVALID_STATE; | 667 | static enum sci_status scic_sds_remote_device_default_stop_handler( |
668 | struct sci_base_remote_device *base_dev) | ||
669 | { | ||
670 | return default_device_handler(base_dev, __func__); | ||
705 | } | 671 | } |
706 | 672 | ||
707 | /** | ||
708 | * | ||
709 | * @device: The struct sci_base_remote_device which is then cast into a | ||
710 | * struct scic_sds_remote_device. | ||
711 | * | ||
712 | * This method is the default fail handler. It logs a warning and returns a | ||
713 | * failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
714 | */ | ||
715 | enum sci_status scic_sds_remote_device_default_fail_handler( | 673 | enum sci_status scic_sds_remote_device_default_fail_handler( |
716 | struct sci_base_remote_device *device) | 674 | struct sci_base_remote_device *base_dev) |
717 | { | 675 | { |
718 | struct scic_sds_remote_device *sds_device = | 676 | return default_device_handler(base_dev, __func__); |
719 | (struct scic_sds_remote_device *)device; | ||
720 | |||
721 | dev_warn(scirdev_to_dev(sds_device), | ||
722 | "%s: SCIC Remote Device requested to fail while in wrong " | ||
723 | "state %d\n", | ||
724 | __func__, | ||
725 | sci_base_state_machine_get_state( | ||
726 | scic_sds_remote_device_get_base_state_machine( | ||
727 | sds_device))); | ||
728 | |||
729 | return SCI_FAILURE_INVALID_STATE; | ||
730 | } | 677 | } |
731 | 678 | ||
732 | /** | ||
733 | * | ||
734 | * @device: The struct sci_base_remote_device which is then cast into a | ||
735 | * struct scic_sds_remote_device. | ||
736 | * | ||
737 | * This method is the default destruct handler. It logs a warning and returns | ||
738 | * a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
739 | */ | ||
740 | enum sci_status scic_sds_remote_device_default_destruct_handler( | 679 | enum sci_status scic_sds_remote_device_default_destruct_handler( |
741 | struct sci_base_remote_device *device) | 680 | struct sci_base_remote_device *base_dev) |
742 | { | 681 | { |
743 | struct scic_sds_remote_device *sds_device = | 682 | return default_device_handler(base_dev, __func__); |
744 | (struct scic_sds_remote_device *)device; | ||
745 | |||
746 | dev_warn(scirdev_to_dev(sds_device), | ||
747 | "%s: SCIC Remote Device requested to destroy while in " | ||
748 | "wrong state %d\n", | ||
749 | __func__, | ||
750 | sci_base_state_machine_get_state( | ||
751 | scic_sds_remote_device_get_base_state_machine( | ||
752 | sds_device))); | ||
753 | |||
754 | return SCI_FAILURE_INVALID_STATE; | ||
755 | } | 683 | } |
756 | 684 | ||
757 | /** | ||
758 | * | ||
759 | * @device: The struct sci_base_remote_device which is then cast into a | ||
760 | * struct scic_sds_remote_device. | ||
761 | * | ||
762 | * This method is the default reset handler. It logs a warning and returns a | ||
763 | * failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
764 | */ | ||
765 | enum sci_status scic_sds_remote_device_default_reset_handler( | 685 | enum sci_status scic_sds_remote_device_default_reset_handler( |
766 | struct sci_base_remote_device *device) | 686 | struct sci_base_remote_device *base_dev) |
767 | { | 687 | { |
768 | struct scic_sds_remote_device *sds_device = | 688 | return default_device_handler(base_dev, __func__); |
769 | (struct scic_sds_remote_device *)device; | ||
770 | |||
771 | dev_warn(scirdev_to_dev(sds_device), | ||
772 | "%s: SCIC Remote Device requested to reset while in wrong " | ||
773 | "state %d\n", | ||
774 | __func__, | ||
775 | sci_base_state_machine_get_state( | ||
776 | scic_sds_remote_device_get_base_state_machine( | ||
777 | sds_device))); | ||
778 | |||
779 | return SCI_FAILURE_INVALID_STATE; | ||
780 | } | 689 | } |
781 | 690 | ||
782 | /** | ||
783 | * | ||
784 | * @device: The struct sci_base_remote_device which is then cast into a | ||
785 | * struct scic_sds_remote_device. | ||
786 | * | ||
787 | * This method is the default reset complete handler. It logs a warning and | ||
788 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
789 | */ | ||
790 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | 691 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( |
791 | struct sci_base_remote_device *device) | 692 | struct sci_base_remote_device *base_dev) |
792 | { | 693 | { |
793 | struct scic_sds_remote_device *sds_device = | 694 | return default_device_handler(base_dev, __func__); |
794 | (struct scic_sds_remote_device *)device; | ||
795 | |||
796 | dev_warn(scirdev_to_dev(sds_device), | ||
797 | "%s: SCIC Remote Device requested to complete reset while " | ||
798 | "in wrong state %d\n", | ||
799 | __func__, | ||
800 | sci_base_state_machine_get_state( | ||
801 | scic_sds_remote_device_get_base_state_machine( | ||
802 | sds_device))); | ||
803 | |||
804 | return SCI_FAILURE_INVALID_STATE; | ||
805 | } | 695 | } |
806 | 696 | ||
807 | /** | ||
808 | * | ||
809 | * @device: The struct sci_base_remote_device which is then cast into a | ||
810 | * struct scic_sds_remote_device. | ||
811 | * | ||
812 | * This method is the default suspend handler. It logs a warning and returns a | ||
813 | * failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
814 | */ | ||
815 | enum sci_status scic_sds_remote_device_default_suspend_handler( | 697 | enum sci_status scic_sds_remote_device_default_suspend_handler( |
816 | struct scic_sds_remote_device *this_device, | 698 | struct scic_sds_remote_device *sci_dev, u32 suspend_type) |
817 | u32 suspend_type) | ||
818 | { | 699 | { |
819 | dev_warn(scirdev_to_dev(this_device), | 700 | return default_device_handler(&sci_dev->parent, __func__); |
820 | "%s: SCIC Remote Device 0x%p requested to suspend %d while " | ||
821 | "in wrong state %d\n", | ||
822 | __func__, | ||
823 | this_device, | ||
824 | suspend_type, | ||
825 | sci_base_state_machine_get_state( | ||
826 | scic_sds_remote_device_get_base_state_machine( | ||
827 | this_device))); | ||
828 | |||
829 | return SCI_FAILURE_INVALID_STATE; | ||
830 | } | 701 | } |
831 | 702 | ||
832 | /** | ||
833 | * | ||
834 | * @device: The struct sci_base_remote_device which is then cast into a | ||
835 | * struct scic_sds_remote_device. | ||
836 | * | ||
837 | * This method is the default resume handler. It logs a warning and returns a | ||
838 | * failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
839 | */ | ||
840 | enum sci_status scic_sds_remote_device_default_resume_handler( | 703 | enum sci_status scic_sds_remote_device_default_resume_handler( |
841 | struct scic_sds_remote_device *this_device) | 704 | struct scic_sds_remote_device *sci_dev) |
842 | { | 705 | { |
843 | dev_warn(scirdev_to_dev(this_device), | 706 | return default_device_handler(&sci_dev->parent, __func__); |
844 | "%s: SCIC Remote Device requested to resume while in " | ||
845 | "wrong state %d\n", | ||
846 | __func__, | ||
847 | sci_base_state_machine_get_state( | ||
848 | scic_sds_remote_device_get_base_state_machine( | ||
849 | this_device))); | ||
850 | |||
851 | return SCI_FAILURE_INVALID_STATE; | ||
852 | } | 707 | } |
853 | 708 | ||
854 | /** | 709 | /** |
@@ -960,113 +815,31 @@ enum sci_status scic_sds_remote_device_default_frame_handler( | |||
960 | return SCI_FAILURE_INVALID_STATE; | 815 | return SCI_FAILURE_INVALID_STATE; |
961 | } | 816 | } |
962 | 817 | ||
963 | /** | ||
964 | * | ||
965 | * @device: The struct sci_base_remote_device which is then cast into a | ||
966 | * struct scic_sds_remote_device. | ||
967 | * @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST | ||
968 | * to start. | ||
969 | * | ||
970 | * This method is the default start io handler. It logs a warning and returns | ||
971 | * a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
972 | */ | ||
973 | enum sci_status scic_sds_remote_device_default_start_request_handler( | 818 | enum sci_status scic_sds_remote_device_default_start_request_handler( |
974 | struct sci_base_remote_device *device, | 819 | struct sci_base_remote_device *base_dev, |
975 | struct sci_base_request *request) | 820 | struct sci_base_request *request) |
976 | { | 821 | { |
977 | struct scic_sds_remote_device *sds_device = | 822 | return default_device_handler(base_dev, __func__); |
978 | (struct scic_sds_remote_device *)device; | ||
979 | |||
980 | dev_warn(scirdev_to_dev(sds_device), | ||
981 | "%s: SCIC Remote Device requested to start io request %p " | ||
982 | "while in wrong state %d\n", | ||
983 | __func__, | ||
984 | request, | ||
985 | sci_base_state_machine_get_state( | ||
986 | scic_sds_remote_device_get_base_state_machine( | ||
987 | (struct scic_sds_remote_device *)device))); | ||
988 | |||
989 | return SCI_FAILURE_INVALID_STATE; | ||
990 | } | 823 | } |
991 | 824 | ||
992 | /** | ||
993 | * | ||
994 | * @device: The struct sci_base_remote_device which is then cast into a | ||
995 | * struct scic_sds_remote_device. | ||
996 | * @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST | ||
997 | * to complete. | ||
998 | * | ||
999 | * This method is the default complete io handler. It logs a warning and | ||
1000 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1001 | */ | ||
1002 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | 825 | enum sci_status scic_sds_remote_device_default_complete_request_handler( |
1003 | struct sci_base_remote_device *device, | 826 | struct sci_base_remote_device *base_dev, |
1004 | struct sci_base_request *request) | 827 | struct sci_base_request *request) |
1005 | { | 828 | { |
1006 | struct scic_sds_remote_device *sds_device = | 829 | return default_device_handler(base_dev, __func__); |
1007 | (struct scic_sds_remote_device *)device; | ||
1008 | |||
1009 | dev_warn(scirdev_to_dev(sds_device), | ||
1010 | "%s: SCIC Remote Device requested to complete io_request %p " | ||
1011 | "while in wrong state %d\n", | ||
1012 | __func__, | ||
1013 | request, | ||
1014 | sci_base_state_machine_get_state( | ||
1015 | scic_sds_remote_device_get_base_state_machine( | ||
1016 | sds_device))); | ||
1017 | |||
1018 | return SCI_FAILURE_INVALID_STATE; | ||
1019 | } | 830 | } |
1020 | 831 | ||
1021 | /** | ||
1022 | * | ||
1023 | * @device: The struct sci_base_remote_device which is then cast into a | ||
1024 | * struct scic_sds_remote_device. | ||
1025 | * @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST | ||
1026 | * to continue. | ||
1027 | * | ||
1028 | * This method is the default continue io handler. It logs a warning and | ||
1029 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1030 | */ | ||
1031 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | 832 | enum sci_status scic_sds_remote_device_default_continue_request_handler( |
1032 | struct sci_base_remote_device *device, | 833 | struct sci_base_remote_device *base_dev, |
1033 | struct sci_base_request *request) | 834 | struct sci_base_request *request) |
1034 | { | 835 | { |
1035 | struct scic_sds_remote_device *sds_device = | 836 | return default_device_handler(base_dev, __func__); |
1036 | (struct scic_sds_remote_device *)device; | ||
1037 | |||
1038 | dev_warn(scirdev_to_dev(sds_device), | ||
1039 | "%s: SCIC Remote Device requested to continue io request %p " | ||
1040 | "while in wrong state %d\n", | ||
1041 | __func__, | ||
1042 | request, | ||
1043 | sci_base_state_machine_get_state( | ||
1044 | scic_sds_remote_device_get_base_state_machine( | ||
1045 | sds_device))); | ||
1046 | |||
1047 | return SCI_FAILURE_INVALID_STATE; | ||
1048 | } | 837 | } |
1049 | 838 | ||
1050 | /** | 839 | /** |
1051 | * | 840 | * |
1052 | * @device: The struct sci_base_remote_device which is then cast into a | 841 | * @device: The struct sci_base_remote_device which is then cast into a |
1053 | * struct scic_sds_remote_device. | 842 | * struct scic_sds_remote_device. |
1054 | * @request: The struct sci_base_request which is then cast into a SCIC_SDS_IO_REQUEST | ||
1055 | * to complete. | ||
1056 | * | ||
1057 | * This method is the default complete task handler. It logs a warning and | ||
1058 | * returns a failure. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1059 | */ | ||
1060 | |||
1061 | /* | ||
1062 | * ***************************************************************************** | ||
1063 | * * NORMAL STATE HANDLERS | ||
1064 | * ***************************************************************************** */ | ||
1065 | |||
1066 | /** | ||
1067 | * | ||
1068 | * @device: The struct sci_base_remote_device which is then cast into a | ||
1069 | * struct scic_sds_remote_device. | ||
1070 | * @frame_index: The frame index for which the struct scic_sds_controller wants this | 843 | * @frame_index: The frame index for which the struct scic_sds_controller wants this |
1071 | * device object to process. | 844 | * device object to process. |
1072 | * | 845 | * |
@@ -1146,45 +919,32 @@ enum sci_status scic_sds_remote_device_general_event_handler( | |||
1146 | * which to construct the remote device. | 919 | * which to construct the remote device. |
1147 | */ | 920 | */ |
1148 | static enum sci_status scic_sds_remote_device_stopped_state_start_handler( | 921 | static enum sci_status scic_sds_remote_device_stopped_state_start_handler( |
1149 | struct sci_base_remote_device *device) | 922 | struct sci_base_remote_device *base_dev) |
1150 | { | 923 | { |
1151 | enum sci_status status; | 924 | enum sci_status status; |
1152 | struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; | 925 | struct scic_sds_remote_device *sci_dev; |
1153 | 926 | ||
1154 | status = scic_sds_remote_node_context_resume( | 927 | sci_dev = container_of(base_dev, typeof(*sci_dev), parent); |
1155 | this_device->rnc, | ||
1156 | scic_sds_remote_device_resume_complete_handler, | ||
1157 | this_device | ||
1158 | ); | ||
1159 | 928 | ||
1160 | if (status == SCI_SUCCESS) { | 929 | status = scic_sds_remote_node_context_resume(sci_dev->rnc, |
1161 | sci_base_state_machine_change_state( | 930 | scic_sds_remote_device_resume_complete_handler, sci_dev); |
1162 | scic_sds_remote_device_get_base_state_machine(this_device), | 931 | |
1163 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING | 932 | if (status == SCI_SUCCESS) |
1164 | ); | 933 | sci_base_state_machine_change_state(&base_dev->state_machine, |
1165 | } | 934 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING); |
1166 | 935 | ||
1167 | return status; | 936 | return status; |
1168 | } | 937 | } |
1169 | 938 | ||
1170 | /** | ||
1171 | * | ||
1172 | * @this_device: The struct sci_base_remote_device which is cast into a | ||
1173 | * struct scic_sds_remote_device. | ||
1174 | * | ||
1175 | * This method will stop a struct scic_sds_remote_device that is already in a stopped | ||
1176 | * state. This is not considered an error since the device is already stopped. | ||
1177 | * enum sci_status SCI_SUCCESS | ||
1178 | */ | ||
1179 | static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( | 939 | static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( |
1180 | struct sci_base_remote_device *this_device) | 940 | struct sci_base_remote_device *base_dev) |
1181 | { | 941 | { |
1182 | return SCI_SUCCESS; | 942 | return SCI_SUCCESS; |
1183 | } | 943 | } |
1184 | 944 | ||
1185 | /** | 945 | /** |
1186 | * | 946 | * |
1187 | * @this_device: The struct sci_base_remote_device which is cast into a | 947 | * @sci_dev: The struct sci_base_remote_device which is cast into a |
1188 | * struct scic_sds_remote_device. | 948 | * struct scic_sds_remote_device. |
1189 | * | 949 | * |
1190 | * This method will destruct a struct scic_sds_remote_device that is in a stopped | 950 | * This method will destruct a struct scic_sds_remote_device that is in a stopped |
@@ -1194,25 +954,19 @@ static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( | |||
1194 | * enum sci_status SCI_SUCCESS | 954 | * enum sci_status SCI_SUCCESS |
1195 | */ | 955 | */ |
1196 | static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( | 956 | static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( |
1197 | struct sci_base_remote_device *device) | 957 | struct sci_base_remote_device *base_dev) |
1198 | { | 958 | { |
1199 | struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; | 959 | struct scic_sds_remote_device *sci_dev; |
1200 | 960 | struct scic_sds_controller *scic; | |
1201 | scic_sds_controller_free_remote_node_context( | ||
1202 | scic_sds_remote_device_get_controller(this_device), | ||
1203 | this_device, | ||
1204 | this_device->rnc->remote_node_index | ||
1205 | ); | ||
1206 | 961 | ||
1207 | scic_sds_remote_node_context_set_remote_node_index( | 962 | sci_dev = container_of(base_dev, typeof(*sci_dev), parent); |
1208 | this_device->rnc, | 963 | scic = scic_sds_remote_device_get_controller(sci_dev); |
1209 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX | 964 | scic_sds_controller_free_remote_node_context(scic, sci_dev, |
1210 | ); | 965 | sci_dev->rnc->remote_node_index); |
966 | sci_dev->rnc->remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; | ||
1211 | 967 | ||
1212 | sci_base_state_machine_change_state( | 968 | sci_base_state_machine_change_state(&base_dev->state_machine, |
1213 | scic_sds_remote_device_get_base_state_machine(this_device), | 969 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL); |
1214 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL | ||
1215 | ); | ||
1216 | 970 | ||
1217 | return SCI_SUCCESS; | 971 | return SCI_SUCCESS; |
1218 | } | 972 | } |
@@ -1223,86 +977,49 @@ static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( | |||
1223 | * ***************************************************************************** */ | 977 | * ***************************************************************************** */ |
1224 | 978 | ||
1225 | static enum sci_status scic_sds_remote_device_starting_state_stop_handler( | 979 | static enum sci_status scic_sds_remote_device_starting_state_stop_handler( |
1226 | struct sci_base_remote_device *device) | 980 | struct sci_base_remote_device *base_dev) |
1227 | { | 981 | { |
1228 | struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; | 982 | struct scic_sds_remote_device *sci_dev; |
1229 | 983 | ||
984 | sci_dev = container_of(base_dev, typeof(*sci_dev), parent); | ||
1230 | /* | 985 | /* |
1231 | * This device has not yet started so there had better be no IO requests | 986 | * This device has not yet started so there had better be no IO requests |
1232 | */ | 987 | */ |
1233 | BUG_ON(this_device->started_request_count != 0); | 988 | BUG_ON(sci_dev->started_request_count != 0); |
1234 | 989 | ||
1235 | /* | 990 | /* |
1236 | * Destroy the remote node context | 991 | * Destroy the remote node context |
1237 | */ | 992 | */ |
1238 | scic_sds_remote_node_context_destruct( | 993 | scic_sds_remote_node_context_destruct(sci_dev->rnc, |
1239 | this_device->rnc, | 994 | scic_sds_cb_remote_device_rnc_destruct_complete, sci_dev); |
1240 | scic_sds_cb_remote_device_rnc_destruct_complete, | ||
1241 | this_device | ||
1242 | ); | ||
1243 | 995 | ||
1244 | /* | 996 | /* |
1245 | * Transition to the stopping state and wait for the remote node to | 997 | * Transition to the stopping state and wait for the remote node to |
1246 | * complete being posted and invalidated. | 998 | * complete being posted and invalidated. |
1247 | */ | 999 | */ |
1248 | sci_base_state_machine_change_state( | 1000 | sci_base_state_machine_change_state(&base_dev->state_machine, |
1249 | scic_sds_remote_device_get_base_state_machine(this_device), | 1001 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); |
1250 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING | ||
1251 | ); | ||
1252 | 1002 | ||
1253 | return SCI_SUCCESS; | 1003 | return SCI_SUCCESS; |
1254 | } | 1004 | } |
1255 | 1005 | ||
1256 | /* | ||
1257 | * ***************************************************************************** | ||
1258 | * * INITIALIZING STATE HANDLERS | ||
1259 | * ***************************************************************************** */ | ||
1260 | |||
1261 | /* There is nothing to do here for SSP devices */ | ||
1262 | |||
1263 | /* | ||
1264 | * ***************************************************************************** | ||
1265 | * * READY STATE HANDLERS | ||
1266 | * ***************************************************************************** */ | ||
1267 | |||
1268 | /** | ||
1269 | * | ||
1270 | * @this_device: The struct scic_sds_remote_device object to be suspended. | ||
1271 | * | ||
1272 | * This method is the resume handler for the struct scic_sds_remote_device object. It | ||
1273 | * will post an RNC resume to the SCU hardware. enum sci_status SCI_SUCCESS | ||
1274 | */ | ||
1275 | |||
1276 | /** | ||
1277 | * | ||
1278 | * @device: The struct sci_base_remote_device object which is cast to a | ||
1279 | * struct scic_sds_remote_device object. | ||
1280 | * | ||
1281 | * This method is the default stop handler for the struct scic_sds_remote_device ready | ||
1282 | * substate machine. It will stop the current substate machine and transition | ||
1283 | * the base state machine to SCI_BASE_REMOTE_DEVICE_STATE_STOPPING. enum sci_status | ||
1284 | * SCI_SUCCESS | ||
1285 | */ | ||
1286 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | 1006 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( |
1287 | struct sci_base_remote_device *device) | 1007 | struct sci_base_remote_device *base_dev) |
1288 | { | 1008 | { |
1289 | struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; | 1009 | struct scic_sds_remote_device *sci_dev; |
1290 | enum sci_status status = SCI_SUCCESS; | 1010 | enum sci_status status = SCI_SUCCESS; |
1291 | 1011 | ||
1012 | sci_dev = container_of(base_dev, typeof(*sci_dev), parent); | ||
1292 | /* Request the parent state machine to transition to the stopping state */ | 1013 | /* Request the parent state machine to transition to the stopping state */ |
1293 | sci_base_state_machine_change_state( | 1014 | sci_base_state_machine_change_state(&base_dev->state_machine, |
1294 | scic_sds_remote_device_get_base_state_machine(this_device), | 1015 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); |
1295 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING | ||
1296 | ); | ||
1297 | 1016 | ||
1298 | if (this_device->started_request_count == 0) { | 1017 | if (sci_dev->started_request_count == 0) { |
1299 | scic_sds_remote_node_context_destruct( | 1018 | scic_sds_remote_node_context_destruct(sci_dev->rnc, |
1300 | this_device->rnc, | ||
1301 | scic_sds_cb_remote_device_rnc_destruct_complete, | 1019 | scic_sds_cb_remote_device_rnc_destruct_complete, |
1302 | this_device | 1020 | sci_dev); |
1303 | ); | ||
1304 | } else | 1021 | } else |
1305 | status = scic_sds_remote_device_terminate_requests(this_device); | 1022 | status = scic_sds_remote_device_terminate_requests(sci_dev); |
1306 | 1023 | ||
1307 | return status; | 1024 | return status; |
1308 | } | 1025 | } |
@@ -1315,32 +1032,20 @@ enum sci_status scic_sds_remote_device_ready_state_stop_handler( | |||
1315 | * This is the ready state device reset handler enum sci_status | 1032 | * This is the ready state device reset handler enum sci_status |
1316 | */ | 1033 | */ |
1317 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | 1034 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( |
1318 | struct sci_base_remote_device *device) | 1035 | struct sci_base_remote_device *base_dev) |
1319 | { | 1036 | { |
1320 | struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device; | 1037 | struct scic_sds_remote_device *sci_dev; |
1321 | 1038 | ||
1039 | sci_dev = container_of(base_dev, typeof(*sci_dev), parent); | ||
1322 | /* Request the parent state machine to transition to the stopping state */ | 1040 | /* Request the parent state machine to transition to the stopping state */ |
1323 | sci_base_state_machine_change_state( | 1041 | sci_base_state_machine_change_state(&base_dev->state_machine, |
1324 | scic_sds_remote_device_get_base_state_machine(this_device), | 1042 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING); |
1325 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING | ||
1326 | ); | ||
1327 | 1043 | ||
1328 | return SCI_SUCCESS; | 1044 | return SCI_SUCCESS; |
1329 | } | 1045 | } |
1330 | 1046 | ||
1331 | /** | 1047 | /** |
1332 | * | 1048 | * |
1333 | * @device: The struct sci_base_remote_device object which is cast to a | ||
1334 | * struct scic_sds_remote_device object. | ||
1335 | * | ||
1336 | * This is the default fail handler for the struct scic_sds_remote_device ready | ||
1337 | * substate machine. It will stop the current ready substate and transition | ||
1338 | * the remote device object to the SCI_BASE_REMOTE_DEVICE_STATE_FAILED. | ||
1339 | * enum sci_status SCI_SUCCESS | ||
1340 | */ | ||
1341 | |||
1342 | /** | ||
1343 | * | ||
1344 | * @device: The struct sci_base_remote_device which is cast to a | 1049 | * @device: The struct sci_base_remote_device which is cast to a |
1345 | * struct scic_sds_remote_device for which the request is to be started. | 1050 | * struct scic_sds_remote_device for which the request is to be started. |
1346 | * @request: The struct sci_base_request which is cast to a SCIC_SDS_IO_REQUEST that | 1051 | * @request: The struct sci_base_request which is cast to a SCIC_SDS_IO_REQUEST that |
@@ -1775,19 +1480,15 @@ const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_h | |||
1775 | static void scic_sds_remote_device_initial_state_enter( | 1480 | static void scic_sds_remote_device_initial_state_enter( |
1776 | struct sci_base_object *object) | 1481 | struct sci_base_object *object) |
1777 | { | 1482 | { |
1778 | struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; | 1483 | struct scic_sds_remote_device *sci_dev = (struct scic_sds_remote_device *)object; |
1779 | 1484 | ||
1780 | SET_STATE_HANDLER( | 1485 | sci_dev = container_of(object, typeof(*sci_dev), parent.parent); |
1781 | this_device, | 1486 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, |
1782 | scic_sds_remote_device_state_handler_table, | 1487 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); |
1783 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL | ||
1784 | ); | ||
1785 | 1488 | ||
1786 | /* Initial state is a transitional state to the stopped state */ | 1489 | /* Initial state is a transitional state to the stopped state */ |
1787 | sci_base_state_machine_change_state( | 1490 | sci_base_state_machine_change_state(&sci_dev->parent.state_machine, |
1788 | scic_sds_remote_device_get_base_state_machine(this_device), | 1491 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); |
1789 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED | ||
1790 | ); | ||
1791 | } | 1492 | } |
1792 | 1493 | ||
1793 | /** | 1494 | /** |
@@ -1803,29 +1504,28 @@ static void scic_sds_remote_device_initial_state_enter( | |||
1803 | static void scic_sds_remote_device_stopped_state_enter( | 1504 | static void scic_sds_remote_device_stopped_state_enter( |
1804 | struct sci_base_object *object) | 1505 | struct sci_base_object *object) |
1805 | { | 1506 | { |
1806 | struct scic_sds_remote_device *sci_dev = | 1507 | struct scic_sds_remote_device *sci_dev; |
1807 | (struct scic_sds_remote_device *)object; | 1508 | struct scic_sds_controller *scic; |
1808 | struct scic_sds_controller *scic = | 1509 | struct isci_remote_device *idev; |
1809 | scic_sds_remote_device_get_controller(sci_dev); | 1510 | struct isci_host *ihost; |
1810 | struct isci_host *ihost = sci_object_get_association(scic); | 1511 | u32 prev_state; |
1811 | struct isci_remote_device *idev = | ||
1812 | sci_object_get_association(sci_dev); | ||
1813 | 1512 | ||
1814 | SET_STATE_HANDLER(sci_dev, | 1513 | sci_dev = container_of(object, typeof(*sci_dev), parent.parent); |
1815 | scic_sds_remote_device_state_handler_table, | 1514 | scic = scic_sds_remote_device_get_controller(sci_dev); |
1515 | ihost = sci_object_get_association(scic); | ||
1516 | idev = sci_object_get_association(sci_dev); | ||
1517 | |||
1518 | SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table, | ||
1816 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); | 1519 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED); |
1817 | 1520 | ||
1818 | /* | 1521 | /* If we are entering from the stopping state let the SCI User know that |
1819 | * If we are entering from the stopping state let the SCI User know that | ||
1820 | * the stop operation has completed. | 1522 | * the stop operation has completed. |
1821 | */ | 1523 | */ |
1822 | if (sci_dev->parent.state_machine.previous_state_id == | 1524 | prev_state = sci_dev->parent.state_machine.previous_state_id; |
1823 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) | 1525 | if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) |
1824 | isci_remote_device_stop_complete(ihost, idev, SCI_SUCCESS); | 1526 | isci_remote_device_stop_complete(ihost, idev, SCI_SUCCESS); |
1825 | 1527 | ||
1826 | scic_sds_controller_remote_device_stopped( | 1528 | scic_sds_controller_remote_device_stopped(scic, sci_dev); |
1827 | scic_sds_remote_device_get_controller(sci_dev), | ||
1828 | sci_dev); | ||
1829 | } | 1529 | } |
1830 | 1530 | ||
1831 | /** | 1531 | /** |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.h b/drivers/scsi/isci/core/scic_sds_remote_device.h index 4841e4579643..aa466249f229 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_device.h +++ b/drivers/scsi/isci/core/scic_sds_remote_device.h | |||
@@ -377,22 +377,6 @@ extern const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_dev | |||
377 | ((this_device)->state_handlers = (handlers)) | 377 | ((this_device)->state_handlers = (handlers)) |
378 | 378 | ||
379 | /** | 379 | /** |
380 | * scic_sds_remote_device_get_base_state_machine() - | ||
381 | * | ||
382 | * This macro returns the base sate machine object for the remote device. | ||
383 | */ | ||
384 | #define scic_sds_remote_device_get_base_state_machine(this_device) \ | ||
385 | (&(this_device)->parent.state_machine) | ||
386 | |||
387 | /** | ||
388 | * scic_sds_remote_device_get_ready_substate_machine() - | ||
389 | * | ||
390 | * This macro returns the remote device ready substate machine | ||
391 | */ | ||
392 | #define scic_sds_remote_device_get_ready_substate_machine(this_device) \ | ||
393 | (&(this_device)->ready_substate_machine) | ||
394 | |||
395 | /** | ||
396 | * scic_sds_remote_device_get_port() - | 380 | * scic_sds_remote_device_get_port() - |
397 | * | 381 | * |
398 | * This macro returns the owning port of this device | 382 | * This macro returns the owning port of this device |
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_context.h b/drivers/scsi/isci/core/scic_sds_remote_node_context.h index 86c6d75a1110..c7c75ae6f092 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_node_context.h +++ b/drivers/scsi/isci/core/scic_sds_remote_node_context.h | |||
@@ -296,9 +296,6 @@ void scic_sds_remote_node_context_construct_buffer( | |||
296 | bool scic_sds_remote_node_context_is_ready( | 296 | bool scic_sds_remote_node_context_is_ready( |
297 | struct scic_sds_remote_node_context *this_rnc); | 297 | struct scic_sds_remote_node_context *this_rnc); |
298 | 298 | ||
299 | #define scic_sds_remote_node_context_set_remote_node_index(rnc, rni) \ | ||
300 | ((rnc)->remote_node_index = (rni)) | ||
301 | |||
302 | #define scic_sds_remote_node_context_get_remote_node_index(rcn) \ | 299 | #define scic_sds_remote_node_context_get_remote_node_index(rcn) \ |
303 | ((rnc)->remote_node_index) | 300 | ((rnc)->remote_node_index) |
304 | 301 | ||