aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2011-03-26 19:11:51 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:00:36 -0400
commit09d7da135b34bc74a7996b5db373521557ddf3d4 (patch)
tree64b66ecb731cd0e609ef3fcb1fd4d460513aaa89
parent52ae18ac80fbdd268720b0daa27ac797a801500c (diff)
isci: Remove event_* calls as they are just wrappers
Removed isci_event_* calls and call those functions directly. Reported-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/Makefile2
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.c400
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.h3
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.c201
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.c444
-rw-r--r--drivers/scsi/isci/core/scic_sds_port_configuration_agent.c97
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_device.c142
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.c36
-rw-r--r--drivers/scsi/isci/core/scic_sds_smp_remote_device.c42
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_remote_device.c74
-rw-r--r--drivers/scsi/isci/events.c609
-rw-r--r--drivers/scsi/isci/events.h373
-rw-r--r--drivers/scsi/isci/isci.h1
-rw-r--r--drivers/scsi/isci/port.c51
-rw-r--r--drivers/scsi/isci/port.h10
15 files changed, 734 insertions, 1751 deletions
diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile
index 1252d768c42d..a65c0ae9d2c4 100644
--- a/drivers/scsi/isci/Makefile
+++ b/drivers/scsi/isci/Makefile
@@ -9,7 +9,7 @@ EXTRA_CFLAGS += -Idrivers/scsi/isci/core/ -Idrivers/scsi/isci/
9obj-$(CONFIG_SCSI_ISCI) += isci.o 9obj-$(CONFIG_SCSI_ISCI) += isci.o
10isci-objs := init.o phy.o request.o sata.o \ 10isci-objs := init.o phy.o request.o sata.o \
11 remote_device.o port.o timers.o \ 11 remote_device.o port.o timers.o \
12 host.o task.o events.o probe_roms.o \ 12 host.o task.o probe_roms.o \
13 core/scic_sds_controller.o \ 13 core/scic_sds_controller.o \
14 core/scic_sds_remote_device.o \ 14 core/scic_sds_remote_device.o \
15 core/scic_sds_request.o \ 15 core/scic_sds_request.o \
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c
index cd31cba28f88..eaaa4cc89a85 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.c
+++ b/drivers/scsi/isci/core/scic_sds_controller.c
@@ -253,19 +253,19 @@ static void scic_sds_controller_phy_startup_timeout_handler(
253 * This method initializes the phy startup operations for controller start. 253 * This method initializes the phy startup operations for controller start.
254 */ 254 */
255enum sci_status scic_sds_controller_initialize_phy_startup( 255enum sci_status scic_sds_controller_initialize_phy_startup(
256 struct scic_sds_controller *this_controller) 256 struct scic_sds_controller *scic)
257{ 257{
258 this_controller->phy_startup_timer = isci_event_timer_create( 258 struct isci_host *ihost = sci_object_get_association(scic);
259 this_controller,
260 scic_sds_controller_phy_startup_timeout_handler,
261 this_controller
262 );
263 259
264 if (this_controller->phy_startup_timer == NULL) { 260 scic->phy_startup_timer = isci_timer_create(ihost,
261 scic,
262 scic_sds_controller_phy_startup_timeout_handler);
263
264 if (scic->phy_startup_timer == NULL)
265 return SCI_FAILURE_INSUFFICIENT_RESOURCES; 265 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
266 } else { 266 else {
267 this_controller->next_phy_to_start = 0; 267 scic->next_phy_to_start = 0;
268 this_controller->phy_startup_timer_pending = false; 268 scic->phy_startup_timer_pending = false;
269 } 269 }
270 270
271 return SCI_SUCCESS; 271 return SCI_SUCCESS;
@@ -278,22 +278,20 @@ enum sci_status scic_sds_controller_initialize_phy_startup(
278 * object. 278 * object.
279 */ 279 */
280void scic_sds_controller_initialize_power_control( 280void scic_sds_controller_initialize_power_control(
281 struct scic_sds_controller *this_controller) 281 struct scic_sds_controller *scic)
282{ 282{
283 this_controller->power_control.timer = isci_event_timer_create( 283 struct isci_host *ihost = sci_object_get_association(scic);
284 this_controller, 284 scic->power_control.timer = isci_timer_create(
285 scic_sds_controller_power_control_timer_handler, 285 ihost,
286 this_controller 286 scic,
287 ); 287 scic_sds_controller_power_control_timer_handler);
288 288
289 memset( 289 memset(scic->power_control.requesters,
290 this_controller->power_control.requesters, 290 0,
291 0, 291 sizeof(scic->power_control.requesters));
292 sizeof(this_controller->power_control.requesters)
293 );
294 292
295 this_controller->power_control.phys_waiting = 0; 293 scic->power_control.phys_waiting = 0;
296 this_controller->power_control.phys_granted_power = 0; 294 scic->power_control.phys_granted_power = 0;
297} 295}
298 296
299/* --------------------------------------------------------------------------- */ 297/* --------------------------------------------------------------------------- */
@@ -730,30 +728,29 @@ void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic)
730 * none. 728 * none.
731 */ 729 */
732static void scic_sds_controller_transition_to_ready( 730static void scic_sds_controller_transition_to_ready(
733 struct scic_sds_controller *this_controller, 731 struct scic_sds_controller *scic,
734 enum sci_status status) 732 enum sci_status status)
735{ 733{
736 if (this_controller->parent.state_machine.current_state_id 734 struct isci_host *ihost = sci_object_get_association(scic);
737 == SCI_BASE_CONTROLLER_STATE_STARTING) { 735
736 if (scic->parent.state_machine.current_state_id ==
737 SCI_BASE_CONTROLLER_STATE_STARTING) {
738 /* 738 /*
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 sci_base_state_machine_change_state( 742 sci_base_state_machine_change_state(
742 scic_sds_controller_get_base_state_machine(this_controller), 743 scic_sds_controller_get_base_state_machine(scic),
743 SCI_BASE_CONTROLLER_STATE_READY 744 SCI_BASE_CONTROLLER_STATE_READY);
744 );
745 745
746 isci_event_controller_start_complete(this_controller, status); 746 isci_host_start_complete(ihost, status);
747 } 747 }
748} 748}
749 749
750/** 750void scic_sds_controller_timeout_handler(void *_scic)
751 * This method is the general timeout handler for the controller. It will take
752 * the correct timetout action based on the current controller state
753 */
754void scic_sds_controller_timeout_handler(
755 struct scic_sds_controller *scic)
756{ 751{
752 struct scic_sds_controller *scic = _scic;
753 struct isci_host *ihost = sci_object_get_association(scic);
757 enum sci_base_controller_states current_state; 754 enum sci_base_controller_states current_state;
758 755
759 current_state = sci_base_state_machine_get_state( 756 current_state = sci_base_state_machine_get_state(
@@ -766,7 +763,7 @@ void scic_sds_controller_timeout_handler(
766 sci_base_state_machine_change_state( 763 sci_base_state_machine_change_state(
767 scic_sds_controller_get_base_state_machine(scic), 764 scic_sds_controller_get_base_state_machine(scic),
768 SCI_BASE_CONTROLLER_STATE_FAILED); 765 SCI_BASE_CONTROLLER_STATE_FAILED);
769 isci_event_controller_stop_complete(scic, SCI_FAILURE_TIMEOUT); 766 isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT);
770 } else /* / @todo Now what do we want to do in this case? */ 767 } else /* / @todo Now what do we want to do in this case? */
771 dev_err(scic_to_dev(scic), 768 dev_err(scic_to_dev(scic),
772 "%s: Controller timer fired when controller was not " 769 "%s: Controller timer fired when controller was not "
@@ -803,37 +800,21 @@ enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller *scic)
803 return status; 800 return status;
804} 801}
805 802
806/** 803static inline void scic_sds_controller_phy_timer_start(
807 * 804 struct scic_sds_controller *scic)
808 *
809 *
810 */
811static void scic_sds_controller_phy_timer_start(
812 struct scic_sds_controller *this_controller)
813{ 805{
814 isci_event_timer_start( 806 isci_timer_start(scic->phy_startup_timer,
815 this_controller, 807 SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT);
816 this_controller->phy_startup_timer,
817 SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT
818 );
819 808
820 this_controller->phy_startup_timer_pending = true; 809 scic->phy_startup_timer_pending = true;
821} 810}
822 811
823/** 812inline void scic_sds_controller_phy_timer_stop(
824 * 813 struct scic_sds_controller *scic)
825 *
826 *
827 */
828void scic_sds_controller_phy_timer_stop(
829 struct scic_sds_controller *this_controller)
830{ 814{
831 isci_event_timer_stop( 815 isci_timer_stop(scic->phy_startup_timer);
832 this_controller,
833 this_controller->phy_startup_timer
834 );
835 816
836 this_controller->phy_startup_timer_pending = false; 817 scic->phy_startup_timer_pending = false;
837} 818}
838 819
839/** 820/**
@@ -1009,19 +990,17 @@ enum sci_status scic_sds_controller_stop_devices(
1009 * ****************************************************************************- */ 990 * ****************************************************************************- */
1010 991
1011/** 992/**
993 * This function starts the power control timer for this controller object.
1012 * 994 *
1013 * 995 * @param scic
1014 * This method starts the power control timer for this controller object.
1015 */ 996 */
1016static void scic_sds_controller_power_control_timer_start( 997static inline void scic_sds_controller_power_control_timer_start(
1017 struct scic_sds_controller *this_controller) 998 struct scic_sds_controller *scic)
1018{ 999{
1019 isci_event_timer_start( 1000 isci_timer_start(scic->power_control.timer,
1020 this_controller, this_controller->power_control.timer, 1001 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
1021 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL
1022 );
1023 1002
1024 this_controller->power_control.timer_started = true; 1003 scic->power_control.timer_started = true;
1025} 1004}
1026 1005
1027/** 1006/**
@@ -1029,20 +1008,22 @@ static void scic_sds_controller_power_control_timer_start(
1029 * 1008 *
1030 * @param scic 1009 * @param scic
1031 */ 1010 */
1032void scic_sds_controller_power_control_timer_stop(struct scic_sds_controller *scic) 1011static inline void scic_sds_controller_power_control_timer_stop(
1012 struct scic_sds_controller *scic)
1033{ 1013{
1034 if (scic->power_control.timer_started) { 1014 if (scic->power_control.timer_started) {
1035 isci_event_timer_stop(scic, scic->power_control.timer); 1015 isci_timer_stop(scic->power_control.timer);
1036 scic->power_control.timer_started = false; 1016 scic->power_control.timer_started = false;
1037 } 1017 }
1038} 1018}
1039 1019
1040/** 1020/**
1041 * This method stops and starts the power control timer for this controller object. 1021 * This method stops and starts the power control timer for this controller
1022 * object.
1042 * 1023 *
1043 * @param scic 1024 * @param scic
1044 */ 1025 */
1045void scic_sds_controller_power_control_timer_restart( 1026static inline void scic_sds_controller_power_control_timer_restart(
1046 struct scic_sds_controller *scic) 1027 struct scic_sds_controller *scic)
1047{ 1028{
1048 scic_sds_controller_power_control_timer_stop(scic); 1029 scic_sds_controller_power_control_timer_stop(scic);
@@ -2893,51 +2874,41 @@ static enum sci_status scic_sds_controller_general_reset_handler(
2893 * * RESET STATE HANDLERS 2874 * * RESET STATE HANDLERS
2894 * ***************************************************************************** */ 2875 * ***************************************************************************** */
2895 2876
2896/** 2877static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic)
2897 *
2898 * @controller: This is the struct sci_base_controller object which is cast into a
2899 * struct scic_sds_controller object.
2900 *
2901 * This method is the struct scic_sds_controller initialize handler for the reset
2902 * state. - Currently this function does nothing enum sci_status SCI_FAILURE This
2903 * function is not yet implemented and is a valid request from the reset state.
2904 */
2905static enum sci_status scic_sds_controller_reset_state_initialize_handler(
2906 struct sci_base_controller *controller)
2907{ 2878{
2908 u32 index;
2909 enum sci_status result = SCI_SUCCESS; 2879 enum sci_status result = SCI_SUCCESS;
2910 struct scic_sds_controller *this_controller; 2880 struct scic_sds_controller *scic;
2881 struct isci_host *ihost;
2882 u32 index;
2911 2883
2912 this_controller = (struct scic_sds_controller *)controller; 2884 scic = container_of(base_scic, typeof(*scic), parent);
2885 ihost = sci_object_get_association(scic);
2913 2886
2914 sci_base_state_machine_change_state( 2887 sci_base_state_machine_change_state(
2915 scic_sds_controller_get_base_state_machine(this_controller), 2888 scic_sds_controller_get_base_state_machine(scic),
2916 SCI_BASE_CONTROLLER_STATE_INITIALIZING 2889 SCI_BASE_CONTROLLER_STATE_INITIALIZING);
2917 );
2918 2890
2919 this_controller->timeout_timer = isci_event_timer_create( 2891 scic->timeout_timer = isci_timer_create(ihost,
2920 this_controller, 2892 scic,
2921 (void (*)(void *))scic_sds_controller_timeout_handler, 2893 scic_sds_controller_timeout_handler);
2922 (void (*)(void *))controller);
2923 2894
2924 scic_sds_controller_initialize_phy_startup(this_controller); 2895 scic_sds_controller_initialize_phy_startup(scic);
2925 2896
2926 scic_sds_controller_initialize_power_control(this_controller); 2897 scic_sds_controller_initialize_power_control(scic);
2927 2898
2928 /* 2899 /*
2929 * There is nothing to do here for B0 since we do not have to 2900 * There is nothing to do here for B0 since we do not have to
2930 * program the AFE registers. 2901 * program the AFE registers.
2931 * / @todo The AFE settings are supposed to be correct for the B0 but 2902 * / @todo The AFE settings are supposed to be correct for the B0 but
2932 * / presently they seem to be wrong. */ 2903 * / presently they seem to be wrong. */
2933 scic_sds_controller_afe_initialization(this_controller); 2904 scic_sds_controller_afe_initialization(scic);
2934 2905
2935 if (SCI_SUCCESS == result) { 2906 if (result == SCI_SUCCESS) {
2936 u32 status; 2907 u32 status;
2937 u32 terminate_loop; 2908 u32 terminate_loop;
2938 2909
2939 /* Take the hardware out of reset */ 2910 /* Take the hardware out of reset */
2940 SMU_SMUSRCR_WRITE(this_controller, 0x00000000); 2911 SMU_SMUSRCR_WRITE(scic, 0x00000000);
2941 2912
2942 /* 2913 /*
2943 * / @todo Provide meaningfull error code for hardware failure 2914 * / @todo Provide meaningfull error code for hardware failure
@@ -2948,11 +2919,11 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(
2948 while (terminate_loop-- && (result != SCI_SUCCESS)) { 2919 while (terminate_loop-- && (result != SCI_SUCCESS)) {
2949 /* Loop until the hardware reports success */ 2920 /* Loop until the hardware reports success */
2950 udelay(SCU_CONTEXT_RAM_INIT_STALL_TIME); 2921 udelay(SCU_CONTEXT_RAM_INIT_STALL_TIME);
2951 status = SMU_SMUCSR_READ(this_controller); 2922 status = SMU_SMUCSR_READ(scic);
2952 2923
2953 if ((status & SCU_RAM_INIT_COMPLETED) == SCU_RAM_INIT_COMPLETED) { 2924 if ((status & SCU_RAM_INIT_COMPLETED) ==
2925 SCU_RAM_INIT_COMPLETED)
2954 result = SCI_SUCCESS; 2926 result = SCI_SUCCESS;
2955 }
2956 } 2927 }
2957 } 2928 }
2958 2929
@@ -2965,39 +2936,42 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(
2965 /* 2936 /*
2966 * Determine what are the actaul device capacities that the 2937 * Determine what are the actaul device capacities that the
2967 * hardware will support */ 2938 * hardware will support */
2968 device_context_capacity = SMU_DCC_READ(this_controller); 2939 device_context_capacity = SMU_DCC_READ(scic);
2969 2940
2970 max_supported_ports = 2941 max_supported_ports = smu_dcc_get_max_ports(device_context_capacity);
2971 smu_dcc_get_max_ports(device_context_capacity); 2942 max_supported_devices = smu_dcc_get_max_remote_node_context(device_context_capacity);
2972 max_supported_devices = 2943 max_supported_io_requests = smu_dcc_get_max_task_context(device_context_capacity);
2973 smu_dcc_get_max_remote_node_context(device_context_capacity);
2974 max_supported_io_requests =
2975 smu_dcc_get_max_task_context(device_context_capacity);
2976 2944
2977 /* Make all PEs that are unassigned match up with the logical ports */ 2945 /*
2946 * Make all PEs that are unassigned match up with the
2947 * logical ports
2948 */
2978 for (index = 0; index < max_supported_ports; index++) { 2949 for (index = 0; index < max_supported_ports; index++) {
2979 scu_register_write( 2950 struct scu_port_task_scheduler_group_registers *ptsg =
2980 this_controller, 2951 &scic->scu_registers->peg0.ptsg;
2981 this_controller->scu_registers->peg0.ptsg.protocol_engine[index], 2952
2982 index 2953 scu_register_write(scic,
2983 ); 2954 ptsg->protocol_engine[index],
2955 index);
2984 } 2956 }
2985 2957
2986 /* Record the smaller of the two capacity values */ 2958 /* Record the smaller of the two capacity values */
2987 this_controller->logical_port_entries = 2959 scic->logical_port_entries =
2988 min(max_supported_ports, this_controller->logical_port_entries); 2960 min(max_supported_ports, scic->logical_port_entries);
2989 2961
2990 this_controller->task_context_entries = 2962 scic->task_context_entries =
2991 min(max_supported_io_requests, this_controller->task_context_entries); 2963 min(max_supported_io_requests,
2964 scic->task_context_entries);
2992 2965
2993 this_controller->remote_node_entries = 2966 scic->remote_node_entries =
2994 min(max_supported_devices, this_controller->remote_node_entries); 2967 min(max_supported_devices, scic->remote_node_entries);
2995 2968
2996 /* 2969 /*
2997 * Now that we have the correct hardware reported minimum values 2970 * Now that we have the correct hardware reported minimum values
2998 * build the MDL for the controller. Default to a performance 2971 * build the MDL for the controller. Default to a performance
2999 * configuration. */ 2972 * configuration.
3000 scic_controller_set_mode(this_controller, SCI_MODE_SPEED); 2973 */
2974 scic_controller_set_mode(scic, SCI_MODE_SPEED);
3001 } 2975 }
3002 2976
3003 /* Initialize hardware PCI Relaxed ordering in DMA engines */ 2977 /* Initialize hardware PCI Relaxed ordering in DMA engines */
@@ -3005,66 +2979,62 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(
3005 u32 dma_configuration; 2979 u32 dma_configuration;
3006 2980
3007 /* Configure the payload DMA */ 2981 /* Configure the payload DMA */
3008 dma_configuration = SCU_PDMACR_READ(this_controller); 2982 dma_configuration = SCU_PDMACR_READ(scic);
3009 dma_configuration |= SCU_PDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE); 2983 dma_configuration |=
3010 SCU_PDMACR_WRITE(this_controller, dma_configuration); 2984 SCU_PDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
2985 SCU_PDMACR_WRITE(scic, dma_configuration);
3011 2986
3012 /* Configure the control DMA */ 2987 /* Configure the control DMA */
3013 dma_configuration = SCU_CDMACR_READ(this_controller); 2988 dma_configuration = SCU_CDMACR_READ(scic);
3014 dma_configuration |= SCU_CDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE); 2989 dma_configuration |=
3015 SCU_CDMACR_WRITE(this_controller, dma_configuration); 2990 SCU_CDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
2991 SCU_CDMACR_WRITE(scic, dma_configuration);
3016 } 2992 }
3017 2993
3018 /* 2994 /*
3019 * Initialize the PHYs before the PORTs because the PHY registers 2995 * Initialize the PHYs before the PORTs because the PHY registers
3020 * are accessed during the port initialization. */ 2996 * are accessed during the port initialization.
2997 */
3021 if (result == SCI_SUCCESS) { 2998 if (result == SCI_SUCCESS) {
3022 /* Initialize the phys */ 2999 /* Initialize the phys */
3023 for (index = 0; 3000 for (index = 0;
3024 (result == SCI_SUCCESS) && (index < SCI_MAX_PHYS); 3001 (result == SCI_SUCCESS) && (index < SCI_MAX_PHYS);
3025 index++) { 3002 index++) {
3026 result = scic_sds_phy_initialize( 3003 result = scic_sds_phy_initialize(
3027 &this_controller->phy_table[index], 3004 &scic->phy_table[index],
3028 &this_controller->scu_registers->peg0.pe[index].tl, 3005 &scic->scu_registers->peg0.pe[index].tl,
3029 &this_controller->scu_registers->peg0.pe[index].ll 3006 &scic->scu_registers->peg0.pe[index].ll);
3030 );
3031 } 3007 }
3032 } 3008 }
3033 3009
3034 if (result == SCI_SUCCESS) { 3010 if (result == SCI_SUCCESS) {
3035 /* Initialize the logical ports */ 3011 /* Initialize the logical ports */
3036 for (index = 0; 3012 for (index = 0;
3037 (index < this_controller->logical_port_entries) 3013 (index < scic->logical_port_entries) &&
3038 && (result == SCI_SUCCESS); 3014 (result == SCI_SUCCESS);
3039 index++) { 3015 index++) {
3040 result = scic_sds_port_initialize( 3016 result = scic_sds_port_initialize(
3041 &this_controller->port_table[index], 3017 &scic->port_table[index],
3042 &this_controller->scu_registers->peg0.ptsg.port[index], 3018 &scic->scu_registers->peg0.ptsg.port[index],
3043 &this_controller->scu_registers->peg0.ptsg.protocol_engine, 3019 &scic->scu_registers->peg0.ptsg.protocol_engine,
3044 &this_controller->scu_registers->peg0.viit[index] 3020 &scic->scu_registers->peg0.viit[index]);
3045 );
3046 } 3021 }
3047 } 3022 }
3048 3023
3049 if (SCI_SUCCESS == result) { 3024 if (result == SCI_SUCCESS)
3050 result = scic_sds_port_configuration_agent_initialize( 3025 result = scic_sds_port_configuration_agent_initialize(
3051 this_controller, 3026 scic,
3052 &this_controller->port_agent 3027 &scic->port_agent);
3053 );
3054 }
3055 3028
3056 /* Advance the controller state machine */ 3029 /* Advance the controller state machine */
3057 if (result == SCI_SUCCESS) { 3030 if (result == SCI_SUCCESS)
3058 sci_base_state_machine_change_state( 3031 sci_base_state_machine_change_state(
3059 scic_sds_controller_get_base_state_machine(this_controller), 3032 scic_sds_controller_get_base_state_machine(scic),
3060 SCI_BASE_CONTROLLER_STATE_INITIALIZED 3033 SCI_BASE_CONTROLLER_STATE_INITIALIZED);
3061 ); 3034 else
3062 } else {
3063 sci_base_state_machine_change_state( 3035 sci_base_state_machine_change_state(
3064 scic_sds_controller_get_base_state_machine(this_controller), 3036 scic_sds_controller_get_base_state_machine(scic),
3065 SCI_BASE_CONTROLLER_STATE_FAILED 3037 SCI_BASE_CONTROLLER_STATE_FAILED);
3066 );
3067 }
3068 3038
3069 return result; 3039 return result;
3070} 3040}
@@ -3076,13 +3046,14 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(
3076 3046
3077/** 3047/**
3078 * 3048 *
3079 * @controller: This is the struct sci_base_controller object which is cast into a 3049 * @controller: This is the struct sci_base_controller object which is cast
3080 * struct scic_sds_controller object. 3050 * into a struct scic_sds_controller object.
3081 * @timeout: This is the allowed time for the controller object to reach the 3051 * @timeout: This is the allowed time for the controller object to reach the
3082 * started state. 3052 * started state.
3083 * 3053 *
3084 * This method is the struct scic_sds_controller start handler for the initialized 3054 * This function is the struct scic_sds_controller start handler for the
3085 * state. - Validate we have a good memory descriptor table - Initialze the 3055 * initialized state.
3056 * - Validate we have a good memory descriptor table - Initialze the
3086 * physical memory before programming the hardware - Program the SCU hardware 3057 * physical memory before programming the hardware - Program the SCU hardware
3087 * with the physical memory addresses passed in the memory descriptor table. - 3058 * with the physical memory addresses passed in the memory descriptor table. -
3088 * Initialzie the TCi pool - Initialize the RNi pool - Initialize the 3059 * Initialzie the TCi pool - Initialize the RNi pool - Initialize the
@@ -3099,70 +3070,74 @@ static enum sci_status scic_sds_controller_initialized_state_start_handler(
3099{ 3070{
3100 u16 index; 3071 u16 index;
3101 enum sci_status result; 3072 enum sci_status result;
3102 struct scic_sds_controller *this_controller; 3073 struct scic_sds_controller *scic;
3103 3074
3104 this_controller = (struct scic_sds_controller *)controller; 3075 scic = (struct scic_sds_controller *)controller;
3105 3076
3106 /* Make sure that the SCI User filled in the memory descriptor table correctly */ 3077 /*
3107 result = scic_sds_controller_validate_memory_descriptor_table(this_controller); 3078 * Make sure that the SCI User filled in the memory descriptor
3079 * table correctly
3080 */
3081 result = scic_sds_controller_validate_memory_descriptor_table(scic);
3108 3082
3109 if (result == SCI_SUCCESS) { 3083 if (result == SCI_SUCCESS) {
3110 /* The memory descriptor list looks good so program the hardware */ 3084 /*
3111 scic_sds_controller_ram_initialization(this_controller); 3085 * The memory descriptor list looks good so program the
3086 * hardware
3087 */
3088 scic_sds_controller_ram_initialization(scic);
3112 } 3089 }
3113 3090
3114 if (result == SCI_SUCCESS) { 3091 if (result == SCI_SUCCESS) {
3115 /* Build the TCi free pool */ 3092 /* Build the TCi free pool */
3116 sci_pool_initialize(this_controller->tci_pool); 3093 sci_pool_initialize(scic->tci_pool);
3117 for (index = 0; index < this_controller->task_context_entries; index++) { 3094 for (index = 0; index < scic->task_context_entries; index++)
3118 sci_pool_put(this_controller->tci_pool, index); 3095 sci_pool_put(scic->tci_pool, index);
3119 }
3120 3096
3121 /* Build the RNi free pool */ 3097 /* Build the RNi free pool */
3122 scic_sds_remote_node_table_initialize( 3098 scic_sds_remote_node_table_initialize(
3123 &this_controller->available_remote_nodes, 3099 &scic->available_remote_nodes,
3124 this_controller->remote_node_entries 3100 scic->remote_node_entries);
3125 );
3126 } 3101 }
3127 3102
3128 if (result == SCI_SUCCESS) { 3103 if (result == SCI_SUCCESS) {
3129 /* 3104 /*
3130 * Before anything else lets make sure we will not be interrupted 3105 * Before anything else lets make sure we will not be
3131 * by the hardware. */ 3106 * interrupted by the hardware.
3132 scic_controller_disable_interrupts(this_controller); 3107 */
3108 scic_controller_disable_interrupts(scic);
3133 3109
3134 /* Enable the port task scheduler */ 3110 /* Enable the port task scheduler */
3135 scic_sds_controller_enable_port_task_scheduler(this_controller); 3111 scic_sds_controller_enable_port_task_scheduler(scic);
3136 3112
3137 /* Assign all the task entries to this controller physical function */ 3113 /* Assign all the task entries to scic physical function */
3138 scic_sds_controller_assign_task_entries(this_controller); 3114 scic_sds_controller_assign_task_entries(scic);
3139 3115
3140 /* Now initialze the completion queue */ 3116 /* Now initialze the completion queue */
3141 scic_sds_controller_initialize_completion_queue(this_controller); 3117 scic_sds_controller_initialize_completion_queue(scic);
3142 3118
3143 /* Initialize the unsolicited frame queue for use */ 3119 /* Initialize the unsolicited frame queue for use */
3144 scic_sds_controller_initialize_unsolicited_frame_queue(this_controller); 3120 scic_sds_controller_initialize_unsolicited_frame_queue(scic);
3145 } 3121 }
3146 3122
3147 /* Start all of the ports on this controller */ 3123 /* Start all of the ports on this controller */
3148 for (index = 0; index < this_controller->logical_port_entries && 3124 for (index = 0;
3149 result == SCI_SUCCESS; index++) { 3125 (index < scic->logical_port_entries) && (result == SCI_SUCCESS);
3150 struct scic_sds_port *sci_port = &this_controller->port_table[index]; 3126 index++) {
3127 struct scic_sds_port *sci_port = &scic->port_table[index];
3151 3128
3152 result = sci_port->state_handlers->parent.start_handler(&sci_port->parent); 3129 result = sci_port->state_handlers->parent.start_handler(
3130 &sci_port->parent);
3153 } 3131 }
3154 3132
3155 if (result == SCI_SUCCESS) { 3133 if (result == SCI_SUCCESS) {
3156 scic_sds_controller_start_next_phy(this_controller); 3134 scic_sds_controller_start_next_phy(scic);
3157 3135
3158 isci_event_timer_start(this_controller, 3136 isci_timer_start(scic->timeout_timer, timeout);
3159 this_controller->timeout_timer,
3160 timeout);
3161 3137
3162 sci_base_state_machine_change_state( 3138 sci_base_state_machine_change_state(
3163 scic_sds_controller_get_base_state_machine(this_controller), 3139 scic_sds_controller_get_base_state_machine(scic),
3164 SCI_BASE_CONTROLLER_STATE_STARTING 3140 SCI_BASE_CONTROLLER_STATE_STARTING);
3165 );
3166 } 3141 }
3167 3142
3168 return result; 3143 return result;
@@ -3241,18 +3216,14 @@ static enum sci_status scic_sds_controller_ready_state_stop_handler(
3241 struct sci_base_controller *controller, 3216 struct sci_base_controller *controller,
3242 u32 timeout) 3217 u32 timeout)
3243{ 3218{
3244 struct scic_sds_controller *this_controller; 3219 struct scic_sds_controller *scic =
3245 3220 (struct scic_sds_controller *)controller;
3246 this_controller = (struct scic_sds_controller *)controller;
3247 3221
3248 isci_event_timer_start(this_controller, 3222 isci_timer_start(scic->timeout_timer, timeout);
3249 this_controller->timeout_timer,
3250 timeout);
3251 3223
3252 sci_base_state_machine_change_state( 3224 sci_base_state_machine_change_state(
3253 scic_sds_controller_get_base_state_machine(this_controller), 3225 scic_sds_controller_get_base_state_machine(scic),
3254 SCI_BASE_CONTROLLER_STATE_STOPPING 3226 SCI_BASE_CONTROLLER_STATE_STOPPING);
3255 );
3256 3227
3257 return SCI_SUCCESS; 3228 return SCI_SUCCESS;
3258} 3229}
@@ -3689,12 +3660,12 @@ static void scic_sds_controller_initial_state_enter(
3689 * from the SCI_BASE_CONTROLLER_STATE_STARTING. - This function stops the 3660 * from the SCI_BASE_CONTROLLER_STATE_STARTING. - This function stops the
3690 * controller starting timeout timer. none 3661 * controller starting timeout timer. none
3691 */ 3662 */
3692static void scic_sds_controller_starting_state_exit( 3663static inline void scic_sds_controller_starting_state_exit(
3693 struct sci_base_object *object) 3664 struct sci_base_object *object)
3694{ 3665{
3695 struct scic_sds_controller *scic = (struct scic_sds_controller *)object; 3666 struct scic_sds_controller *scic = (struct scic_sds_controller *)object;
3696 3667
3697 isci_event_timer_stop(scic, scic->timeout_timer); 3668 isci_timer_stop(scic->timeout_timer);
3698} 3669}
3699 3670
3700/** 3671/**
@@ -3762,21 +3733,20 @@ static void scic_sds_controller_stopping_state_enter(
3762 3733
3763/** 3734/**
3764 * 3735 *
3765 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller 3736 * @object: This is the struct sci_base_object which is cast to a struct
3766 * object. 3737 * scic_sds_controller object.
3767 * 3738 *
3768 * This method implements the actions taken by the struct scic_sds_controller on exit 3739 * This funciton implements the actions taken by the struct scic_sds_controller
3769 * from the SCI_BASE_CONTROLLER_STATE_STOPPING. - This function stops the 3740 * on exit from the SCI_BASE_CONTROLLER_STATE_STOPPING. -
3770 * controller stopping timeout timer. none 3741 * This function stops the controller stopping timeout timer.
3771 */ 3742 */
3772static void scic_sds_controller_stopping_state_exit( 3743static inline void scic_sds_controller_stopping_state_exit(
3773 struct sci_base_object *object) 3744 struct sci_base_object *object)
3774{ 3745{
3775 struct scic_sds_controller *this_controller; 3746 struct scic_sds_controller *scic =
3776 3747 (struct scic_sds_controller *)object;
3777 this_controller = (struct scic_sds_controller *)object;
3778 3748
3779 isci_event_timer_stop(this_controller, this_controller->timeout_timer); 3749 isci_timer_stop(scic->timeout_timer);
3780} 3750}
3781 3751
3782/** 3752/**
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h
index 6386a64896c0..f426324bf3a9 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.h
+++ b/drivers/scsi/isci/core/scic_sds_controller.h
@@ -681,8 +681,7 @@ void scic_sds_controller_copy_task_context(
681 struct scic_sds_controller *this_controller, 681 struct scic_sds_controller *this_controller,
682 struct scic_sds_request *this_request); 682 struct scic_sds_request *this_request);
683 683
684void scic_sds_controller_timeout_handler( 684void scic_sds_controller_timeout_handler(void *controller);
685 struct scic_sds_controller *controller);
686 685
687void scic_sds_controller_initialize_power_control( 686void scic_sds_controller_initialize_power_control(
688 struct scic_sds_controller *this_controller); 687 struct scic_sds_controller *this_controller);
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c
index 27174589a863..225e67a9e7b1 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.c
+++ b/drivers/scsi/isci/core/scic_sds_phy.c
@@ -366,18 +366,23 @@ void scic_sds_phy_set_port(
366 */ 366 */
367enum sci_status scic_sds_phy_initialize( 367enum sci_status scic_sds_phy_initialize(
368 struct scic_sds_phy *sci_phy, 368 struct scic_sds_phy *sci_phy,
369 struct scu_transport_layer_registers __iomem *transport_layer_registers, 369 struct scu_transport_layer_registers __iomem *transport_layer_registers,
370 struct scu_link_layer_registers __iomem *link_layer_registers) 370 struct scu_link_layer_registers __iomem *link_layer_registers)
371{ 371{
372 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
373 struct isci_host *ihost = sci_object_get_association(scic);
374
372 /* Create the SIGNATURE FIS Timeout timer for this phy */ 375 /* Create the SIGNATURE FIS Timeout timer for this phy */
373 sci_phy->sata_timeout_timer = isci_event_timer_create( 376 sci_phy->sata_timeout_timer =
374 scic_sds_phy_get_controller(sci_phy), 377 isci_timer_create(
375 scic_sds_phy_sata_timeout, 378 ihost,
376 sci_phy 379 sci_phy,
377 ); 380 scic_sds_phy_sata_timeout);
378 381
379 /* Perfrom the initialization of the TL hardware */ 382 /* Perfrom the initialization of the TL hardware */
380 scic_sds_phy_transport_layer_initialization(sci_phy, transport_layer_registers); 383 scic_sds_phy_transport_layer_initialization(
384 sci_phy,
385 transport_layer_registers);
381 386
382 /* Perofrm the initialization of the PE hardware */ 387 /* Perofrm the initialization of the PE hardware */
383 scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers); 388 scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers);
@@ -387,8 +392,7 @@ enum sci_status scic_sds_phy_initialize(
387 * transition to the stopped state. */ 392 * transition to the stopped state. */
388 sci_base_state_machine_change_state( 393 sci_base_state_machine_change_state(
389 scic_sds_phy_get_base_state_machine(sci_phy), 394 scic_sds_phy_get_base_state_machine(sci_phy),
390 SCI_BASE_PHY_STATE_STOPPED 395 SCI_BASE_PHY_STATE_STOPPED);
391 );
392 396
393 return SCI_SUCCESS; 397 return SCI_SUCCESS;
394} 398}
@@ -1742,49 +1746,42 @@ static void scic_sds_phy_starting_await_sata_power_substate_exit(
1742 1746
1743/** 1747/**
1744 * 1748 *
1745 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. 1749 * @object: This is the struct sci_base_object which is cast to a
1750 * struct scic_sds_phy object.
1746 * 1751 *
1747 * This method will perform the actions required by the struct scic_sds_phy on 1752 * This function will perform the actions required by the struct scic_sds_phy on
1748 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the 1753 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the
1749 * struct scic_sds_phy object state handlers for this state. none 1754 * struct scic_sds_phy object state handlers for this state. none
1750 */ 1755 */
1751static void scic_sds_phy_starting_await_sata_phy_substate_enter( 1756static void scic_sds_phy_starting_await_sata_phy_substate_enter(
1752 struct sci_base_object *object) 1757 struct sci_base_object *object)
1753{ 1758{
1754 struct scic_sds_phy *this_phy; 1759 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)object;
1755
1756 this_phy = (struct scic_sds_phy *)object;
1757 1760
1758 scic_sds_phy_set_starting_substate_handlers( 1761 scic_sds_phy_set_starting_substate_handlers(
1759 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN 1762 sci_phy,
1760 ); 1763 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
1761 1764
1762 isci_event_timer_start( 1765 isci_timer_start(sci_phy->sata_timeout_timer,
1763 scic_sds_phy_get_controller(this_phy), 1766 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1764 this_phy->sata_timeout_timer,
1765 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT
1766 );
1767} 1767}
1768 1768
1769/** 1769/**
1770 * 1770 *
1771 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. 1771 * @object: This is the struct sci_base_object which is cast to a
1772 * struct scic_sds_phy object.
1772 * 1773 *
1773 * This method will perform the actions required by the struct scic_sds_phy on exiting 1774 * This method will perform the actions required by the struct scic_sds_phy
1775 * on exiting
1774 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer 1776 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
1775 * that was started on entry to await sata phy event notification none 1777 * that was started on entry to await sata phy event notification none
1776 */ 1778 */
1777static void scic_sds_phy_starting_await_sata_phy_substate_exit( 1779static inline void scic_sds_phy_starting_await_sata_phy_substate_exit(
1778 struct sci_base_object *object) 1780 struct sci_base_object *object)
1779{ 1781{
1780 struct scic_sds_phy *this_phy; 1782 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)object;
1781 1783
1782 this_phy = (struct scic_sds_phy *)object; 1784 isci_timer_stop(sci_phy->sata_timeout_timer);
1783
1784 isci_event_timer_stop(
1785 scic_sds_phy_get_controller(this_phy),
1786 this_phy->sata_timeout_timer
1787 );
1788} 1785}
1789 1786
1790/** 1787/**
@@ -1798,104 +1795,92 @@ static void scic_sds_phy_starting_await_sata_phy_substate_exit(
1798static void scic_sds_phy_starting_await_sata_speed_substate_enter( 1795static void scic_sds_phy_starting_await_sata_speed_substate_enter(
1799 struct sci_base_object *object) 1796 struct sci_base_object *object)
1800{ 1797{
1801 struct scic_sds_phy *this_phy; 1798 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)object;
1802
1803 this_phy = (struct scic_sds_phy *)object;
1804 1799
1805 scic_sds_phy_set_starting_substate_handlers( 1800 scic_sds_phy_set_starting_substate_handlers(
1806 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN 1801 sci_phy,
1807 ); 1802 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
1808 1803
1809 isci_event_timer_start( 1804 isci_timer_start(sci_phy->sata_timeout_timer,
1810 scic_sds_phy_get_controller(this_phy), 1805 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1811 this_phy->sata_timeout_timer,
1812 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT
1813 );
1814} 1806}
1815 1807
1816/** 1808/**
1817 * 1809 *
1818 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. 1810 * @object: This is the struct sci_base_object which is cast to a
1811 * struct scic_sds_phy object.
1819 * 1812 *
1820 * This method will perform the actions required by the struct scic_sds_phy on exiting 1813 * This function will perform the actions required by the
1814 * struct scic_sds_phy on exiting
1821 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer 1815 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
1822 * that was started on entry to await sata phy event notification none 1816 * that was started on entry to await sata phy event notification none
1823 */ 1817 */
1824static void scic_sds_phy_starting_await_sata_speed_substate_exit( 1818static inline void scic_sds_phy_starting_await_sata_speed_substate_exit(
1825 struct sci_base_object *object) 1819 struct sci_base_object *object)
1826{ 1820{
1827 struct scic_sds_phy *this_phy; 1821 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)object;
1828 1822
1829 this_phy = (struct scic_sds_phy *)object; 1823 isci_timer_stop(sci_phy->sata_timeout_timer);
1830
1831 isci_event_timer_stop(
1832 scic_sds_phy_get_controller(this_phy),
1833 this_phy->sata_timeout_timer
1834 );
1835} 1824}
1836 1825
1837/** 1826/**
1838 * 1827 *
1839 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. 1828 * @object: This is the struct sci_base_object which is cast to a
1829 * struct scic_sds_phy object.
1840 * 1830 *
1841 * This method will perform the actions required by the struct scic_sds_phy on 1831 * This function will perform the actions required by the struct scic_sds_phy on
1842 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the 1832 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the
1843 * struct scic_sds_phy object state handlers for this state. - Start the SIGNATURE FIS 1833 * struct scic_sds_phy object state handlers for this state.
1834 * - Start the SIGNATURE FIS
1844 * timeout timer none 1835 * timeout timer none
1845 */ 1836 */
1846static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter( 1837static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(
1847 struct sci_base_object *object) 1838 struct sci_base_object *object)
1848{ 1839{
1849 bool continue_to_ready_state; 1840 bool continue_to_ready_state;
1850 struct scic_sds_phy *this_phy; 1841 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)object;
1851
1852 this_phy = (struct scic_sds_phy *)object;
1853 1842
1854 scic_sds_phy_set_starting_substate_handlers( 1843 scic_sds_phy_set_starting_substate_handlers(
1855 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF 1844 sci_phy,
1856 ); 1845 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
1857 1846
1858 continue_to_ready_state = scic_sds_port_link_detected( 1847 continue_to_ready_state = scic_sds_port_link_detected(
1859 this_phy->owning_port, 1848 sci_phy->owning_port,
1860 this_phy 1849 sci_phy);
1861 );
1862 1850
1863 if (continue_to_ready_state) { 1851 if (continue_to_ready_state) {
1864 /* 1852 /*
1865 * Clear the PE suspend condition so we can actually receive SIG FIS 1853 * Clear the PE suspend condition so we can actually
1866 * The hardware will not respond to the XRDY until the PE suspend 1854 * receive SIG FIS
1867 * condition is cleared. */ 1855 * The hardware will not respond to the XRDY until the PE
1868 scic_sds_phy_resume(this_phy); 1856 * suspend condition is cleared.
1857 */
1858 scic_sds_phy_resume(sci_phy);
1869 1859
1870 isci_event_timer_start( 1860 isci_timer_start(sci_phy->sata_timeout_timer,
1871 scic_sds_phy_get_controller(this_phy), 1861 SCIC_SDS_SIGNATURE_FIS_TIMEOUT);
1872 this_phy->sata_timeout_timer, 1862 } else
1873 SCIC_SDS_SIGNATURE_FIS_TIMEOUT 1863 sci_phy->is_in_link_training = false;
1874 );
1875 } else {
1876 this_phy->is_in_link_training = false;
1877 }
1878} 1864}
1879 1865
1880/** 1866/**
1881 * 1867 *
1882 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_phy object. 1868 * @object: This is the struct sci_base_object which is cast to a
1869 * struct scic_sds_phy object.
1883 * 1870 *
1884 * This method will perform the actions required by the struct scic_sds_phy on exiting 1871 * This function will perform the actions required by the
1872 * struct scic_sds_phy on exiting
1885 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE 1873 * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE
1886 * FIS timeout timer. none 1874 * FIS timeout timer. none
1887 */ 1875 */
1888static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit( 1876static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(
1889 struct sci_base_object *object) 1877 struct sci_base_object *object)
1890{ 1878{
1891 struct scic_sds_phy *this_phy; 1879 struct scic_sds_phy *sci_phy;
1892 1880
1893 this_phy = (struct scic_sds_phy *)object; 1881 sci_phy = (struct scic_sds_phy *)object;
1894 1882
1895 isci_event_timer_stop( 1883 isci_timer_stop(sci_phy->sata_timeout_timer);
1896 scic_sds_phy_get_controller(this_phy),
1897 this_phy->sata_timeout_timer
1898 );
1899} 1884}
1900 1885
1901/** 1886/**
@@ -2158,27 +2143,30 @@ enum sci_status scic_sds_phy_default_consume_power_handler(
2158 2143
2159/** 2144/**
2160 * 2145 *
2161 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy 2146 * @phy: This is the struct sci_base_phy object which is cast into a
2162 * object. 2147 * struct scic_sds_phy object.
2163 * 2148 *
2164 * This method takes the struct scic_sds_phy from a stopped state and attempts to 2149 * This method takes the struct scic_sds_phy from a stopped state and
2165 * start it. - The phy state machine is transitioned to the 2150 * attempts to start it. - The phy state machine is transitioned to the
2166 * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS 2151 * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS
2167 */ 2152 */
2168static enum sci_status scic_sds_phy_stopped_state_start_handler(struct sci_base_phy *phy) 2153static enum sci_status scic_sds_phy_stopped_state_start_handler(
2154 struct sci_base_phy *phy)
2169{ 2155{
2170 struct scic_sds_phy *this_phy; 2156 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)phy;
2171 2157 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
2172 this_phy = (struct scic_sds_phy *)phy; 2158 struct isci_host *ihost = sci_object_get_association(scic);
2173 2159
2174 /* Create the SIGNATURE FIS Timeout timer for this phy */ 2160 /* Create the SIGNATURE FIS Timeout timer for this phy */
2175 this_phy->sata_timeout_timer = isci_event_timer_create( 2161 sci_phy->sata_timeout_timer =
2176 scic_sds_phy_get_controller(this_phy), 2162 isci_timer_create(
2177 scic_sds_phy_sata_timeout, this_phy); 2163 ihost,
2164 sci_phy,
2165 scic_sds_phy_sata_timeout);
2178 2166
2179 if (this_phy->sata_timeout_timer != NULL) { 2167 if (sci_phy->sata_timeout_timer != NULL) {
2180 sci_base_state_machine_change_state( 2168 sci_base_state_machine_change_state(
2181 scic_sds_phy_get_base_state_machine(this_phy), 2169 scic_sds_phy_get_base_state_machine(sci_phy),
2182 SCI_BASE_PHY_STATE_STARTING); 2170 SCI_BASE_PHY_STATE_STARTING);
2183 } 2171 }
2184 2172
@@ -2525,14 +2513,16 @@ static void scic_sds_phy_initial_state_enter(
2525 * @object: This is the struct sci_base_object which is cast to a 2513 * @object: This is the struct sci_base_object which is cast to a
2526 * struct scic_sds_phy object. 2514 * struct scic_sds_phy object.
2527 * 2515 *
2528 * This method will perform the actions required by the struct scic_sds_phy on 2516 * This function will perform the actions required by the struct scic_sds_phy on
2529 * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state 2517 * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
2530 * handlers for the phy object base state machine initial state. - The SCU 2518 * handlers for the phy object base state machine initial state. - The SCU
2531 * hardware is requested to stop the protocol engine. none 2519 * hardware is requested to stop the protocol engine. none
2532 */ 2520 */
2533static void scic_sds_phy_stopped_state_enter(struct sci_base_object *object) 2521static void scic_sds_phy_stopped_state_enter(struct sci_base_object *object)
2534{ 2522{
2535 struct scic_sds_phy *sci_phy; 2523 struct scic_sds_phy *sci_phy = (struct scic_sds_phy *)object;
2524 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
2525 struct isci_host *ihost = sci_object_get_association(scic);
2536 2526
2537 sci_phy = (struct scic_sds_phy *)object; 2527 sci_phy = (struct scic_sds_phy *)object;
2538 2528
@@ -2541,11 +2531,11 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_object *object)
2541 * reset state 2531 * reset state
2542 */ 2532 */
2543 2533
2544 scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_STOPPED); 2534 scic_sds_phy_set_base_state_handlers(sci_phy,
2535 SCI_BASE_PHY_STATE_STOPPED);
2545 2536
2546 if (sci_phy->sata_timeout_timer != NULL) { 2537 if (sci_phy->sata_timeout_timer != NULL) {
2547 isci_event_timer_destroy(scic_sds_phy_get_controller(sci_phy), 2538 isci_del_timer(ihost, sci_phy->sata_timeout_timer);
2548 sci_phy->sata_timeout_timer);
2549 2539
2550 sci_phy->sata_timeout_timer = NULL; 2540 sci_phy->sata_timeout_timer = NULL;
2551 } 2541 }
@@ -2554,9 +2544,10 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_object *object)
2554 2544
2555 if (sci_phy->parent.state_machine.previous_state_id != 2545 if (sci_phy->parent.state_machine.previous_state_id !=
2556 SCI_BASE_PHY_STATE_INITIAL) 2546 SCI_BASE_PHY_STATE_INITIAL)
2557 scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy), 2547 scic_sds_controller_link_down(
2558 scic_sds_phy_get_port(sci_phy), 2548 scic_sds_phy_get_controller(sci_phy),
2559 sci_phy); 2549 scic_sds_phy_get_port(sci_phy),
2550 sci_phy);
2560} 2551}
2561 2552
2562/** 2553/**
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c
index a41fe426ac26..3ae0f0d80f1f 100644
--- a/drivers/scsi/isci/core/scic_sds_port.c
+++ b/drivers/scsi/isci/core/scic_sds_port.c
@@ -738,34 +738,32 @@ void scic_sds_port_setup_transports(
738 * @do_notify_user: This parameter specifies whether to inform the user (via 738 * @do_notify_user: This parameter specifies whether to inform the user (via
739 * scic_cb_port_link_up()) as to the fact that a new phy as become ready. 739 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
740 * 740 *
741 * This method will activate the phy in the port. Activation includes: - adding 741 * This function will activate the phy in the port.
742 * Activation includes: - adding
742 * the phy to the port - enabling the Protocol Engine in the silicon. - 743 * the phy to the port - enabling the Protocol Engine in the silicon. -
743 * notifying the user that the link is up. none 744 * notifying the user that the link is up. none
744 */ 745 */
745void scic_sds_port_activate_phy( 746void scic_sds_port_activate_phy(struct scic_sds_port *sci_port,
746 struct scic_sds_port *this_port, 747 struct scic_sds_phy *sci_phy,
747 struct scic_sds_phy *the_phy, 748 bool do_notify_user)
748 bool do_notify_user)
749{ 749{
750 struct scic_sds_controller *controller; 750 struct scic_sds_controller *scic =
751 scic_sds_port_get_controller(sci_port);
751 struct sci_sas_identify_address_frame_protocols protocols; 752 struct sci_sas_identify_address_frame_protocols protocols;
753 struct isci_host *ihost = sci_object_get_association(scic);
752 754
753 controller = scic_sds_port_get_controller(this_port); 755 scic_sds_phy_get_attached_phy_protocols(sci_phy, &protocols);
754 scic_sds_phy_get_attached_phy_protocols(the_phy, &protocols);
755 756
756 /* If this is sata port then the phy has already been resumed */ 757 /* If this is sata port then the phy has already been resumed */
757 if (!protocols.u.bits.stp_target) { 758 if (!protocols.u.bits.stp_target)
758 scic_sds_phy_resume(the_phy); 759 scic_sds_phy_resume(sci_phy);
759 }
760 760
761 this_port->active_phy_mask |= 1 << the_phy->phy_index; 761 sci_port->active_phy_mask |= 1 << sci_phy->phy_index;
762 762
763 scic_sds_controller_clear_invalid_phy(controller, the_phy); 763 scic_sds_controller_clear_invalid_phy(scic, sci_phy);
764 764
765 if (do_notify_user == true) 765 if (do_notify_user == true)
766 isci_event_port_link_up(this_port->owning_controller, 766 isci_port_link_up(ihost, sci_port, sci_phy);
767 this_port,
768 the_phy);
769} 767}
770 768
771/** 769/**
@@ -773,27 +771,30 @@ void scic_sds_port_activate_phy(
773 * @this_port: This is the port on which the phy should be deactivated. 771 * @this_port: This is the port on which the phy should be deactivated.
774 * @the_phy: This is the specific phy that is no longer active in the port. 772 * @the_phy: This is the specific phy that is no longer active in the port.
775 * @do_notify_user: This parameter specifies whether to inform the user (via 773 * @do_notify_user: This parameter specifies whether to inform the user (via
776 * isci_event_port_link_down()) as to the fact that a new phy as become 774 * isci_port_link_down()) as to the fact that a new phy as become
777 * ready. 775 * ready.
778 * 776 *
779 * This method will deactivate the supplied phy in the port. none 777 * This function will deactivate the supplied phy in the port. none
780 */ 778 */
781void scic_sds_port_deactivate_phy( 779void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
782 struct scic_sds_port *this_port, 780 struct scic_sds_phy *sci_phy,
783 struct scic_sds_phy *the_phy, 781 bool do_notify_user)
784 bool do_notify_user)
785{ 782{
786 this_port->active_phy_mask &= ~(1 << the_phy->phy_index); 783 struct scic_sds_controller *scic =
784 scic_sds_port_get_controller(sci_port);
785 struct isci_port *iport = sci_object_get_association(sci_port);
786 struct isci_host *ihost = sci_object_get_association(scic);
787 struct isci_phy *iphy = sci_object_get_association(sci_phy);
788
789 sci_port->active_phy_mask &= ~(1 << sci_phy->phy_index);
787 790
788 the_phy->max_negotiated_speed = SCI_SAS_NO_LINK_RATE; 791 sci_phy->max_negotiated_speed = SCI_SAS_NO_LINK_RATE;
789 792
790 /* Re-assign the phy back to the LP as if it were a narrow port */ 793 /* Re-assign the phy back to the LP as if it were a narrow port */
791 SCU_PCSPExCR_WRITE(this_port, the_phy->phy_index, the_phy->phy_index); 794 SCU_PCSPExCR_WRITE(sci_port, sci_phy->phy_index, sci_phy->phy_index);
792 795
793 if (do_notify_user == true) 796 if (do_notify_user == true)
794 isci_event_port_link_down(this_port->owning_controller, 797 isci_port_link_down(ihost, iphy, iport);
795 this_port,
796 the_phy);
797} 798}
798 799
799/** 800/**
@@ -801,22 +802,24 @@ void scic_sds_port_deactivate_phy(
801 * @this_port: This is the port on which the phy should be disabled. 802 * @this_port: This is the port on which the phy should be disabled.
802 * @the_phy: This is the specific phy which to disabled. 803 * @the_phy: This is the specific phy which to disabled.
803 * 804 *
804 * This method will disable the phy and report that the phy is not valid for 805 * This function will disable the phy and report that the phy is not valid for
805 * this port object. None 806 * this port object. None
806 */ 807 */
807static void scic_sds_port_invalid_link_up( 808static void scic_sds_port_invalid_link_up(
808 struct scic_sds_port *this_port, 809 struct scic_sds_port *sci_port,
809 struct scic_sds_phy *the_phy) 810 struct scic_sds_phy *sci_phy)
810{ 811{
811 struct scic_sds_controller *controller = scic_sds_port_get_controller(this_port); 812 struct scic_sds_controller *scic =
813 scic_sds_port_get_controller(sci_port);
812 814
813 /* 815 /*
814 * Check to see if we have alreay reported this link as bad and if not go 816 * Check to see if we have alreay reported this link as bad and if
815 * ahead and tell the SCI_USER that we have discovered an invalid link. */ 817 * not go ahead and tell the SCI_USER that we have discovered an
816 if ((controller->invalid_phy_mask & (1 << the_phy->phy_index)) == 0) { 818 * invalid link.
817 scic_sds_controller_set_invalid_phy(controller, the_phy); 819 */
818 820 if ((scic->invalid_phy_mask & (1 << sci_phy->phy_index)) == 0) {
819 isci_event_port_invalid_link_up(controller, this_port, the_phy); 821 scic_sds_controller_set_invalid_phy(scic, sci_phy);
822 isci_port_invalid_link_up(scic, sci_port, sci_phy);
820 } 823 }
821} 824}
822 825
@@ -950,44 +953,48 @@ enum sci_status scic_sds_port_complete_io(
950 */ 953 */
951static void scic_sds_port_timeout_handler(void *port) 954static void scic_sds_port_timeout_handler(void *port)
952{ 955{
953 struct scic_sds_port *this_port = port; 956 struct scic_sds_port *sci_port = port;
954 u32 current_state; 957 u32 current_state;
955 958
956 current_state = sci_base_state_machine_get_state( 959 current_state = sci_base_state_machine_get_state(
957 &this_port->parent.state_machine); 960 &sci_port->parent.state_machine);
958 961
959 if (current_state == SCI_BASE_PORT_STATE_RESETTING) { 962 if (current_state == SCI_BASE_PORT_STATE_RESETTING) {
960 /* 963 /*
961 * if the port is still in the resetting state then the timeout fired 964 * if the port is still in the resetting state then the
962 * before the reset completed. */ 965 * timeout fired before the reset completed.
966 */
963 sci_base_state_machine_change_state( 967 sci_base_state_machine_change_state(
964 &this_port->parent.state_machine, 968 &sci_port->parent.state_machine,
965 SCI_BASE_PORT_STATE_FAILED 969 SCI_BASE_PORT_STATE_FAILED);
966 );
967 } else if (current_state == SCI_BASE_PORT_STATE_STOPPED) { 970 } else if (current_state == SCI_BASE_PORT_STATE_STOPPED) {
968 /* 971 /*
969 * if the port is stopped then the start request failed 972 * if the port is stopped then the start request failed
970 * In this case stay in the stopped state. */ 973 * In this case stay in the stopped state.
971 dev_err(sciport_to_dev(this_port), 974 */
975 dev_err(sciport_to_dev(sci_port),
972 "%s: SCIC Port 0x%p failed to stop before tiemout.\n", 976 "%s: SCIC Port 0x%p failed to stop before tiemout.\n",
973 __func__, 977 __func__,
974 this_port); 978 sci_port);
975 } else if (current_state == SCI_BASE_PORT_STATE_STOPPING) { 979 } else if (current_state == SCI_BASE_PORT_STATE_STOPPING) {
976 /* if the port is still stopping then the stop has not completed */ 980 /*
977 isci_event_port_stop_complete( 981 * if the port is still stopping then the stop has not
978 scic_sds_port_get_controller(this_port), 982 * completed
979 port, 983 */
980 SCI_FAILURE_TIMEOUT 984 isci_port_stop_complete(
981 ); 985 scic_sds_port_get_controller(sci_port),
986 sci_port,
987 SCI_FAILURE_TIMEOUT);
982 } else { 988 } else {
983 /* 989 /*
984 * The port is in the ready state and we have a timer reporting a timeout 990 * The port is in the ready state and we have a timer
985 * this should not happen. */ 991 * reporting a timeout this should not happen.
986 dev_err(sciport_to_dev(this_port), 992 */
993 dev_err(sciport_to_dev(sci_port),
987 "%s: SCIC Port 0x%p is processing a timeout operation " 994 "%s: SCIC Port 0x%p is processing a timeout operation "
988 "in state %d.\n", 995 "in state %d.\n",
989 __func__, 996 __func__,
990 this_port, 997 sci_port,
991 current_state); 998 current_state);
992 } 999 }
993} 1000}
@@ -1067,13 +1074,14 @@ enum sci_sas_link_rate scic_sds_port_get_max_allowed_speed(
1067 * 1074 *
1068 */ 1075 */
1069void scic_sds_port_broadcast_change_received( 1076void scic_sds_port_broadcast_change_received(
1070 struct scic_sds_port *this_port, 1077 struct scic_sds_port *sci_port,
1071 struct scic_sds_phy *this_phy) 1078 struct scic_sds_phy *sci_phy)
1072{ 1079{
1080 struct scic_sds_controller *scic = sci_port->owning_controller;
1081 struct isci_host *ihost = sci_object_get_association(scic);
1082
1073 /* notify the user. */ 1083 /* notify the user. */
1074 isci_event_port_bc_change_primitive_received( 1084 isci_port_bc_change_received(ihost, sci_port, sci_phy);
1075 this_port->owning_controller, this_port, this_phy
1076 );
1077} 1085}
1078 1086
1079 1087
@@ -1267,30 +1275,29 @@ static enum sci_status scic_sds_port_ready_waiting_substate_start_io_handler(
1267 * 1275 *
1268 * This method will casue the port to reset. enum sci_status SCI_SUCCESS 1276 * This method will casue the port to reset. enum sci_status SCI_SUCCESS
1269 */ 1277 */
1270static enum sci_status scic_sds_port_ready_operational_substate_reset_handler( 1278static enum
1271 struct sci_base_port *port, 1279sci_status scic_sds_port_ready_operational_substate_reset_handler(
1272 u32 timeout) 1280 struct sci_base_port *port,
1281 u32 timeout)
1273{ 1282{
1274 enum sci_status status = SCI_FAILURE_INVALID_PHY; 1283 enum sci_status status = SCI_FAILURE_INVALID_PHY;
1275 u32 phy_index; 1284 u32 phy_index;
1276 struct scic_sds_port *this_port = (struct scic_sds_port *)port; 1285 struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
1277 struct scic_sds_phy *selected_phy = NULL; 1286 struct scic_sds_phy *selected_phy = NULL;
1278 1287
1279 1288
1280 /* Select a phy on which we can send the hard reset request. */ 1289 /* Select a phy on which we can send the hard reset request. */
1281 for ( 1290 for (phy_index = 0;
1282 phy_index = 0; 1291 (phy_index < SCI_MAX_PHYS) && (selected_phy == NULL);
1283 (phy_index < SCI_MAX_PHYS) 1292 phy_index++) {
1284 && (selected_phy == NULL); 1293 selected_phy = sci_port->phy_table[phy_index];
1285 phy_index++ 1294
1286 ) { 1295 if ((selected_phy != NULL) &&
1287 selected_phy = this_port->phy_table[phy_index]; 1296 !scic_sds_port_active_phy(sci_port, selected_phy)) {
1288 1297 /*
1289 if ( 1298 * We found a phy but it is not ready select
1290 (selected_phy != NULL) 1299 * different phy
1291 && !scic_sds_port_active_phy(this_port, selected_phy) 1300 */
1292 ) {
1293 /* We found a phy but it is not ready select different phy */
1294 selected_phy = NULL; 1301 selected_phy = NULL;
1295 } 1302 }
1296 } 1303 }
@@ -1300,18 +1307,13 @@ static enum sci_status scic_sds_port_ready_operational_substate_reset_handler(
1300 status = scic_sds_phy_reset(selected_phy); 1307 status = scic_sds_phy_reset(selected_phy);
1301 1308
1302 if (status == SCI_SUCCESS) { 1309 if (status == SCI_SUCCESS) {
1303 isci_event_timer_start( 1310 isci_timer_start(sci_port->timer_handle, timeout);
1304 scic_sds_port_get_controller(this_port), 1311 sci_port->not_ready_reason =
1305 this_port->timer_handle, 1312 SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
1306 timeout
1307 );
1308
1309 this_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
1310 1313
1311 sci_base_state_machine_change_state( 1314 sci_base_state_machine_change_state(
1312 &this_port->parent.state_machine, 1315 &sci_port->parent.state_machine,
1313 SCI_BASE_PORT_STATE_RESETTING 1316 SCI_BASE_PORT_STATE_RESETTING);
1314 );
1315 } 1317 }
1316 } 1318 }
1317 1319
@@ -1686,10 +1688,11 @@ static void scic_sds_port_ready_substate_waiting_enter(
1686 1688
1687/** 1689/**
1688 * 1690 *
1689 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. 1691 * @object: This is the struct sci_base_object which is cast to a
1692 * struct scic_sds_port object.
1690 * 1693 *
1691 * This method will perform the actions required by the struct scic_sds_port on 1694 * This function will perform the actions required by the struct scic_sds_port
1692 * entering the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function sets 1695 * on entering the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function sets
1693 * the state handlers for the port object, notifies the SCI User that the port 1696 * the state handlers for the port object, notifies the SCI User that the port
1694 * is ready, and resumes port operations. none 1697 * is ready, and resumes port operations. none
1695 */ 1698 */
@@ -1697,32 +1700,34 @@ static void scic_sds_port_ready_substate_operational_enter(
1697 struct sci_base_object *object) 1700 struct sci_base_object *object)
1698{ 1701{
1699 u32 index; 1702 u32 index;
1700 struct scic_sds_port *this_port = (struct scic_sds_port *)object; 1703 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
1704 struct scic_sds_controller *scic =
1705 scic_sds_port_get_controller(sci_port);
1706 struct isci_host *ihost = sci_object_get_association(scic);
1707 struct isci_port *iport = sci_object_get_association(sci_port);
1701 1708
1702 scic_sds_port_set_ready_state_handlers( 1709 scic_sds_port_set_ready_state_handlers(
1703 this_port, SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL 1710 sci_port,
1704 ); 1711 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL);
1705 1712
1706 isci_event_port_ready( 1713 isci_port_ready(ihost, iport);
1707 scic_sds_port_get_controller(this_port), this_port
1708 );
1709 1714
1710 for (index = 0; index < SCI_MAX_PHYS; index++) { 1715 for (index = 0; index < SCI_MAX_PHYS; index++) {
1711 if (this_port->phy_table[index] != NULL) { 1716 if (sci_port->phy_table[index] != NULL)
1712 scic_sds_port_write_phy_assignment( 1717 scic_sds_port_write_phy_assignment(
1713 this_port, this_port->phy_table[index] 1718 sci_port,
1714 ); 1719 sci_port->phy_table[index]);
1715 }
1716 } 1720 }
1717 1721
1718 scic_sds_port_update_viit_entry(this_port); 1722 scic_sds_port_update_viit_entry(sci_port);
1719 1723
1720 scic_sds_port_resume_port_task_scheduler(this_port); 1724 scic_sds_port_resume_port_task_scheduler(sci_port);
1721 1725
1722 /* Post the dummy task for the port so the hardware can schedule 1726 /*
1727 * Post the dummy task for the port so the hardware can schedule
1723 * io correctly 1728 * io correctly
1724 */ 1729 */
1725 scic_sds_port_post_dummy_request(this_port); 1730 scic_sds_port_post_dummy_request(sci_port);
1726} 1731}
1727 1732
1728/** 1733/**
@@ -1736,20 +1741,20 @@ static void scic_sds_port_ready_substate_operational_enter(
1736static void scic_sds_port_ready_substate_operational_exit( 1741static void scic_sds_port_ready_substate_operational_exit(
1737 struct sci_base_object *object) 1742 struct sci_base_object *object)
1738{ 1743{
1739 struct scic_sds_port *this_port = (struct scic_sds_port *)object; 1744 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
1745 struct scic_sds_controller *scic =
1746 scic_sds_port_get_controller(sci_port);
1747 struct isci_host *ihost = sci_object_get_association(scic);
1748 struct isci_port *iport = sci_object_get_association(sci_port);
1740 1749
1741/* 1750 /*
1742 * Kill the dummy task for this port if it has not yet posted 1751 * Kill the dummy task for this port if it has not yet posted
1743 * the hardware will treat this as a NOP and just return abort 1752 * the hardware will treat this as a NOP and just return abort
1744 * complete. 1753 * complete.
1745 */ 1754 */
1746 scic_sds_port_abort_dummy_request(this_port); 1755 scic_sds_port_abort_dummy_request(sci_port);
1747 1756
1748 isci_event_port_not_ready( 1757 isci_port_not_ready(ihost, iport);
1749 scic_sds_port_get_controller(this_port),
1750 this_port,
1751 this_port->not_ready_reason
1752 );
1753} 1758}
1754 1759
1755/* 1760/*
@@ -1759,7 +1764,8 @@ static void scic_sds_port_ready_substate_operational_exit(
1759 1764
1760/** 1765/**
1761 * scic_sds_port_ready_substate_configuring_enter() - 1766 * scic_sds_port_ready_substate_configuring_enter() -
1762 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. 1767 * @object: This is the struct sci_base_object which is cast to a
1768 * struct scic_sds_port object.
1763 * 1769 *
1764 * This method will perform the actions required by the struct scic_sds_port on 1770 * This method will perform the actions required by the struct scic_sds_port on
1765 * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports 1771 * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports
@@ -1768,29 +1774,26 @@ static void scic_sds_port_ready_substate_operational_exit(
1768static void scic_sds_port_ready_substate_configuring_enter( 1774static void scic_sds_port_ready_substate_configuring_enter(
1769 struct sci_base_object *object) 1775 struct sci_base_object *object)
1770{ 1776{
1771 struct scic_sds_port *this_port = (struct scic_sds_port *)object; 1777 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
1778 struct scic_sds_controller *scic =
1779 scic_sds_port_get_controller(sci_port);
1780 struct isci_host *ihost = sci_object_get_association(scic);
1781 struct isci_port *iport = sci_object_get_association(sci_port);
1772 1782
1773 scic_sds_port_set_ready_state_handlers( 1783 scic_sds_port_set_ready_state_handlers(
1774 this_port, SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING 1784 sci_port,
1775 ); 1785 SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING);
1776 1786
1777 if (this_port->active_phy_mask == 0) { 1787 if (sci_port->active_phy_mask == 0) {
1778 isci_event_port_not_ready( 1788 isci_port_not_ready(ihost, iport);
1779 scic_sds_port_get_controller(this_port),
1780 this_port,
1781 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS
1782 );
1783 1789
1784 sci_base_state_machine_change_state( 1790 sci_base_state_machine_change_state(
1785 &this_port->ready_substate_machine, 1791 &sci_port->ready_substate_machine,
1786 SCIC_SDS_PORT_READY_SUBSTATE_WAITING 1792 SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
1787 ); 1793 } else if (sci_port->started_request_count == 0)
1788 } else if (this_port->started_request_count == 0) {
1789 sci_base_state_machine_change_state( 1794 sci_base_state_machine_change_state(
1790 &this_port->ready_substate_machine, 1795 &sci_port->ready_substate_machine,
1791 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL 1796 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL);
1792 );
1793 }
1794} 1797}
1795 1798
1796static void scic_sds_port_ready_substate_configuring_exit( 1799static void scic_sds_port_ready_substate_configuring_exit(
@@ -2165,42 +2168,52 @@ static enum sci_status scic_sds_port_general_complete_io_handler(
2165/** 2168/**
2166 * scic_sds_port_stopped_state_start_handler() - stop a port from "started" 2169 * scic_sds_port_stopped_state_start_handler() - stop a port from "started"
2167 * 2170 *
2168 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port 2171 * @port: This is the struct sci_base_port object which is cast into a
2169 * object. 2172 * struct scic_sds_port object.
2170 * 2173 *
2171 * This method takes the struct scic_sds_port from a stopped state and attempts to 2174 * This function takes the struct scic_sds_port from a stopped state and
2172 * start it. To start a port it must have no assiged devices and it must have 2175 * attempts to start it. To start a port it must have no assiged devices and
2173 * at least one phy assigned to it. If those conditions are met then the port 2176 * it must have at least one phy assigned to it. If those conditions are
2174 * can transition to the ready state. enum sci_status 2177 * met then the port can transition to the ready state.
2175 * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION This struct scic_sds_port object could 2178 * enum sci_status
2176 * not be started because the port configuration is not valid. SCI_SUCCESS the 2179 * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION
2177 * start request is successful and the struct scic_sds_port object has transitioned to 2180 * This struct scic_sds_port object could not be started because the port
2178 * the SCI_BASE_PORT_STATE_READY. 2181 * configuration is not valid.
2182 * SCI_SUCCESS
2183 * the start request is successful and the struct scic_sds_port object
2184 * has transitioned to the SCI_BASE_PORT_STATE_READY.
2179 */ 2185 */
2180static enum sci_status scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port) 2186static enum sci_status
2187scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port)
2181{ 2188{
2182 struct scic_sds_port *sci_port = container_of(base_port, typeof(*sci_port), parent); 2189 struct scic_sds_port *sci_port =
2190 container_of(base_port, typeof(*sci_port), parent);
2183 struct scic_sds_controller *scic = sci_port->owning_controller; 2191 struct scic_sds_controller *scic = sci_port->owning_controller;
2192 struct isci_host *ihost = sci_object_get_association(scic);
2184 enum sci_status status = SCI_SUCCESS; 2193 enum sci_status status = SCI_SUCCESS;
2185 u32 phy_mask; 2194 u32 phy_mask;
2186 2195
2187 if (sci_port->assigned_device_count > 0) { 2196 if (sci_port->assigned_device_count > 0) {
2188 /* 2197 /*
2189 * / @todo This is a start failure operation because there are still 2198 * @todo This is a start failure operation because
2190 * / devices assigned to this port. There must be no devices 2199 * there are still devices assigned to this port.
2191 * / assigned to a port on a start operation. */ 2200 * There must be no devices assigned to a port on a
2201 * start operation.
2202 */
2192 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 2203 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
2193 } 2204 }
2194 2205
2195 sci_port->timer_handle = isci_event_timer_create(scic, 2206 sci_port->timer_handle =
2196 scic_sds_port_timeout_handler, 2207 isci_timer_create(ihost,
2197 sci_port); 2208 sci_port,
2209 scic_sds_port_timeout_handler);
2198 2210
2199 if (!sci_port->timer_handle) 2211 if (!sci_port->timer_handle)
2200 return SCI_FAILURE_INSUFFICIENT_RESOURCES; 2212 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
2201 2213
2202 if (sci_port->reserved_rni == SCU_DUMMY_INDEX) { 2214 if (sci_port->reserved_rni == SCU_DUMMY_INDEX) {
2203 u16 rni = scic_sds_remote_node_table_allocate_remote_node(&scic->available_remote_nodes, 1); 2215 u16 rni = scic_sds_remote_node_table_allocate_remote_node(
2216 &scic->available_remote_nodes, 1);
2204 2217
2205 if (rni != SCU_DUMMY_INDEX) 2218 if (rni != SCU_DUMMY_INDEX)
2206 scic_sds_port_construct_dummy_rnc(sci_port, rni); 2219 scic_sds_port_construct_dummy_rnc(sci_port, rni);
@@ -2715,50 +2728,41 @@ static void scic_sds_port_stopped_state_exit(
2715 2728
2716/** 2729/**
2717 * 2730 *
2718 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. 2731 * @object: This is the struct sci_base_object which is cast to a
2732 * struct scic_sds_port object.
2719 * 2733 *
2720 * This method will perform the actions required by the struct scic_sds_port on 2734 * This method will perform the actions required by the struct scic_sds_port on
2721 * entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state 2735 * entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state
2722 * handlers for the struct scic_sds_port object, reports the port object as not ready 2736 * handlers for the struct scic_sds_port object, reports the port object as
2723 * and starts the ready substate machine. none 2737 * not ready and starts the ready substate machine. none
2724 */ 2738 */
2725static void scic_sds_port_ready_state_enter( 2739static void scic_sds_port_ready_state_enter(struct sci_base_object *object)
2726 struct sci_base_object *object)
2727{ 2740{
2728 struct scic_sds_port *this_port; 2741 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
2742 struct isci_port *iport = sci_object_get_association(sci_port);
2743 struct scic_sds_controller *scic =
2744 scic_sds_port_get_controller(sci_port);
2745 struct isci_host *ihost = sci_object_get_association(scic);
2729 2746
2730 this_port = (struct scic_sds_port *)object; 2747 /*
2748 * Put the ready state handlers in place though they will not be
2749 * there long
2750 */
2751 scic_sds_port_set_base_state_handlers(sci_port,
2752 SCI_BASE_PORT_STATE_READY);
2731 2753
2732 /* Put the ready state handlers in place though they will not be there long */ 2754 if (sci_port->parent.state_machine.previous_state_id ==
2733 scic_sds_port_set_base_state_handlers( 2755 SCI_BASE_PORT_STATE_RESETTING)
2734 this_port, SCI_BASE_PORT_STATE_READY 2756 isci_port_hard_reset_complete(iport, SCI_SUCCESS);
2735 ); 2757 else /* Notify the caller that the port is not yet ready */
2736 2758 isci_port_not_ready(ihost, iport);
2737 if (
2738 SCI_BASE_PORT_STATE_RESETTING
2739 == this_port->parent.state_machine.previous_state_id
2740 ) {
2741 isci_event_port_hard_reset_complete(
2742 scic_sds_port_get_controller(this_port),
2743 this_port,
2744 SCI_SUCCESS
2745 );
2746 } else {
2747 /* Notify the caller that the port is not yet ready */
2748 isci_event_port_not_ready(
2749 scic_sds_port_get_controller(this_port),
2750 this_port,
2751 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS
2752 );
2753 }
2754 2759
2755 /* Post and suspend the dummy remote node context for this port. */ 2760 /* Post and suspend the dummy remote node context for this port. */
2756 scic_sds_port_post_dummy_remote_node(this_port); 2761 scic_sds_port_post_dummy_remote_node(sci_port);
2757 2762
2758 /* Start the ready substate machine */ 2763 /* Start the ready substate machine */
2759 sci_base_state_machine_start( 2764 sci_base_state_machine_start(
2760 scic_sds_port_get_ready_substate_machine(this_port) 2765 scic_sds_port_get_ready_substate_machine(sci_port));
2761 );
2762} 2766}
2763 2767
2764/** 2768/**
@@ -2802,22 +2806,19 @@ static void scic_sds_port_resetting_state_enter(
2802 2806
2803/** 2807/**
2804 * 2808 *
2805 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. 2809 * @object: This is the struct sci_base_object which is cast to a
2810 * struct scic_sds_port object.
2806 * 2811 *
2807 * This method will perform the actions required by the struct scic_sds_port on 2812 * This function will perform the actions required by the
2813 * struct scic_sds_port on
2808 * exiting the SCI_BASE_STATE_RESETTING. This function does nothing. none 2814 * exiting the SCI_BASE_STATE_RESETTING. This function does nothing. none
2809 */ 2815 */
2810static void scic_sds_port_resetting_state_exit( 2816static inline void scic_sds_port_resetting_state_exit(
2811 struct sci_base_object *object) 2817 struct sci_base_object *object)
2812{ 2818{
2813 struct scic_sds_port *this_port; 2819 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
2814 2820
2815 this_port = (struct scic_sds_port *)object; 2821 isci_timer_stop(sci_port->timer_handle);
2816
2817 isci_event_timer_stop(
2818 scic_sds_port_get_controller(this_port),
2819 this_port->timer_handle
2820 );
2821} 2822}
2822 2823
2823/** 2824/**
@@ -2842,51 +2843,42 @@ static void scic_sds_port_stopping_state_enter(
2842 2843
2843/** 2844/**
2844 * 2845 *
2845 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. 2846 * @object: This is the struct sci_base_object which is cast to a
2847 * struct scic_sds_port object.
2846 * 2848 *
2847 * This method will perform the actions required by the struct scic_sds_port on 2849 * This function will perform the actions required by the
2850 * struct scic_sds_port on
2848 * exiting the SCI_BASE_STATE_STOPPING. This function does nothing. none 2851 * exiting the SCI_BASE_STATE_STOPPING. This function does nothing. none
2849 */ 2852 */
2850static void scic_sds_port_stopping_state_exit( 2853static inline void
2851 struct sci_base_object *object) 2854scic_sds_port_stopping_state_exit(struct sci_base_object *object)
2852{ 2855{
2853 struct scic_sds_port *this_port; 2856 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
2854
2855 this_port = (struct scic_sds_port *)object;
2856 2857
2857 isci_event_timer_stop( 2858 isci_timer_stop(sci_port->timer_handle);
2858 scic_sds_port_get_controller(this_port),
2859 this_port->timer_handle
2860 );
2861 2859
2862 scic_sds_port_destroy_dummy_resources(this_port); 2860 scic_sds_port_destroy_dummy_resources(sci_port);
2863} 2861}
2864 2862
2865/** 2863/**
2866 * 2864 *
2867 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object. 2865 * @object: This is the struct sci_base_object which is cast to a
2866 * struct scic_sds_port object.
2868 * 2867 *
2869 * This method will perform the actions required by the struct scic_sds_port on 2868 * This function will perform the actions required by the
2869 * struct scic_sds_port on
2870 * entering the SCI_BASE_PORT_STATE_STOPPING. This function sets the stopping 2870 * entering the SCI_BASE_PORT_STATE_STOPPING. This function sets the stopping
2871 * state handlers for the struct scic_sds_port object. none 2871 * state handlers for the struct scic_sds_port object. none
2872 */ 2872 */
2873static void scic_sds_port_failed_state_enter( 2873static void scic_sds_port_failed_state_enter(struct sci_base_object *object)
2874 struct sci_base_object *object)
2875{ 2874{
2876 struct scic_sds_port *this_port; 2875 struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
2877 2876 struct isci_port *iport = sci_object_get_association(sci_port);
2878 this_port = (struct scic_sds_port *)object;
2879 2877
2880 scic_sds_port_set_base_state_handlers( 2878 scic_sds_port_set_base_state_handlers(sci_port,
2881 this_port, 2879 SCI_BASE_PORT_STATE_FAILED);
2882 SCI_BASE_PORT_STATE_FAILED
2883 );
2884 2880
2885 isci_event_port_hard_reset_complete( 2881 isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT);
2886 scic_sds_port_get_controller(this_port),
2887 this_port,
2888 SCI_FAILURE_TIMEOUT
2889 );
2890} 2882}
2891 2883
2892/* --------------------------------------------------------------------------- */ 2884/* --------------------------------------------------------------------------- */
diff --git a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c
index 7c9521049ae7..d2d3f5293b2c 100644
--- a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c
+++ b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c
@@ -431,46 +431,47 @@ static void scic_sds_mpc_agent_link_up(
431 * assigned port. 431 * assigned port.
432 * @phy: This is the phy object which has gone link down. 432 * @phy: This is the phy object which has gone link down.
433 * 433 *
434 * This method handles the manual port configuration link down notifications. 434 * This function handles the manual port configuration link down notifications.
435 * Since all ports and phys are associated at initialization time we just turn 435 * Since all ports and phys are associated at initialization time we just turn
436 * around and notifiy the port object of the link down event. If this PHY is 436 * around and notifiy the port object of the link down event. If this PHY is
437 * not associated with a port there is no action taken. Is it possible to get a 437 * not associated with a port there is no action taken. Is it possible to get a
438 * link down notification from a phy that has no assocoated port? 438 * link down notification from a phy that has no assocoated port?
439 */ 439 */
440static void scic_sds_mpc_agent_link_down( 440static void scic_sds_mpc_agent_link_down(
441 struct scic_sds_controller *controller, 441 struct scic_sds_controller *scic,
442 struct scic_sds_port_configuration_agent *port_agent, 442 struct scic_sds_port_configuration_agent *port_agent,
443 struct scic_sds_port *port, 443 struct scic_sds_port *sci_port,
444 struct scic_sds_phy *phy) 444 struct scic_sds_phy *sci_phy)
445{ 445{
446 if (port != NULL) { 446 if (sci_port != NULL) {
447 /* 447 /*
448 * If we can form a new port from the remainder of the phys then we want 448 * If we can form a new port from the remainder of the phys
449 * to start the timer to allow the SCI User to cleanup old devices and 449 * then we want to start the timer to allow the SCI User to
450 * rediscover the port before rebuilding the port with the phys that 450 * cleanup old devices and rediscover the port before
451 * remain in the ready state. */ 451 * rebuilding the port with the phys that remain in the ready
452 port_agent->phy_ready_mask &= ~(1 << scic_sds_phy_get_index(phy)); 452 * state.
453 port_agent->phy_configured_mask &= ~(1 << scic_sds_phy_get_index(phy)); 453 */
454 port_agent->phy_ready_mask &=
455 ~(1 << scic_sds_phy_get_index(sci_phy));
456 port_agent->phy_configured_mask &=
457 ~(1 << scic_sds_phy_get_index(sci_phy));
454 458
455 /* 459 /*
456 * Check to see if there are more phys waiting to be configured into a port. 460 * Check to see if there are more phys waiting to be
457 * If there are allow the SCI User to tear down this port, if necessary, and 461 * configured into a port. If there are allow the SCI User
458 * then reconstruc the port after the timeout. */ 462 * to tear down this port, if necessary, and then reconstruct
459 if ( 463 * the port after the timeout.
460 (port_agent->phy_configured_mask == 0x0000) 464 */
461 && (port_agent->phy_ready_mask != 0x0000) 465 if ((port_agent->phy_configured_mask == 0x0000) &&
462 && !port_agent->timer_pending 466 (port_agent->phy_ready_mask != 0x0000) &&
463 ) { 467 !port_agent->timer_pending) {
464 port_agent->timer_pending = true; 468 port_agent->timer_pending = true;
465 469
466 isci_event_timer_start( 470 isci_timer_start(port_agent->timer,
467 controller, 471 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT);
468 port_agent->timer,
469 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT
470 );
471 } 472 }
472 473
473 scic_sds_port_link_down(port, phy); 474 scic_sds_port_link_down(sci_port, sci_phy);
474 } 475 }
475} 476}
476 477
@@ -535,19 +536,18 @@ static enum sci_status scic_sds_apc_agent_validate_phy_configuration(
535 * the next time period. This could be caused by either a link down event or a 536 * the next time period. This could be caused by either a link down event or a
536 * link up event where we can not yet tell to which port a phy belongs. 537 * link up event where we can not yet tell to which port a phy belongs.
537 */ 538 */
538static void scic_sds_apc_agent_start_timer( 539static inline void scic_sds_apc_agent_start_timer(
539 struct scic_sds_controller *controller, 540 struct scic_sds_controller *scic,
540 struct scic_sds_port_configuration_agent *port_agent, 541 struct scic_sds_port_configuration_agent *port_agent,
541 struct scic_sds_phy *phy, 542 struct scic_sds_phy *sci_phy,
542 u32 timeout) 543 u32 timeout)
543{ 544{
544 if (port_agent->timer_pending) { 545 if (port_agent->timer_pending)
545 isci_event_timer_stop(controller, port_agent->timer); 546 isci_timer_stop(port_agent->timer);
546 }
547 547
548 port_agent->timer_pending = true; 548 port_agent->timer_pending = true;
549 549
550 isci_event_timer_start(controller, port_agent->timer, timeout); 550 isci_timer_start(port_agent->timer, timeout);
551} 551}
552 552
553/** 553/**
@@ -816,45 +816,46 @@ void scic_sds_port_configuration_agent_construct(
816 * This method will construct the port configuration agent for this controller. 816 * This method will construct the port configuration agent for this controller.
817 */ 817 */
818enum sci_status scic_sds_port_configuration_agent_initialize( 818enum sci_status scic_sds_port_configuration_agent_initialize(
819 struct scic_sds_controller *controller, 819 struct scic_sds_controller *scic,
820 struct scic_sds_port_configuration_agent *port_agent) 820 struct scic_sds_port_configuration_agent *port_agent)
821{ 821{
822 enum sci_status status = SCI_SUCCESS; 822 enum sci_status status = SCI_SUCCESS;
823 enum SCIC_PORT_CONFIGURATION_MODE mode; 823 enum SCIC_PORT_CONFIGURATION_MODE mode;
824 struct isci_host *ihost = sci_object_get_association(scic);
824 825
825 mode = controller->oem_parameters.sds1.controller.mode_type; 826 mode = scic->oem_parameters.sds1.controller.mode_type;
826 827
827 if (mode == SCIC_PORT_MANUAL_CONFIGURATION_MODE) { 828 if (mode == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
828 status = scic_sds_mpc_agent_validate_phy_configuration(controller, port_agent); 829 status = scic_sds_mpc_agent_validate_phy_configuration(
830 scic, port_agent);
829 831
830 port_agent->link_up_handler = scic_sds_mpc_agent_link_up; 832 port_agent->link_up_handler = scic_sds_mpc_agent_link_up;
831 port_agent->link_down_handler = scic_sds_mpc_agent_link_down; 833 port_agent->link_down_handler = scic_sds_mpc_agent_link_down;
832 834
833 port_agent->timer = isci_event_timer_create( 835 port_agent->timer = isci_timer_create(
834 controller, 836 ihost,
835 scic_sds_mpc_agent_timeout_handler, 837 scic,
836 controller 838 scic_sds_mpc_agent_timeout_handler);
837 );
838 } else { 839 } else {
839 status = scic_sds_apc_agent_validate_phy_configuration(controller, port_agent); 840 status = scic_sds_apc_agent_validate_phy_configuration(
841 scic, port_agent);
840 842
841 port_agent->link_up_handler = scic_sds_apc_agent_link_up; 843 port_agent->link_up_handler = scic_sds_apc_agent_link_up;
842 port_agent->link_down_handler = scic_sds_apc_agent_link_down; 844 port_agent->link_down_handler = scic_sds_apc_agent_link_down;
843 845
844 port_agent->timer = isci_event_timer_create( 846 port_agent->timer = isci_timer_create(
845 controller, 847 ihost,
846 scic_sds_apc_agent_timeout_handler, 848 scic,
847 controller 849 scic_sds_apc_agent_timeout_handler);
848 );
849 } 850 }
850 851
851 /* Make sure we have actually gotten a timer */ 852 /* Make sure we have actually gotten a timer */
852 if ((status == SCI_SUCCESS) && (port_agent->timer == NULL)) { 853 if ((status == SCI_SUCCESS) && (port_agent->timer == NULL)) {
853 dev_err(scic_to_dev(controller), 854 dev_err(scic_to_dev(scic),
854 "%s: Controller 0x%p automatic port configuration " 855 "%s: Controller 0x%p automatic port configuration "
855 "agent could not get timer.\n", 856 "agent could not get timer.\n",
856 __func__, 857 __func__,
857 controller); 858 scic);
858 859
859 status = SCI_FAILURE; 860 status = SCI_FAILURE;
860 } 861 }
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.c b/drivers/scsi/isci/core/scic_sds_remote_device.c
index 0ac6ca0f3291..f722678eed8e 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_remote_device.c
@@ -1795,7 +1795,7 @@ static void scic_sds_remote_device_initial_state_enter(
1795 * @object: This is the struct sci_base_object that is cast into a 1795 * @object: This is the struct sci_base_object that is cast into a
1796 * struct scic_sds_remote_device. 1796 * struct scic_sds_remote_device.
1797 * 1797 *
1798 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it 1798 * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it
1799 * sets the stopped state handlers and if this state is entered from the 1799 * sets the stopped state handlers and if this state is entered from the
1800 * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING then the SCI User is informed that the 1800 * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING then the SCI User is informed that the
1801 * device stop is complete. none 1801 * device stop is complete. none
@@ -1803,30 +1803,29 @@ static void scic_sds_remote_device_initial_state_enter(
1803static void scic_sds_remote_device_stopped_state_enter( 1803static void scic_sds_remote_device_stopped_state_enter(
1804 struct sci_base_object *object) 1804 struct sci_base_object *object)
1805{ 1805{
1806 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 1806 struct scic_sds_remote_device *sci_dev =
1807 (struct scic_sds_remote_device *)object;
1808 struct scic_sds_controller *scic =
1809 scic_sds_remote_device_get_controller(sci_dev);
1810 struct isci_host *ihost = sci_object_get_association(scic);
1811 struct isci_remote_device *idev =
1812 sci_object_get_association(sci_dev);
1807 1813
1808 SET_STATE_HANDLER( 1814 SET_STATE_HANDLER(sci_dev,
1809 this_device, 1815 scic_sds_remote_device_state_handler_table,
1810 scic_sds_remote_device_state_handler_table, 1816 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
1811 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
1812 );
1813 1817
1814 /* 1818 /*
1815 * 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
1816 * the stop operation has completed. */ 1820 * the stop operation has completed.
1817 if (this_device->parent.state_machine.previous_state_id 1821 */
1818 == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) { 1822 if (sci_dev->parent.state_machine.previous_state_id ==
1819 isci_event_remote_device_stop_complete( 1823 SCI_BASE_REMOTE_DEVICE_STATE_STOPPING)
1820 scic_sds_remote_device_get_controller(this_device), 1824 isci_remote_device_stop_complete(ihost, idev, SCI_SUCCESS);
1821 this_device,
1822 SCI_SUCCESS
1823 );
1824 }
1825 1825
1826 scic_sds_controller_remote_device_stopped( 1826 scic_sds_controller_remote_device_stopped(
1827 scic_sds_remote_device_get_controller(this_device), 1827 scic_sds_remote_device_get_controller(sci_dev),
1828 this_device 1828 sci_dev);
1829 );
1830} 1829}
1831 1830
1832/** 1831/**
@@ -1834,29 +1833,28 @@ static void scic_sds_remote_device_stopped_state_enter(
1834 * @object: This is the struct sci_base_object that is cast into a 1833 * @object: This is the struct sci_base_object that is cast into a
1835 * struct scic_sds_remote_device. 1834 * struct scic_sds_remote_device.
1836 * 1835 *
1837 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it 1836 * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it
1838 * sets the starting state handlers, sets the device not ready, and posts the 1837 * sets the starting state handlers, sets the device not ready, and posts the
1839 * remote node context to the hardware. none 1838 * remote node context to the hardware. none
1840 */ 1839 */
1841static void scic_sds_remote_device_starting_state_enter( 1840static void scic_sds_remote_device_starting_state_enter(
1842 struct sci_base_object *object) 1841 struct sci_base_object *object)
1843{ 1842{
1844 struct scic_sds_controller *the_controller; 1843 struct scic_sds_controller *scic;
1845 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 1844 struct scic_sds_remote_device *sci_dev =
1845 (struct scic_sds_remote_device *)object;
1846 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
1846 1847
1847 the_controller = scic_sds_remote_device_get_controller(this_device); 1848 scic = scic_sds_remote_device_get_controller(sci_dev);
1848 1849
1849 SET_STATE_HANDLER( 1850 SET_STATE_HANDLER(
1850 this_device, 1851 sci_dev,
1851 scic_sds_remote_device_state_handler_table, 1852 scic_sds_remote_device_state_handler_table,
1852 SCI_BASE_REMOTE_DEVICE_STATE_STARTING 1853 SCI_BASE_REMOTE_DEVICE_STATE_STARTING);
1853 );
1854 1854
1855 isci_event_remote_device_not_ready( 1855 isci_remote_device_not_ready(
1856 the_controller, 1856 idev,
1857 this_device, 1857 SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED);
1858 SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED
1859 );
1860} 1858}
1861 1859
1862/** 1860/**
@@ -1864,27 +1862,29 @@ static void scic_sds_remote_device_starting_state_enter(
1864 * @object: This is the struct sci_base_object that is cast into a 1862 * @object: This is the struct sci_base_object that is cast into a
1865 * struct scic_sds_remote_device. 1863 * struct scic_sds_remote_device.
1866 * 1864 *
1867 * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it 1865 * This is the exit function for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it
1868 * reports that the device start is complete. none 1866 * reports that the device start is complete. none
1869 */ 1867 */
1870static void scic_sds_remote_device_starting_state_exit( 1868static void scic_sds_remote_device_starting_state_exit(
1871 struct sci_base_object *object) 1869 struct sci_base_object *object)
1872{ 1870{
1873 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 1871 struct scic_sds_remote_device *sci_dev =
1872 (struct scic_sds_remote_device *)object;
1873 struct scic_sds_controller *scic =
1874 scic_sds_remote_device_get_controller(sci_dev);
1875 struct isci_host *ihost = sci_object_get_association(scic);
1876 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
1877
1874 1878
1875 /* 1879 /*
1876 * / @todo Check the device object for the proper return code for this 1880 * @todo Check the device object for the proper return code for this
1877 * / callback */ 1881 * callback
1878 isci_event_remote_device_start_complete( 1882 */
1879 scic_sds_remote_device_get_controller(this_device), 1883 isci_remote_device_start_complete(ihost, idev, SCI_SUCCESS);
1880 this_device,
1881 SCI_SUCCESS
1882 );
1883 1884
1884 scic_sds_controller_remote_device_started( 1885 scic_sds_controller_remote_device_started(
1885 scic_sds_remote_device_get_controller(this_device), 1886 scic_sds_remote_device_get_controller(sci_dev),
1886 this_device 1887 sci_dev);
1887 );
1888} 1888}
1889 1889
1890/** 1890/**
@@ -1892,30 +1892,28 @@ static void scic_sds_remote_device_starting_state_exit(
1892 * @object: This is the struct sci_base_object that is cast into a 1892 * @object: This is the struct sci_base_object that is cast into a
1893 * struct scic_sds_remote_device. 1893 * struct scic_sds_remote_device.
1894 * 1894 *
1895 * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets 1895 * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets
1896 * the ready state handlers, and starts the ready substate machine. none 1896 * the ready state handlers, and starts the ready substate machine. none
1897 */ 1897 */
1898static void scic_sds_remote_device_ready_state_enter( 1898static void scic_sds_remote_device_ready_state_enter(
1899 struct sci_base_object *object) 1899 struct sci_base_object *object)
1900{ 1900{
1901 struct scic_sds_controller *the_controller; 1901 struct scic_sds_remote_device *sci_dev =
1902 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 1902 (struct scic_sds_remote_device *)object;
1903 1903 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
1904 the_controller = scic_sds_remote_device_get_controller(this_device); 1904 struct scic_sds_controller *scic
1905 = scic_sds_remote_device_get_controller(sci_dev);
1905 1906
1906 SET_STATE_HANDLER( 1907 SET_STATE_HANDLER(sci_dev,
1907 this_device, 1908 scic_sds_remote_device_state_handler_table,
1908 scic_sds_remote_device_state_handler_table, 1909 SCI_BASE_REMOTE_DEVICE_STATE_READY);
1909 SCI_BASE_REMOTE_DEVICE_STATE_READY
1910 );
1911 1910
1912 the_controller->remote_device_sequence[this_device->rnc->remote_node_index]++; 1911 scic->remote_device_sequence[sci_dev->rnc->remote_node_index]++;
1913 1912
1914 if (this_device->has_ready_substate_machine) { 1913 if (sci_dev->has_ready_substate_machine)
1915 sci_base_state_machine_start(&this_device->ready_substate_machine); 1914 sci_base_state_machine_start(&sci_dev->ready_substate_machine);
1916 } else { 1915 else
1917 isci_event_remote_device_ready(the_controller, this_device); 1916 isci_remote_device_ready(idev);
1918 }
1919} 1917}
1920 1918
1921/** 1919/**
@@ -1923,26 +1921,22 @@ static void scic_sds_remote_device_ready_state_enter(
1923 * @object: This is the struct sci_base_object that is cast into a 1921 * @object: This is the struct sci_base_object that is cast into a
1924 * struct scic_sds_remote_device. 1922 * struct scic_sds_remote_device.
1925 * 1923 *
1926 * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_READY it does 1924 * This is the exit function for the SCI_BASE_REMOTE_DEVICE_STATE_READY it does
1927 * nothing. none 1925 * nothing. none
1928 */ 1926 */
1929static void scic_sds_remote_device_ready_state_exit( 1927static void scic_sds_remote_device_ready_state_exit(
1930 struct sci_base_object *object) 1928 struct sci_base_object *object)
1931{ 1929{
1932 struct scic_sds_controller *the_controller; 1930 struct scic_sds_remote_device *sci_dev =
1933 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 1931 (struct scic_sds_remote_device *)object;
1932 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
1934 1933
1935 the_controller = scic_sds_remote_device_get_controller(this_device); 1934 if (sci_dev->has_ready_substate_machine)
1936 1935 sci_base_state_machine_stop(&sci_dev->ready_substate_machine);
1937 if (this_device->has_ready_substate_machine) { 1936 else
1938 sci_base_state_machine_stop(&this_device->ready_substate_machine); 1937 isci_remote_device_not_ready(
1939 } else { 1938 idev,
1940 isci_event_remote_device_not_ready( 1939 SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED);
1941 the_controller,
1942 this_device,
1943 SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED
1944 );
1945 }
1946} 1940}
1947 1941
1948/** 1942/**
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c
index 00bebb9c0692..4542f4e75f7f 100644
--- a/drivers/scsi/isci/core/scic_sds_request.c
+++ b/drivers/scsi/isci/core/scic_sds_request.c
@@ -2077,30 +2077,24 @@ static void scic_sds_request_started_state_exit(
2077static void scic_sds_request_completed_state_enter( 2077static void scic_sds_request_completed_state_enter(
2078 struct sci_base_object *object) 2078 struct sci_base_object *object)
2079{ 2079{
2080 struct scic_sds_request *this_request = (struct scic_sds_request *)object; 2080 struct scic_sds_request *sci_req = (struct scic_sds_request *)object;
2081 struct scic_sds_controller *scic =
2082 scic_sds_request_get_controller(sci_req);
2083 struct isci_host *ihost = sci_object_get_association(scic);
2084 struct isci_request *ireq = sci_object_get_association(sci_req);
2081 2085
2082 SET_STATE_HANDLER( 2086
2083 this_request, 2087 SET_STATE_HANDLER(sci_req,
2084 scic_sds_request_state_handler_table, 2088 scic_sds_request_state_handler_table,
2085 SCI_BASE_REQUEST_STATE_COMPLETED 2089 SCI_BASE_REQUEST_STATE_COMPLETED);
2086 );
2087 2090
2088 /* Tell the SCI_USER that the IO request is complete */ 2091 /* Tell the SCI_USER that the IO request is complete */
2089 if (this_request->is_task_management_request == false) { 2092 if (sci_req->is_task_management_request == false)
2090 isci_event_io_request_complete( 2093 isci_request_io_request_complete(ihost,
2091 scic_sds_request_get_controller(this_request), 2094 ireq,
2092 scic_sds_request_get_device(this_request), 2095 sci_req->sci_status);
2093 this_request, 2096 else
2094 this_request->sci_status 2097 isci_task_request_complete(ihost, ireq, sci_req->sci_status);
2095 );
2096 } else {
2097 isci_event_task_request_complete(
2098 scic_sds_request_get_controller(this_request),
2099 scic_sds_request_get_device(this_request),
2100 this_request,
2101 this_request->sci_status
2102 );
2103 }
2104} 2098}
2105 2099
2106/** 2100/**
diff --git a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c b/drivers/scsi/isci/core/scic_sds_smp_remote_device.c
index 93e6ab83b01d..fb832ef544e5 100644
--- a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_smp_remote_device.c
@@ -250,22 +250,23 @@ const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_device_rea
250 * struct scic_sds_remote_device. 250 * struct scic_sds_remote_device.
251 * 251 *
252 * This is the SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE enter method. 252 * This is the SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE enter method.
253 * This method sets the ready cmd substate handlers and reports the device as 253 * This function sets the ready cmd substate handlers and reports the device as
254 * ready. none 254 * ready. none
255 */ 255 */
256static void scic_sds_smp_remote_device_ready_idle_substate_enter( 256static inline void scic_sds_smp_remote_device_ready_idle_substate_enter(
257 struct sci_base_object *object) 257 struct sci_base_object *object)
258{ 258{
259 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 259 struct scic_sds_remote_device *sci_dev =
260 (struct scic_sds_remote_device *)object;
261 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
262
260 263
261 SET_STATE_HANDLER( 264 SET_STATE_HANDLER(
262 this_device, 265 sci_dev,
263 scic_sds_smp_remote_device_ready_substate_handler_table, 266 scic_sds_smp_remote_device_ready_substate_handler_table,
264 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE 267 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
265 );
266 268
267 isci_event_remote_device_ready( 269 isci_remote_device_ready(idev);
268 scic_sds_remote_device_get_controller(this_device), this_device);
269} 270}
270 271
271/** 272/**
@@ -274,27 +275,26 @@ static void scic_sds_smp_remote_device_ready_idle_substate_enter(
274 * struct scic_sds_remote_device. 275 * struct scic_sds_remote_device.
275 * 276 *
276 * This is the SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD enter method. This 277 * This is the SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD enter method. This
277 * method sets the remote device objects ready cmd substate handlers, and 278 * function sets the remote device objects ready cmd substate handlers, and
278 * notify core user that the device is not ready. none 279 * notify core user that the device is not ready. none
279 */ 280 */
280static void scic_sds_smp_remote_device_ready_cmd_substate_enter( 281static void scic_sds_smp_remote_device_ready_cmd_substate_enter(
281 struct sci_base_object *object) 282 struct sci_base_object *object)
282{ 283{
283 struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; 284 struct scic_sds_remote_device *sci_dev =
285 (struct scic_sds_remote_device *)object;
286 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
284 287
285 BUG_ON(this_device->working_request == NULL); 288 BUG_ON(sci_dev->working_request == NULL);
286 289
287 SET_STATE_HANDLER( 290 SET_STATE_HANDLER(
288 this_device, 291 sci_dev,
289 scic_sds_smp_remote_device_ready_substate_handler_table, 292 scic_sds_smp_remote_device_ready_substate_handler_table,
290 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD 293 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD);
291 );
292 294
293 isci_event_remote_device_not_ready( 295 isci_remote_device_not_ready(
294 scic_sds_remote_device_get_controller(this_device), 296 idev,
295 this_device, 297 SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED);
296 SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED
297 );
298} 298}
299 299
300/** 300/**
diff --git a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c b/drivers/scsi/isci/core/scic_sds_stp_remote_device.c
index 9a615f07cefe..cb396d127773 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_remote_device.c
@@ -677,23 +677,22 @@ const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_device_rea
677 * * STP REMOTE DEVICE READY SUBSTATE PRIVATE METHODS 677 * * STP REMOTE DEVICE READY SUBSTATE PRIVATE METHODS
678 * ***************************************************************************** */ 678 * ***************************************************************************** */
679 679
680static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler( 680static inline void
681 void *user_cookie) 681scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(
682 void *user_cookie)
682{ 683{
683 struct scic_sds_remote_device *this_device; 684 struct scic_sds_remote_device *sci_dev =
684 685 (struct scic_sds_remote_device *)user_cookie;
685 this_device = (struct scic_sds_remote_device *)user_cookie; 686 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
686 687
687 /* 688 /*
688 * For NCQ operation we do not issue a 689 * For NCQ operation we do not issue a
689 * scic_cb_remote_device_not_ready(). As a result, avoid sending 690 * scic_cb_remote_device_not_ready(). As a result, avoid sending
690 * the ready notification. */ 691 * the ready notification.
691 if (this_device->ready_substate_machine.previous_state_id 692 */
692 != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ) { 693 if (sci_dev->ready_substate_machine.previous_state_id !=
693 isci_event_remote_device_ready( 694 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ)
694 scic_sds_remote_device_get_controller(this_device), this_device 695 isci_remote_device_ready(idev);
695 );
696 }
697} 696}
698 697
699/* 698/*
@@ -749,26 +748,23 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(
749 * struct scic_sds_remote_device object. 748 * struct scic_sds_remote_device object.
750 * 749 *
751 */ 750 */
752static void scic_sds_stp_remote_device_ready_cmd_substate_enter( 751static inline void scic_sds_stp_remote_device_ready_cmd_substate_enter(
753 struct sci_base_object *device) 752 struct sci_base_object *device)
754{ 753{
755 struct scic_sds_remote_device *this_device; 754 struct scic_sds_remote_device *sci_dev =
755 (struct scic_sds_remote_device *)device;
756 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
756 757
757 this_device = (struct scic_sds_remote_device *)device; 758 BUG_ON(sci_dev->working_request == NULL);
758
759 BUG_ON(this_device->working_request == NULL);
760 759
761 SET_STATE_HANDLER( 760 SET_STATE_HANDLER(
762 this_device, 761 sci_dev,
763 scic_sds_stp_remote_device_ready_substate_handler_table, 762 scic_sds_stp_remote_device_ready_substate_handler_table,
764 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD 763 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD);
765 );
766 764
767 isci_event_remote_device_not_ready( 765 isci_remote_device_not_ready(
768 scic_sds_remote_device_get_controller(this_device), 766 idev,
769 this_device, 767 SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED);
770 SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED
771 );
772} 768}
773 769
774/* 770/*
@@ -807,27 +803,21 @@ static void scic_sds_stp_remote_device_ready_ncq_substate_enter(
807 * struct scic_sds_remote_device object. 803 * struct scic_sds_remote_device object.
808 * 804 *
809 */ 805 */
810static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter( 806static inline void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(
811 struct sci_base_object *device) 807 struct sci_base_object *device)
812{ 808{
813 struct scic_sds_remote_device *this_device; 809 struct scic_sds_remote_device *sci_dev =
814 810 (struct scic_sds_remote_device *)device;
815 this_device = (struct scic_sds_remote_device *)device; 811 struct isci_remote_device *idev = sci_object_get_association(sci_dev);
816 812
817 SET_STATE_HANDLER( 813 SET_STATE_HANDLER(
818 this_device, 814 sci_dev,
819 scic_sds_stp_remote_device_ready_substate_handler_table, 815 scic_sds_stp_remote_device_ready_substate_handler_table,
820 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR 816 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR);
821 );
822 817
823 if (this_device->not_ready_reason == 818 if (sci_dev->not_ready_reason ==
824 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED) { 819 SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED)
825 isci_event_remote_device_not_ready( 820 isci_remote_device_not_ready(idev, sci_dev->not_ready_reason);
826 scic_sds_remote_device_get_controller(this_device),
827 this_device,
828 this_device->not_ready_reason
829 );
830 }
831} 821}
832 822
833/* 823/*
diff --git a/drivers/scsi/isci/events.c b/drivers/scsi/isci/events.c
deleted file mode 100644
index 9d58e458a37b..000000000000
--- a/drivers/scsi/isci/events.c
+++ /dev/null
@@ -1,609 +0,0 @@
1/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56
57/**
58 * This file contains isci module object implementation.
59 *
60 *
61 */
62
63#include "isci.h"
64#include "request.h"
65#include "sata.h"
66#include "task.h"
67#include "events.h"
68
69/**
70 * isci_event_timer_create() - This callback method asks the user to create a
71 * timer and provide a handle for this timer for use in further timer
72 * interactions. The appropriate isci timer object function is called to
73 * create a timer object.
74 * @timer_callback: This parameter specifies the callback method to be invoked
75 * whenever the timer expires.
76 * @controller: This parameter specifies the controller with which this timer
77 * is to be associated.
78 * @cb_param: opaque callback parameter
79 *
80 * This method returns a handle to a timer object created by the user. The
81 * handle will be utilized for all further interactions relating to this timer.
82 */
83void *isci_event_timer_create(struct scic_sds_controller *scic,
84 void (*timer_callback)(void *),
85 void *cb_param)
86{
87 struct isci_host *ihost = sci_object_get_association(scic);
88 struct isci_timer *itimer;
89
90 itimer = isci_timer_create(ihost, cb_param, timer_callback);
91
92 dev_dbg(&ihost->pdev->dev, "%s: timer = %p\n", __func__, itimer);
93
94 return itimer;
95}
96
97
98/**
99 * isci_event_timer_start() - This callback method asks the user to start the
100 * supplied timer. The appropriate isci timer object function is called to
101 * start the timer.
102 * @controller: This parameter specifies the controller with which this timer
103 * is to associated.
104 * @timer: This parameter specifies the timer to be started.
105 * @milliseconds: This parameter specifies the number of milliseconds for which
106 * to stall. The operating system driver is allowed to round this value up
107 * where necessary.
108 *
109 */
110void isci_event_timer_start(
111 struct scic_sds_controller *controller,
112 void *timer,
113 u32 milliseconds)
114{
115 struct isci_host *isci_host;
116
117 isci_host =
118 (struct isci_host *)sci_object_get_association(controller);
119
120 dev_dbg(&isci_host->pdev->dev,
121 "%s: isci_host = %p, timer = %p, milliseconds = %d\n",
122 __func__, isci_host, timer, milliseconds);
123
124 isci_timer_start((struct isci_timer *)timer, milliseconds);
125
126}
127
128/**
129 * isci_event_timer_stop() - This callback method asks the user to stop the
130 * supplied timer. The appropriate isci timer object function is called to
131 * stop the timer.
132 * @controller: This parameter specifies the controller with which this timer
133 * is to associated.
134 * @timer: This parameter specifies the timer to be stopped.
135 *
136 */
137void isci_event_timer_stop(struct scic_sds_controller *controller, void *timer)
138{
139 struct isci_host *isci_host = sci_object_get_association(controller);
140
141 dev_dbg(&isci_host->pdev->dev,
142 "%s: isci_host = %p, timer = %p\n",
143 __func__, isci_host, timer);
144
145 isci_timer_stop((struct isci_timer *)timer);
146}
147
148void isci_event_timer_destroy(struct scic_sds_controller *scic, void *timer)
149{
150 struct isci_host *ihost = sci_object_get_association(scic);
151
152 dev_dbg(&ihost->pdev->dev, "%s: ihost = %p, timer = %p\n",
153 __func__, ihost, timer);
154
155 isci_del_timer(ihost, timer);
156}
157
158/**
159 * isci_event_controller_start_complete() - This user callback will inform the
160 * user that the controller has finished the start process. The associated
161 * isci host adapter's start_complete function is called.
162 * @controller: This parameter specifies the controller that was started.
163 * @completion_status: This parameter specifies the results of the start
164 * operation. SCI_SUCCESS indicates successful completion.
165 *
166 */
167void isci_event_controller_start_complete(
168 struct scic_sds_controller *controller,
169 enum sci_status completion_status)
170{
171 struct isci_host *isci_host =
172 (struct isci_host *)sci_object_get_association(controller);
173
174 dev_dbg(&isci_host->pdev->dev,
175 "%s: isci_host = %p\n", __func__, isci_host);
176
177 isci_host_start_complete(isci_host, completion_status);
178}
179
180/**
181 * isci_event_controller_stop_complete() - This user callback will inform the user
182 * that the controller has finished the stop process. The associated isci
183 * host adapter's start_complete function is called.
184 * @controller: This parameter specifies the controller that was stopped.
185 * @completion_status: This parameter specifies the results of the stop
186 * operation. SCI_SUCCESS indicates successful completion.
187 *
188 */
189void isci_event_controller_stop_complete(
190 struct scic_sds_controller *controller,
191 enum sci_status completion_status)
192{
193 struct isci_host *isci_host =
194 (struct isci_host *)sci_object_get_association(controller);
195
196 dev_dbg(&isci_host->pdev->dev,
197 "%s: status = 0x%x\n", __func__, completion_status);
198 isci_host_stop_complete(isci_host, completion_status);
199}
200
201/**
202 * isci_event_io_request_complete() - This user callback will inform the user that
203 * an IO request has completed.
204 * @controller: This parameter specifies the controller on which the IO is
205 * completing.
206 * @remote_device: This parameter specifies the remote device on which this IO
207 * request is completing.
208 * @io_request: This parameter specifies the IO request that has completed.
209 * @completion_status: This parameter specifies the results of the IO request
210 * operation. SCI_SUCCESS indicates successful completion.
211 *
212 */
213void isci_event_io_request_complete(
214 struct scic_sds_controller *controller,
215 struct scic_sds_remote_device *remote_device,
216 struct scic_sds_request *scic_io_request,
217 enum sci_io_status completion_status)
218{
219 struct isci_request *request;
220 struct isci_host *isci_host;
221
222 isci_host =
223 (struct isci_host *)sci_object_get_association(controller);
224
225 request =
226 (struct isci_request *)sci_object_get_association(
227 scic_io_request
228 );
229
230 isci_request_io_request_complete(isci_host,
231 request,
232 completion_status);
233}
234
235/**
236 * isci_event_task_request_complete() - This user callback will inform the user
237 * that a task management request completed.
238 * @controller: This parameter specifies the controller on which the task
239 * management request is completing.
240 * @remote_device: This parameter specifies the remote device on which this
241 * task management request is completing.
242 * @task_request: This parameter specifies the task management request that has
243 * completed.
244 * @completion_status: This parameter specifies the results of the IO request
245 * operation. SCI_SUCCESS indicates successful completion.
246 *
247 */
248void isci_event_task_request_complete(
249 struct scic_sds_controller *controller,
250 struct scic_sds_remote_device *remote_device,
251 struct scic_sds_request *scic_task_request,
252 enum sci_task_status completion_status)
253{
254 struct isci_request *request;
255 struct isci_host *isci_host;
256
257 isci_host =
258 (struct isci_host *)sci_object_get_association(controller);
259
260 request =
261 (struct isci_request *)sci_object_get_association(
262 scic_task_request);
263
264 isci_task_request_complete(isci_host, request, completion_status);
265}
266
267/**
268 * isci_event_port_stop_complete() - This method informs the user when a stop
269 * operation on the port has completed.
270 * @controller: This parameter represents the controller which contains the
271 * port.
272 * @port: This parameter specifies the SCI port object for which the callback
273 * is being invoked.
274 * @completion_status: This parameter specifies the status for the operation
275 * being completed.
276 *
277 */
278void isci_event_port_stop_complete(
279 struct scic_sds_controller *controller,
280 struct scic_sds_port *port,
281 enum sci_status completion_status)
282{
283 struct isci_host *isci_host;
284
285 isci_host = (struct isci_host *)sci_object_get_association(controller);
286
287 dev_notice(&isci_host->pdev->dev, "Port stop complete\n");
288}
289
290/**
291 * isci_event_port_hard_reset_complete() - This method informs the user when a
292 * hard reset on the port has completed. This hard reset could have been
293 * initiated by the user or by the remote port.
294 * @controller: This parameter represents the controller which contains the
295 * port.
296 * @port: This parameter specifies the SCI port object for which the callback
297 * is being invoked.
298 * @completion_status: This parameter specifies the status for the operation
299 * being completed.
300 *
301 */
302void isci_event_port_hard_reset_complete(
303 struct scic_sds_controller *controller,
304 struct scic_sds_port *port,
305 enum sci_status completion_status)
306{
307 struct isci_port *isci_port
308 = (struct isci_port *)sci_object_get_association(port);
309
310 isci_port_hard_reset_complete(isci_port, completion_status);
311}
312
313/**
314 * isci_event_port_ready() - This method informs the user that the port is now in
315 * a ready state and can be utilized to issue IOs.
316 * @controller: This parameter represents the controller which contains the
317 * port.
318 * @port: This parameter specifies the SCI port object for which the callback
319 * is being invoked.
320 *
321 */
322void isci_event_port_ready(
323 struct scic_sds_controller *controller,
324 struct scic_sds_port *port)
325{
326 struct isci_port *isci_port;
327 struct isci_host *isci_host;
328
329 isci_host =
330 (struct isci_host *)sci_object_get_association(controller);
331
332 isci_port =
333 (struct isci_port *)sci_object_get_association(port);
334
335 dev_dbg(&isci_host->pdev->dev,
336 "%s: isci_port = %p\n", __func__, isci_port);
337
338 isci_port_ready(isci_host, isci_port);
339}
340
341/**
342 * isci_event_port_not_ready() - This method informs the user that the port is now
343 * not in a ready (i.e. busy) state and can't be utilized to issue IOs.
344 * @controller: This parameter represents the controller which contains the
345 * port.
346 * @port: This parameter specifies the SCI port object for which the callback
347 * is being invoked.
348 *
349 */
350void isci_event_port_not_ready(
351 struct scic_sds_controller *controller,
352 struct scic_sds_port *port,
353 u32 reason_code)
354{
355 struct isci_port *isci_port;
356 struct isci_host *isci_host;
357
358 isci_host =
359 (struct isci_host *)sci_object_get_association(controller);
360
361 isci_port =
362 (struct isci_port *)sci_object_get_association(port);
363
364 dev_dbg(&isci_host->pdev->dev,
365 "%s: isci_port = %p\n", __func__, isci_port);
366
367 isci_port_not_ready(isci_host, isci_port);
368}
369
370/**
371 * isci_event_port_invalid_link_up() - This method informs the SCI Core user that
372 * a phy/link became ready, but the phy is not allowed in the port. In some
373 * situations the underlying hardware only allows for certain phy to port
374 * mappings. If these mappings are violated, then this API is invoked.
375 * @controller: This parameter represents the controller which contains the
376 * port.
377 * @port: This parameter specifies the SCI port object for which the callback
378 * is being invoked.
379 * @phy: This parameter specifies the phy that came ready, but the phy can't be
380 * a valid member of the port.
381 *
382 */
383void isci_event_port_invalid_link_up(
384 struct scic_sds_controller *controller,
385 struct scic_sds_port *port,
386 struct scic_sds_phy *phy)
387{
388 struct isci_host *isci_host;
389
390 isci_host = (struct isci_host *)sci_object_get_association(controller);
391 dev_warn(&isci_host->pdev->dev, "Invalid link up!\n");
392}
393
394/**
395 * isci_event_port_bc_change_primitive_received() - This callback method informs
396 * the user that a broadcast change primitive was received.
397 * @controller: This parameter represents the controller which contains the
398 * port.
399 * @port: This parameter specifies the SCI port object for which the callback
400 * is being invoked. For instances where the phy on which the primitive was
401 * received is not part of a port, this parameter will be NULL.
402 * @phy: This parameter specifies the phy on which the primitive was received.
403 *
404 */
405void isci_event_port_bc_change_primitive_received(
406 struct scic_sds_controller *controller,
407 struct scic_sds_port *port,
408 struct scic_sds_phy *phy)
409{
410 struct isci_host *isci_host;
411
412 isci_host =
413 (struct isci_host *)sci_object_get_association(controller);
414
415 dev_dbg(&isci_host->pdev->dev,
416 "%s: port = %p, phy = %p\n", __func__, port, phy);
417 isci_port_bc_change_received(isci_host, port, phy);
418}
419
420
421
422
423/**
424 * isci_event_port_link_up() - This callback method informs the user that a phy
425 * has become operational and is capable of communicating with the remote
426 * end point.
427 * @controller: This parameter represents the controller associated with the
428 * phy.
429 * @port: This parameter specifies the port object for which the user callback
430 * is being invoked. There may be conditions where this parameter can be
431 * NULL
432 * @phy: This parameter specifies the phy object for which the user callback is
433 * being invoked.
434 *
435 * none.
436 */
437void isci_event_port_link_up(
438 struct scic_sds_controller *controller,
439 struct scic_sds_port *port,
440 struct scic_sds_phy *phy)
441{
442 struct isci_host *isci_host;
443
444 isci_host =
445 (struct isci_host *)sci_object_get_association(controller);
446
447 dev_dbg(&isci_host->pdev->dev,
448 "%s: phy = %p\n", __func__, phy);
449
450 isci_port_link_up(isci_host, port, phy);
451}
452
453/**
454 * isci_event_port_link_down() - This callback method informs the user that a phy
455 * is no longer operational and is not capable of communicating with the
456 * remote end point.
457 * @controller: This parameter represents the controller associated with the
458 * phy.
459 * @port: This parameter specifies the port object for which the user callback
460 * is being invoked. There may be conditions where this parameter can be
461 * NULL
462 * @phy: This parameter specifies the phy object for which the user callback is
463 * being invoked.
464 *
465 * none.
466 */
467void isci_event_port_link_down(
468 struct scic_sds_controller *controller,
469 struct scic_sds_port *port,
470 struct scic_sds_phy *phy)
471{
472 struct isci_host *isci_host;
473 struct isci_phy *isci_phy;
474 struct isci_port *isci_port;
475
476 isci_host =
477 (struct isci_host *)sci_object_get_association(controller);
478
479 isci_phy =
480 (struct isci_phy *)sci_object_get_association(phy);
481
482 isci_port =
483 (struct isci_port *)sci_object_get_association(port);
484
485 dev_dbg(&isci_host->pdev->dev,
486 "%s: isci_port = %p\n", __func__, isci_port);
487
488 isci_port_link_down(isci_host, isci_phy, isci_port);
489}
490
491/**
492 * isci_event_remote_device_start_complete() - This user callback method will
493 * inform the user that a start operation has completed.
494 * @controller: This parameter specifies the core controller associated with
495 * the completion callback.
496 * @remote_device: This parameter specifies the remote device associated with
497 * the completion callback.
498 * @completion_status: This parameter specifies the completion status for the
499 * operation.
500 *
501 */
502void isci_event_remote_device_start_complete(
503 struct scic_sds_controller *controller,
504 struct scic_sds_remote_device *remote_device,
505 enum sci_status completion_status)
506{
507 struct isci_host *isci_host;
508 struct isci_remote_device *isci_device;
509
510 isci_host =
511 (struct isci_host *)sci_object_get_association(controller);
512
513 isci_device =
514 (struct isci_remote_device *)sci_object_get_association(
515 remote_device
516 );
517
518 dev_dbg(&isci_host->pdev->dev,
519 "%s: isci_device = %p\n", __func__, isci_device);
520
521 isci_remote_device_start_complete(
522 isci_host, isci_device, completion_status);
523
524}
525
526/**
527 * isci_event_remote_device_stop_complete() - This user callback method will
528 * inform the user that a stop operation has completed.
529 * @scic: This parameter specifies the core controller associated with
530 * the completion callback.
531 * @remote_device: This parameter specifies the remote device associated with
532 * the completion callback.
533 * @completion_status: This parameter specifies the completion status for the
534 * operation.
535 *
536 */
537void isci_event_remote_device_stop_complete(struct scic_sds_controller *scic,
538 struct scic_sds_remote_device *sci_dev,
539 enum sci_status completion_status)
540{
541 struct isci_host *ihost;
542 struct isci_remote_device *idev;
543
544 ihost = sci_object_get_association(scic);
545 idev = sci_object_get_association(sci_dev);
546
547 dev_dbg(&ihost->pdev->dev,
548 "%s: idev = %p\n", __func__, idev);
549
550 isci_remote_device_stop_complete(ihost, idev, completion_status);
551}
552
553/**
554 * isci_event_remote_device_ready() - This user callback method will inform the
555 * user that a remote device is now capable of handling IO requests.
556 * @controller: This parameter specifies the core controller associated with
557 * the completion callback.
558 * @remote_device: This parameter specifies the remote device associated with
559 * the callback.
560 *
561 */
562void isci_event_remote_device_ready(
563 struct scic_sds_controller *controller,
564 struct scic_sds_remote_device *remote_device)
565{
566 struct isci_remote_device *isci_device =
567 (struct isci_remote_device *)
568 sci_object_get_association(remote_device);
569
570 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
571 "%s: isci_device = %p\n", __func__, isci_device);
572
573 isci_remote_device_ready(isci_device);
574}
575
576/**
577 * isci_event_remote_device_not_ready() - This user callback method will inform
578 * the user that a remote device is no longer capable of handling IO
579 * requests (until a ready callback is invoked).
580 * @controller: This parameter specifies the core controller associated with
581 * the completion callback.
582 * @remote_device: This parameter specifies the remote device associated with
583 * the callback.
584 * @reason_code: This parameter specifies the reason for the remote device
585 * going to a not ready state.
586 *
587 */
588void isci_event_remote_device_not_ready(
589 struct scic_sds_controller *controller,
590 struct scic_sds_remote_device *remote_device,
591 u32 reason_code)
592{
593 struct isci_remote_device *isci_device =
594 (struct isci_remote_device *)
595 sci_object_get_association(remote_device);
596
597 struct isci_host *isci_host;
598
599 isci_host =
600 (struct isci_host *)sci_object_get_association(controller);
601
602 dev_dbg(&isci_host->pdev->dev,
603 "%s: isci_device = %p, reason_code = %x\n",
604 __func__, isci_device, reason_code);
605
606 isci_remote_device_not_ready(isci_device, reason_code);
607}
608
609
diff --git a/drivers/scsi/isci/events.h b/drivers/scsi/isci/events.h
deleted file mode 100644
index fa2f6aa1093c..000000000000
--- a/drivers/scsi/isci/events.h
+++ /dev/null
@@ -1,373 +0,0 @@
1/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#ifndef _ISCI_EVENT_H_
57#define _ISCI_EVENT_H_
58
59/**
60 * isci_event_timer_create() - This callback method asks the user to create a
61 * timer and provide a handle for this timer for use in further timer
62 * interactions.
63 * @controller: This parameter specifies the controller with which this timer
64 * is to be associated.
65 * @timer_callback: This parameter specifies the callback method to be invoked
66 * whenever the timer expires.
67 * @cookie: This parameter specifies a piece of information that the user must
68 * retain. This cookie is to be supplied by the user anytime a timeout
69 * occurs for the created timer.
70 *
71 * The "timer_callback" method should be executed in a mutually exlusive manner
72 * from the controller completion handler handler. This method returns a handle
73 * to a timer object created by the user. The handle will be utilized for all
74 * further interactions relating to this timer.
75 */
76void *isci_event_timer_create(
77 struct scic_sds_controller *controller,
78 void (*timer_callback)(void *),
79 void *cookie);
80
81/**
82 * isci_event_timer_start() - This callback method asks the user to start the
83 * supplied timer.
84 * @controller: This parameter specifies the controller with which this timer
85 * is to associated.
86 * @timer: This parameter specifies the timer to be started.
87 * @milliseconds: This parameter specifies the number of milliseconds for which
88 * to stall. The operating system driver is allowed to round this value up
89 * where necessary.
90 *
91 * All timers in the system started by the SCI Core are one shot timers.
92 * Therefore, the SCI user should make sure that it removes the timer from it's
93 * list when a timer actually fires. Additionally, SCI Core user's should be
94 * able to handle calls from the SCI Core to stop a timer that may already be
95 * stopped. none
96 */
97void isci_event_timer_start(
98 struct scic_sds_controller *controller,
99 void *timer,
100 u32 milliseconds);
101
102/**
103 * isci_event_timer_stop() - This callback method asks the user to stop the
104 * supplied timer.
105 * @controller: This parameter specifies the controller with which this timer
106 * is to associated.
107 * @timer: This parameter specifies the timer to be stopped.
108 *
109 */
110void isci_event_timer_stop(
111 struct scic_sds_controller *controller,
112 void *timer);
113
114
115void isci_event_timer_destroy(struct scic_sds_controller *scic, void *timer);
116
117/**
118 * isci_event_controller_start_complete() - This user callback will inform the
119 * user that the controller has finished the start process.
120 * @controller: This parameter specifies the controller that was started.
121 * @completion_status: This parameter specifies the results of the start
122 * operation. SCI_SUCCESS indicates successful completion.
123 *
124 */
125void isci_event_controller_start_complete(
126 struct scic_sds_controller *controller,
127 enum sci_status completion_status);
128
129/**
130 * isci_event_controller_stop_complete() - This user callback will inform the
131 * user that the controller has finished the stop process.
132 * @controller: This parameter specifies the controller that was stopped.
133 * @completion_status: This parameter specifies the results of the stop
134 * operation. SCI_SUCCESS indicates successful completion.
135 *
136 */
137void isci_event_controller_stop_complete(
138 struct scic_sds_controller *controller,
139 enum sci_status completion_status);
140
141/**
142 * isci_event_io_request_complete() - This user callback will inform the user
143 * that an IO request has completed.
144 * @controller: This parameter specifies the controller on which the IO is
145 * completing.
146 * @remote_device: This parameter specifies the remote device on which this IO
147 * request is completing.
148 * @io_request: This parameter specifies the IO request that has completed.
149 * @completion_status: This parameter specifies the results of the IO request
150 * operation. SCI_SUCCESS indicates successful completion.
151 *
152 */
153void isci_event_io_request_complete(
154 struct scic_sds_controller *controller,
155 struct scic_sds_remote_device *remote_device,
156 struct scic_sds_request *scic_io_request,
157 enum sci_io_status completion_status);
158
159/**
160 * isci_event_task_request_complete() - This user callback will inform the user
161 * that a task management request completed.
162 * @controller: This parameter specifies the controller on which the task
163 * management request is completing.
164 * @remote_device: This parameter specifies the remote device on which this
165 * task management request is completing.
166 * @task_request: This parameter specifies the task management request that has
167 * completed.
168 * @completion_status: This parameter specifies the results of the IO request
169 * operation. SCI_SUCCESS indicates successful completion.
170 *
171 */
172void isci_event_task_request_complete(
173 struct scic_sds_controller *controller,
174 struct scic_sds_remote_device *remote_device,
175 struct scic_sds_request *scic_task_request,
176 enum sci_task_status completion_status);
177
178/**
179 * isci_event_port_stop_complete() - This method informs the user when a stop
180 * operation on the port has completed.
181 * @controller: This parameter represents the controller which contains the
182 * port.
183 * @port: This parameter specifies the SCI port object for which the callback
184 * is being invoked.
185 * @completion_status: This parameter specifies the status for the operation
186 * being completed.
187 *
188 */
189void isci_event_port_stop_complete(
190 struct scic_sds_controller *controller,
191 struct scic_sds_port *port,
192 enum sci_status completion_status);
193
194/**
195 * isci_event_port_hard_reset_complete() - This method informs the user when a
196 * hard reset on the port has completed. This hard reset could have been
197 * initiated by the user or by the remote port.
198 * @controller: This parameter represents the controller which contains the
199 * port.
200 * @port: This parameter specifies the SCI port object for which the callback
201 * is being invoked.
202 * @completion_status: This parameter specifies the status for the operation
203 * being completed.
204 *
205 */
206void isci_event_port_hard_reset_complete(
207 struct scic_sds_controller *controller,
208 struct scic_sds_port *port,
209 enum sci_status completion_status);
210
211/**
212 * isci_event_port_ready() - This method informs the user that the port is now
213 * in a ready state and can be utilized to issue IOs.
214 * @controller: This parameter represents the controller which contains the
215 * port.
216 * @port: This parameter specifies the SCI port object for which the callback
217 * is being invoked.
218 *
219 */
220void isci_event_port_ready(
221 struct scic_sds_controller *controller,
222 struct scic_sds_port *port);
223
224/**
225 * isci_event_port_not_ready() - This method informs the user that the port is
226 * now not in a ready (i.e. busy) state and can't be utilized to issue IOs.
227 * @controller: This parameter represents the controller which contains the
228 * port.
229 * @port: This parameter specifies the SCI port object for which the callback
230 * is being invoked.
231 * @reason_code: This parameter specifies the reason for the port not ready
232 * callback.
233 *
234 */
235void isci_event_port_not_ready(
236 struct scic_sds_controller *controller,
237 struct scic_sds_port *port,
238 u32 reason_code);
239
240/**
241 * isci_event_port_invalid_link_up() - This method informs the SCI Core user
242 * that a phy/link became ready, but the phy is not allowed in the port. In
243 * some situations the underlying hardware only allows for certain phy to port
244 * mappings. If these mappings are violated, then this API is invoked.
245 * @controller: This parameter represents the controller which contains the
246 * port.
247 * @port: This parameter specifies the SCI port object for which the callback
248 * is being invoked.
249 * @phy: This parameter specifies the phy that came ready, but the phy can't be
250 * a valid member of the port.
251 *
252 */
253void isci_event_port_invalid_link_up(
254 struct scic_sds_controller *controller,
255 struct scic_sds_port *port,
256 struct scic_sds_phy *phy);
257
258/**
259 * isci_event_port_bc_change_primitive_received() - This callback method informs
260 * the user that a broadcast change primitive was received.
261 * @controller: This parameter represents the controller which contains the
262 * port.
263 * @port: This parameter specifies the SCI port object for which the callback
264 * is being invoked. For instances where the phy on which the primitive was
265 * received is not part of a port, this parameter will be
266 * NULL.
267 * @phy: This parameter specifies the phy on which the primitive was received.
268 *
269 */
270void isci_event_port_bc_change_primitive_received(
271 struct scic_sds_controller *controller,
272 struct scic_sds_port *port,
273 struct scic_sds_phy *phy);
274
275/**
276 * isci_event_port_link_up() - This callback method informs the user that a phy
277 * has become operational and is capable of communicating with the remote
278 * end point.
279 * @controller: This parameter represents the controller associated with the
280 * phy.
281 * @port: This parameter specifies the port object for which the user callback
282 * is being invoked. There may be conditions where this parameter can be
283 * NULL
284 * @phy: This parameter specifies the phy object for which the user callback is
285 * being invoked.
286 *
287 */
288void isci_event_port_link_up(
289 struct scic_sds_controller *controller,
290 struct scic_sds_port *port,
291 struct scic_sds_phy *phy);
292
293/**
294 * isci_event_port_link_down() - This callback method informs the user that a
295 * phy is no longer operational and is not capable of communicating with the
296 * remote end point.
297 * @controller: This parameter represents the controller associated with the
298 * phy.
299 * @port: This parameter specifies the port object for which the user callback
300 * is being invoked. There may be conditions where this parameter can be
301 * NULL
302 * @phy: This parameter specifies the phy object for which the user callback is
303 * being invoked.
304 *
305 */
306void isci_event_port_link_down(
307 struct scic_sds_controller *controller,
308 struct scic_sds_port *port,
309 struct scic_sds_phy *phy);
310
311/**
312 * isci_event_remote_device_start_complete() - This user callback method will
313 * inform the user that a start operation has completed.
314 * @controller: This parameter specifies the core controller associated with
315 * the completion callback.
316 * @remote_device: This parameter specifies the remote device associated with
317 * the completion callback.
318 * @completion_status: This parameter specifies the completion status for the
319 * operation.
320 *
321 */
322void isci_event_remote_device_start_complete(
323 struct scic_sds_controller *controller,
324 struct scic_sds_remote_device *remote_device,
325 enum sci_status completion_status);
326
327/**
328 * isci_event_remote_device_stop_complete() - This user callback method will
329 * inform the user that a stop operation has completed.
330 * @controller: This parameter specifies the core controller associated with
331 * the completion callback.
332 * @remote_device: This parameter specifies the remote device associated with
333 * the completion callback.
334 * @completion_status: This parameter specifies the completion status for the
335 * operation.
336 *
337 */
338void isci_event_remote_device_stop_complete(
339 struct scic_sds_controller *controller,
340 struct scic_sds_remote_device *remote_device,
341 enum sci_status completion_status);
342
343/**
344 * isci_event_remote_device_ready() - This user callback method will inform the
345 * user that a remote device is now capable of handling IO requests.
346 * @controller: This parameter specifies the core controller associated with
347 * the completion callback.
348 * @remote_device: This parameter specifies the remote device associated with
349 * the callback.
350 *
351 */
352void isci_event_remote_device_ready(
353 struct scic_sds_controller *controller,
354 struct scic_sds_remote_device *remote_device);
355
356/**
357 * isci_event_remote_device_not_ready() - This user callback method will inform
358 * the user that a remote device is no longer capable of handling IO
359 * requests (until a ready callback is invoked).
360 * @controller: This parameter specifies the core controller associated with
361 * the completion callback.
362 * @remote_device: This parameter specifies the remote device associated with
363 * the callback.
364 * @reason_code: This paramete specifies the reason the remote device is not
365 * ready.
366 *
367 */
368void isci_event_remote_device_not_ready(
369 struct scic_sds_controller *controller,
370 struct scic_sds_remote_device *remote_device,
371 u32 reason_code);
372
373#endif
diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h
index a2df59c9e06d..87643857bade 100644
--- a/drivers/scsi/isci/isci.h
+++ b/drivers/scsi/isci/isci.h
@@ -71,7 +71,6 @@
71#include "timers.h" 71#include "timers.h"
72#include "sci_status.h" 72#include "sci_status.h"
73#include "request.h" 73#include "request.h"
74#include "events.h"
75#include "task.h" 74#include "task.h"
76#include "sata.h" 75#include "sata.h"
77 76
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index a5b2565ac5af..666076a2834e 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -279,10 +279,8 @@ void isci_port_link_up(
279 * @port: This parameter specifies the isci port with the active link. 279 * @port: This parameter specifies the isci port with the active link.
280 * 280 *
281 */ 281 */
282void isci_port_link_down( 282void isci_port_link_down(struct isci_host *isci_host, struct isci_phy *isci_phy,
283 struct isci_host *isci_host, 283 struct isci_port *isci_port)
284 struct isci_phy *isci_phy,
285 struct isci_port *isci_port)
286{ 284{
287 struct isci_remote_device *isci_device; 285 struct isci_remote_device *isci_device;
288 286
@@ -358,9 +356,7 @@ void isci_port_formed(
358 * @port: This parameter specifies the sci port with the active link. 356 * @port: This parameter specifies the sci port with the active link.
359 * 357 *
360 */ 358 */
361void isci_port_ready( 359void isci_port_ready(struct isci_host *isci_host, struct isci_port *isci_port)
362 struct isci_host *isci_host,
363 struct isci_port *isci_port)
364{ 360{
365 dev_dbg(&isci_host->pdev->dev, 361 dev_dbg(&isci_host->pdev->dev,
366 "%s: isci_port = %p\n", __func__, isci_port); 362 "%s: isci_port = %p\n", __func__, isci_port);
@@ -378,9 +374,7 @@ void isci_port_ready(
378 * @port: This parameter specifies the sci port with the active link. 374 * @port: This parameter specifies the sci port with the active link.
379 * 375 *
380 */ 376 */
381void isci_port_not_ready( 377void isci_port_not_ready(struct isci_host *isci_host, struct isci_port *isci_port)
382 struct isci_host *isci_host,
383 struct isci_port *isci_port)
384{ 378{
385 dev_dbg(&isci_host->pdev->dev, 379 dev_dbg(&isci_host->pdev->dev,
386 "%s: isci_port = %p\n", __func__, isci_port); 380 "%s: isci_port = %p\n", __func__, isci_port);
@@ -394,9 +388,8 @@ void isci_port_not_ready(
394 * process. 388 * process.
395 * 389 *
396 */ 390 */
397void isci_port_hard_reset_complete( 391void isci_port_hard_reset_complete(struct isci_port *isci_port,
398 struct isci_port *isci_port, 392 enum sci_status completion_status)
399 enum sci_status completion_status)
400{ 393{
401 dev_dbg(&isci_port->isci_host->pdev->dev, 394 dev_dbg(&isci_port->isci_host->pdev->dev,
402 "%s: isci_port = %p, completion_status=%x\n", 395 "%s: isci_port = %p, completion_status=%x\n",
@@ -480,3 +473,35 @@ int isci_port_perform_hard_reset(
480 473
481 return ret; 474 return ret;
482} 475}
476
477/**
478 * isci_port_invalid_link_up() - This function informs the SCI Core user that
479 * a phy/link became ready, but the phy is not allowed in the port. In some
480 * situations the underlying hardware only allows for certain phy to port
481 * mappings. If these mappings are violated, then this API is invoked.
482 * @controller: This parameter represents the controller which contains the
483 * port.
484 * @port: This parameter specifies the SCI port object for which the callback
485 * is being invoked.
486 * @phy: This parameter specifies the phy that came ready, but the phy can't be
487 * a valid member of the port.
488 *
489 */
490void isci_port_invalid_link_up(struct scic_sds_controller *scic,
491 struct scic_sds_port *sci_port,
492 struct scic_sds_phy *phy)
493{
494 struct isci_host *ihost =
495 (struct isci_host *)sci_object_get_association(scic);
496
497 dev_warn(&ihost->pdev->dev, "Invalid link up!\n");
498}
499
500void isci_port_stop_complete(struct scic_sds_controller *scic,
501 struct scic_sds_port *sci_port,
502 enum sci_status completion_status)
503{
504 struct isci_host *ihost = sci_object_get_association(scic);
505
506 dev_dbg(&ihost->pdev->dev, "Port stop complete\n");
507}
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h
index b7a7dd7dca69..dfdd12a0f68e 100644
--- a/drivers/scsi/isci/port.h
+++ b/drivers/scsi/isci/port.h
@@ -147,5 +147,15 @@ int isci_port_perform_hard_reset(
147 struct isci_port *isci_port_ptr, 147 struct isci_port *isci_port_ptr,
148 struct isci_phy *isci_phy_ptr); 148 struct isci_phy *isci_phy_ptr);
149 149
150void isci_port_invalid_link_up(
151 struct scic_sds_controller *scic,
152 struct scic_sds_port *sci_port,
153 struct scic_sds_phy *phy);
154
155void isci_port_stop_complete(
156 struct scic_sds_controller *scic,
157 struct scic_sds_port *sci_port,
158 enum sci_status completion_status);
159
150#endif /* !defined(_ISCI_PORT_H_) */ 160#endif /* !defined(_ISCI_PORT_H_) */
151 161