]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/scsi/isci/host.c
isci: convert port config agent timer to sci_timer
[karo-tx-linux.git] / drivers / scsi / isci / host.c
index 2bb9f1073e73c525bf73f29d4d30584e9bcc2b27..468357ffc771e7f4a04dc2555c8acf2167d831b8 100644 (file)
@@ -932,6 +932,28 @@ static void scic_sds_controller_phy_timer_start(struct scic_sds_controller *scic
        scic->phy_startup_timer_pending = true;
 }
 
+static bool is_phy_starting(struct scic_sds_phy *sci_phy)
+{
+       enum scic_sds_phy_states state;
+
+       state = sci_phy->state_machine.current_state_id;
+       switch (state) {
+       case SCI_BASE_PHY_STATE_STARTING:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF:
+       case SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL:
+               return true;
+       default:
+               return false;
+       }
+}
+
 /**
  * scic_sds_controller_start_next_phy - start phy
  * @scic: controller
@@ -961,7 +983,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
                        sci_phy = &ihost->phys[index].sci;
                        state = sci_phy->state_machine.current_state_id;
 
-                       if (!scic_sds_phy_get_port(sci_phy))
+                       if (!phy_get_non_dummy_port(sci_phy))
                                continue;
 
                        /* The controller start operation is complete iff:
@@ -975,7 +997,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
                            (sci_phy->is_in_link_training == false &&
                             state == SCI_BASE_PHY_STATE_STOPPED) ||
                            (sci_phy->is_in_link_training == true &&
-                            state == SCI_BASE_PHY_STATE_STARTING)) {
+                            is_phy_starting(sci_phy))) {
                                is_controller_start_complete = false;
                                break;
                        }
@@ -992,7 +1014,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
                sci_phy = &ihost->phys[scic->next_phy_to_start].sci;
 
                if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
-                       if (scic_sds_phy_get_port(sci_phy) == NULL) {
+                       if (phy_get_non_dummy_port(sci_phy) == NULL) {
                                scic->next_phy_to_start++;
 
                                /* Caution recursion ahead be forwarned
@@ -1086,7 +1108,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
        for (index = 0; index < scic->logical_port_entries; index++) {
                struct scic_sds_port *sci_port = &ihost->ports[index].sci;
 
-               result = sci_port->state_handlers->start_handler(sci_port);
+               result = scic_sds_port_start(sci_port);
                if (result)
                        return result;
        }
@@ -1337,6 +1359,15 @@ void isci_host_deinit(struct isci_host *ihost)
 
        wait_for_stop(ihost);
        scic_controller_reset(&ihost->sci);
+
+       /* Cancel any/all outstanding port timers */
+       for (i = 0; i < ihost->sci.logical_port_entries; i++) {
+               struct scic_sds_port *sci_port = &ihost->ports[i].sci;
+               del_timer_sync(&sci_port->timer.timer);
+       }
+
+       del_timer_sync(&ihost->sci.port_agent.timer.timer);
+
        isci_timer_list_destroy(ihost);
 }
 
@@ -1382,17 +1413,17 @@ static void isci_user_parameters_get(
        u->max_number_concurrent_device_spin_up = max_concurr_spinup;
 }
 
-static void scic_sds_controller_initial_state_enter(void *object)
+static void scic_sds_controller_initial_state_enter(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        sci_base_state_machine_change_state(&scic->state_machine,
                        SCI_BASE_CONTROLLER_STATE_RESET);
 }
 
-static inline void scic_sds_controller_starting_state_exit(void *object)
+static inline void scic_sds_controller_starting_state_exit(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        isci_timer_stop(scic->timeout_timer);
 }
@@ -1517,17 +1548,17 @@ static enum sci_status scic_controller_set_interrupt_coalescence(
 }
 
 
-static void scic_sds_controller_ready_state_enter(void *object)
+static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        /* set the default interrupt coalescence number and timeout value. */
        scic_controller_set_interrupt_coalescence(scic, 0x10, 250);
 }
 
-static void scic_sds_controller_ready_state_exit(void *object)
+static void scic_sds_controller_ready_state_exit(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        /* disable interrupt coalescence. */
        scic_controller_set_interrupt_coalescence(scic, 0, 0);
@@ -1569,10 +1600,8 @@ static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller
 
        for (index = 0; index < scic->logical_port_entries; index++) {
                struct scic_sds_port *sci_port = &ihost->ports[index].sci;
-               scic_sds_port_handler_t stop;
 
-               stop = sci_port->state_handlers->stop_handler;
-               port_status = stop(sci_port);
+               port_status = scic_sds_port_stop(sci_port);
 
                if ((port_status != SCI_SUCCESS) &&
                    (port_status != SCI_FAILURE_INVALID_STATE)) {
@@ -1618,9 +1647,9 @@ static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controll
        return status;
 }
 
-static void scic_sds_controller_stopping_state_enter(void *object)
+static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        /* Stop all of the components for this controller */
        scic_sds_controller_stop_phys(scic);
@@ -1628,9 +1657,9 @@ static void scic_sds_controller_stopping_state_enter(void *object)
        scic_sds_controller_stop_devices(scic);
 }
 
-static void scic_sds_controller_stopping_state_exit(void *object)
+static void scic_sds_controller_stopping_state_exit(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        isci_timer_stop(scic->timeout_timer);
 }
@@ -1659,9 +1688,9 @@ static void scic_sds_controller_reset_hardware(struct scic_sds_controller *scic)
        writel(0, &scic->scu_registers->sdma.unsolicited_frame_get_pointer);
 }
 
-static void scic_sds_controller_resetting_state_enter(void *object)
+static void scic_sds_controller_resetting_state_enter(struct sci_base_state_machine *sm)
 {
-       struct scic_sds_controller *scic = object;
+       struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
 
        scic_sds_controller_reset_hardware(scic);
        sci_base_state_machine_change_state(&scic->state_machine,
@@ -1765,8 +1794,8 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
        u8 i;
 
        sci_base_state_machine_construct(&scic->state_machine,
-               scic, scic_sds_controller_state_table,
-               SCI_BASE_CONTROLLER_STATE_INITIAL);
+                                        scic_sds_controller_state_table,
+                                        SCI_BASE_CONTROLLER_STATE_INITIAL);
 
        sci_base_state_machine_start(&scic->state_machine);