Commit e301370a authored by Edmund Nadolski's avatar Edmund Nadolski Committed by Dan Williams

isci: state machine cleanup

This cleans up several areas of the state machine mechanism:

 o Rename sci_base_state_machine_change_state to sci_change_state
 o Remove sci_base_state_machine_get_state function
 o Rename 'state_machine' struct member to 'sm' in client structs
 o Shorten the name of request states
 o Shorten state machine state names as follows:
        SCI_BASE_CONTROLLER_STATE_xxx to SCIC_xxx
        SCI_BASE_PHY_STATE_xxx to SCI_PHY_xxx
        SCIC_SDS_PHY_STARTING_SUBSTATE_xxx to SCI_PHY_SUB_xxx
        SCI_BASE_PORT_STATE_xxx to SCI_PORT_xxx and
        SCIC_SDS_PORT_READY_SUBSTATE_xxx to SCI_PORT_SUB_xxx
        SCI_BASE_REMOTE_DEVICE_STATE_xxx to SCI_DEV_xxx
        SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_STP_DEV_xxx
        SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_SMP_DEV_xxx
        SCIC_SDS_REMOTE_NODE_CONTEXT_xxx_STATE to SCI_RNC_xxx
Signed-off-by: default avatarEdmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 8d2c65c0
...@@ -635,8 +635,7 @@ static void scic_sds_controller_error_handler(struct scic_sds_controller *scic) ...@@ -635,8 +635,7 @@ static void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__, dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
interrupt_status); interrupt_status);
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_FAILED);
SCI_BASE_CONTROLLER_STATE_FAILED);
return; return;
} }
...@@ -895,14 +894,12 @@ static void scic_sds_controller_transition_to_ready( ...@@ -895,14 +894,12 @@ static void scic_sds_controller_transition_to_ready(
{ {
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
if (scic->state_machine.current_state_id == if (scic->sm.current_state_id == SCIC_STARTING) {
SCI_BASE_CONTROLLER_STATE_STARTING) {
/* /*
* We move into the ready state, because some of the phys/ports * We move into the ready state, because some of the phys/ports
* may be up and operational. * may be up and operational.
*/ */
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_READY);
SCI_BASE_CONTROLLER_STATE_READY);
isci_host_start_complete(ihost, status); isci_host_start_complete(ihost, status);
} }
...@@ -912,18 +909,18 @@ static bool is_phy_starting(struct scic_sds_phy *sci_phy) ...@@ -912,18 +909,18 @@ static bool is_phy_starting(struct scic_sds_phy *sci_phy)
{ {
enum scic_sds_phy_states state; enum scic_sds_phy_states state;
state = sci_phy->state_machine.current_state_id; state = sci_phy->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_PHY_STATE_STARTING: case SCI_PHY_STARTING:
case SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL: case SCI_PHY_SUB_INITIAL:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN: case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF: case SCI_PHY_SUB_AWAIT_IAF_UF:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER: case SCI_PHY_SUB_AWAIT_SAS_POWER:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER: case SCI_PHY_SUB_AWAIT_SATA_POWER:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN: case SCI_PHY_SUB_AWAIT_SATA_PHY_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN: case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF: case SCI_PHY_SUB_AWAIT_SIG_FIS_UF:
case SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL: case SCI_PHY_SUB_FINAL:
return true; return true;
default: default:
return false; return false;
...@@ -957,7 +954,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro ...@@ -957,7 +954,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
for (index = 0; index < SCI_MAX_PHYS; index++) { for (index = 0; index < SCI_MAX_PHYS; index++) {
sci_phy = &ihost->phys[index].sci; sci_phy = &ihost->phys[index].sci;
state = sci_phy->state_machine.current_state_id; state = sci_phy->sm.current_state_id;
if (!phy_get_non_dummy_port(sci_phy)) if (!phy_get_non_dummy_port(sci_phy))
continue; continue;
...@@ -968,12 +965,9 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro ...@@ -968,12 +965,9 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
* - have an indication of a connected device and it has * - have an indication of a connected device and it has
* finished the link training process. * finished the link training process.
*/ */
if ((sci_phy->is_in_link_training == false && if ((sci_phy->is_in_link_training == false && state == SCI_PHY_INITIAL) ||
state == SCI_BASE_PHY_STATE_INITIAL) || (sci_phy->is_in_link_training == false && state == SCI_PHY_STOPPED) ||
(sci_phy->is_in_link_training == false && (sci_phy->is_in_link_training == true && is_phy_starting(sci_phy))) {
state == SCI_BASE_PHY_STATE_STOPPED) ||
(sci_phy->is_in_link_training == true &&
is_phy_starting(sci_phy))) {
is_controller_start_complete = false; is_controller_start_complete = false;
break; break;
} }
...@@ -1059,8 +1053,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic, ...@@ -1059,8 +1053,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
enum sci_status result; enum sci_status result;
u16 index; u16 index;
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_INITIALIZED) {
SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"SCIC Controller start operation requested in " "SCIC Controller start operation requested in "
"invalid state\n"); "invalid state\n");
...@@ -1108,8 +1101,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic, ...@@ -1108,8 +1101,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
sci_mod_timer(&scic->timer, timeout); sci_mod_timer(&scic->timer, timeout);
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_STARTING);
SCI_BASE_CONTROLLER_STATE_STARTING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1279,8 +1271,7 @@ static void isci_host_completion_routine(unsigned long data) ...@@ -1279,8 +1271,7 @@ static void isci_host_completion_routine(unsigned long data)
static enum sci_status scic_controller_stop(struct scic_sds_controller *scic, static enum sci_status scic_controller_stop(struct scic_sds_controller *scic,
u32 timeout) u32 timeout)
{ {
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_READY) {
SCI_BASE_CONTROLLER_STATE_READY) {
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"SCIC Controller stop operation requested in " "SCIC Controller stop operation requested in "
"invalid state\n"); "invalid state\n");
...@@ -1288,8 +1279,7 @@ static enum sci_status scic_controller_stop(struct scic_sds_controller *scic, ...@@ -1288,8 +1279,7 @@ static enum sci_status scic_controller_stop(struct scic_sds_controller *scic,
} }
sci_mod_timer(&scic->timer, timeout); sci_mod_timer(&scic->timer, timeout);
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_STOPPING);
SCI_BASE_CONTROLLER_STATE_STOPPING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1307,17 +1297,16 @@ static enum sci_status scic_controller_stop(struct scic_sds_controller *scic, ...@@ -1307,17 +1297,16 @@ static enum sci_status scic_controller_stop(struct scic_sds_controller *scic,
*/ */
static enum sci_status scic_controller_reset(struct scic_sds_controller *scic) static enum sci_status scic_controller_reset(struct scic_sds_controller *scic)
{ {
switch (scic->state_machine.current_state_id) { switch (scic->sm.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_RESET: case SCIC_RESET:
case SCI_BASE_CONTROLLER_STATE_READY: case SCIC_READY:
case SCI_BASE_CONTROLLER_STATE_STOPPED: case SCIC_STOPPED:
case SCI_BASE_CONTROLLER_STATE_FAILED: case SCIC_FAILED:
/* /*
* The reset operation is not a graceful cleanup, just * The reset operation is not a graceful cleanup, just
* perform the state transition. * perform the state transition.
*/ */
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_RESETTING);
SCI_BASE_CONTROLLER_STATE_RESETTING);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
...@@ -1416,15 +1405,14 @@ static void isci_user_parameters_get( ...@@ -1416,15 +1405,14 @@ static void isci_user_parameters_get(
static void scic_sds_controller_initial_state_enter(struct sci_base_state_machine *sm) static void scic_sds_controller_initial_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_RESET);
SCI_BASE_CONTROLLER_STATE_RESET);
} }
static inline void scic_sds_controller_starting_state_exit(struct sci_base_state_machine *sm) static inline void scic_sds_controller_starting_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
sci_del_timer(&scic->timer); sci_del_timer(&scic->timer);
} }
...@@ -1551,7 +1539,7 @@ static enum sci_status scic_controller_set_interrupt_coalescence( ...@@ -1551,7 +1539,7 @@ static enum sci_status scic_controller_set_interrupt_coalescence(
static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine *sm) static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
/* set the default interrupt coalescence number and timeout value. */ /* set the default interrupt coalescence number and timeout value. */
scic_controller_set_interrupt_coalescence(scic, 0x10, 250); scic_controller_set_interrupt_coalescence(scic, 0x10, 250);
...@@ -1559,7 +1547,7 @@ static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine ...@@ -1559,7 +1547,7 @@ static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine
static void scic_sds_controller_ready_state_exit(struct sci_base_state_machine *sm) static void scic_sds_controller_ready_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
/* disable interrupt coalescence. */ /* disable interrupt coalescence. */
scic_controller_set_interrupt_coalescence(scic, 0, 0); scic_controller_set_interrupt_coalescence(scic, 0, 0);
...@@ -1650,7 +1638,7 @@ static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controll ...@@ -1650,7 +1638,7 @@ static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controll
static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machine *sm) static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
/* Stop all of the components for this controller */ /* Stop all of the components for this controller */
scic_sds_controller_stop_phys(scic); scic_sds_controller_stop_phys(scic);
...@@ -1660,7 +1648,7 @@ static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machi ...@@ -1660,7 +1648,7 @@ static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machi
static void scic_sds_controller_stopping_state_exit(struct sci_base_state_machine *sm) static void scic_sds_controller_stopping_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
sci_del_timer(&scic->timer); sci_del_timer(&scic->timer);
} }
...@@ -1691,36 +1679,35 @@ static void scic_sds_controller_reset_hardware(struct scic_sds_controller *scic) ...@@ -1691,36 +1679,35 @@ static void scic_sds_controller_reset_hardware(struct scic_sds_controller *scic)
static void scic_sds_controller_resetting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_controller_resetting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine); struct scic_sds_controller *scic = container_of(sm, typeof(*scic), sm);
scic_sds_controller_reset_hardware(scic); scic_sds_controller_reset_hardware(scic);
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_RESET);
SCI_BASE_CONTROLLER_STATE_RESET);
} }
static const struct sci_base_state scic_sds_controller_state_table[] = { static const struct sci_base_state scic_sds_controller_state_table[] = {
[SCI_BASE_CONTROLLER_STATE_INITIAL] = { [SCIC_INITIAL] = {
.enter_state = scic_sds_controller_initial_state_enter, .enter_state = scic_sds_controller_initial_state_enter,
}, },
[SCI_BASE_CONTROLLER_STATE_RESET] = {}, [SCIC_RESET] = {},
[SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {}, [SCIC_INITIALIZING] = {},
[SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {}, [SCIC_INITIALIZED] = {},
[SCI_BASE_CONTROLLER_STATE_STARTING] = { [SCIC_STARTING] = {
.exit_state = scic_sds_controller_starting_state_exit, .exit_state = scic_sds_controller_starting_state_exit,
}, },
[SCI_BASE_CONTROLLER_STATE_READY] = { [SCIC_READY] = {
.enter_state = scic_sds_controller_ready_state_enter, .enter_state = scic_sds_controller_ready_state_enter,
.exit_state = scic_sds_controller_ready_state_exit, .exit_state = scic_sds_controller_ready_state_exit,
}, },
[SCI_BASE_CONTROLLER_STATE_RESETTING] = { [SCIC_RESETTING] = {
.enter_state = scic_sds_controller_resetting_state_enter, .enter_state = scic_sds_controller_resetting_state_enter,
}, },
[SCI_BASE_CONTROLLER_STATE_STOPPING] = { [SCIC_STOPPING] = {
.enter_state = scic_sds_controller_stopping_state_enter, .enter_state = scic_sds_controller_stopping_state_enter,
.exit_state = scic_sds_controller_stopping_state_exit, .exit_state = scic_sds_controller_stopping_state_exit,
}, },
[SCI_BASE_CONTROLLER_STATE_STOPPED] = {}, [SCIC_STOPPED] = {},
[SCI_BASE_CONTROLLER_STATE_FAILED] = {} [SCIC_FAILED] = {}
}; };
static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic) static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic)
...@@ -1774,7 +1761,7 @@ static void controller_timeout(unsigned long data) ...@@ -1774,7 +1761,7 @@ static void controller_timeout(unsigned long data)
struct sci_timer *tmr = (struct sci_timer *)data; struct sci_timer *tmr = (struct sci_timer *)data;
struct scic_sds_controller *scic = container_of(tmr, typeof(*scic), timer); struct scic_sds_controller *scic = container_of(tmr, typeof(*scic), timer);
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct sci_base_state_machine *sm = &scic->state_machine; struct sci_base_state_machine *sm = &scic->sm;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ihost->scic_lock, flags); spin_lock_irqsave(&ihost->scic_lock, flags);
...@@ -1782,10 +1769,10 @@ static void controller_timeout(unsigned long data) ...@@ -1782,10 +1769,10 @@ static void controller_timeout(unsigned long data)
if (tmr->cancel) if (tmr->cancel)
goto done; goto done;
if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING) if (sm->current_state_id == SCIC_STARTING)
scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT); scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT);
else if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STOPPING) { else if (sm->current_state_id == SCIC_STOPPING) {
sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_FAILED); sci_change_state(sm, SCIC_FAILED);
isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT); isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT);
} else /* / @todo Now what do we want to do in this case? */ } else /* / @todo Now what do we want to do in this case? */
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
...@@ -1820,11 +1807,11 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci ...@@ -1820,11 +1807,11 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
u8 i; u8 i;
sci_base_state_machine_construct(&scic->state_machine, sci_base_state_machine_construct(&scic->sm,
scic_sds_controller_state_table, scic_sds_controller_state_table,
SCI_BASE_CONTROLLER_STATE_INITIAL); SCIC_INITIAL);
sci_base_state_machine_start(&scic->state_machine); sci_base_state_machine_start(&scic->sm);
scic->scu_registers = scu_base; scic->scu_registers = scu_base;
scic->smu_registers = smu_base; scic->smu_registers = smu_base;
...@@ -1899,11 +1886,11 @@ int scic_oem_parameters_validate(struct scic_sds_oem_params *oem) ...@@ -1899,11 +1886,11 @@ int scic_oem_parameters_validate(struct scic_sds_oem_params *oem)
static enum sci_status scic_oem_parameters_set(struct scic_sds_controller *scic, static enum sci_status scic_oem_parameters_set(struct scic_sds_controller *scic,
union scic_oem_parameters *scic_parms) union scic_oem_parameters *scic_parms)
{ {
u32 state = scic->state_machine.current_state_id; u32 state = scic->sm.current_state_id;
if (state == SCI_BASE_CONTROLLER_STATE_RESET || if (state == SCIC_RESET ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZING || state == SCIC_INITIALIZING ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) { state == SCIC_INITIALIZED) {
if (scic_oem_parameters_validate(&scic_parms->sds1)) if (scic_oem_parameters_validate(&scic_parms->sds1))
return SCI_FAILURE_INVALID_PARAMETER_VALUE; return SCI_FAILURE_INVALID_PARAMETER_VALUE;
...@@ -2168,10 +2155,8 @@ static enum sci_status scic_controller_set_mode(struct scic_sds_controller *scic ...@@ -2168,10 +2155,8 @@ static enum sci_status scic_controller_set_mode(struct scic_sds_controller *scic
{ {
enum sci_status status = SCI_SUCCESS; enum sci_status status = SCI_SUCCESS;
if ((scic->state_machine.current_state_id == if ((scic->sm.current_state_id == SCIC_INITIALIZING) ||
SCI_BASE_CONTROLLER_STATE_INITIALIZING) || (scic->sm.current_state_id == SCIC_INITIALIZED)) {
(scic->state_machine.current_state_id ==
SCI_BASE_CONTROLLER_STATE_INITIALIZED)) {
switch (operating_mode) { switch (operating_mode) {
case SCI_MODE_SPEED: case SCI_MODE_SPEED:
scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES; scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
...@@ -2216,20 +2201,19 @@ static void scic_sds_controller_initialize_power_control(struct scic_sds_control ...@@ -2216,20 +2201,19 @@ static void scic_sds_controller_initialize_power_control(struct scic_sds_control
static enum sci_status scic_controller_initialize(struct scic_sds_controller *scic) static enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
{ {
struct sci_base_state_machine *sm = &scic->state_machine; struct sci_base_state_machine *sm = &scic->sm;
enum sci_status result = SCI_SUCCESS; enum sci_status result = SCI_SUCCESS;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
u32 index, state; u32 index, state;
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_RESET) {
SCI_BASE_CONTROLLER_STATE_RESET) {
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"SCIC Controller initialize operation requested " "SCIC Controller initialize operation requested "
"in invalid state\n"); "in invalid state\n");
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING); sci_change_state(sm, SCIC_INITIALIZING);
sci_init_timer(&scic->phy_timer, phy_startup_timeout); sci_init_timer(&scic->phy_timer, phy_startup_timeout);
...@@ -2374,10 +2358,10 @@ static enum sci_status scic_controller_initialize(struct scic_sds_controller *sc ...@@ -2374,10 +2358,10 @@ static enum sci_status scic_controller_initialize(struct scic_sds_controller *sc
/* Advance the controller state machine */ /* Advance the controller state machine */
if (result == SCI_SUCCESS) if (result == SCI_SUCCESS)
state = SCI_BASE_CONTROLLER_STATE_INITIALIZED; state = SCIC_INITIALIZED;
else else
state = SCI_BASE_CONTROLLER_STATE_FAILED; state = SCIC_FAILED;
sci_base_state_machine_change_state(sm, state); sci_change_state(sm, state);
return result; return result;
} }
...@@ -2386,11 +2370,11 @@ static enum sci_status scic_user_parameters_set( ...@@ -2386,11 +2370,11 @@ static enum sci_status scic_user_parameters_set(
struct scic_sds_controller *scic, struct scic_sds_controller *scic,
union scic_user_parameters *scic_parms) union scic_user_parameters *scic_parms)
{ {
u32 state = scic->state_machine.current_state_id; u32 state = scic->sm.current_state_id;
if (state == SCI_BASE_CONTROLLER_STATE_RESET || if (state == SCIC_RESET ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZING || state == SCIC_INITIALIZING ||
state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) { state == SCIC_INITIALIZED) {
u16 index; u16 index;
/* /*
...@@ -2612,15 +2596,15 @@ int isci_host_init(struct isci_host *isci_host) ...@@ -2612,15 +2596,15 @@ int isci_host_init(struct isci_host *isci_host)
void scic_sds_controller_link_up(struct scic_sds_controller *scic, void scic_sds_controller_link_up(struct scic_sds_controller *scic,
struct scic_sds_port *port, struct scic_sds_phy *phy) struct scic_sds_port *port, struct scic_sds_phy *phy)
{ {
switch (scic->state_machine.current_state_id) { switch (scic->sm.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_STARTING: case SCIC_STARTING:
sci_del_timer(&scic->phy_timer); sci_del_timer(&scic->phy_timer);
scic->phy_startup_timer_pending = false; scic->phy_startup_timer_pending = false;
scic->port_agent.link_up_handler(scic, &scic->port_agent, scic->port_agent.link_up_handler(scic, &scic->port_agent,
port, phy); port, phy);
scic_sds_controller_start_next_phy(scic); scic_sds_controller_start_next_phy(scic);
break; break;
case SCI_BASE_CONTROLLER_STATE_READY: case SCIC_READY:
scic->port_agent.link_up_handler(scic, &scic->port_agent, scic->port_agent.link_up_handler(scic, &scic->port_agent,
port, phy); port, phy);
break; break;
...@@ -2628,16 +2612,16 @@ void scic_sds_controller_link_up(struct scic_sds_controller *scic, ...@@ -2628,16 +2612,16 @@ void scic_sds_controller_link_up(struct scic_sds_controller *scic,
dev_dbg(scic_to_dev(scic), dev_dbg(scic_to_dev(scic),
"%s: SCIC Controller linkup event from phy %d in " "%s: SCIC Controller linkup event from phy %d in "
"unexpected state %d\n", __func__, phy->phy_index, "unexpected state %d\n", __func__, phy->phy_index,
scic->state_machine.current_state_id); scic->sm.current_state_id);
} }
} }
void scic_sds_controller_link_down(struct scic_sds_controller *scic, void scic_sds_controller_link_down(struct scic_sds_controller *scic,
struct scic_sds_port *port, struct scic_sds_phy *phy) struct scic_sds_port *port, struct scic_sds_phy *phy)
{ {
switch (scic->state_machine.current_state_id) { switch (scic->sm.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_STARTING: case SCIC_STARTING:
case SCI_BASE_CONTROLLER_STATE_READY: case SCIC_READY:
scic->port_agent.link_down_handler(scic, &scic->port_agent, scic->port_agent.link_down_handler(scic, &scic->port_agent,
port, phy); port, phy);
break; break;
...@@ -2647,7 +2631,7 @@ void scic_sds_controller_link_down(struct scic_sds_controller *scic, ...@@ -2647,7 +2631,7 @@ void scic_sds_controller_link_down(struct scic_sds_controller *scic,
"unexpected state %d\n", "unexpected state %d\n",
__func__, __func__,
phy->phy_index, phy->phy_index,
scic->state_machine.current_state_id); scic->sm.current_state_id);
} }
} }
...@@ -2663,8 +2647,7 @@ static bool scic_sds_controller_has_remote_devices_stopping( ...@@ -2663,8 +2647,7 @@ static bool scic_sds_controller_has_remote_devices_stopping(
for (index = 0; index < controller->remote_node_entries; index++) { for (index = 0; index < controller->remote_node_entries; index++) {
if ((controller->device_table[index] != NULL) && if ((controller->device_table[index] != NULL) &&
(controller->device_table[index]->state_machine.current_state_id (controller->device_table[index]->sm.current_state_id == SCI_DEV_STOPPING))
== SCI_BASE_REMOTE_DEVICE_STATE_STOPPING))
return true; return true;
} }
...@@ -2678,19 +2661,17 @@ static bool scic_sds_controller_has_remote_devices_stopping( ...@@ -2678,19 +2661,17 @@ static bool scic_sds_controller_has_remote_devices_stopping(
void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic, void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev) struct scic_sds_remote_device *sci_dev)
{ {
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_STOPPING) {
SCI_BASE_CONTROLLER_STATE_STOPPING) {
dev_dbg(scic_to_dev(scic), dev_dbg(scic_to_dev(scic),
"SCIC Controller 0x%p remote device stopped event " "SCIC Controller 0x%p remote device stopped event "
"from device 0x%p in unexpected state %d\n", "from device 0x%p in unexpected state %d\n",
scic, sci_dev, scic, sci_dev,
scic->state_machine.current_state_id); scic->sm.current_state_id);
return; return;
} }
if (!scic_sds_controller_has_remote_devices_stopping(scic)) { if (!scic_sds_controller_has_remote_devices_stopping(scic)) {
sci_base_state_machine_change_state(&scic->state_machine, sci_change_state(&scic->sm, SCIC_STOPPED);
SCI_BASE_CONTROLLER_STATE_STOPPED);
} }
} }
...@@ -2948,8 +2929,7 @@ enum sci_status scic_controller_start_io( ...@@ -2948,8 +2929,7 @@ enum sci_status scic_controller_start_io(
{ {
enum sci_status status; enum sci_status status;
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_READY) {
SCI_BASE_CONTROLLER_STATE_READY) {
dev_warn(scic_to_dev(scic), "invalid state to start I/O"); dev_warn(scic_to_dev(scic), "invalid state to start I/O");
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
...@@ -2986,8 +2966,7 @@ enum sci_status scic_controller_terminate_request( ...@@ -2986,8 +2966,7 @@ enum sci_status scic_controller_terminate_request(
{ {
enum sci_status status; enum sci_status status;
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_READY) {
SCI_BASE_CONTROLLER_STATE_READY) {
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"invalid state to terminate request\n"); "invalid state to terminate request\n");
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -3037,11 +3016,11 @@ enum sci_status scic_controller_complete_io( ...@@ -3037,11 +3016,11 @@ enum sci_status scic_controller_complete_io(
enum sci_status status; enum sci_status status;
u16 index; u16 index;
switch (scic->state_machine.current_state_id) { switch (scic->sm.current_state_id) {
case SCI_BASE_CONTROLLER_STATE_STOPPING: case SCIC_STOPPING:
/* XXX: Implement this function */ /* XXX: Implement this function */
return SCI_FAILURE; return SCI_FAILURE;
case SCI_BASE_CONTROLLER_STATE_READY: case SCIC_READY:
status = scic_sds_remote_device_complete_io(scic, rdev, request); status = scic_sds_remote_device_complete_io(scic, rdev, request);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
...@@ -3060,8 +3039,7 @@ enum sci_status scic_controller_continue_io(struct scic_sds_request *sci_req) ...@@ -3060,8 +3039,7 @@ enum sci_status scic_controller_continue_io(struct scic_sds_request *sci_req)
{ {
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_READY) {
SCI_BASE_CONTROLLER_STATE_READY) {
dev_warn(scic_to_dev(scic), "invalid state to continue I/O"); dev_warn(scic_to_dev(scic), "invalid state to continue I/O");
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
...@@ -3107,8 +3085,7 @@ enum sci_task_status scic_controller_start_task( ...@@ -3107,8 +3085,7 @@ enum sci_task_status scic_controller_start_task(
{ {
enum sci_status status; enum sci_status status;
if (scic->state_machine.current_state_id != if (scic->sm.current_state_id != SCIC_READY) {
SCI_BASE_CONTROLLER_STATE_READY) {
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC Controller starting task from invalid " "%s: SCIC Controller starting task from invalid "
"state\n", "state\n",
......
...@@ -134,7 +134,7 @@ struct scic_sds_controller { ...@@ -134,7 +134,7 @@ struct scic_sds_controller {
* This field contains the information for the base controller state * This field contains the information for the base controller state
* machine. * machine.
*/ */
struct sci_base_state_machine state_machine; struct sci_base_state_machine sm;
/** /**
* Timer for controller start/stop operations. * Timer for controller start/stop operations.
...@@ -359,7 +359,7 @@ enum scic_sds_controller_states { ...@@ -359,7 +359,7 @@ enum scic_sds_controller_states {
/** /**
* Simply the initial state for the base controller state machine. * Simply the initial state for the base controller state machine.
*/ */
SCI_BASE_CONTROLLER_STATE_INITIAL = 0, SCIC_INITIAL = 0,
/** /**
* This state indicates that the controller is reset. The memory for * This state indicates that the controller is reset. The memory for
...@@ -368,7 +368,7 @@ enum scic_sds_controller_states { ...@@ -368,7 +368,7 @@ enum scic_sds_controller_states {
* This state is entered from the INITIAL state. * This state is entered from the INITIAL state.
* This state is entered from the RESETTING state. * This state is entered from the RESETTING state.
*/ */
SCI_BASE_CONTROLLER_STATE_RESET, SCIC_RESET,
/** /**
* This state is typically an action state that indicates the controller * This state is typically an action state that indicates the controller
...@@ -376,28 +376,28 @@ enum scic_sds_controller_states { ...@@ -376,28 +376,28 @@ enum scic_sds_controller_states {
* are permitted. * are permitted.
* This state is entered from the RESET state. * This state is entered from the RESET state.
*/ */
SCI_BASE_CONTROLLER_STATE_INITIALIZING, SCIC_INITIALIZING,
/** /**
* This state indicates that the controller has been successfully * This state indicates that the controller has been successfully
* initialized. In this state no new IO operations are permitted. * initialized. In this state no new IO operations are permitted.
* This state is entered from the INITIALIZING state. * This state is entered from the INITIALIZING state.
*/ */
SCI_BASE_CONTROLLER_STATE_INITIALIZED, SCIC_INITIALIZED,
/** /**
* This state indicates the the controller is in the process of becoming * This state indicates the the controller is in the process of becoming
* ready (i.e. starting). In this state no new IO operations are permitted. * ready (i.e. starting). In this state no new IO operations are permitted.
* This state is entered from the INITIALIZED state. * This state is entered from the INITIALIZED state.
*/ */
SCI_BASE_CONTROLLER_STATE_STARTING, SCIC_STARTING,
/** /**
* This state indicates the controller is now ready. Thus, the user * This state indicates the controller is now ready. Thus, the user
* is able to perform IO operations on the controller. * is able to perform IO operations on the controller.
* This state is entered from the STARTING state. * This state is entered from the STARTING state.
*/ */
SCI_BASE_CONTROLLER_STATE_READY, SCIC_READY,
/** /**
* This state is typically an action state that indicates the controller * This state is typically an action state that indicates the controller
...@@ -408,7 +408,7 @@ enum scic_sds_controller_states { ...@@ -408,7 +408,7 @@ enum scic_sds_controller_states {
* This state is entered from the FAILED state. * This state is entered from the FAILED state.
* This state is entered from the STOPPED state. * This state is entered from the STOPPED state.
*/ */
SCI_BASE_CONTROLLER_STATE_RESETTING, SCIC_RESETTING,
/** /**
* This state indicates that the controller is in the process of stopping. * This state indicates that the controller is in the process of stopping.
...@@ -416,14 +416,14 @@ enum scic_sds_controller_states { ...@@ -416,14 +416,14 @@ enum scic_sds_controller_states {
* operations are allowed to complete. * operations are allowed to complete.
* This state is entered from the READY state. * This state is entered from the READY state.
*/ */
SCI_BASE_CONTROLLER_STATE_STOPPING, SCIC_STOPPING,
/** /**
* This state indicates that the controller has successfully been stopped. * This state indicates that the controller has successfully been stopped.
* In this state no new IO operations are permitted. * In this state no new IO operations are permitted.
* This state is entered from the STOPPING state. * This state is entered from the STOPPING state.
*/ */
SCI_BASE_CONTROLLER_STATE_STOPPED, SCIC_STOPPED,
/** /**
* This state indicates that the controller could not successfully be * This state indicates that the controller could not successfully be
...@@ -433,10 +433,7 @@ enum scic_sds_controller_states { ...@@ -433,10 +433,7 @@ enum scic_sds_controller_states {
* This state is entered from the STOPPING state. * This state is entered from the STOPPING state.
* This state is entered from the RESETTING state. * This state is entered from the RESETTING state.
*/ */
SCI_BASE_CONTROLLER_STATE_FAILED, SCIC_FAILED,
SCI_BASE_CONTROLLER_MAX_STATES
}; };
......
...@@ -249,8 +249,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, ...@@ -249,8 +249,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout); writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout);
/* We can exit the initial state to the stopped state */ /* We can exit the initial state to the stopped state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STOPPED);
SCI_BASE_PHY_STATE_STOPPED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -273,8 +272,7 @@ static void phy_sata_timeout(unsigned long data) ...@@ -273,8 +272,7 @@ static void phy_sata_timeout(unsigned long data)
__func__, __func__,
sci_phy); sci_phy);
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
done: done:
spin_unlock_irqrestore(&ihost->scic_lock, flags); spin_unlock_irqrestore(&ihost->scic_lock, flags);
} }
...@@ -342,8 +340,7 @@ enum sci_status scic_sds_phy_initialize( ...@@ -342,8 +340,7 @@ enum sci_status scic_sds_phy_initialize(
/* /*
* There is nothing that needs to be done in this state just * There is nothing that needs to be done in this state just
* transition to the stopped state. */ * transition to the stopped state. */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STOPPED);
SCI_BASE_PHY_STATE_STOPPED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -436,34 +433,33 @@ void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy, ...@@ -436,34 +433,33 @@ void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy,
enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy) enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy)
{ {
enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id; enum scic_sds_phy_states state = sci_phy->sm.current_state_id;
if (state != SCI_BASE_PHY_STATE_STOPPED) { if (state != SCI_PHY_STOPPED) {
dev_dbg(sciphy_to_dev(sci_phy), dev_dbg(sciphy_to_dev(sci_phy),
"%s: in wrong state: %d\n", __func__, state); "%s: in wrong state: %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy) enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
{ {
enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id; enum scic_sds_phy_states state = sci_phy->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL: case SCI_PHY_SUB_INITIAL:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN: case SCI_PHY_SUB_AWAIT_OSSP_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN: case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER: case SCI_PHY_SUB_AWAIT_SAS_POWER:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER: case SCI_PHY_SUB_AWAIT_SATA_POWER:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN: case SCI_PHY_SUB_AWAIT_SATA_PHY_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN: case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN:
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF: case SCI_PHY_SUB_AWAIT_SIG_FIS_UF:
case SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL: case SCI_PHY_SUB_FINAL:
case SCI_BASE_PHY_STATE_READY: case SCI_PHY_READY:
break; break;
default: default:
dev_dbg(sciphy_to_dev(sci_phy), dev_dbg(sciphy_to_dev(sci_phy),
...@@ -471,32 +467,30 @@ enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy) ...@@ -471,32 +467,30 @@ enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STOPPED);
SCI_BASE_PHY_STATE_STOPPED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
enum sci_status scic_sds_phy_reset(struct scic_sds_phy *sci_phy) enum sci_status scic_sds_phy_reset(struct scic_sds_phy *sci_phy)
{ {
enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id; enum scic_sds_phy_states state = sci_phy->sm.current_state_id;
if (state != SCI_BASE_PHY_STATE_READY) { if (state != SCI_PHY_READY) {
dev_dbg(sciphy_to_dev(sci_phy), dev_dbg(sciphy_to_dev(sci_phy),
"%s: in wrong state: %d\n", __func__, state); "%s: in wrong state: %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_RESETTING);
SCI_BASE_PHY_STATE_RESETTING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy) enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy)
{ {
enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id; enum scic_sds_phy_states state = sci_phy->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER: { case SCI_PHY_SUB_AWAIT_SAS_POWER: {
u32 enable_spinup; u32 enable_spinup;
enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
...@@ -504,12 +498,11 @@ enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy) ...@@ -504,12 +498,11 @@ enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy)
writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control); writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control);
/* Change state to the final state this substate machine has run to completion */ /* Change state to the final state this substate machine has run to completion */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_FINAL);
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER: { case SCI_PHY_SUB_AWAIT_SATA_POWER: {
u32 scu_sas_pcfg_value; u32 scu_sas_pcfg_value;
/* Release the spinup hold state and reset the OOB state machine */ /* Release the spinup hold state and reset the OOB state machine */
...@@ -528,8 +521,7 @@ enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy) ...@@ -528,8 +521,7 @@ enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy)
&sci_phy->link_layer_registers->phy_configuration); &sci_phy->link_layer_registers->phy_configuration);
/* Change state to the final state this substate machine has run to completion */ /* Change state to the final state this substate machine has run to completion */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_PHY_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -566,10 +558,7 @@ static void scic_sds_phy_start_sas_link_training( ...@@ -566,10 +558,7 @@ static void scic_sds_phy_start_sas_link_training(
writel(phy_control, writel(phy_control,
&sci_phy->link_layer_registers->phy_configuration); &sci_phy->link_layer_registers->phy_configuration);
sci_base_state_machine_change_state( sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SAS_SPEED_EN);
&sci_phy->state_machine,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
);
sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS; sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS;
} }
...@@ -585,10 +574,7 @@ static void scic_sds_phy_start_sas_link_training( ...@@ -585,10 +574,7 @@ static void scic_sds_phy_start_sas_link_training(
static void scic_sds_phy_start_sata_link_training( static void scic_sds_phy_start_sata_link_training(
struct scic_sds_phy *sci_phy) struct scic_sds_phy *sci_phy)
{ {
sci_base_state_machine_change_state( sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_POWER);
&sci_phy->state_machine,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
);
sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
} }
...@@ -611,17 +597,16 @@ static void scic_sds_phy_complete_link_training( ...@@ -611,17 +597,16 @@ static void scic_sds_phy_complete_link_training(
{ {
sci_phy->max_negotiated_speed = max_link_rate; sci_phy->max_negotiated_speed = max_link_rate;
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, next_state);
next_state);
} }
enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
u32 event_code) u32 event_code)
{ {
enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id; enum scic_sds_phy_states state = sci_phy->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN: case SCI_PHY_SUB_AWAIT_OSSP_EN:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_SAS_PHY_DETECTED: case SCU_EVENT_SAS_PHY_DETECTED:
scic_sds_phy_start_sas_link_training(sci_phy); scic_sds_phy_start_sas_link_training(sci_phy);
...@@ -640,7 +625,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -640,7 +625,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE; return SCI_FAILURE;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN: case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_SAS_PHY_DETECTED: case SCU_EVENT_SAS_PHY_DETECTED:
/* /*
...@@ -652,21 +637,21 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -652,21 +637,21 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
scic_sds_phy_complete_link_training( scic_sds_phy_complete_link_training(
sci_phy, sci_phy,
SAS_LINK_RATE_1_5_GBPS, SAS_LINK_RATE_1_5_GBPS,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); SCI_PHY_SUB_AWAIT_IAF_UF);
break; break;
case SCU_EVENT_SAS_30: case SCU_EVENT_SAS_30:
case SCU_EVENT_SAS_30_SSC: case SCU_EVENT_SAS_30_SSC:
scic_sds_phy_complete_link_training( scic_sds_phy_complete_link_training(
sci_phy, sci_phy,
SAS_LINK_RATE_3_0_GBPS, SAS_LINK_RATE_3_0_GBPS,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); SCI_PHY_SUB_AWAIT_IAF_UF);
break; break;
case SCU_EVENT_SAS_60: case SCU_EVENT_SAS_60:
case SCU_EVENT_SAS_60_SSC: case SCU_EVENT_SAS_60_SSC:
scic_sds_phy_complete_link_training( scic_sds_phy_complete_link_training(
sci_phy, sci_phy,
SAS_LINK_RATE_6_0_GBPS, SAS_LINK_RATE_6_0_GBPS,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); SCI_PHY_SUB_AWAIT_IAF_UF);
break; break;
case SCU_EVENT_SATA_SPINUP_HOLD: case SCU_EVENT_SATA_SPINUP_HOLD:
/* /*
...@@ -676,8 +661,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -676,8 +661,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
break; break;
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
default: default:
dev_warn(sciphy_to_dev(sci_phy), dev_warn(sciphy_to_dev(sci_phy),
...@@ -689,7 +673,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -689,7 +673,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
break; break;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF: case SCI_PHY_SUB_AWAIT_IAF_UF:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_SAS_PHY_DETECTED: case SCU_EVENT_SAS_PHY_DETECTED:
/* Backup the state machine */ /* Backup the state machine */
...@@ -706,8 +690,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -706,8 +690,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
case SCU_EVENT_HARD_RESET_RECEIVED: case SCU_EVENT_HARD_RESET_RECEIVED:
/* Start the oob/sn state machine over again */ /* Start the oob/sn state machine over again */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
default: default:
dev_warn(sciphy_to_dev(sci_phy), dev_warn(sciphy_to_dev(sci_phy),
...@@ -717,12 +700,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -717,12 +700,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE; return SCI_FAILURE;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER: case SCI_PHY_SUB_AWAIT_SAS_POWER:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
default: default:
dev_warn(sciphy_to_dev(sci_phy), dev_warn(sciphy_to_dev(sci_phy),
...@@ -733,12 +715,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -733,12 +715,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE; return SCI_FAILURE;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER: case SCI_PHY_SUB_AWAIT_SATA_POWER:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
case SCU_EVENT_SATA_SPINUP_HOLD: case SCU_EVENT_SATA_SPINUP_HOLD:
/* These events are received every 10ms and are /* These events are received every 10ms and are
...@@ -762,12 +743,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -762,12 +743,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE; return SCI_FAILURE;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN: case SCI_PHY_SUB_AWAIT_SATA_PHY_EN:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
case SCU_EVENT_SATA_SPINUP_HOLD: case SCU_EVENT_SATA_SPINUP_HOLD:
/* These events might be received since we dont know how many may be in /* These events might be received since we dont know how many may be in
...@@ -778,8 +758,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -778,8 +758,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
/* We have received the SATA PHY notification change state */ /* We have received the SATA PHY notification change state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
break; break;
case SCU_EVENT_SAS_PHY_DETECTED: case SCU_EVENT_SAS_PHY_DETECTED:
/* There has been a change in the phy type before OOB/SN for the /* There has been a change in the phy type before OOB/SN for the
...@@ -797,7 +776,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -797,7 +776,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE;; return SCI_FAILURE;;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN: case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_SATA_PHY_DETECTED: case SCU_EVENT_SATA_PHY_DETECTED:
/* /*
...@@ -809,26 +788,25 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -809,26 +788,25 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
scic_sds_phy_complete_link_training( scic_sds_phy_complete_link_training(
sci_phy, sci_phy,
SAS_LINK_RATE_1_5_GBPS, SAS_LINK_RATE_1_5_GBPS,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
break; break;
case SCU_EVENT_SATA_30: case SCU_EVENT_SATA_30:
case SCU_EVENT_SATA_30_SSC: case SCU_EVENT_SATA_30_SSC:
scic_sds_phy_complete_link_training( scic_sds_phy_complete_link_training(
sci_phy, sci_phy,
SAS_LINK_RATE_3_0_GBPS, SAS_LINK_RATE_3_0_GBPS,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
break; break;
case SCU_EVENT_SATA_60: case SCU_EVENT_SATA_60:
case SCU_EVENT_SATA_60_SSC: case SCU_EVENT_SATA_60_SSC:
scic_sds_phy_complete_link_training( scic_sds_phy_complete_link_training(
sci_phy, sci_phy,
SAS_LINK_RATE_6_0_GBPS, SAS_LINK_RATE_6_0_GBPS,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
break; break;
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
case SCU_EVENT_SAS_PHY_DETECTED: case SCU_EVENT_SAS_PHY_DETECTED:
/* /*
...@@ -846,18 +824,16 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -846,18 +824,16 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF: case SCI_PHY_SUB_AWAIT_SIG_FIS_UF:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_SATA_PHY_DETECTED: case SCU_EVENT_SATA_PHY_DETECTED:
/* Backup the state machine */ /* Backup the state machine */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
break; break;
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
default: default:
...@@ -870,12 +846,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -870,12 +846,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE; return SCI_FAILURE;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_PHY_STATE_READY: case SCI_PHY_READY:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_LINK_FAILURE: case SCU_EVENT_LINK_FAILURE:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
case SCU_EVENT_BROADCAST_CHANGE: case SCU_EVENT_BROADCAST_CHANGE:
/* Broadcast change received. Notify the port. */ /* Broadcast change received. Notify the port. */
...@@ -892,12 +867,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -892,12 +867,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_PHY_STATE_RESETTING: case SCI_PHY_RESETTING:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_HARD_RESET_TRANSMITTED: case SCU_EVENT_HARD_RESET_TRANSMITTED:
/* Link failure change state back to the starting state */ /* Link failure change state back to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
break; break;
default: default:
dev_warn(sciphy_to_dev(sci_phy), dev_warn(sciphy_to_dev(sci_phy),
...@@ -919,12 +893,12 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, ...@@ -919,12 +893,12 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy, enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
u32 frame_index) u32 frame_index)
{ {
enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id; enum scic_sds_phy_states state = sci_phy->sm.current_state_id;
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
enum sci_status result; enum sci_status result;
switch (state) { switch (state) {
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF: { case SCI_PHY_SUB_AWAIT_IAF_UF: {
u32 *frame_words; u32 *frame_words;
struct sas_identify_frame iaf; struct sas_identify_frame iaf;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
...@@ -946,15 +920,14 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy, ...@@ -946,15 +920,14 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
* state since there are no power requirements for * state since there are no power requirements for
* expander phys. * expander phys.
*/ */
state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL; state = SCI_PHY_SUB_FINAL;
} else { } else {
/* We got the IAF we can now go to the await spinup /* We got the IAF we can now go to the await spinup
* semaphore state * semaphore state
*/ */
state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER; state = SCI_PHY_SUB_AWAIT_SAS_POWER;
} }
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, state);
state);
result = SCI_SUCCESS; result = SCI_SUCCESS;
} else } else
dev_warn(sciphy_to_dev(sci_phy), dev_warn(sciphy_to_dev(sci_phy),
...@@ -965,7 +938,7 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy, ...@@ -965,7 +938,7 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return result; return result;
} }
case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF: { case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: {
struct dev_to_host_fis *frame_header; struct dev_to_host_fis *frame_header;
u32 *fis_frame_data; u32 *fis_frame_data;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
...@@ -989,8 +962,7 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy, ...@@ -989,8 +962,7 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
fis_frame_data); fis_frame_data);
/* got IAF we can now go to the await spinup semaphore state */ /* got IAF we can now go to the await spinup semaphore state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_FINAL);
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
result = SCI_SUCCESS; result = SCI_SUCCESS;
} else } else
...@@ -1014,16 +986,15 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy, ...@@ -1014,16 +986,15 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
/* This is just an temporary state go off to the starting state */ /* This is just an temporary state go off to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_OSSP_EN);
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
} }
static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_insert(scic, sci_phy); scic_sds_controller_power_control_queue_insert(scic, sci_phy);
...@@ -1031,7 +1002,7 @@ static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base ...@@ -1031,7 +1002,7 @@ static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base
static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_remove(scic, sci_phy); scic_sds_controller_power_control_queue_remove(scic, sci_phy);
...@@ -1039,7 +1010,7 @@ static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_ ...@@ -1039,7 +1010,7 @@ static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_
static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_insert(scic, sci_phy); scic_sds_controller_power_control_queue_insert(scic, sci_phy);
...@@ -1047,7 +1018,7 @@ static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_bas ...@@ -1047,7 +1018,7 @@ static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_bas
static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_remove(scic, sci_phy); scic_sds_controller_power_control_queue_remove(scic, sci_phy);
...@@ -1055,35 +1026,35 @@ static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base ...@@ -1055,35 +1026,35 @@ static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base
static void scic_sds_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
sci_mod_timer(&sci_phy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); sci_mod_timer(&sci_phy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
} }
static void scic_sds_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
sci_del_timer(&sci_phy->sata_timer); sci_del_timer(&sci_phy->sata_timer);
} }
static void scic_sds_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
sci_mod_timer(&sci_phy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); sci_mod_timer(&sci_phy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
} }
static void scic_sds_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
sci_del_timer(&sci_phy->sata_timer); sci_del_timer(&sci_phy->sata_timer);
} }
static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) { if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) {
...@@ -1103,20 +1074,19 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_bas ...@@ -1103,20 +1074,19 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_bas
static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
sci_del_timer(&sci_phy->sata_timer); sci_del_timer(&sci_phy->sata_timer);
} }
static void scic_sds_phy_starting_final_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_final_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
/* State machine has run to completion so exit out and change /* State machine has run to completion so exit out and change
* the base state machine to the ready state * the base state machine to the ready state
*/ */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_READY);
SCI_BASE_PHY_STATE_READY);
} }
/** /**
...@@ -1202,7 +1172,7 @@ static void scu_link_layer_tx_hard_reset( ...@@ -1202,7 +1172,7 @@ static void scu_link_layer_tx_hard_reset(
static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
/* /*
* @todo We need to get to the controller to place this PE in a * @todo We need to get to the controller to place this PE in a
...@@ -1212,7 +1182,7 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm) ...@@ -1212,7 +1182,7 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm)
scu_link_layer_stop_protocol_engine(sci_phy); scu_link_layer_stop_protocol_engine(sci_phy);
if (sci_phy->state_machine.previous_state_id != SCI_BASE_PHY_STATE_INITIAL) if (sci_phy->sm.previous_state_id != SCI_PHY_INITIAL)
scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy), scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy),
phy_get_non_dummy_port(sci_phy), phy_get_non_dummy_port(sci_phy),
sci_phy); sci_phy);
...@@ -1220,7 +1190,7 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm) ...@@ -1220,7 +1190,7 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm)
static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
scu_link_layer_stop_protocol_engine(sci_phy); scu_link_layer_stop_protocol_engine(sci_phy);
scu_link_layer_start_oob(sci_phy); scu_link_layer_start_oob(sci_phy);
...@@ -1229,18 +1199,17 @@ static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm) ...@@ -1229,18 +1199,17 @@ static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm)
sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
sci_phy->bcn_received_while_port_unassigned = false; sci_phy->bcn_received_while_port_unassigned = false;
if (sci_phy->state_machine.previous_state_id == SCI_BASE_PHY_STATE_READY) if (sci_phy->sm.previous_state_id == SCI_PHY_READY)
scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy), scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy),
phy_get_non_dummy_port(sci_phy), phy_get_non_dummy_port(sci_phy),
sci_phy); sci_phy);
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_SUB_INITIAL);
SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
} }
static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy), scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy),
phy_get_non_dummy_port(sci_phy), phy_get_non_dummy_port(sci_phy),
...@@ -1250,14 +1219,14 @@ static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm) ...@@ -1250,14 +1219,14 @@ static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm)
static void scic_sds_phy_ready_state_exit(struct sci_base_state_machine *sm) static void scic_sds_phy_ready_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
scic_sds_phy_suspend(sci_phy); scic_sds_phy_suspend(sci_phy);
} }
static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine); struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm);
/* The phy is being reset, therefore deactivate it from the port. In /* The phy is being reset, therefore deactivate it from the port. In
* the resetting state we don't notify the user regarding link up and * the resetting state we don't notify the user regarding link up and
...@@ -1271,66 +1240,65 @@ static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm ...@@ -1271,66 +1240,65 @@ static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm
/* The SCU does not need to have a discrete reset state so /* The SCU does not need to have a discrete reset state so
* just go back to the starting state. * just go back to the starting state.
*/ */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_change_state(&sci_phy->sm, SCI_PHY_STARTING);
SCI_BASE_PHY_STATE_STARTING);
} }
} }
static const struct sci_base_state scic_sds_phy_state_table[] = { static const struct sci_base_state scic_sds_phy_state_table[] = {
[SCI_BASE_PHY_STATE_INITIAL] = { }, [SCI_PHY_INITIAL] = { },
[SCI_BASE_PHY_STATE_STOPPED] = { [SCI_PHY_STOPPED] = {
.enter_state = scic_sds_phy_stopped_state_enter, .enter_state = scic_sds_phy_stopped_state_enter,
}, },
[SCI_BASE_PHY_STATE_STARTING] = { [SCI_PHY_STARTING] = {
.enter_state = scic_sds_phy_starting_state_enter, .enter_state = scic_sds_phy_starting_state_enter,
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { [SCI_PHY_SUB_INITIAL] = {
.enter_state = scic_sds_phy_starting_initial_substate_enter, .enter_state = scic_sds_phy_starting_initial_substate_enter,
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { }, [SCI_PHY_SUB_AWAIT_OSSP_EN] = { },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { }, [SCI_PHY_SUB_AWAIT_SAS_SPEED_EN] = { },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { }, [SCI_PHY_SUB_AWAIT_IAF_UF] = { },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { [SCI_PHY_SUB_AWAIT_SAS_POWER] = {
.enter_state = scic_sds_phy_starting_await_sas_power_substate_enter, .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter,
.exit_state = scic_sds_phy_starting_await_sas_power_substate_exit, .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit,
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { [SCI_PHY_SUB_AWAIT_SATA_POWER] = {
.enter_state = scic_sds_phy_starting_await_sata_power_substate_enter, .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter,
.exit_state = scic_sds_phy_starting_await_sata_power_substate_exit .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { [SCI_PHY_SUB_AWAIT_SATA_PHY_EN] = {
.enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter, .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter,
.exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { [SCI_PHY_SUB_AWAIT_SATA_SPEED_EN] = {
.enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter, .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter,
.exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { [SCI_PHY_SUB_AWAIT_SIG_FIS_UF] = {
.enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter, .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter,
.exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit
}, },
[SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { [SCI_PHY_SUB_FINAL] = {
.enter_state = scic_sds_phy_starting_final_substate_enter, .enter_state = scic_sds_phy_starting_final_substate_enter,
}, },
[SCI_BASE_PHY_STATE_READY] = { [SCI_PHY_READY] = {
.enter_state = scic_sds_phy_ready_state_enter, .enter_state = scic_sds_phy_ready_state_enter,
.exit_state = scic_sds_phy_ready_state_exit, .exit_state = scic_sds_phy_ready_state_exit,
}, },
[SCI_BASE_PHY_STATE_RESETTING] = { [SCI_PHY_RESETTING] = {
.enter_state = scic_sds_phy_resetting_state_enter, .enter_state = scic_sds_phy_resetting_state_enter,
}, },
[SCI_BASE_PHY_STATE_FINAL] = { }, [SCI_PHY_FINAL] = { },
}; };
void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
struct scic_sds_port *owning_port, u8 phy_index) struct scic_sds_port *owning_port, u8 phy_index)
{ {
sci_base_state_machine_construct(&sci_phy->state_machine, sci_base_state_machine_construct(&sci_phy->sm,
scic_sds_phy_state_table, scic_sds_phy_state_table,
SCI_BASE_PHY_STATE_INITIAL); SCI_PHY_INITIAL);
sci_base_state_machine_start(&sci_phy->state_machine); sci_base_state_machine_start(&sci_phy->sm);
/* Copy the rest of the input data to our locals */ /* Copy the rest of the input data to our locals */
sci_phy->owning_port = owning_port; sci_phy->owning_port = owning_port;
......
...@@ -94,7 +94,7 @@ struct scic_sds_phy { ...@@ -94,7 +94,7 @@ struct scic_sds_phy {
/** /**
* This field contains the information for the base phy state machine. * This field contains the information for the base phy state machine.
*/ */
struct sci_base_state_machine state_machine; struct sci_base_state_machine sm;
/** /**
* This field specifies the port object that owns/contains this phy. * This field specifies the port object that owns/contains this phy.
...@@ -410,7 +410,7 @@ enum scic_sds_phy_states { ...@@ -410,7 +410,7 @@ enum scic_sds_phy_states {
/** /**
* Simply the initial state for the base domain state machine. * Simply the initial state for the base domain state machine.
*/ */
SCI_BASE_PHY_STATE_INITIAL, SCI_PHY_INITIAL,
/** /**
* This state indicates that the phy has successfully been stopped. * This state indicates that the phy has successfully been stopped.
...@@ -420,7 +420,7 @@ enum scic_sds_phy_states { ...@@ -420,7 +420,7 @@ enum scic_sds_phy_states {
* This state is entered from the READY state. * This state is entered from the READY state.
* This state is entered from the RESETTING state. * This state is entered from the RESETTING state.
*/ */
SCI_BASE_PHY_STATE_STOPPED, SCI_PHY_STOPPED,
/** /**
* This state indicates that the phy is in the process of becomming * This state indicates that the phy is in the process of becomming
...@@ -429,57 +429,57 @@ enum scic_sds_phy_states { ...@@ -429,57 +429,57 @@ enum scic_sds_phy_states {
* This state is entered from the READY state. * This state is entered from the READY state.
* This state is entered from the RESETTING state. * This state is entered from the RESETTING state.
*/ */
SCI_BASE_PHY_STATE_STARTING, SCI_PHY_STARTING,
/** /**
* Initial state * Initial state
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL, SCI_PHY_SUB_INITIAL,
/** /**
* Wait state for the hardware OSSP event type notification * Wait state for the hardware OSSP event type notification
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN, SCI_PHY_SUB_AWAIT_OSSP_EN,
/** /**
* Wait state for the PHY speed notification * Wait state for the PHY speed notification
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN, SCI_PHY_SUB_AWAIT_SAS_SPEED_EN,
/** /**
* Wait state for the IAF Unsolicited frame notification * Wait state for the IAF Unsolicited frame notification
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF, SCI_PHY_SUB_AWAIT_IAF_UF,
/** /**
* Wait state for the request to consume power * Wait state for the request to consume power
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER, SCI_PHY_SUB_AWAIT_SAS_POWER,
/** /**
* Wait state for request to consume power * Wait state for request to consume power
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER, SCI_PHY_SUB_AWAIT_SATA_POWER,
/** /**
* Wait state for the SATA PHY notification * Wait state for the SATA PHY notification
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN, SCI_PHY_SUB_AWAIT_SATA_PHY_EN,
/** /**
* Wait for the SATA PHY speed notification * Wait for the SATA PHY speed notification
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN,
/** /**
* Wait state for the SIGNATURE FIS unsolicited frame notification * Wait state for the SIGNATURE FIS unsolicited frame notification
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF, SCI_PHY_SUB_AWAIT_SIG_FIS_UF,
/** /**
* Exit state for this state machine * Exit state for this state machine
*/ */
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL, SCI_PHY_SUB_FINAL,
/** /**
* This state indicates the the phy is now ready. Thus, the user * This state indicates the the phy is now ready. Thus, the user
...@@ -487,19 +487,19 @@ enum scic_sds_phy_states { ...@@ -487,19 +487,19 @@ enum scic_sds_phy_states {
* is currently part of a valid port. * is currently part of a valid port.
* This state is entered from the STARTING state. * This state is entered from the STARTING state.
*/ */
SCI_BASE_PHY_STATE_READY, SCI_PHY_READY,
/** /**
* This state indicates that the phy is in the process of being reset. * This state indicates that the phy is in the process of being reset.
* In this state no new IO operations are permitted on this phy. * In this state no new IO operations are permitted on this phy.
* This state is entered from the READY state. * This state is entered from the READY state.
*/ */
SCI_BASE_PHY_STATE_RESETTING, SCI_PHY_RESETTING,
/** /**
* Simply the final state for the base phy state machine. * Simply the final state for the base phy state machine.
*/ */
SCI_BASE_PHY_STATE_FINAL, SCI_PHY_FINAL,
}; };
/** /**
......
...@@ -807,10 +807,10 @@ static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port, ...@@ -807,10 +807,10 @@ static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port,
static bool is_port_ready_state(enum scic_sds_port_states state) static bool is_port_ready_state(enum scic_sds_port_states state)
{ {
switch (state) { switch (state) {
case SCI_BASE_PORT_STATE_READY: case SCI_PORT_READY:
case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: case SCI_PORT_SUB_WAITING:
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: case SCI_PORT_SUB_CONFIGURING:
return true; return true;
default: default:
return false; return false;
...@@ -821,13 +821,13 @@ static bool is_port_ready_state(enum scic_sds_port_states state) ...@@ -821,13 +821,13 @@ static bool is_port_ready_state(enum scic_sds_port_states state)
static void port_state_machine_change(struct scic_sds_port *sci_port, static void port_state_machine_change(struct scic_sds_port *sci_port,
enum scic_sds_port_states state) enum scic_sds_port_states state)
{ {
struct sci_base_state_machine *sm = &sci_port->state_machine; struct sci_base_state_machine *sm = &sci_port->sm;
enum scic_sds_port_states old_state = sm->current_state_id; enum scic_sds_port_states old_state = sm->current_state_id;
if (is_port_ready_state(old_state) && !is_port_ready_state(state)) if (is_port_ready_state(old_state) && !is_port_ready_state(state))
sci_port->ready_exit = true; sci_port->ready_exit = true;
sci_base_state_machine_change_state(sm, state); sci_change_state(sm, state);
sci_port->ready_exit = false; sci_port->ready_exit = false;
} }
...@@ -862,11 +862,11 @@ static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port ...@@ -862,11 +862,11 @@ static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port
if ((phy_sas_address.high == port_sas_address.high && if ((phy_sas_address.high == port_sas_address.high &&
phy_sas_address.low == port_sas_address.low) || phy_sas_address.low == port_sas_address.low) ||
sci_port->active_phy_mask == 0) { sci_port->active_phy_mask == 0) {
struct sci_base_state_machine *sm = &sci_port->state_machine; struct sci_base_state_machine *sm = &sci_port->sm;
scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user); scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user);
if (sm->current_state_id == SCI_BASE_PORT_STATE_RESETTING) if (sm->current_state_id == SCI_PORT_RESETTING)
port_state_machine_change(sci_port, SCI_BASE_PORT_STATE_READY); port_state_machine_change(sci_port, SCI_PORT_READY);
} else } else
scic_sds_port_invalid_link_up(sci_port, sci_phy); scic_sds_port_invalid_link_up(sci_port, sci_phy);
} }
...@@ -938,14 +938,14 @@ static void port_timeout(unsigned long data) ...@@ -938,14 +938,14 @@ static void port_timeout(unsigned long data)
if (tmr->cancel) if (tmr->cancel)
goto done; goto done;
current_state = sci_base_state_machine_get_state(&sci_port->state_machine); current_state = sci_port->sm.current_state_id;
if (current_state == SCI_BASE_PORT_STATE_RESETTING) { if (current_state == SCI_PORT_RESETTING) {
/* if the port is still in the resetting state then the timeout /* if the port is still in the resetting state then the timeout
* fired before the reset completed. * fired before the reset completed.
*/ */
port_state_machine_change(sci_port, SCI_BASE_PORT_STATE_FAILED); port_state_machine_change(sci_port, SCI_PORT_FAILED);
} else if (current_state == SCI_BASE_PORT_STATE_STOPPED) { } else if (current_state == SCI_PORT_STOPPED) {
/* if the port is stopped then the start request failed In this /* if the port is stopped then the start request failed In this
* case stay in the stopped state. * case stay in the stopped state.
*/ */
...@@ -953,7 +953,7 @@ static void port_timeout(unsigned long data) ...@@ -953,7 +953,7 @@ static void port_timeout(unsigned long data)
"%s: SCIC Port 0x%p failed to stop before tiemout.\n", "%s: SCIC Port 0x%p failed to stop before tiemout.\n",
__func__, __func__,
sci_port); sci_port);
} else if (current_state == SCI_BASE_PORT_STATE_STOPPING) { } else if (current_state == SCI_PORT_STOPPING) {
/* if the port is still stopping then the stop has not completed */ /* if the port is still stopping then the stop has not completed */
isci_port_stop_complete(sci_port->owning_controller, isci_port_stop_complete(sci_port->owning_controller,
sci_port, sci_port,
...@@ -1139,7 +1139,7 @@ scic_sds_port_resume_port_task_scheduler(struct scic_sds_port *port) ...@@ -1139,7 +1139,7 @@ scic_sds_port_resume_port_task_scheduler(struct scic_sds_port *port)
static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm) static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
scic_sds_port_suspend_port_task_scheduler(sci_port); scic_sds_port_suspend_port_task_scheduler(sci_port);
...@@ -1148,14 +1148,14 @@ static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_mac ...@@ -1148,14 +1148,14 @@ static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_mac
if (sci_port->active_phy_mask != 0) { if (sci_port->active_phy_mask != 0) {
/* At least one of the phys on the port is ready */ /* At least one of the phys on the port is ready */
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL); SCI_PORT_SUB_OPERATIONAL);
} }
} }
static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm) static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm)
{ {
u32 index; u32 index;
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
...@@ -1211,12 +1211,12 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci ...@@ -1211,12 +1211,12 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci
* @object: This is the object which is cast to a struct scic_sds_port object. * @object: This is the object which is cast to a struct scic_sds_port object.
* *
* This method will perform the actions required by the struct scic_sds_port on * This method will perform the actions required by the struct scic_sds_port on
* exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports * exiting the SCI_PORT_SUB_OPERATIONAL. This function reports
* the port not ready and suspends the port task scheduler. none * the port not ready and suspends the port task scheduler. none
*/ */
static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm) static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
...@@ -1236,7 +1236,7 @@ static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_ ...@@ -1236,7 +1236,7 @@ static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_
static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm) static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
...@@ -1245,15 +1245,15 @@ static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state ...@@ -1245,15 +1245,15 @@ static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state
isci_port_not_ready(ihost, iport); isci_port_not_ready(ihost, iport);
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING); SCI_PORT_SUB_WAITING);
} else if (sci_port->started_request_count == 0) } else if (sci_port->started_request_count == 0)
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL); SCI_PORT_SUB_OPERATIONAL);
} }
static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm) static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
scic_sds_port_suspend_port_task_scheduler(sci_port); scic_sds_port_suspend_port_task_scheduler(sci_port);
if (sci_port->ready_exit) if (sci_port->ready_exit)
...@@ -1267,8 +1267,8 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) ...@@ -1267,8 +1267,8 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port)
enum scic_sds_port_states state; enum scic_sds_port_states state;
u32 phy_mask; u32 phy_mask;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
if (state != SCI_BASE_PORT_STATE_STOPPED) { if (state != SCI_PORT_STOPPED) {
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
"%s: in wrong state: %d\n", __func__, state); "%s: in wrong state: %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -1315,7 +1315,7 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) ...@@ -1315,7 +1315,7 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port)
*/ */
if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) {
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCI_BASE_PORT_STATE_READY); SCI_PORT_READY);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1332,16 +1332,16 @@ enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port) ...@@ -1332,16 +1332,16 @@ enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port)
{ {
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_PORT_STATE_STOPPED: case SCI_PORT_STOPPED:
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: case SCI_PORT_SUB_WAITING:
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: case SCI_PORT_SUB_CONFIGURING:
case SCI_BASE_PORT_STATE_RESETTING: case SCI_PORT_RESETTING:
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCI_BASE_PORT_STATE_STOPPING); SCI_PORT_STOPPING);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
...@@ -1357,8 +1357,8 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 ...@@ -1357,8 +1357,8 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
enum scic_sds_port_states state; enum scic_sds_port_states state;
u32 phy_index; u32 phy_index;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
if (state != SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL) { if (state != SCI_PORT_SUB_OPERATIONAL) {
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
"%s: in wrong state: %d\n", __func__, state); "%s: in wrong state: %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -1389,7 +1389,7 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 ...@@ -1389,7 +1389,7 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCI_BASE_PORT_STATE_RESETTING); SCI_PORT_RESETTING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -1408,9 +1408,9 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, ...@@ -1408,9 +1408,9 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
enum sci_status status; enum sci_status status;
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_PORT_STATE_STOPPED: { case SCI_PORT_STOPPED: {
struct sci_sas_address port_sas_address; struct sci_sas_address port_sas_address;
/* Read the port assigned SAS Address if there is one */ /* Read the port assigned SAS Address if there is one */
...@@ -1430,8 +1430,8 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, ...@@ -1430,8 +1430,8 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
} }
return scic_sds_port_set_phy(sci_port, sci_phy); return scic_sds_port_set_phy(sci_port, sci_phy);
} }
case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: case SCI_PORT_SUB_WAITING:
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
status = scic_sds_port_set_phy(sci_port, sci_phy); status = scic_sds_port_set_phy(sci_port, sci_phy);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
...@@ -1439,10 +1439,10 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, ...@@ -1439,10 +1439,10 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); scic_sds_port_general_link_up_handler(sci_port, sci_phy, true);
sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
port_state_machine_change(sci_port, SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); port_state_machine_change(sci_port, SCI_PORT_SUB_CONFIGURING);
return status; return status;
case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: case SCI_PORT_SUB_CONFIGURING:
status = scic_sds_port_set_phy(sci_port, sci_phy); status = scic_sds_port_set_phy(sci_port, sci_phy);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
...@@ -1453,7 +1453,7 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, ...@@ -1453,7 +1453,7 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
* the port. * the port.
*/ */
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); SCI_PORT_SUB_CONFIGURING);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
...@@ -1477,12 +1477,12 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port, ...@@ -1477,12 +1477,12 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
enum sci_status status; enum sci_status status;
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_PORT_STATE_STOPPED: case SCI_PORT_STOPPED:
return scic_sds_port_clear_phy(sci_port, sci_phy); return scic_sds_port_clear_phy(sci_port, sci_phy);
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
status = scic_sds_port_clear_phy(sci_port, sci_phy); status = scic_sds_port_clear_phy(sci_port, sci_phy);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
...@@ -1490,9 +1490,9 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port, ...@@ -1490,9 +1490,9 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
scic_sds_port_deactivate_phy(sci_port, sci_phy, true); scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); SCI_PORT_SUB_CONFIGURING);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: case SCI_PORT_SUB_CONFIGURING:
status = scic_sds_port_clear_phy(sci_port, sci_phy); status = scic_sds_port_clear_phy(sci_port, sci_phy);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
...@@ -1503,7 +1503,7 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port, ...@@ -1503,7 +1503,7 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
* the port * the port
*/ */
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); SCI_PORT_SUB_CONFIGURING);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
...@@ -1517,21 +1517,21 @@ enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port, ...@@ -1517,21 +1517,21 @@ enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
{ {
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: case SCI_PORT_SUB_WAITING:
/* Since this is the first phy going link up for the port we /* Since this is the first phy going link up for the port we
* can just enable it and continue * can just enable it and continue
*/ */
scic_sds_port_activate_phy(sci_port, sci_phy, true); scic_sds_port_activate_phy(sci_port, sci_phy, true);
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL); SCI_PORT_SUB_OPERATIONAL);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); scic_sds_port_general_link_up_handler(sci_port, sci_phy, true);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_PORT_STATE_RESETTING: case SCI_PORT_RESETTING:
/* TODO We should make sure that the phy that has gone /* TODO We should make sure that the phy that has gone
* link up is the same one on which we sent the reset. It is * link up is the same one on which we sent the reset. It is
* possible that the phy on which we sent the reset is not the * possible that the phy on which we sent the reset is not the
...@@ -1560,9 +1560,9 @@ enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port, ...@@ -1560,9 +1560,9 @@ enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port,
{ {
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
scic_sds_port_deactivate_phy(sci_port, sci_phy, true); scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
/* If there are no active phys left in the port, then /* If there are no active phys left in the port, then
...@@ -1571,9 +1571,9 @@ enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port, ...@@ -1571,9 +1571,9 @@ enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port,
*/ */
if (sci_port->active_phy_mask == 0) if (sci_port->active_phy_mask == 0)
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING); SCI_PORT_SUB_WAITING);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_PORT_STATE_RESETTING: case SCI_PORT_RESETTING:
/* In the resetting state we don't notify the user regarding /* In the resetting state we don't notify the user regarding
* link up and link down notifications. */ * link up and link down notifications. */
scic_sds_port_deactivate_phy(sci_port, sci_phy, false); scic_sds_port_deactivate_phy(sci_port, sci_phy, false);
...@@ -1591,11 +1591,11 @@ enum sci_status scic_sds_port_start_io(struct scic_sds_port *sci_port, ...@@ -1591,11 +1591,11 @@ enum sci_status scic_sds_port_start_io(struct scic_sds_port *sci_port,
{ {
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: case SCI_PORT_SUB_WAITING:
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
sci_port->started_request_count++; sci_port->started_request_count++;
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
...@@ -1611,31 +1611,31 @@ enum sci_status scic_sds_port_complete_io(struct scic_sds_port *sci_port, ...@@ -1611,31 +1611,31 @@ enum sci_status scic_sds_port_complete_io(struct scic_sds_port *sci_port,
{ {
enum scic_sds_port_states state; enum scic_sds_port_states state;
state = sci_port->state_machine.current_state_id; state = sci_port->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_PORT_STATE_STOPPED: case SCI_PORT_STOPPED:
dev_warn(sciport_to_dev(sci_port), dev_warn(sciport_to_dev(sci_port),
"%s: in wrong state: %d\n", __func__, state); "%s: in wrong state: %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCI_BASE_PORT_STATE_STOPPING: case SCI_PORT_STOPPING:
scic_sds_port_decrement_request_count(sci_port); scic_sds_port_decrement_request_count(sci_port);
if (sci_port->started_request_count == 0) if (sci_port->started_request_count == 0)
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCI_BASE_PORT_STATE_STOPPED); SCI_PORT_STOPPED);
break; break;
case SCI_BASE_PORT_STATE_READY: case SCI_PORT_READY:
case SCI_BASE_PORT_STATE_RESETTING: case SCI_PORT_RESETTING:
case SCI_BASE_PORT_STATE_FAILED: case SCI_PORT_FAILED:
case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: case SCI_PORT_SUB_WAITING:
case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: case SCI_PORT_SUB_OPERATIONAL:
scic_sds_port_decrement_request_count(sci_port); scic_sds_port_decrement_request_count(sci_port);
break; break;
case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: case SCI_PORT_SUB_CONFIGURING:
scic_sds_port_decrement_request_count(sci_port); scic_sds_port_decrement_request_count(sci_port);
if (sci_port->started_request_count == 0) { if (sci_port->started_request_count == 0) {
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL); SCI_PORT_SUB_OPERATIONAL);
} }
break; break;
} }
...@@ -1707,9 +1707,9 @@ static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port) ...@@ -1707,9 +1707,9 @@ static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm) static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
if (sci_port->state_machine.previous_state_id == SCI_BASE_PORT_STATE_STOPPING) { if (sci_port->sm.previous_state_id == SCI_PORT_STOPPING) {
/* /*
* If we enter this state becasuse of a request to stop * If we enter this state becasuse of a request to stop
* the port then we want to disable the hardwares port * the port then we want to disable the hardwares port
...@@ -1720,7 +1720,7 @@ static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm) ...@@ -1720,7 +1720,7 @@ static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm) static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
/* Enable and suspend the port task scheduler */ /* Enable and suspend the port task scheduler */
scic_sds_port_enable_port_task_scheduler(sci_port); scic_sds_port_enable_port_task_scheduler(sci_port);
...@@ -1728,14 +1728,14 @@ static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm) ...@@ -1728,14 +1728,14 @@ static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm) static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
u32 prev_state; u32 prev_state;
prev_state = sci_port->state_machine.previous_state_id; prev_state = sci_port->sm.previous_state_id;
if (prev_state == SCI_BASE_PORT_STATE_RESETTING) if (prev_state == SCI_PORT_RESETTING)
isci_port_hard_reset_complete(iport, SCI_SUCCESS); isci_port_hard_reset_complete(iport, SCI_SUCCESS);
else else
isci_port_not_ready(ihost, iport); isci_port_not_ready(ihost, iport);
...@@ -1745,19 +1745,19 @@ static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm) ...@@ -1745,19 +1745,19 @@ static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
/* Start the ready substate machine */ /* Start the ready substate machine */
port_state_machine_change(sci_port, port_state_machine_change(sci_port,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING); SCI_PORT_SUB_WAITING);
} }
static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm) static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
sci_del_timer(&sci_port->timer); sci_del_timer(&sci_port->timer);
} }
static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm) static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
sci_del_timer(&sci_port->timer); sci_del_timer(&sci_port->timer);
...@@ -1766,7 +1766,7 @@ static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm) ...@@ -1766,7 +1766,7 @@ static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm)
static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm) static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT); isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT);
...@@ -1775,31 +1775,31 @@ static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm) ...@@ -1775,31 +1775,31 @@ static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm)
/* --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- */
static const struct sci_base_state scic_sds_port_state_table[] = { static const struct sci_base_state scic_sds_port_state_table[] = {
[SCI_BASE_PORT_STATE_STOPPED] = { [SCI_PORT_STOPPED] = {
.enter_state = scic_sds_port_stopped_state_enter, .enter_state = scic_sds_port_stopped_state_enter,
.exit_state = scic_sds_port_stopped_state_exit .exit_state = scic_sds_port_stopped_state_exit
}, },
[SCI_BASE_PORT_STATE_STOPPING] = { [SCI_PORT_STOPPING] = {
.exit_state = scic_sds_port_stopping_state_exit .exit_state = scic_sds_port_stopping_state_exit
}, },
[SCI_BASE_PORT_STATE_READY] = { [SCI_PORT_READY] = {
.enter_state = scic_sds_port_ready_state_enter, .enter_state = scic_sds_port_ready_state_enter,
}, },
[SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = { [SCI_PORT_SUB_WAITING] = {
.enter_state = scic_sds_port_ready_substate_waiting_enter, .enter_state = scic_sds_port_ready_substate_waiting_enter,
}, },
[SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL] = { [SCI_PORT_SUB_OPERATIONAL] = {
.enter_state = scic_sds_port_ready_substate_operational_enter, .enter_state = scic_sds_port_ready_substate_operational_enter,
.exit_state = scic_sds_port_ready_substate_operational_exit .exit_state = scic_sds_port_ready_substate_operational_exit
}, },
[SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING] = { [SCI_PORT_SUB_CONFIGURING] = {
.enter_state = scic_sds_port_ready_substate_configuring_enter, .enter_state = scic_sds_port_ready_substate_configuring_enter,
.exit_state = scic_sds_port_ready_substate_configuring_exit .exit_state = scic_sds_port_ready_substate_configuring_exit
}, },
[SCI_BASE_PORT_STATE_RESETTING] = { [SCI_PORT_RESETTING] = {
.exit_state = scic_sds_port_resetting_state_exit .exit_state = scic_sds_port_resetting_state_exit
}, },
[SCI_BASE_PORT_STATE_FAILED] = { [SCI_PORT_FAILED] = {
.enter_state = scic_sds_port_failed_state_enter, .enter_state = scic_sds_port_failed_state_enter,
} }
}; };
...@@ -1807,11 +1807,11 @@ static const struct sci_base_state scic_sds_port_state_table[] = { ...@@ -1807,11 +1807,11 @@ static const struct sci_base_state scic_sds_port_state_table[] = {
void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index, void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index,
struct scic_sds_controller *scic) struct scic_sds_controller *scic)
{ {
sci_base_state_machine_construct(&sci_port->state_machine, sci_base_state_machine_construct(&sci_port->sm,
scic_sds_port_state_table, scic_sds_port_state_table,
SCI_BASE_PORT_STATE_STOPPED); SCI_PORT_STOPPED);
sci_base_state_machine_start(&sci_port->state_machine); sci_base_state_machine_start(&sci_port->sm);
sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT; sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
sci_port->physical_port_index = index; sci_port->physical_port_index = index;
......
...@@ -84,7 +84,7 @@ struct scic_sds_port { ...@@ -84,7 +84,7 @@ struct scic_sds_port {
/** /**
* This field contains the information for the base port state machine. * This field contains the information for the base port state machine.
*/ */
struct sci_base_state_machine state_machine; struct sci_base_state_machine sm;
bool ready_exit; bool ready_exit;
...@@ -224,7 +224,7 @@ enum scic_sds_port_states { ...@@ -224,7 +224,7 @@ enum scic_sds_port_states {
* In this state no new IO operations are permitted. * In this state no new IO operations are permitted.
* This state is entered from the STOPPING state. * This state is entered from the STOPPING state.
*/ */
SCI_BASE_PORT_STATE_STOPPED, SCI_PORT_STOPPED,
/** /**
* This state indicates that the port is in the process of stopping. * This state indicates that the port is in the process of stopping.
...@@ -232,33 +232,33 @@ enum scic_sds_port_states { ...@@ -232,33 +232,33 @@ enum scic_sds_port_states {
* operations are allowed to complete. * operations are allowed to complete.
* This state is entered from the READY state. * This state is entered from the READY state.
*/ */
SCI_BASE_PORT_STATE_STOPPING, SCI_PORT_STOPPING,
/** /**
* This state indicates the port is now ready. Thus, the user is * This state indicates the port is now ready. Thus, the user is
* able to perform IO operations on this port. * able to perform IO operations on this port.
* This state is entered from the STARTING state. * This state is entered from the STARTING state.
*/ */
SCI_BASE_PORT_STATE_READY, SCI_PORT_READY,
/** /**
* The substate where the port is started and ready but has no * The substate where the port is started and ready but has no
* active phys. * active phys.
*/ */
SCIC_SDS_PORT_READY_SUBSTATE_WAITING, SCI_PORT_SUB_WAITING,
/** /**
* The substate where the port is started and ready and there is * The substate where the port is started and ready and there is
* at least one phy operational. * at least one phy operational.
*/ */
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL, SCI_PORT_SUB_OPERATIONAL,
/** /**
* The substate where the port is started and there was an * The substate where the port is started and there was an
* add/remove phy event. This state is only used in Automatic * add/remove phy event. This state is only used in Automatic
* Port Configuration Mode (APC) * Port Configuration Mode (APC)
*/ */
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING, SCI_PORT_SUB_CONFIGURING,
/** /**
* This state indicates the port is in the process of performing a hard * This state indicates the port is in the process of performing a hard
...@@ -266,14 +266,14 @@ enum scic_sds_port_states { ...@@ -266,14 +266,14 @@ enum scic_sds_port_states {
* port. * port.
* This state is entered from the READY state. * This state is entered from the READY state.
*/ */
SCI_BASE_PORT_STATE_RESETTING, SCI_PORT_RESETTING,
/** /**
* This state indicates the port has failed a reset request. This state * This state indicates the port has failed a reset request. This state
* is entered when a port reset request times out. * is entered when a port reset request times out.
* This state is entered from the RESETTING state. * This state is entered from the RESETTING state.
*/ */
SCI_BASE_PORT_STATE_FAILED, SCI_PORT_FAILED,
}; };
......
...@@ -661,13 +661,13 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic, ...@@ -661,13 +661,13 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true); scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true);
} else { } else {
/* the phy is already the part of the port */ /* the phy is already the part of the port */
u32 port_state = sci_port->state_machine.current_state_id; u32 port_state = sci_port->sm.current_state_id;
/* if the PORT'S state is resetting then the link up is from /* if the PORT'S state is resetting then the link up is from
* port hard reset in this case, we need to tell the port * port hard reset in this case, we need to tell the port
* that link up is recieved * that link up is recieved
*/ */
BUG_ON(port_state != SCI_BASE_PORT_STATE_RESETTING); BUG_ON(port_state != SCI_PORT_RESETTING);
port_agent->phy_ready_mask |= 1 << phy_index; port_agent->phy_ready_mask |= 1 << phy_index;
scic_sds_port_link_up(sci_port, sci_phy); scic_sds_port_link_up(sci_port, sci_phy);
} }
......
...@@ -126,8 +126,7 @@ static void rnc_destruct_done(void *_dev) ...@@ -126,8 +126,7 @@ static void rnc_destruct_done(void *_dev)
struct scic_sds_remote_device *sci_dev = _dev; struct scic_sds_remote_device *sci_dev = _dev;
BUG_ON(sci_dev->started_request_count != 0); BUG_ON(sci_dev->started_request_count != 0);
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_DEV_STOPPED);
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
} }
static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds_remote_device *sci_dev) static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds_remote_device *sci_dev)
...@@ -154,20 +153,20 @@ static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds ...@@ -154,20 +153,20 @@ static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds
enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev, enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev,
u32 timeout) u32 timeout)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: case SCI_DEV_INITIAL:
case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: case SCI_DEV_FAILED:
case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: case SCI_DEV_FINAL:
default: default:
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: case SCI_DEV_STOPPED:
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: case SCI_DEV_STARTING:
/* device not started so there had better be no requests */ /* device not started so there had better be no requests */
BUG_ON(sci_dev->started_request_count != 0); BUG_ON(sci_dev->started_request_count != 0);
scic_sds_remote_node_context_destruct(&sci_dev->rnc, scic_sds_remote_node_context_destruct(&sci_dev->rnc,
...@@ -175,17 +174,17 @@ enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev, ...@@ -175,17 +174,17 @@ enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev,
/* Transition to the stopping state and wait for the /* Transition to the stopping state and wait for the
* remote node to complete being posted and invalidated. * remote node to complete being posted and invalidated.
*/ */
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); sci_change_state(sm, SCI_DEV_STOPPING);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_STP_DEV_IDLE:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: case SCI_STP_DEV_NCQ:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); sci_change_state(sm, SCI_DEV_STOPPING);
if (sci_dev->started_request_count == 0) { if (sci_dev->started_request_count == 0) {
scic_sds_remote_node_context_destruct(&sci_dev->rnc, scic_sds_remote_node_context_destruct(&sci_dev->rnc,
rnc_destruct_done, sci_dev); rnc_destruct_done, sci_dev);
...@@ -193,70 +192,70 @@ enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev, ...@@ -193,70 +192,70 @@ enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev,
} else } else
return scic_sds_remote_device_terminate_requests(sci_dev); return scic_sds_remote_device_terminate_requests(sci_dev);
break; break;
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: case SCI_DEV_STOPPING:
/* All requests should have been terminated, but if there is an /* All requests should have been terminated, but if there is an
* attempt to stop a device already in the stopping state, then * attempt to stop a device already in the stopping state, then
* try again to terminate. * try again to terminate.
*/ */
return scic_sds_remote_device_terminate_requests(sci_dev); return scic_sds_remote_device_terminate_requests(sci_dev);
case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: case SCI_DEV_RESETTING:
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); sci_change_state(sm, SCI_DEV_STOPPING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
} }
enum sci_status scic_remote_device_reset(struct scic_sds_remote_device *sci_dev) enum sci_status scic_remote_device_reset(struct scic_sds_remote_device *sci_dev)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: case SCI_DEV_INITIAL:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: case SCI_DEV_STOPPED:
case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: case SCI_DEV_STARTING:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: case SCI_DEV_STOPPING:
case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: case SCI_DEV_FAILED:
case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: case SCI_DEV_RESETTING:
case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: case SCI_DEV_FINAL:
default: default:
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_STP_DEV_IDLE:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: case SCI_STP_DEV_NCQ:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_RESETTING); sci_change_state(sm, SCI_DEV_RESETTING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
} }
enum sci_status scic_remote_device_reset_complete(struct scic_sds_remote_device *sci_dev) enum sci_status scic_remote_device_reset_complete(struct scic_sds_remote_device *sci_dev)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
if (state != SCI_BASE_REMOTE_DEVICE_STATE_RESETTING) { if (state != SCI_DEV_RESETTING) {
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
} }
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_READY); sci_change_state(sm, SCI_DEV_READY);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sci_dev, enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sci_dev,
u32 suspend_type) u32 suspend_type)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
if (state != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD) { if (state != SCI_STP_DEV_CMD) {
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -269,30 +268,30 @@ enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sc ...@@ -269,30 +268,30 @@ enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sc
enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_device *sci_dev, enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_device *sci_dev,
u32 frame_index) u32 frame_index)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
enum sci_status status; enum sci_status status;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: case SCI_DEV_INITIAL:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: case SCI_DEV_STOPPED:
case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: case SCI_DEV_STARTING:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_STP_DEV_IDLE:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: case SCI_DEV_FINAL:
default: default:
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
/* Return the frame back to the controller */ /* Return the frame back to the controller */
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: case SCI_DEV_STOPPING:
case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: case SCI_DEV_FAILED:
case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: { case SCI_DEV_RESETTING: {
struct scic_sds_request *sci_req; struct scic_sds_request *sci_req;
struct ssp_frame_hdr hdr; struct ssp_frame_hdr hdr;
void *frame_header; void *frame_header;
...@@ -319,7 +318,7 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi ...@@ -319,7 +318,7 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
} }
break; break;
} }
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: { case SCI_STP_DEV_NCQ: {
struct dev_to_host_fis *hdr; struct dev_to_host_fis *hdr;
status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control, status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
...@@ -333,7 +332,7 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi ...@@ -333,7 +332,7 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
/* TODO Check sactive and complete associated IO if any. */ /* TODO Check sactive and complete associated IO if any. */
sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR); sci_change_state(sm, SCI_STP_DEV_NCQ_ERROR);
} else if (hdr->fis_type == FIS_REGD2H && } else if (hdr->fis_type == FIS_REGD2H &&
(hdr->status & ATA_ERR)) { (hdr->status & ATA_ERR)) {
/* /*
...@@ -341,16 +340,15 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi ...@@ -341,16 +340,15 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
* Treat this like an SDB error FIS ready reason. * Treat this like an SDB error FIS ready reason.
*/ */
sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_STP_DEV_NCQ_ERROR);
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR);
} else } else
status = SCI_FAILURE; status = SCI_FAILURE;
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
break; break;
} }
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
/* The device does not process any UF received from the hardware while /* The device does not process any UF received from the hardware while
* in this state. All unsolicited frames are forwarded to the io request * in this state. All unsolicited frames are forwarded to the io request
* object. * object.
...@@ -365,18 +363,18 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi ...@@ -365,18 +363,18 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev) static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_STP_DEV_IDLE:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: case SCI_STP_DEV_NCQ:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
return true; return true;
default: default:
return false; return false;
...@@ -386,7 +384,7 @@ static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev) ...@@ -386,7 +384,7 @@ static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev)
enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_device *sci_dev, enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_device *sci_dev,
u32 event_code) u32 event_code)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
enum sci_status status; enum sci_status status;
...@@ -429,7 +427,7 @@ enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_devi ...@@ -429,7 +427,7 @@ enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_devi
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
if (state == SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE) { if (state == SCI_STP_DEV_IDLE) {
/* We pick up suspension events to handle specifically to this /* We pick up suspension events to handle specifically to this
* state. We resume the RNC right away. * state. We resume the RNC right away.
...@@ -459,26 +457,26 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic ...@@ -459,26 +457,26 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
struct scic_sds_remote_device *sci_dev, struct scic_sds_remote_device *sci_dev,
struct scic_sds_request *sci_req) struct scic_sds_request *sci_req)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
struct scic_sds_port *sci_port = sci_dev->owning_port; struct scic_sds_port *sci_port = sci_dev->owning_port;
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
enum sci_status status; enum sci_status status;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: case SCI_DEV_INITIAL:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: case SCI_DEV_STOPPED:
case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: case SCI_DEV_STARTING:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: case SCI_DEV_STOPPING:
case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: case SCI_DEV_FAILED:
case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: case SCI_DEV_RESETTING:
case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: case SCI_DEV_FINAL:
default: default:
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
/* attempt to start an io request for this device object. The remote /* attempt to start an io request for this device object. The remote
* device object will issue the start request for the io and if * device object will issue the start request for the io and if
* successful it will start the request for the port object then * successful it will start the request for the port object then
...@@ -494,7 +492,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic ...@@ -494,7 +492,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
status = scic_sds_request_start(sci_req); status = scic_sds_request_start(sci_req);
break; break;
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: { case SCI_STP_DEV_IDLE: {
/* handle the start io operation for a sata device that is in /* handle the start io operation for a sata device that is in
* the command idle state. - Evalute the type of IO request to * the command idle state. - Evalute the type of IO request to
* be started - If its an NCQ request change to NCQ substate - * be started - If its an NCQ request change to NCQ substate -
...@@ -519,15 +517,15 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic ...@@ -519,15 +517,15 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
break; break;
if (task->ata_task.use_ncq) if (task->ata_task.use_ncq)
new_state = SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ; new_state = SCI_STP_DEV_NCQ;
else { else {
sci_dev->working_request = sci_req; sci_dev->working_request = sci_req;
new_state = SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD; new_state = SCI_STP_DEV_CMD;
} }
sci_base_state_machine_change_state(sm, new_state); sci_change_state(sm, new_state);
break; break;
} }
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: { case SCI_STP_DEV_NCQ: {
struct sas_task *task = isci_request_access_task(ireq); struct sas_task *task = isci_request_access_task(ireq);
if (task->ata_task.use_ncq) { if (task->ata_task.use_ncq) {
...@@ -544,9 +542,9 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic ...@@ -544,9 +542,9 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
break; break;
} }
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); status = scic_sds_port_start_io(sci_port, sci_dev, sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
...@@ -560,11 +558,10 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic ...@@ -560,11 +558,10 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
break; break;
sci_dev->working_request = sci_req; sci_dev->working_request = sci_req;
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_SMP_DEV_CMD);
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD);
break; break;
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
/* device is already handling a command it can not accept new commands /* device is already handling a command it can not accept new commands
* until this one is complete. * until this one is complete.
*/ */
...@@ -597,31 +594,31 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s ...@@ -597,31 +594,31 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
struct scic_sds_remote_device *sci_dev, struct scic_sds_remote_device *sci_dev,
struct scic_sds_request *sci_req) struct scic_sds_request *sci_req)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
struct scic_sds_port *sci_port = sci_dev->owning_port; struct scic_sds_port *sci_port = sci_dev->owning_port;
enum sci_status status; enum sci_status status;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: case SCI_DEV_INITIAL:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: case SCI_DEV_STOPPED:
case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: case SCI_DEV_STARTING:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_STP_DEV_IDLE:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: case SCI_DEV_FAILED:
case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: case SCI_DEV_FINAL:
default: default:
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: case SCI_DEV_RESETTING:
status = common_complete_io(sci_port, sci_dev, sci_req); status = common_complete_io(sci_port, sci_dev, sci_req);
break; break;
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: case SCI_STP_DEV_NCQ:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
status = common_complete_io(sci_port, sci_dev, sci_req); status = common_complete_io(sci_port, sci_dev, sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
break; break;
...@@ -632,17 +629,17 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s ...@@ -632,17 +629,17 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
* can reach RNC state handler, these IOs will be completed by RNC with * can reach RNC state handler, these IOs will be completed by RNC with
* status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE". * status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE".
*/ */
sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET); sci_change_state(sm, SCI_STP_DEV_AWAIT_RESET);
} else if (scic_sds_remote_device_get_request_count(sci_dev) == 0) } else if (scic_sds_remote_device_get_request_count(sci_dev) == 0)
sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); sci_change_state(sm, SCI_STP_DEV_IDLE);
break; break;
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
status = common_complete_io(sci_port, sci_dev, sci_req); status = common_complete_io(sci_port, sci_dev, sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
break; break;
sci_base_state_machine_change_state(sm, SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); sci_change_state(sm, SCI_SMP_DEV_IDLE);
break; break;
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: case SCI_DEV_STOPPING:
status = common_complete_io(sci_port, sci_dev, sci_req); status = common_complete_io(sci_port, sci_dev, sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
break; break;
...@@ -676,30 +673,30 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc ...@@ -676,30 +673,30 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
struct scic_sds_remote_device *sci_dev, struct scic_sds_remote_device *sci_dev,
struct scic_sds_request *sci_req) struct scic_sds_request *sci_req)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
struct scic_sds_port *sci_port = sci_dev->owning_port; struct scic_sds_port *sci_port = sci_dev->owning_port;
enum sci_status status; enum sci_status status;
switch (state) { switch (state) {
case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: case SCI_DEV_INITIAL:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: case SCI_DEV_STOPPED:
case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: case SCI_DEV_STARTING:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_SMP_DEV_IDLE:
case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_SMP_DEV_CMD:
case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: case SCI_DEV_STOPPING:
case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: case SCI_DEV_FAILED:
case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: case SCI_DEV_RESETTING:
case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: case SCI_DEV_FINAL:
default: default:
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: case SCI_STP_DEV_IDLE:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: case SCI_STP_DEV_CMD:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: case SCI_STP_DEV_NCQ:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: case SCI_STP_DEV_NCQ_ERROR:
case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: case SCI_STP_DEV_AWAIT_RESET:
status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); status = scic_sds_port_start_io(sci_port, sci_dev, sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
...@@ -717,7 +714,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc ...@@ -717,7 +714,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
* management request. * management request.
*/ */
sci_dev->working_request = sci_req; sci_dev->working_request = sci_req;
sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD); sci_change_state(sm, SCI_STP_DEV_CMD);
/* The remote node context must cleanup the TCi to NCQ mapping /* The remote node context must cleanup the TCi to NCQ mapping
* table. The only way to do this correctly is to either write * table. The only way to do this correctly is to either write
...@@ -739,7 +736,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc ...@@ -739,7 +736,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
* post TC when RNC gets resumed. * post TC when RNC gets resumed.
*/ */
return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS; return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS;
case SCI_BASE_REMOTE_DEVICE_STATE_READY: case SCI_DEV_READY:
status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); status = scic_sds_port_start_io(sci_port, sci_dev, sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
...@@ -790,8 +787,7 @@ static void remote_device_resume_done(void *_dev) ...@@ -790,8 +787,7 @@ static void remote_device_resume_done(void *_dev)
return; return;
/* go 'ready' if we are not already in a ready state */ /* go 'ready' if we are not already in a ready state */
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_DEV_READY);
SCI_BASE_REMOTE_DEVICE_STATE_READY);
} }
static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(void *_dev) static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(void *_dev)
...@@ -803,17 +799,16 @@ static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handl ...@@ -803,17 +799,16 @@ static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handl
/* For NCQ operation we do not issue a isci_remote_device_not_ready(). /* For NCQ operation we do not issue a isci_remote_device_not_ready().
* As a result, avoid sending the ready notification. * As a result, avoid sending the ready notification.
*/ */
if (sci_dev->state_machine.previous_state_id != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ) if (sci_dev->sm.previous_state_id != SCI_STP_DEV_NCQ)
isci_remote_device_ready(scic_to_ihost(scic), idev); isci_remote_device_ready(scic_to_ihost(scic), idev);
} }
static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
/* Initial state is a transitional state to the stopped state */ /* Initial state is a transitional state to the stopped state */
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_DEV_STOPPED);
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
} }
/** /**
...@@ -831,11 +826,11 @@ static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_mac ...@@ -831,11 +826,11 @@ static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_mac
*/ */
static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev) static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
struct scic_sds_controller *scic; struct scic_sds_controller *scic;
if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { if (state != SCI_DEV_STOPPED) {
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -845,7 +840,7 @@ static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device ...@@ -845,7 +840,7 @@ static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device
scic_sds_controller_free_remote_node_context(scic, sci_dev, scic_sds_controller_free_remote_node_context(scic, sci_dev,
sci_dev->rnc.remote_node_index); sci_dev->rnc.remote_node_index);
sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_FINAL); sci_change_state(sm, SCI_DEV_FINAL);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -906,7 +901,7 @@ static void isci_remote_device_stop_complete(struct isci_host *ihost, ...@@ -906,7 +901,7 @@ static void isci_remote_device_stop_complete(struct isci_host *ihost,
static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
u32 prev_state; u32 prev_state;
...@@ -914,8 +909,8 @@ static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_mac ...@@ -914,8 +909,8 @@ static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_mac
/* If we are entering from the stopping state let the SCI User know that /* If we are entering from the stopping state let the SCI User know that
* the stop operation has completed. * the stop operation has completed.
*/ */
prev_state = sci_dev->state_machine.previous_state_id; prev_state = sci_dev->sm.previous_state_id;
if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) if (prev_state == SCI_DEV_STOPPING)
isci_remote_device_stop_complete(scic_to_ihost(scic), idev); isci_remote_device_stop_complete(scic_to_ihost(scic), idev);
scic_sds_controller_remote_device_stopped(scic, sci_dev); scic_sds_controller_remote_device_stopped(scic, sci_dev);
...@@ -923,7 +918,7 @@ static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_mac ...@@ -923,7 +918,7 @@ static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_mac
static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
...@@ -934,7 +929,7 @@ static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_ma ...@@ -934,7 +929,7 @@ static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_ma
static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
struct domain_device *dev = idev->domain_dev; struct domain_device *dev = idev->domain_dev;
...@@ -942,18 +937,16 @@ static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machi ...@@ -942,18 +937,16 @@ static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machi
scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++; scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++;
if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) {
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_STP_DEV_IDLE);
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
} else if (dev_is_expander(dev)) { } else if (dev_is_expander(dev)) {
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_change_state(&sci_dev->sm, SCI_SMP_DEV_IDLE);
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
} else } else
isci_remote_device_ready(scic_to_ihost(scic), idev); isci_remote_device_ready(scic_to_ihost(scic), idev);
} }
static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machine *sm) static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct domain_device *dev = sci_dev_to_domain(sci_dev); struct domain_device *dev = sci_dev_to_domain(sci_dev);
if (dev->dev_type == SAS_END_DEV) { if (dev->dev_type == SAS_END_DEV) {
...@@ -967,7 +960,7 @@ static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machin ...@@ -967,7 +960,7 @@ static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machin
static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
scic_sds_remote_node_context_suspend( scic_sds_remote_node_context_suspend(
&sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
...@@ -975,14 +968,14 @@ static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_m ...@@ -975,14 +968,14 @@ static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_m
static void scic_sds_remote_device_resetting_state_exit(struct sci_base_state_machine *sm) static void scic_sds_remote_device_resetting_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL);
} }
static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
sci_dev->working_request = NULL; sci_dev->working_request = NULL;
if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) { if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) {
...@@ -999,7 +992,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base ...@@ -999,7 +992,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base
static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
BUG_ON(sci_dev->working_request == NULL); BUG_ON(sci_dev->working_request == NULL);
...@@ -1010,7 +1003,7 @@ static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_ ...@@ -1010,7 +1003,7 @@ static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_
static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
...@@ -1021,7 +1014,7 @@ static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci ...@@ -1021,7 +1014,7 @@ static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci
static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev)); isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev));
...@@ -1029,7 +1022,7 @@ static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base ...@@ -1029,7 +1022,7 @@ static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base
static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
BUG_ON(sci_dev->working_request == NULL); BUG_ON(sci_dev->working_request == NULL);
...@@ -1040,50 +1033,50 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_ ...@@ -1040,50 +1033,50 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_
static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm) static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
sci_dev->working_request = NULL; sci_dev->working_request = NULL;
} }
static const struct sci_base_state scic_sds_remote_device_state_table[] = { static const struct sci_base_state scic_sds_remote_device_state_table[] = {
[SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { [SCI_DEV_INITIAL] = {
.enter_state = scic_sds_remote_device_initial_state_enter, .enter_state = scic_sds_remote_device_initial_state_enter,
}, },
[SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { [SCI_DEV_STOPPED] = {
.enter_state = scic_sds_remote_device_stopped_state_enter, .enter_state = scic_sds_remote_device_stopped_state_enter,
}, },
[SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { [SCI_DEV_STARTING] = {
.enter_state = scic_sds_remote_device_starting_state_enter, .enter_state = scic_sds_remote_device_starting_state_enter,
}, },
[SCI_BASE_REMOTE_DEVICE_STATE_READY] = { [SCI_DEV_READY] = {
.enter_state = scic_sds_remote_device_ready_state_enter, .enter_state = scic_sds_remote_device_ready_state_enter,
.exit_state = scic_sds_remote_device_ready_state_exit .exit_state = scic_sds_remote_device_ready_state_exit
}, },
[SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { [SCI_STP_DEV_IDLE] = {
.enter_state = scic_sds_stp_remote_device_ready_idle_substate_enter, .enter_state = scic_sds_stp_remote_device_ready_idle_substate_enter,
}, },
[SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { [SCI_STP_DEV_CMD] = {
.enter_state = scic_sds_stp_remote_device_ready_cmd_substate_enter, .enter_state = scic_sds_stp_remote_device_ready_cmd_substate_enter,
}, },
[SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { }, [SCI_STP_DEV_NCQ] = { },
[SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { [SCI_STP_DEV_NCQ_ERROR] = {
.enter_state = scic_sds_stp_remote_device_ready_ncq_error_substate_enter, .enter_state = scic_sds_stp_remote_device_ready_ncq_error_substate_enter,
}, },
[SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { }, [SCI_STP_DEV_AWAIT_RESET] = { },
[SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { [SCI_SMP_DEV_IDLE] = {
.enter_state = scic_sds_smp_remote_device_ready_idle_substate_enter, .enter_state = scic_sds_smp_remote_device_ready_idle_substate_enter,
}, },
[SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { [SCI_SMP_DEV_CMD] = {
.enter_state = scic_sds_smp_remote_device_ready_cmd_substate_enter, .enter_state = scic_sds_smp_remote_device_ready_cmd_substate_enter,
.exit_state = scic_sds_smp_remote_device_ready_cmd_substate_exit, .exit_state = scic_sds_smp_remote_device_ready_cmd_substate_exit,
}, },
[SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { }, [SCI_DEV_STOPPING] = { },
[SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { }, [SCI_DEV_FAILED] = { },
[SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { [SCI_DEV_RESETTING] = {
.enter_state = scic_sds_remote_device_resetting_state_enter, .enter_state = scic_sds_remote_device_resetting_state_enter,
.exit_state = scic_sds_remote_device_resetting_state_exit .exit_state = scic_sds_remote_device_resetting_state_exit
}, },
[SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { }, [SCI_DEV_FINAL] = { },
}; };
/** /**
...@@ -1102,11 +1095,11 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port, ...@@ -1102,11 +1095,11 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port,
sci_dev->owning_port = sci_port; sci_dev->owning_port = sci_port;
sci_dev->started_request_count = 0; sci_dev->started_request_count = 0;
sci_base_state_machine_construct(&sci_dev->state_machine, sci_base_state_machine_construct(&sci_dev->sm,
scic_sds_remote_device_state_table, scic_sds_remote_device_state_table,
SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); SCI_DEV_INITIAL);
sci_base_state_machine_start(&sci_dev->state_machine); sci_base_state_machine_start(&sci_dev->sm);
scic_sds_remote_node_context_construct(&sci_dev->rnc, scic_sds_remote_node_context_construct(&sci_dev->rnc,
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
...@@ -1224,11 +1217,11 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci ...@@ -1224,11 +1217,11 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev, static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev,
u32 timeout) u32 timeout)
{ {
struct sci_base_state_machine *sm = &sci_dev->state_machine; struct sci_base_state_machine *sm = &sci_dev->sm;
enum scic_sds_remote_device_states state = sm->current_state_id; enum scic_sds_remote_device_states state = sm->current_state_id;
enum sci_status status; enum sci_status status;
if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { if (state != SCI_DEV_STOPPED) {
dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
__func__, state); __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -1240,7 +1233,7 @@ static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *s ...@@ -1240,7 +1233,7 @@ static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *s
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STARTING); sci_change_state(sm, SCI_DEV_STARTING);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
......
...@@ -74,7 +74,7 @@ struct scic_sds_remote_device { ...@@ -74,7 +74,7 @@ struct scic_sds_remote_device {
* This field contains the information for the base remote device state * This field contains the information for the base remote device state
* machine. * machine.
*/ */
struct sci_base_state_machine state_machine; struct sci_base_state_machine sm;
/** /**
* This field is the programmed device port width. This value is * This field is the programmed device port width. This value is
...@@ -109,7 +109,7 @@ struct scic_sds_remote_device { ...@@ -109,7 +109,7 @@ struct scic_sds_remote_device {
/** /**
* This field contains the stated request count for the remote device. The * This field contains the stated request count for the remote device. The
* device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all * device can not reach the SCI_DEV_STOPPED until all
* requests are complete and the rnc_posted value is false. * requests are complete and the rnc_posted value is false.
*/ */
u32 started_request_count; u32 started_request_count;
...@@ -213,7 +213,7 @@ enum scic_sds_remote_device_states { ...@@ -213,7 +213,7 @@ enum scic_sds_remote_device_states {
/** /**
* Simply the initial state for the base remote device state machine. * Simply the initial state for the base remote device state machine.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, SCI_DEV_INITIAL,
/** /**
* This state indicates that the remote device has successfully been * This state indicates that the remote device has successfully been
...@@ -221,7 +221,7 @@ enum scic_sds_remote_device_states { ...@@ -221,7 +221,7 @@ enum scic_sds_remote_device_states {
* This state is entered from the INITIAL state. * This state is entered from the INITIAL state.
* This state is entered from the STOPPING state. * This state is entered from the STOPPING state.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, SCI_DEV_STOPPED,
/** /**
* This state indicates the the remote device is in the process of * This state indicates the the remote device is in the process of
...@@ -229,34 +229,34 @@ enum scic_sds_remote_device_states { ...@@ -229,34 +229,34 @@ enum scic_sds_remote_device_states {
* are permitted. * are permitted.
* This state is entered from the STOPPED state. * This state is entered from the STOPPED state.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_STARTING, SCI_DEV_STARTING,
/** /**
* This state indicates the remote device is now ready. Thus, the user * This state indicates the remote device is now ready. Thus, the user
* is able to perform IO operations on the remote device. * is able to perform IO operations on the remote device.
* This state is entered from the STARTING state. * This state is entered from the STARTING state.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_READY, SCI_DEV_READY,
/** /**
* This is the idle substate for the stp remote device. When there are no * This is the idle substate for the stp remote device. When there are no
* active IO for the device it is is in this state. * active IO for the device it is is in this state.
*/ */
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, SCI_STP_DEV_IDLE,
/** /**
* This is the command state for for the STP remote device. This state is * This is the command state for for the STP remote device. This state is
* entered when the device is processing a non-NCQ command. The device object * entered when the device is processing a non-NCQ command. The device object
* will fail any new start IO requests until this command is complete. * will fail any new start IO requests until this command is complete.
*/ */
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, SCI_STP_DEV_CMD,
/** /**
* This is the NCQ state for the STP remote device. This state is entered * This is the NCQ state for the STP remote device. This state is entered
* when the device is processing an NCQ reuqest. It will remain in this state * when the device is processing an NCQ reuqest. It will remain in this state
* so long as there is one or more NCQ requests being processed. * so long as there is one or more NCQ requests being processed.
*/ */
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, SCI_STP_DEV_NCQ,
/** /**
* This is the NCQ error state for the STP remote device. This state is * This is the NCQ error state for the STP remote device. This state is
...@@ -264,25 +264,25 @@ enum scic_sds_remote_device_states { ...@@ -264,25 +264,25 @@ enum scic_sds_remote_device_states {
* NCQ state. The device object will only accept a READ LOG command while in * NCQ state. The device object will only accept a READ LOG command while in
* this state. * this state.
*/ */
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, SCI_STP_DEV_NCQ_ERROR,
/** /**
* This is the READY substate indicates the device is waiting for the RESET task * This is the READY substate indicates the device is waiting for the RESET task
* coming to be recovered from certain hardware specific error. * coming to be recovered from certain hardware specific error.
*/ */
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, SCI_STP_DEV_AWAIT_RESET,
/** /**
* This is the ready operational substate for the remote device. This is the * This is the ready operational substate for the remote device. This is the
* normal operational state for a remote device. * normal operational state for a remote device.
*/ */
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, SCI_SMP_DEV_IDLE,
/** /**
* This is the suspended state for the remote device. This is the state that * This is the suspended state for the remote device. This is the state that
* the device is placed in when a RNC suspend is received by the SCU hardware. * the device is placed in when a RNC suspend is received by the SCU hardware.
*/ */
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, SCI_SMP_DEV_CMD,
/** /**
* This state indicates that the remote device is in the process of * This state indicates that the remote device is in the process of
...@@ -291,7 +291,7 @@ enum scic_sds_remote_device_states { ...@@ -291,7 +291,7 @@ enum scic_sds_remote_device_states {
* This state is entered from the READY state. * This state is entered from the READY state.
* This state is entered from the FAILED state. * This state is entered from the FAILED state.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, SCI_DEV_STOPPING,
/** /**
* This state indicates that the remote device has failed. * This state indicates that the remote device has failed.
...@@ -299,19 +299,19 @@ enum scic_sds_remote_device_states { ...@@ -299,19 +299,19 @@ enum scic_sds_remote_device_states {
* This state is entered from the INITIALIZING state. * This state is entered from the INITIALIZING state.
* This state is entered from the READY state. * This state is entered from the READY state.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_FAILED, SCI_DEV_FAILED,
/** /**
* This state indicates the device is being reset. * This state indicates the device is being reset.
* In this state no new IO operations are permitted. * In this state no new IO operations are permitted.
* This state is entered from the READY state. * This state is entered from the READY state.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, SCI_DEV_RESETTING,
/** /**
* Simply the final state for the base remote device state machine. * Simply the final state for the base remote device state machine.
*/ */
SCI_BASE_REMOTE_DEVICE_STATE_FINAL, SCI_DEV_FINAL,
}; };
static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc)
......
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
bool scic_sds_remote_node_context_is_ready( bool scic_sds_remote_node_context_is_ready(
struct scic_sds_remote_node_context *sci_rnc) struct scic_sds_remote_node_context *sci_rnc)
{ {
u32 current_state = sci_base_state_machine_get_state(&sci_rnc->state_machine); u32 current_state = sci_rnc->sm.current_state_id;
if (current_state == SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) { if (current_state == SCI_RNC_READY) {
return true; return true;
} }
...@@ -268,12 +268,12 @@ static void scic_sds_remote_node_context_invalidate_context_buffer( ...@@ -268,12 +268,12 @@ static void scic_sds_remote_node_context_invalidate_context_buffer(
static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine); struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
/* Check to see if we have gotten back to the initial state because /* Check to see if we have gotten back to the initial state because
* someone requested to destroy the remote node context object. * someone requested to destroy the remote node context object.
*/ */
if (sm->previous_state_id == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE) { if (sm->previous_state_id == SCI_RNC_INVALIDATING) {
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
scic_sds_remote_node_context_notify_user(rnc); scic_sds_remote_node_context_notify_user(rnc);
} }
...@@ -281,21 +281,21 @@ static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_sta ...@@ -281,21 +281,21 @@ static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_sta
static void scic_sds_remote_node_context_posting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_posting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), state_machine); struct scic_sds_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), sm);
scic_sds_remote_node_context_validate_context_buffer(sci_rnc); scic_sds_remote_node_context_validate_context_buffer(sci_rnc);
} }
static void scic_sds_remote_node_context_invalidating_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_invalidating_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine); struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
scic_sds_remote_node_context_invalidate_context_buffer(rnc); scic_sds_remote_node_context_invalidate_context_buffer(rnc);
} }
static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine); struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
struct scic_sds_remote_device *sci_dev; struct scic_sds_remote_device *sci_dev;
struct domain_device *dev; struct domain_device *dev;
...@@ -318,7 +318,7 @@ static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_st ...@@ -318,7 +318,7 @@ static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_st
static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine); struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
...@@ -328,41 +328,41 @@ static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state ...@@ -328,41 +328,41 @@ static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state
static void scic_sds_remote_node_context_tx_suspended_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_tx_suspended_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine); struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
scic_sds_remote_node_context_continue_state_transitions(rnc); scic_sds_remote_node_context_continue_state_transitions(rnc);
} }
static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_state_machine *sm) static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine); struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm);
scic_sds_remote_node_context_continue_state_transitions(rnc); scic_sds_remote_node_context_continue_state_transitions(rnc);
} }
static const struct sci_base_state scic_sds_remote_node_context_state_table[] = { static const struct sci_base_state scic_sds_remote_node_context_state_table[] = {
[SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = { [SCI_RNC_INITIAL] = {
.enter_state = scic_sds_remote_node_context_initial_state_enter, .enter_state = scic_sds_remote_node_context_initial_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = { [SCI_RNC_POSTING] = {
.enter_state = scic_sds_remote_node_context_posting_state_enter, .enter_state = scic_sds_remote_node_context_posting_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = { [SCI_RNC_INVALIDATING] = {
.enter_state = scic_sds_remote_node_context_invalidating_state_enter, .enter_state = scic_sds_remote_node_context_invalidating_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = { [SCI_RNC_RESUMING] = {
.enter_state = scic_sds_remote_node_context_resuming_state_enter, .enter_state = scic_sds_remote_node_context_resuming_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = { [SCI_RNC_READY] = {
.enter_state = scic_sds_remote_node_context_ready_state_enter, .enter_state = scic_sds_remote_node_context_ready_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = { [SCI_RNC_TX_SUSPENDED] = {
.enter_state = scic_sds_remote_node_context_tx_suspended_state_enter, .enter_state = scic_sds_remote_node_context_tx_suspended_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = { [SCI_RNC_TX_RX_SUSPENDED] = {
.enter_state = scic_sds_remote_node_context_tx_rx_suspended_state_enter, .enter_state = scic_sds_remote_node_context_tx_rx_suspended_state_enter,
}, },
[SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = { }, [SCI_RNC_AWAIT_SUSPENSION] = { },
}; };
void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc, void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc,
...@@ -373,11 +373,11 @@ void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context ...@@ -373,11 +373,11 @@ void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context
rnc->remote_node_index = remote_node_index; rnc->remote_node_index = remote_node_index;
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
sci_base_state_machine_construct(&rnc->state_machine, sci_base_state_machine_construct(&rnc->sm,
scic_sds_remote_node_context_state_table, scic_sds_remote_node_context_state_table,
SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE); SCI_RNC_INITIAL);
sci_base_state_machine_start(&rnc->state_machine); sci_base_state_machine_start(&rnc->sm);
} }
enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remote_node_context *sci_rnc, enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remote_node_context *sci_rnc,
...@@ -385,26 +385,24 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot ...@@ -385,26 +385,24 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
{ {
enum scis_sds_remote_node_context_states state; enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id; state = sci_rnc->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE: case SCI_RNC_POSTING:
switch (scu_get_event_code(event_code)) { switch (scu_get_event_code(event_code)) {
case SCU_EVENT_POST_RNC_COMPLETE: case SCU_EVENT_POST_RNC_COMPLETE:
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_READY);
SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE);
break; break;
default: default:
goto out; goto out;
} }
break; break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE: case SCI_RNC_INVALIDATING:
if (scu_get_event_code(event_code) == SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE) { if (scu_get_event_code(event_code) == SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE) {
if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL)
state = SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE; state = SCI_RNC_INITIAL;
else else
state = SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE; state = SCI_RNC_POSTING;
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, state);
state);
} else { } else {
switch (scu_get_event_type(event_code)) { switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TYPE_RNC_SUSPEND_TX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
...@@ -421,10 +419,9 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot ...@@ -421,10 +419,9 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
} }
} }
break; break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE: case SCI_RNC_RESUMING:
if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) { if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) {
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_READY);
SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE);
} else { } else {
switch (scu_get_event_type(event_code)) { switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TYPE_RNC_SUSPEND_TX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
...@@ -441,32 +438,28 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot ...@@ -441,32 +438,28 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
} }
} }
break; break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE: case SCI_RNC_READY:
switch (scu_get_event_type(event_code)) { switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TL_RNC_SUSPEND_TX: case SCU_EVENT_TL_RNC_SUSPEND_TX:
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED);
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE);
sci_rnc->suspension_code = scu_get_event_specifier(event_code); sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break; break;
case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED);
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE);
sci_rnc->suspension_code = scu_get_event_specifier(event_code); sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break; break;
default: default:
goto out; goto out;
} }
break; break;
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE: case SCI_RNC_AWAIT_SUSPENSION:
switch (scu_get_event_type(event_code)) { switch (scu_get_event_type(event_code)) {
case SCU_EVENT_TL_RNC_SUSPEND_TX: case SCU_EVENT_TL_RNC_SUSPEND_TX:
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED);
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE);
sci_rnc->suspension_code = scu_get_event_specifier(event_code); sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break; break;
case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED);
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE);
sci_rnc->suspension_code = scu_get_event_specifier(event_code); sci_rnc->suspension_code = scu_get_event_specifier(event_code);
break; break;
default: default:
...@@ -493,22 +486,21 @@ enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_nod ...@@ -493,22 +486,21 @@ enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_nod
{ {
enum scis_sds_remote_node_context_states state; enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id; state = sci_rnc->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE: case SCI_RNC_INVALIDATING:
scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p); scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE: case SCI_RNC_POSTING:
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE: case SCI_RNC_RESUMING:
case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE: case SCI_RNC_READY:
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE: case SCI_RNC_TX_SUSPENDED:
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE: case SCI_RNC_TX_RX_SUSPENDED:
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE: case SCI_RNC_AWAIT_SUSPENSION:
scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p); scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p);
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING);
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE: case SCI_RNC_INITIAL:
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state); "%s: invalid state %d\n", __func__, state);
/* We have decided that the destruct request on the remote node context /* We have decided that the destruct request on the remote node context
...@@ -530,8 +522,8 @@ enum sci_status scic_sds_remote_node_context_suspend(struct scic_sds_remote_node ...@@ -530,8 +522,8 @@ enum sci_status scic_sds_remote_node_context_suspend(struct scic_sds_remote_node
{ {
enum scis_sds_remote_node_context_states state; enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id; state = sci_rnc->sm.current_state_id;
if (state != SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) { if (state != SCI_RNC_READY) {
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state); "%s: invalid state %d\n", __func__, state);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -546,8 +538,7 @@ enum sci_status scic_sds_remote_node_context_suspend(struct scic_sds_remote_node ...@@ -546,8 +538,7 @@ enum sci_status scic_sds_remote_node_context_suspend(struct scic_sds_remote_node
SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX); SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX);
} }
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_AWAIT_SUSPENSION);
SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -557,27 +548,26 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_ ...@@ -557,27 +548,26 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_
{ {
enum scis_sds_remote_node_context_states state; enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id; state = sci_rnc->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE: case SCI_RNC_INITIAL:
if (sci_rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) if (sci_rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
scic_sds_remote_node_context_construct_buffer(sci_rnc); scic_sds_remote_node_context_construct_buffer(sci_rnc);
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_POSTING);
SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE: case SCI_RNC_POSTING:
case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE: case SCI_RNC_INVALIDATING:
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE: case SCI_RNC_RESUMING:
if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY)
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
sci_rnc->user_callback = cb_fn; sci_rnc->user_callback = cb_fn;
sci_rnc->user_cookie = cb_p; sci_rnc->user_cookie = cb_p;
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE: { case SCI_RNC_TX_SUSPENDED: {
struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc); struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
struct domain_device *dev = sci_dev_to_domain(sci_dev); struct domain_device *dev = sci_dev_to_domain(sci_dev);
...@@ -585,27 +575,23 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_ ...@@ -585,27 +575,23 @@ enum sci_status scic_sds_remote_node_context_resume(struct scic_sds_remote_node_
/* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */ /* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */
if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev)) if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev))
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
if (sci_dev->is_direct_attached) { if (sci_dev->is_direct_attached) {
/* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */ /* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
} else { } else {
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING);
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
} }
} else } else
return SCI_FAILURE; return SCI_FAILURE;
return SCI_SUCCESS; return SCI_SUCCESS;
} }
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE: case SCI_RNC_TX_RX_SUSPENDED:
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
sci_base_state_machine_change_state(&sci_rnc->state_machine, sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING);
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE: case SCI_RNC_AWAIT_SUSPENSION:
scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); scic_sds_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
...@@ -620,8 +606,8 @@ enum sci_status scic_sds_remote_node_context_start_io(struct scic_sds_remote_nod ...@@ -620,8 +606,8 @@ enum sci_status scic_sds_remote_node_context_start_io(struct scic_sds_remote_nod
{ {
enum scis_sds_remote_node_context_states state; enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id; state = sci_rnc->sm.current_state_id;
if (state != SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) { if (state != SCI_RNC_READY) {
dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
"%s: invalid state %d\n", __func__, state); "%s: invalid state %d\n", __func__, state);
return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
...@@ -634,14 +620,14 @@ enum sci_status scic_sds_remote_node_context_start_task(struct scic_sds_remote_n ...@@ -634,14 +620,14 @@ enum sci_status scic_sds_remote_node_context_start_task(struct scic_sds_remote_n
{ {
enum scis_sds_remote_node_context_states state; enum scis_sds_remote_node_context_states state;
state = sci_rnc->state_machine.current_state_id; state = sci_rnc->sm.current_state_id;
switch (state) { switch (state) {
case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE: case SCI_RNC_RESUMING:
case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE: case SCI_RNC_READY:
case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE: case SCI_RNC_AWAIT_SUSPENSION:
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE: case SCI_RNC_TX_SUSPENDED:
case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE: case SCI_RNC_TX_RX_SUSPENDED:
scic_sds_remote_node_context_resume(sci_rnc, NULL, NULL); scic_sds_remote_node_context_resume(sci_rnc, NULL, NULL);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
......
...@@ -92,45 +92,45 @@ enum scis_sds_remote_node_context_states { ...@@ -92,45 +92,45 @@ enum scis_sds_remote_node_context_states {
* This state is the initial state for a remote node context. On a resume * This state is the initial state for a remote node context. On a resume
* request the remote node context will transition to the posting state. * request the remote node context will transition to the posting state.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE, SCI_RNC_INITIAL,
/** /**
* This is a transition state that posts the RNi to the hardware. Once the RNC * This is a transition state that posts the RNi to the hardware. Once the RNC
* is posted the remote node context will be made ready. * is posted the remote node context will be made ready.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE, SCI_RNC_POSTING,
/** /**
* This is a transition state that will post an RNC invalidate to the * This is a transition state that will post an RNC invalidate to the
* hardware. Once the invalidate is complete the remote node context will * hardware. Once the invalidate is complete the remote node context will
* transition to the posting state. * transition to the posting state.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE, SCI_RNC_INVALIDATING,
/** /**
* This is a transition state that will post an RNC resume to the hardare. * This is a transition state that will post an RNC resume to the hardare.
* Once the event notification of resume complete is received the remote node * Once the event notification of resume complete is received the remote node
* context will transition to the ready state. * context will transition to the ready state.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE, SCI_RNC_RESUMING,
/** /**
* This is the state that the remote node context must be in to accept io * This is the state that the remote node context must be in to accept io
* request operations. * request operations.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE, SCI_RNC_READY,
/** /**
* This is the state that the remote node context transitions to when it gets * This is the state that the remote node context transitions to when it gets
* a TX suspend notification from the hardware. * a TX suspend notification from the hardware.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE, SCI_RNC_TX_SUSPENDED,
/** /**
* This is the state that the remote node context transitions to when it gets * This is the state that the remote node context transitions to when it gets
* a TX RX suspend notification from the hardware. * a TX RX suspend notification from the hardware.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE, SCI_RNC_TX_RX_SUSPENDED,
/** /**
* This state is a wait state for the remote node context that waits for a * This state is a wait state for the remote node context that waits for a
...@@ -138,7 +138,7 @@ enum scis_sds_remote_node_context_states { ...@@ -138,7 +138,7 @@ enum scis_sds_remote_node_context_states {
* there is a request to supend the remote node context or when there is a TC * there is a request to supend the remote node context or when there is a TC
* completion where the remote node will be suspended by the hardware. * completion where the remote node will be suspended by the hardware.
*/ */
SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE SCI_RNC_AWAIT_SUSPENSION
}; };
/** /**
...@@ -194,7 +194,7 @@ struct scic_sds_remote_node_context { ...@@ -194,7 +194,7 @@ struct scic_sds_remote_node_context {
/** /**
* This field contains the data for the object's state machine. * This field contains the data for the object's state machine.
*/ */
struct sci_base_state_machine state_machine; struct sci_base_state_machine sm;
}; };
void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc, void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc,
......
...@@ -649,8 +649,7 @@ static enum sci_status scic_io_request_construct_basic_ssp(struct scic_sds_reque ...@@ -649,8 +649,7 @@ static enum sci_status scic_io_request_construct_basic_ssp(struct scic_sds_reque
scic_sds_io_request_build_ssp_command_iu(sci_req); scic_sds_io_request_build_ssp_command_iu(sci_req);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -664,8 +663,7 @@ enum sci_status scic_task_request_construct_ssp( ...@@ -664,8 +663,7 @@ enum sci_status scic_task_request_construct_ssp(
/* Fill in the SSP Task IU */ /* Fill in the SSP Task IU */
scic_sds_task_request_build_ssp_task_iu(sci_req); scic_sds_task_request_build_ssp_task_iu(sci_req);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -687,8 +685,7 @@ static enum sci_status scic_io_request_construct_basic_sata(struct scic_sds_requ ...@@ -687,8 +685,7 @@ static enum sci_status scic_io_request_construct_basic_sata(struct scic_sds_requ
copy); copy);
if (status == SCI_SUCCESS) if (status == SCI_SUCCESS)
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return status; return status;
} }
...@@ -718,8 +715,7 @@ enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_re ...@@ -718,8 +715,7 @@ enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_re
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return status; return status;
} }
...@@ -761,8 +757,8 @@ enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req) ...@@ -761,8 +757,8 @@ enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req)
scic_sds_remote_device_get_sequence(sci_req->target_device)) scic_sds_remote_device_get_sequence(sci_req->target_device))
return SCI_FAILURE; return SCI_FAILURE;
state = sci_req->state_machine.current_state_id; state = sci_req->sm.current_state_id;
if (state != SCI_BASE_REQUEST_STATE_CONSTRUCTED) { if (state != SCI_REQ_CONSTRUCTED) {
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC IO Request requested to start while in wrong " "%s: SCIC IO Request requested to start while in wrong "
"state %d\n", __func__, state); "state %d\n", __func__, state);
...@@ -818,8 +814,7 @@ enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req) ...@@ -818,8 +814,7 @@ enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req)
sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag); sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag);
/* Everything is good go ahead and change state */ /* Everything is good go ahead and change state */
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STARTED);
SCI_BASE_REQUEST_STATE_STARTED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -832,52 +827,47 @@ scic_sds_io_request_terminate(struct scic_sds_request *sci_req) ...@@ -832,52 +827,47 @@ scic_sds_io_request_terminate(struct scic_sds_request *sci_req)
{ {
enum sci_base_request_states state; enum sci_base_request_states state;
state = sci_req->state_machine.current_state_id; state = sci_req->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_REQUEST_STATE_CONSTRUCTED: case SCI_REQ_CONSTRUCTED:
scic_sds_request_set_status(sci_req, scic_sds_request_set_status(sci_req,
SCU_TASK_DONE_TASK_ABORT, SCU_TASK_DONE_TASK_ABORT,
SCI_FAILURE_IO_TERMINATED); SCI_FAILURE_IO_TERMINATED);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_REQUEST_STATE_STARTED: case SCI_REQ_STARTED:
case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION: case SCI_REQ_TASK_WAIT_TC_COMP:
case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: case SCI_REQ_SMP_WAIT_RESP:
case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION: case SCI_REQ_SMP_WAIT_TC_COMP:
case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE: case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE: case SCI_REQ_STP_UDMA_WAIT_D2H:
case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE: case SCI_REQ_STP_NON_DATA_WAIT_H2D:
case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE: case SCI_REQ_STP_NON_DATA_WAIT_D2H:
case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE: case SCI_REQ_STP_PIO_WAIT_H2D:
case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE: case SCI_REQ_STP_PIO_WAIT_FRAME:
case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE: case SCI_REQ_STP_PIO_DATA_IN:
case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE: case SCI_REQ_STP_PIO_DATA_OUT:
case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE: case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED:
case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE: case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG:
case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE: case SCI_REQ_STP_SOFT_RESET_WAIT_D2H:
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_ABORTING);
SCI_BASE_REQUEST_STATE_ABORTING);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE: case SCI_REQ_TASK_WAIT_TC_RESP:
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_ABORTING);
SCI_BASE_REQUEST_STATE_ABORTING); sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
sci_base_state_machine_change_state(&sci_req->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_REQUEST_STATE_ABORTING: case SCI_REQ_ABORTING:
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCI_BASE_REQUEST_STATE_COMPLETED: case SCI_REQ_COMPLETED:
default: default:
dev_warn(scic_to_dev(sci_req->owning_controller), dev_warn(scic_to_dev(sci_req->owning_controller),
"%s: SCIC IO Request requested to abort while in wrong " "%s: SCIC IO Request requested to abort while in wrong "
"state %d\n", "state %d\n",
__func__, __func__,
sci_base_state_machine_get_state(&sci_req->state_machine)); sci_req->sm.current_state_id);
break; break;
} }
...@@ -889,8 +879,8 @@ enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req) ...@@ -889,8 +879,8 @@ enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req)
enum sci_base_request_states state; enum sci_base_request_states state;
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
state = sci_req->state_machine.current_state_id; state = sci_req->sm.current_state_id;
if (WARN_ONCE(state != SCI_BASE_REQUEST_STATE_COMPLETED, if (WARN_ONCE(state != SCI_REQ_COMPLETED,
"isci: request completion from wrong state (%d)\n", state)) "isci: request completion from wrong state (%d)\n", state))
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -902,8 +892,7 @@ enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req) ...@@ -902,8 +892,7 @@ enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req)
sci_req->saved_rx_frame_index); sci_req->saved_rx_frame_index);
/* XXX can we just stop the machine and remove the 'final' state? */ /* XXX can we just stop the machine and remove the 'final' state? */
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_FINAL);
SCI_BASE_REQUEST_STATE_FINAL);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
...@@ -913,9 +902,9 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r ...@@ -913,9 +902,9 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r
enum sci_base_request_states state; enum sci_base_request_states state;
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
state = sci_req->state_machine.current_state_id; state = sci_req->sm.current_state_id;
if (state != SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE) { if (state != SCI_REQ_STP_PIO_DATA_IN) {
dev_warn(scic_to_dev(scic), "%s: (%x) in wrong state %d\n", dev_warn(scic_to_dev(scic), "%s: (%x) in wrong state %d\n",
__func__, event_code, state); __func__, event_code, state);
...@@ -927,8 +916,7 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r ...@@ -927,8 +916,7 @@ enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_r
/* We are waiting for data and the SCU has R_ERR the data frame. /* We are waiting for data and the SCU has R_ERR the data frame.
* Go back to waiting for the D2H Register FIS * Go back to waiting for the D2H Register FIS
*/ */
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
...@@ -967,8 +955,9 @@ static void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req) ...@@ -967,8 +955,9 @@ static void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req)
memcpy(resp_buf, ssp_response->resp_data, len); memcpy(resp_buf, ssp_response->resp_data, len);
} }
static enum sci_status request_started_state_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) request_started_state_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
struct ssp_response_iu *resp_iu; struct ssp_response_iu *resp_iu;
u8 datapres; u8 datapres;
...@@ -1110,13 +1099,13 @@ static enum sci_status request_started_state_tc_event(struct scic_sds_request *s ...@@ -1110,13 +1099,13 @@ static enum sci_status request_started_state_tc_event(struct scic_sds_request *s
*/ */
/* In all cases we will treat this as the completion of the IO req. */ /* In all cases we will treat this as the completion of the IO req. */
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
static enum sci_status request_aborting_state_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) request_aborting_state_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT): case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT):
...@@ -1124,8 +1113,7 @@ static enum sci_status request_aborting_state_tc_event(struct scic_sds_request * ...@@ -1124,8 +1113,7 @@ static enum sci_status request_aborting_state_tc_event(struct scic_sds_request *
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_TASK_ABORT, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_TASK_ABORT,
SCI_FAILURE_IO_TERMINATED); SCI_FAILURE_IO_TERMINATED);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
default: default:
...@@ -1146,8 +1134,7 @@ static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request * ...@@ -1146,8 +1134,7 @@ static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request *
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_TASK_WAIT_TC_RESP);
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE);
break; break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
/* Currently, the decision is to simply allow the task request /* Currently, the decision is to simply allow the task request
...@@ -1160,27 +1147,28 @@ static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request * ...@@ -1160,27 +1147,28 @@ static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request *
"ACK/NAK timeout\n", __func__, sci_req, "ACK/NAK timeout\n", __func__, sci_req,
completion_code); completion_code);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_TASK_WAIT_TC_RESP);
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE);
break; break;
default: default:
/* All other completion status cause the IO to be complete. If a NAK /*
* was received, then it is up to the user to retry the request. * All other completion status cause the IO to be complete.
* If a NAK was received, then it is up to the user to retry
* the request.
*/ */
scic_sds_request_set_status(sci_req, scic_sds_request_set_status(sci_req,
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
} }
static enum sci_status smp_request_await_response_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) smp_request_await_response_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
...@@ -1191,8 +1179,7 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque ...@@ -1191,8 +1179,7 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR):
...@@ -1209,8 +1196,7 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque ...@@ -1209,8 +1196,7 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_SMP_RESP_TO_ERR, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_SMP_RESP_TO_ERR,
SCI_FAILURE_RETRY_REQUIRED); SCI_FAILURE_RETRY_REQUIRED);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
default: default:
...@@ -1221,24 +1207,23 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque ...@@ -1221,24 +1207,23 @@ static enum sci_status smp_request_await_response_tc_event(struct scic_sds_reque
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
} }
static enum sci_status smp_request_await_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) smp_request_await_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
default: default:
/* All other completion status cause the IO to be /* All other completion status cause the IO to be
...@@ -1249,8 +1234,7 @@ static enum sci_status smp_request_await_tc_event(struct scic_sds_request *sci_r ...@@ -1249,8 +1234,7 @@ static enum sci_status smp_request_await_tc_event(struct scic_sds_request *sci_r
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
...@@ -1311,16 +1295,16 @@ static struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(struct scic ...@@ -1311,16 +1295,16 @@ static struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(struct scic
return current_sgl; return current_sgl;
} }
static enum sci_status stp_request_non_data_await_h2d_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) stp_request_non_data_await_h2d_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H);
SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE);
break; break;
default: default:
...@@ -1332,8 +1316,7 @@ static enum sci_status stp_request_non_data_await_h2d_tc_event(struct scic_sds_r ...@@ -1332,8 +1316,7 @@ static enum sci_status stp_request_non_data_await_h2d_tc_event(struct scic_sds_r
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
...@@ -1509,17 +1492,19 @@ static enum sci_status scic_sds_stp_request_pio_data_in_copy_data( ...@@ -1509,17 +1492,19 @@ static enum sci_status scic_sds_stp_request_pio_data_in_copy_data(
return status; return status;
} }
static enum sci_status stp_request_pio_await_h2d_completion_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) stp_request_pio_await_h2d_completion_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
enum sci_status status = SCI_SUCCESS; enum sci_status status = SCI_SUCCESS;
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS); scic_sds_request_set_status(sci_req,
SCU_TASK_DONE_GOOD,
SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
break; break;
default: default:
...@@ -1531,16 +1516,16 @@ static enum sci_status stp_request_pio_await_h2d_completion_tc_event(struct scic ...@@ -1531,16 +1516,16 @@ static enum sci_status stp_request_pio_await_h2d_completion_tc_event(struct scic
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
return status; return status;
} }
static enum sci_status pio_data_out_tx_done_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) pio_data_out_tx_done_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
enum sci_status status = SCI_SUCCESS; enum sci_status status = SCI_SUCCESS;
bool all_frames_transferred = false; bool all_frames_transferred = false;
...@@ -1566,28 +1551,24 @@ static enum sci_status pio_data_out_tx_done_tc_event(struct scic_sds_request *sc ...@@ -1566,28 +1551,24 @@ static enum sci_status pio_data_out_tx_done_tc_event(struct scic_sds_request *sc
/* all data transferred. */ /* all data transferred. */
if (all_frames_transferred) { if (all_frames_transferred) {
/* /*
* Change the state to SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_FRAME_SUBSTATE * Change the state to SCI_REQ_STP_PIO_DATA_IN
* and wait for PIO_SETUP fis / or D2H REg fis. */ * and wait for PIO_SETUP fis / or D2H REg fis. */
sci_base_state_machine_change_state( sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
&sci_req->state_machine,
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE
);
} }
break; break;
default: default:
/* /*
* All other completion status cause the IO to be complete. If a NAK * All other completion status cause the IO to be complete.
* was received, then it is up to the user to retry the request. */ * If a NAK was received, then it is up to the user to retry
* the request.
*/
scic_sds_request_set_status( scic_sds_request_set_status(
sci_req, sci_req,
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
);
sci_base_state_machine_change_state( sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
&sci_req->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
break; break;
} }
...@@ -1600,8 +1581,7 @@ static void scic_sds_stp_request_udma_complete_request( ...@@ -1600,8 +1581,7 @@ static void scic_sds_stp_request_udma_complete_request(
enum sci_status sci_status) enum sci_status sci_status)
{ {
scic_sds_request_set_status(request, scu_status, sci_status); scic_sds_request_set_status(request, scu_status, sci_status);
sci_base_state_machine_change_state(&request->state_machine, sci_change_state(&request->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
} }
static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct scic_sds_request *sci_req, static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct scic_sds_request *sci_req,
...@@ -1632,8 +1612,9 @@ static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct sc ...@@ -1632,8 +1612,9 @@ static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct sc
return status; return status;
} }
enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, enum sci_status
u32 frame_index) scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
u32 frame_index)
{ {
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
struct scic_sds_stp_request *stp_req = &sci_req->stp.req; struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
...@@ -1641,9 +1622,9 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1641,9 +1622,9 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
enum sci_status status; enum sci_status status;
ssize_t word_cnt; ssize_t word_cnt;
state = sci_req->state_machine.current_state_id; state = sci_req->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_REQUEST_STATE_STARTED: { case SCI_REQ_STARTED: {
struct ssp_frame_hdr ssp_hdr; struct ssp_frame_hdr ssp_hdr;
void *frame_header; void *frame_header;
...@@ -1684,20 +1665,21 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1684,20 +1665,21 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
} }
/* /*
* In any case we are done with this frame buffer return it to the * In any case we are done with this frame buffer return it to
* controller * the controller
*/ */
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE:
case SCI_REQ_TASK_WAIT_TC_RESP:
scic_sds_io_request_copy_response(sci_req); scic_sds_io_request_copy_response(sci_req);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
scic_sds_controller_release_frame(scic,frame_index); scic_sds_controller_release_frame(scic,frame_index);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: {
case SCI_REQ_SMP_WAIT_RESP: {
struct smp_resp *rsp_hdr = &sci_req->smp.rsp; struct smp_resp *rsp_hdr = &sci_req->smp.rsp;
void *frame_header; void *frame_header;
...@@ -1725,32 +1707,40 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1725,32 +1707,40 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_SMP_WAIT_TC_COMP);
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION);
} else { } else {
/* This was not a response frame why did it get forwarded? */ /*
* This was not a response frame why did it get
* forwarded?
*/
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
"%s: SCIC SMP Request 0x%p received unexpected frame " "%s: SCIC SMP Request 0x%p received unexpected "
"%d type 0x%02x\n", __func__, sci_req, "frame %d type 0x%02x\n",
frame_index, rsp_hdr->frame_type); __func__,
sci_req,
frame_index,
rsp_hdr->frame_type);
scic_sds_request_set_status(sci_req, scic_sds_request_set_status(sci_req,
SCU_TASK_DONE_SMP_FRM_TYPE_ERR, SCU_TASK_DONE_SMP_FRM_TYPE_ERR,
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
} }
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE:
return scic_sds_stp_request_udma_general_frame_handler(sci_req, frame_index); case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE: return scic_sds_stp_request_udma_general_frame_handler(sci_req,
frame_index);
case SCI_REQ_STP_UDMA_WAIT_D2H:
/* Use the general frame handler to copy the resposne data */ /* Use the general frame handler to copy the resposne data */
status = scic_sds_stp_request_udma_general_frame_handler(sci_req, frame_index); status = scic_sds_stp_request_udma_general_frame_handler(sci_req,
frame_index);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
return status; return status;
...@@ -1758,8 +1748,10 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1758,8 +1748,10 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
scic_sds_stp_request_udma_complete_request(sci_req, scic_sds_stp_request_udma_complete_request(sci_req,
SCU_TASK_DONE_CHECK_RESPONSE, SCU_TASK_DONE_CHECK_RESPONSE,
SCI_FAILURE_IO_RESPONSE_VALID); SCI_FAILURE_IO_RESPONSE_VALID);
return SCI_SUCCESS; return SCI_SUCCESS;
case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE: {
case SCI_REQ_STP_NON_DATA_WAIT_D2H: {
struct dev_to_host_fis *frame_header; struct dev_to_host_fis *frame_header;
u32 *frame_buffer; u32 *frame_buffer;
...@@ -1769,9 +1761,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1769,9 +1761,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
"%s: SCIC IO Request 0x%p could not get frame header " "%s: SCIC IO Request 0x%p could not get frame "
"for frame index %d, status %x\n", "header for frame index %d, status %x\n",
__func__, stp_req, frame_index, status); __func__,
stp_req,
frame_index,
status);
return status; return status;
} }
...@@ -1802,15 +1797,15 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1802,15 +1797,15 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
break; break;
} }
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
/* Frame has been decoded return it to the controller */ /* Frame has been decoded return it to the controller */
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return status; return status;
} }
case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE: {
case SCI_REQ_STP_PIO_WAIT_FRAME: {
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
struct sas_task *task = isci_request_access_task(ireq); struct sas_task *task = isci_request_access_task(ireq);
struct dev_to_host_fis *frame_header; struct dev_to_host_fis *frame_header;
...@@ -1822,8 +1817,8 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1822,8 +1817,8 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
"%s: SCIC IO Request 0x%p could not get frame header " "%s: SCIC IO Request 0x%p could not get frame "
"for frame index %d, status %x\n", "header for frame index %d, status %x\n",
__func__, stp_req, frame_index, status); __func__, stp_req, frame_index, status);
return status; return status;
} }
...@@ -1835,9 +1830,10 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1835,9 +1830,10 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
frame_index, frame_index,
(void **)&frame_buffer); (void **)&frame_buffer);
/* Get the data from the PIO Setup The SCU Hardware returns /* Get the data from the PIO Setup The SCU Hardware
* first word in the frame_header and the rest of the data is in * returns first word in the frame_header and the rest
* the frame buffer so we need to back up one dword * of the data is in the frame buffer so we need to
* back up one dword
*/ */
/* transfer_count: first 16bits in the 4th dword */ /* transfer_count: first 16bits in the 4th dword */
...@@ -1856,31 +1852,33 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1856,31 +1852,33 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
* request was PIO Data-in or Data out * request was PIO Data-in or Data out
*/ */
if (task->data_dir == DMA_FROM_DEVICE) { if (task->data_dir == DMA_FROM_DEVICE) {
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_DATA_IN);
SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE);
} else if (task->data_dir == DMA_TO_DEVICE) { } else if (task->data_dir == DMA_TO_DEVICE) {
/* Transmit data */ /* Transmit data */
status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req); status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req);
if (status != SCI_SUCCESS) if (status != SCI_SUCCESS)
break; break;
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_DATA_OUT);
SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE);
} }
break; break;
case FIS_SETDEVBITS: case FIS_SETDEVBITS:
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
break; break;
case FIS_REGD2H: case FIS_REGD2H:
if (frame_header->status & ATA_BUSY) { if (frame_header->status & ATA_BUSY) {
/* Now why is the drive sending a D2H Register FIS when /*
* it is still busy? Do nothing since we are still in * Now why is the drive sending a D2H Register
* the right state. * FIS when it is still busy? Do nothing since
* we are still in the right state.
*/ */
dev_dbg(scic_to_dev(scic), dev_dbg(scic_to_dev(scic),
"%s: SCIC PIO Request 0x%p received " "%s: SCIC PIO Request 0x%p received "
"D2H Register FIS with BSY status " "D2H Register FIS with BSY status "
"0x%x\n", __func__, stp_req, "0x%x\n",
__func__,
stp_req,
frame_header->status); frame_header->status);
break; break;
} }
...@@ -1897,9 +1895,9 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1897,9 +1895,9 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
SCU_TASK_DONE_CHECK_RESPONSE, SCU_TASK_DONE_CHECK_RESPONSE,
SCI_FAILURE_IO_RESPONSE_VALID); SCI_FAILURE_IO_RESPONSE_VALID);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
default: default:
/* FIXME: what do we do here? */ /* FIXME: what do we do here? */
break; break;
...@@ -1910,7 +1908,8 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1910,7 +1908,8 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
return status; return status;
} }
case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE: {
case SCI_REQ_STP_PIO_DATA_IN: {
struct dev_to_host_fis *frame_header; struct dev_to_host_fis *frame_header;
struct sata_fis_data *frame_buffer; struct sata_fis_data *frame_buffer;
...@@ -1920,9 +1919,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1920,9 +1919,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
"%s: SCIC IO Request 0x%p could not get frame header " "%s: SCIC IO Request 0x%p could not get frame "
"for frame index %d, status %x\n", "header for frame index %d, status %x\n",
__func__, stp_req, frame_index, status); __func__,
stp_req,
frame_index,
status);
return status; return status;
} }
...@@ -1930,15 +1932,17 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1930,15 +1932,17 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
"%s: SCIC PIO Request 0x%p received frame %d " "%s: SCIC PIO Request 0x%p received frame %d "
"with fis type 0x%02x when expecting a data " "with fis type 0x%02x when expecting a data "
"fis.\n", __func__, stp_req, frame_index, "fis.\n",
__func__,
stp_req,
frame_index,
frame_header->fis_type); frame_header->fis_type);
scic_sds_request_set_status(sci_req, scic_sds_request_set_status(sci_req,
SCU_TASK_DONE_GOOD, SCU_TASK_DONE_GOOD,
SCI_FAILURE_IO_REQUIRES_SCSI_ABORT); SCI_FAILURE_IO_REQUIRES_SCSI_ABORT);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
/* Frame is decoded return it to the controller */ /* Frame is decoded return it to the controller */
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
...@@ -1972,15 +1976,14 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1972,15 +1976,14 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
SCU_TASK_DONE_CHECK_RESPONSE, SCU_TASK_DONE_CHECK_RESPONSE,
SCI_FAILURE_IO_RESPONSE_VALID); SCI_FAILURE_IO_RESPONSE_VALID);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
} else { } else {
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
} }
return status; return status;
} }
case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE: {
case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: {
struct dev_to_host_fis *frame_header; struct dev_to_host_fis *frame_header;
u32 *frame_buffer; u32 *frame_buffer;
...@@ -1989,9 +1992,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -1989,9 +1992,12 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
(void **)&frame_header); (void **)&frame_header);
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
dev_err(scic_to_dev(scic), dev_err(scic_to_dev(scic),
"%s: SCIC IO Request 0x%p could not get frame header " "%s: SCIC IO Request 0x%p could not get frame "
"for frame index %d, status %x\n", "header for frame index %d, status %x\n",
__func__, stp_req, frame_index, status); __func__,
stp_req,
frame_index,
status);
return status; return status;
} }
...@@ -2010,35 +2016,43 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r ...@@ -2010,35 +2016,43 @@ enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_r
SCU_TASK_DONE_CHECK_RESPONSE, SCU_TASK_DONE_CHECK_RESPONSE,
SCI_FAILURE_IO_RESPONSE_VALID); SCI_FAILURE_IO_RESPONSE_VALID);
break; break;
default: default:
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: IO Request:0x%p Frame Id:%d protocol " "%s: IO Request:0x%p Frame Id:%d protocol "
"violation occurred\n", __func__, stp_req, "violation occurred\n",
__func__,
stp_req,
frame_index); frame_index);
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_UNEXP_FIS, scic_sds_request_set_status(sci_req,
SCU_TASK_DONE_UNEXP_FIS,
SCI_FAILURE_PROTOCOL_VIOLATION); SCI_FAILURE_PROTOCOL_VIOLATION);
break; break;
} }
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
/* Frame has been decoded return it to the controller */ /* Frame has been decoded return it to the controller */
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return status; return status;
} }
case SCI_BASE_REQUEST_STATE_ABORTING: case SCI_REQ_ABORTING:
/* TODO: Is it even possible to get an unsolicited frame in the /*
* TODO: Is it even possible to get an unsolicited frame in the
* aborting state? * aborting state?
*/ */
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return SCI_SUCCESS; return SCI_SUCCESS;
default: default:
dev_warn(scic_to_dev(scic), dev_warn(scic_to_dev(scic),
"%s: SCIC IO Request given unexpected frame %x while in " "%s: SCIC IO Request given unexpected frame %x while "
"state %d\n", __func__, frame_index, state); "in state %d\n",
__func__,
frame_index,
state);
scic_sds_controller_release_frame(scic, frame_index); scic_sds_controller_release_frame(scic, frame_index);
return SCI_FAILURE_INVALID_STATE; return SCI_FAILURE_INVALID_STATE;
...@@ -2075,8 +2089,7 @@ static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request * ...@@ -2075,8 +2089,7 @@ static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request *
* the device so we must change state to wait * the device so we must change state to wait
* for it * for it
*/ */
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_UDMA_WAIT_D2H);
SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE);
} }
break; break;
...@@ -2105,45 +2118,45 @@ static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request * ...@@ -2105,45 +2118,45 @@ static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request *
return status; return status;
} }
static enum sci_status stp_request_soft_reset_await_h2d_asserted_tc_event(struct scic_sds_request *sci_req, static enum sci_status
u32 completion_code) stp_request_soft_reset_await_h2d_asserted_tc_event(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG);
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE);
break; break;
default: default:
/* /*
* All other completion status cause the IO to be complete. If a NAK * All other completion status cause the IO to be complete.
* was received, then it is up to the user to retry the request. */ * If a NAK was received, then it is up to the user to retry
* the request.
*/
scic_sds_request_set_status(sci_req, scic_sds_request_set_status(sci_req,
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
return SCI_SUCCESS; return SCI_SUCCESS;
} }
static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event( static enum sci_status
struct scic_sds_request *sci_req, stp_request_soft_reset_await_h2d_diagnostic_tc_event(struct scic_sds_request *sci_req,
u32 completion_code) u32 completion_code)
{ {
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD, scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS); SCI_SUCCESS);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_STP_SOFT_RESET_WAIT_D2H);
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE);
break; break;
default: default:
...@@ -2155,8 +2168,7 @@ static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event( ...@@ -2155,8 +2168,7 @@ static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event(
SCU_NORMALIZE_COMPLETION_STATUS(completion_code), SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
SCI_BASE_REQUEST_STATE_COMPLETED);
break; break;
} }
...@@ -2164,42 +2176,64 @@ static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event( ...@@ -2164,42 +2176,64 @@ static enum sci_status stp_request_soft_reset_await_h2d_diagnostic_tc_event(
} }
enum sci_status enum sci_status
scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 completion_code) scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req,
u32 completion_code)
{ {
enum sci_base_request_states state; enum sci_base_request_states state;
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
state = sci_req->state_machine.current_state_id; state = sci_req->sm.current_state_id;
switch (state) { switch (state) {
case SCI_BASE_REQUEST_STATE_STARTED: case SCI_REQ_STARTED:
return request_started_state_tc_event(sci_req, completion_code); return request_started_state_tc_event(sci_req, completion_code);
case SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION:
return ssp_task_request_await_tc_event(sci_req, completion_code); case SCI_REQ_TASK_WAIT_TC_COMP:
case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE: return ssp_task_request_await_tc_event(sci_req,
return smp_request_await_response_tc_event(sci_req, completion_code); completion_code);
case SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION:
return smp_request_await_tc_event(sci_req, completion_code); case SCI_REQ_SMP_WAIT_RESP:
case SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE: return smp_request_await_response_tc_event(sci_req,
return stp_request_udma_await_tc_event(sci_req, completion_code); completion_code);
case SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE:
return stp_request_non_data_await_h2d_tc_event(sci_req, completion_code); case SCI_REQ_SMP_WAIT_TC_COMP:
case SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE: return smp_request_await_tc_event(sci_req, completion_code);
return stp_request_pio_await_h2d_completion_tc_event(sci_req, completion_code);
case SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE: case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
return pio_data_out_tx_done_tc_event(sci_req, completion_code); return stp_request_udma_await_tc_event(sci_req,
case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE: completion_code);
return stp_request_soft_reset_await_h2d_asserted_tc_event(sci_req, completion_code);
case SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE: case SCI_REQ_STP_NON_DATA_WAIT_H2D:
return stp_request_soft_reset_await_h2d_diagnostic_tc_event(sci_req, completion_code); return stp_request_non_data_await_h2d_tc_event(sci_req,
case SCI_BASE_REQUEST_STATE_ABORTING: completion_code);
return request_aborting_state_tc_event(sci_req, completion_code);
default: case SCI_REQ_STP_PIO_WAIT_H2D:
dev_warn(scic_to_dev(scic), return stp_request_pio_await_h2d_completion_tc_event(sci_req,
"%s: SCIC IO Request given task completion notification %x " completion_code);
"while in wrong state %d\n", __func__, completion_code,
state); case SCI_REQ_STP_PIO_DATA_OUT:
return SCI_FAILURE_INVALID_STATE; return pio_data_out_tx_done_tc_event(sci_req, completion_code);
case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED:
return stp_request_soft_reset_await_h2d_asserted_tc_event(sci_req,
completion_code);
case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG:
return stp_request_soft_reset_await_h2d_diagnostic_tc_event(sci_req,
completion_code);
case SCI_REQ_ABORTING:
return request_aborting_state_tc_event(sci_req,
completion_code);
default:
dev_warn(scic_to_dev(scic),
"%s: SCIC IO Request given task completion "
"notification %x while in wrong state %d\n",
__func__,
completion_code,
state);
return SCI_FAILURE_INVALID_STATE;
} }
} }
...@@ -2896,7 +2930,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host, ...@@ -2896,7 +2930,7 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm) static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
struct domain_device *dev = sci_dev_to_domain(sci_req->target_device); struct domain_device *dev = sci_dev_to_domain(sci_req->target_device);
struct sas_task *task; struct sas_task *task;
...@@ -2910,34 +2944,31 @@ static void scic_sds_request_started_state_enter(struct sci_base_state_machine * ...@@ -2910,34 +2944,31 @@ static void scic_sds_request_started_state_enter(struct sci_base_state_machine *
* substates * substates
*/ */
if (!task && dev->dev_type == SAS_END_DEV) { if (!task && dev->dev_type == SAS_END_DEV) {
sci_base_state_machine_change_state(sm, sci_change_state(sm, SCI_REQ_TASK_WAIT_TC_COMP);
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION);
} else if (!task && } else if (!task &&
(isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high || (isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high ||
isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) { isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) {
sci_base_state_machine_change_state(sm, sci_change_state(sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED);
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE);
} else if (task && task->task_proto == SAS_PROTOCOL_SMP) { } else if (task && task->task_proto == SAS_PROTOCOL_SMP) {
sci_base_state_machine_change_state(sm, sci_change_state(sm, SCI_REQ_SMP_WAIT_RESP);
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE);
} else if (task && sas_protocol_ata(task->task_proto) && } else if (task && sas_protocol_ata(task->task_proto) &&
!task->ata_task.use_ncq) { !task->ata_task.use_ncq) {
u32 state; u32 state;
if (task->data_dir == DMA_NONE) if (task->data_dir == DMA_NONE)
state = SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE; state = SCI_REQ_STP_NON_DATA_WAIT_H2D;
else if (task->ata_task.dma_xfer) else if (task->ata_task.dma_xfer)
state = SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE; state = SCI_REQ_STP_UDMA_WAIT_TC_COMP;
else /* PIO */ else /* PIO */
state = SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE; state = SCI_REQ_STP_PIO_WAIT_H2D;
sci_base_state_machine_change_state(sm, state); sci_change_state(sm, state);
} }
} }
static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm) static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
...@@ -2952,7 +2983,7 @@ static void scic_sds_request_completed_state_enter(struct sci_base_state_machine ...@@ -2952,7 +2983,7 @@ static void scic_sds_request_completed_state_enter(struct sci_base_state_machine
static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm) static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
/* Setting the abort bit in the Task Context is required by the silicon. */ /* Setting the abort bit in the Task Context is required by the silicon. */
sci_req->task_context_buffer->abort = 1; sci_req->task_context_buffer->abort = 1;
...@@ -2960,7 +2991,7 @@ static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine ...@@ -2960,7 +2991,7 @@ static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine
static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
scic_sds_remote_device_set_working_request(sci_req->target_device, scic_sds_remote_device_set_working_request(sci_req->target_device,
sci_req); sci_req);
...@@ -2968,7 +2999,7 @@ static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(str ...@@ -2968,7 +2999,7 @@ static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(str
static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
scic_sds_remote_device_set_working_request(sci_req->target_device, scic_sds_remote_device_set_working_request(sci_req->target_device,
sci_req); sci_req);
...@@ -2976,7 +3007,7 @@ static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct s ...@@ -2976,7 +3007,7 @@ static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct s
static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
scic_sds_remote_device_set_working_request(sci_req->target_device, scic_sds_remote_device_set_working_request(sci_req->target_device,
sci_req); sci_req);
...@@ -2984,7 +3015,7 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completio ...@@ -2984,7 +3015,7 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completio
static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm) static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine); struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
struct scu_task_context *task_context; struct scu_task_context *task_context;
struct host_to_dev_fis *h2d_fis; struct host_to_dev_fis *h2d_fis;
enum sci_status status; enum sci_status status;
...@@ -3003,51 +3034,53 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_complet ...@@ -3003,51 +3034,53 @@ static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_complet
} }
static const struct sci_base_state scic_sds_request_state_table[] = { static const struct sci_base_state scic_sds_request_state_table[] = {
[SCI_BASE_REQUEST_STATE_INITIAL] = { }, [SCI_REQ_INIT] = { },
[SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { }, [SCI_REQ_CONSTRUCTED] = { },
[SCI_BASE_REQUEST_STATE_STARTED] = { [SCI_REQ_STARTED] = {
.enter_state = scic_sds_request_started_state_enter, .enter_state = scic_sds_request_started_state_enter,
}, },
[SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = { [SCI_REQ_STP_NON_DATA_WAIT_H2D] = {
.enter_state = scic_sds_stp_request_started_non_data_await_h2d_completion_enter, .enter_state = scic_sds_stp_request_started_non_data_await_h2d_completion_enter,
}, },
[SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = { }, [SCI_REQ_STP_NON_DATA_WAIT_D2H] = { },
[SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = { [SCI_REQ_STP_PIO_WAIT_H2D] = {
.enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter, .enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter,
}, },
[SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = { }, [SCI_REQ_STP_PIO_WAIT_FRAME] = { },
[SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = { }, [SCI_REQ_STP_PIO_DATA_IN] = { },
[SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = { }, [SCI_REQ_STP_PIO_DATA_OUT] = { },
[SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = { }, [SCI_REQ_STP_UDMA_WAIT_TC_COMP] = { },
[SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = { }, [SCI_REQ_STP_UDMA_WAIT_D2H] = { },
[SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = { [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED] = {
.enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter, .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter,
}, },
[SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE] = { [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG] = {
.enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter, .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter,
}, },
[SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = { }, [SCI_REQ_STP_SOFT_RESET_WAIT_D2H] = { },
[SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = { }, [SCI_REQ_TASK_WAIT_TC_COMP] = { },
[SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = { }, [SCI_REQ_TASK_WAIT_TC_RESP] = { },
[SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = { }, [SCI_REQ_SMP_WAIT_RESP] = { },
[SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = { }, [SCI_REQ_SMP_WAIT_TC_COMP] = { },
[SCI_BASE_REQUEST_STATE_COMPLETED] = { [SCI_REQ_COMPLETED] = {
.enter_state = scic_sds_request_completed_state_enter, .enter_state = scic_sds_request_completed_state_enter,
}, },
[SCI_BASE_REQUEST_STATE_ABORTING] = { [SCI_REQ_ABORTING] = {
.enter_state = scic_sds_request_aborting_state_enter, .enter_state = scic_sds_request_aborting_state_enter,
}, },
[SCI_BASE_REQUEST_STATE_FINAL] = { }, [SCI_REQ_FINAL] = { },
}; };
static void scic_sds_general_request_construct(struct scic_sds_controller *scic, static void
struct scic_sds_remote_device *sci_dev, scic_sds_general_request_construct(struct scic_sds_controller *scic,
u16 io_tag, struct scic_sds_request *sci_req) struct scic_sds_remote_device *sci_dev,
u16 io_tag,
struct scic_sds_request *sci_req)
{ {
sci_base_state_machine_construct(&sci_req->state_machine, sci_base_state_machine_construct(&sci_req->sm,
scic_sds_request_state_table, scic_sds_request_state_table,
SCI_BASE_REQUEST_STATE_INITIAL); SCI_REQ_INIT);
sci_base_state_machine_start(&sci_req->state_machine); sci_base_state_machine_start(&sci_req->sm);
sci_req->io_tag = io_tag; sci_req->io_tag = io_tag;
sci_req->owning_controller = scic; sci_req->owning_controller = scic;
...@@ -3322,8 +3355,7 @@ scic_io_request_construct_smp(struct scic_sds_request *sci_req) ...@@ -3322,8 +3355,7 @@ scic_io_request_construct_smp(struct scic_sds_request *sci_req)
scu_smp_request_construct_task_context(sci_req, smp_req->req_len); scu_smp_request_construct_task_context(sci_req, smp_req->req_len);
sci_base_state_machine_change_state(&sci_req->state_machine, sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return SCI_SUCCESS; return SCI_SUCCESS;
} }
......
...@@ -96,37 +96,42 @@ struct scic_sds_stp_request { ...@@ -96,37 +96,42 @@ struct scic_sds_stp_request {
u32 udma; u32 udma;
struct scic_sds_stp_pio_request { struct scic_sds_stp_pio_request {
/** /*
* Total transfer for the entire PIO request recorded at request constuction * Total transfer for the entire PIO request recorded
* time. * at request constuction time.
* *
* @todo Should we just decrement this value for each byte of data transitted * @todo Should we just decrement this value for each
* or received to elemenate the current_transfer_bytes field? * byte of data transitted or received to elemenate
* the current_transfer_bytes field?
*/ */
u32 total_transfer_bytes; u32 total_transfer_bytes;
/** /*
* Total number of bytes received/transmitted in data frames since the start * Total number of bytes received/transmitted in data
* of the IO request. At the end of the IO request this should equal the * frames since the start of the IO request. At the
* end of the IO request this should equal the
* total_transfer_bytes. * total_transfer_bytes.
*/ */
u32 current_transfer_bytes; u32 current_transfer_bytes;
/** /*
* The number of bytes requested in the in the PIO setup. * The number of bytes requested in the in the PIO
* setup.
*/ */
u32 pio_transfer_bytes; u32 pio_transfer_bytes;
/** /*
* PIO Setup ending status value to tell us if we need to wait for another FIS * PIO Setup ending status value to tell us if we need
* or if the transfer is complete. On the receipt of a D2H FIS this will be * to wait for another FIS or if the transfer is
* complete. On the receipt of a D2H FIS this will be
* the status field of that FIS. * the status field of that FIS.
*/ */
u8 ending_status; u8 ending_status;
/** /*
* On receipt of a D2H FIS this will be the ending error field if the * On receipt of a D2H FIS this will be the ending
* ending_status has the SATA_STATUS_ERR bit set. * error field if the ending_status has the
* SATA_STATUS_ERR bit set.
*/ */
u8 ending_error; u8 ending_error;
...@@ -138,8 +143,9 @@ struct scic_sds_stp_request { ...@@ -138,8 +143,9 @@ struct scic_sds_stp_request {
} pio; } pio;
struct { struct {
/** /*
* The number of bytes requested in the PIO setup before CDB data frame. * The number of bytes requested in the PIO setup
* before CDB data frame.
*/ */
u32 device_preferred_cdb_length; u32 device_preferred_cdb_length;
} packet; } packet;
...@@ -147,57 +153,59 @@ struct scic_sds_stp_request { ...@@ -147,57 +153,59 @@ struct scic_sds_stp_request {
}; };
struct scic_sds_request { struct scic_sds_request {
/** /*
* This field contains the information for the base request state machine. * This field contains the information for the base request state
* machine.
*/ */
struct sci_base_state_machine state_machine; struct sci_base_state_machine sm;
/** /*
* This field simply points to the controller to which this IO request * This field simply points to the controller to which this IO request
* is associated. * is associated.
*/ */
struct scic_sds_controller *owning_controller; struct scic_sds_controller *owning_controller;
/** /*
* This field simply points to the remote device to which this IO request * This field simply points to the remote device to which this IO
* is associated. * request is associated.
*/ */
struct scic_sds_remote_device *target_device; struct scic_sds_remote_device *target_device;
/** /*
* This field is utilized to determine if the SCI user is managing * This field is utilized to determine if the SCI user is managing
* the IO tag for this request or if the core is managing it. * the IO tag for this request or if the core is managing it.
*/ */
bool was_tag_assigned_by_user; bool was_tag_assigned_by_user;
/** /*
* This field indicates the IO tag for this request. The IO tag is * This field indicates the IO tag for this request. The IO tag is
* comprised of the task_index and a sequence count. The sequence count * comprised of the task_index and a sequence count. The sequence count
* is utilized to help identify tasks from one life to another. * is utilized to help identify tasks from one life to another.
*/ */
u16 io_tag; u16 io_tag;
/** /*
* This field specifies the protocol being utilized for this * This field specifies the protocol being utilized for this
* IO request. * IO request.
*/ */
enum sci_request_protocol protocol; enum sci_request_protocol protocol;
/** /*
* This field indicates the completion status taken from the SCUs * This field indicates the completion status taken from the SCUs
* completion code. It indicates the completion result for the SCU hardware. * completion code. It indicates the completion result for the SCU
* hardware.
*/ */
u32 scu_status; u32 scu_status;
/** /*
* This field indicates the completion status returned to the SCI user. It * This field indicates the completion status returned to the SCI user.
* indicates the users view of the io request completion. * It indicates the users view of the io request completion.
*/ */
u32 sci_status; u32 sci_status;
/** /*
* This field contains the value to be utilized when posting (e.g. Post_TC, * This field contains the value to be utilized when posting
* Post_TC_Abort) this request to the silicon. * (e.g. Post_TC, * Post_TC_Abort) this request to the silicon.
*/ */
u32 post_context; u32 post_context;
...@@ -208,26 +216,26 @@ struct scic_sds_request { ...@@ -208,26 +216,26 @@ struct scic_sds_request {
#define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2) #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2)
struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
/** /*
* This field indicates if this request is a task management request or * This field indicates if this request is a task management request or
* normal IO request. * normal IO request.
*/ */
bool is_task_management_request; bool is_task_management_request;
/** /*
* This field is a pointer to the stored rx frame data. It is used in STP * This field is a pointer to the stored rx frame data. It is used in
* internal requests and SMP response frames. If this field is non-NULL the * STP internal requests and SMP response frames. If this field is
* saved frame must be released on IO request completion. * non-NULL the saved frame must be released on IO request completion.
* *
* @todo In the future do we want to keep a list of RX frame buffers? * @todo In the future do we want to keep a list of RX frame buffers?
*/ */
u32 saved_rx_frame_index; u32 saved_rx_frame_index;
/** /*
* This field in the recorded device sequence for the io request. This is * This field in the recorded device sequence for the io request.
* recorded during the build operation and is compared in the start * This is recorded during the build operation and is compared in the
* operation. If the sequence is different then there was a change of * start operation. If the sequence is different then there was a
* devices from the build to start operations. * change of devices from the build to start operations.
*/ */
u8 device_sequence; u8 device_sequence;
...@@ -286,7 +294,7 @@ struct isci_request { ...@@ -286,7 +294,7 @@ struct isci_request {
dma_addr_t request_daddr; dma_addr_t request_daddr;
dma_addr_t zero_scatter_daddr; dma_addr_t zero_scatter_daddr;
unsigned int num_sg_entries; /* returned by pci_alloc_sg */ unsigned int num_sg_entries; /* returned by pci_alloc_sg */
/** Note: "io_request_completion" is completed in two different ways /** Note: "io_request_completion" is completed in two different ways
* depending on whether this is a TMF or regular request. * depending on whether this is a TMF or regular request.
...@@ -315,104 +323,105 @@ static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_ ...@@ -315,104 +323,105 @@ static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_
* *
*/ */
enum sci_base_request_states { enum sci_base_request_states {
/** /*
* Simply the initial state for the base request state machine. * Simply the initial state for the base request state machine.
*/ */
SCI_BASE_REQUEST_STATE_INITIAL, SCI_REQ_INIT,
/** /*
* This state indicates that the request has been constructed. This state * This state indicates that the request has been constructed.
* is entered from the INITIAL state. * This state is entered from the INITIAL state.
*/ */
SCI_BASE_REQUEST_STATE_CONSTRUCTED, SCI_REQ_CONSTRUCTED,
/** /*
* This state indicates that the request has been started. This state is * This state indicates that the request has been started. This state
* entered from the CONSTRUCTED state. * is entered from the CONSTRUCTED state.
*/ */
SCI_BASE_REQUEST_STATE_STARTED, SCI_REQ_STARTED,
SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE, SCI_REQ_STP_UDMA_WAIT_TC_COMP,
SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE, SCI_REQ_STP_UDMA_WAIT_D2H,
SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE, SCI_REQ_STP_NON_DATA_WAIT_H2D,
SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE, SCI_REQ_STP_NON_DATA_WAIT_D2H,
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED,
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG,
SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, SCI_REQ_STP_SOFT_RESET_WAIT_D2H,
/** /*
* While in this state the IO request object is waiting for the TC completion * While in this state the IO request object is waiting for the TC
* notification for the H2D Register FIS * completion notification for the H2D Register FIS
*/ */
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE, SCI_REQ_STP_PIO_WAIT_H2D,
/** /*
* While in this state the IO request object is waiting for either a PIO Setup * While in this state the IO request object is waiting for either a
* FIS or a D2H register FIS. The type of frame received is based on the * PIO Setup FIS or a D2H register FIS. The type of frame received is
* result of the prior frame and line conditions. * based on the result of the prior frame and line conditions.
*/ */
SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE, SCI_REQ_STP_PIO_WAIT_FRAME,
/** /*
* While in this state the IO request object is waiting for a DATA frame from * While in this state the IO request object is waiting for a DATA
* the device. * frame from the device.
*/ */
SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE, SCI_REQ_STP_PIO_DATA_IN,
/** /*
* While in this state the IO request object is waiting to transmit the next data * While in this state the IO request object is waiting to transmit
* frame to the device. * the next data frame to the device.
*/ */
SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, SCI_REQ_STP_PIO_DATA_OUT,
/** /*
* The AWAIT_TC_COMPLETION sub-state indicates that the started raw * The AWAIT_TC_COMPLETION sub-state indicates that the started raw
* task management request is waiting for the transmission of the * task management request is waiting for the transmission of the
* initial frame (i.e. command, task, etc.). * initial frame (i.e. command, task, etc.).
*/ */
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, SCI_REQ_TASK_WAIT_TC_COMP,
/** /*
* This sub-state indicates that the started task management request * This sub-state indicates that the started task management request
* is waiting for the reception of an unsolicited frame * is waiting for the reception of an unsolicited frame
* (i.e. response IU). * (i.e. response IU).
*/ */
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, SCI_REQ_TASK_WAIT_TC_RESP,
/** /*
* This sub-state indicates that the started task management request * This sub-state indicates that the started task management request
* is waiting for the reception of an unsolicited frame * is waiting for the reception of an unsolicited frame
* (i.e. response IU). * (i.e. response IU).
*/ */
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, SCI_REQ_SMP_WAIT_RESP,
/** /*
* The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP
* waiting for the transmission of the initial frame (i.e. command, task, etc.). * request is waiting for the transmission of the initial frame
* (i.e. command, task, etc.).
*/ */
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, SCI_REQ_SMP_WAIT_TC_COMP,
/** /*
* This state indicates that the request has completed. * This state indicates that the request has completed.
* This state is entered from the STARTED state. This state is entered from * This state is entered from the STARTED state. This state is entered
* the ABORTING state. * from the ABORTING state.
*/ */
SCI_BASE_REQUEST_STATE_COMPLETED, SCI_REQ_COMPLETED,
/** /*
* This state indicates that the request is in the process of being * This state indicates that the request is in the process of being
* terminated/aborted. * terminated/aborted.
* This state is entered from the CONSTRUCTED state. * This state is entered from the CONSTRUCTED state.
* This state is entered from the STARTED state. * This state is entered from the STARTED state.
*/ */
SCI_BASE_REQUEST_STATE_ABORTING, SCI_REQ_ABORTING,
/** /*
* Simply the final state for the base request state machine. * Simply the final state for the base request state machine.
*/ */
SCI_BASE_REQUEST_STATE_FINAL, SCI_REQ_FINAL,
}; };
/** /**
...@@ -498,13 +507,18 @@ enum sci_base_request_states { ...@@ -498,13 +507,18 @@ enum sci_base_request_states {
enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req);
enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req);
enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, enum sci_status
u32 event_code); scic_sds_io_request_event_handler(struct scic_sds_request *sci_req,
enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, u32 event_code);
u32 frame_index); enum sci_status
enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
extern enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req); u32 frame_index);
extern enum sci_status scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code); enum sci_status
scic_sds_task_request_terminate(struct scic_sds_request *sci_req);
extern enum sci_status
scic_sds_request_complete(struct scic_sds_request *sci_req);
extern enum sci_status
scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code);
/* XXX open code in caller */ /* XXX open code in caller */
static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req,
...@@ -523,8 +537,8 @@ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, ...@@ -523,8 +537,8 @@ static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req,
} }
/* XXX open code in caller */ /* XXX open code in caller */
static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, static inline dma_addr_t
void *virt_addr) scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, void *virt_addr)
{ {
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
...@@ -543,9 +557,8 @@ static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *s ...@@ -543,9 +557,8 @@ static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *s
* *
* status of the object as a isci_request_status enum. * status of the object as a isci_request_status enum.
*/ */
static inline static inline enum isci_request_status
enum isci_request_status isci_request_get_state( isci_request_get_state(struct isci_request *isci_request)
struct isci_request *isci_request)
{ {
BUG_ON(isci_request == NULL); BUG_ON(isci_request == NULL);
...@@ -566,9 +579,9 @@ enum isci_request_status isci_request_get_state( ...@@ -566,9 +579,9 @@ enum isci_request_status isci_request_get_state(
* @status: This Parameter is the new status of the object * @status: This Parameter is the new status of the object
* *
*/ */
static inline enum isci_request_status isci_request_change_state( static inline enum isci_request_status
struct isci_request *isci_request, isci_request_change_state(struct isci_request *isci_request,
enum isci_request_status status) enum isci_request_status status)
{ {
enum isci_request_status old_state; enum isci_request_status old_state;
unsigned long flags; unsigned long flags;
...@@ -597,10 +610,10 @@ static inline enum isci_request_status isci_request_change_state( ...@@ -597,10 +610,10 @@ static inline enum isci_request_status isci_request_change_state(
* *
* state previous to any change. * state previous to any change.
*/ */
static inline enum isci_request_status isci_request_change_started_to_newstate( static inline enum isci_request_status
struct isci_request *isci_request, isci_request_change_started_to_newstate(struct isci_request *isci_request,
struct completion *completion_ptr, struct completion *completion_ptr,
enum isci_request_status newstate) enum isci_request_status newstate)
{ {
enum isci_request_status old_state; enum isci_request_status old_state;
unsigned long flags; unsigned long flags;
...@@ -615,6 +628,7 @@ static inline enum isci_request_status isci_request_change_started_to_newstate( ...@@ -615,6 +628,7 @@ static inline enum isci_request_status isci_request_change_started_to_newstate(
isci_request->io_request_completion = completion_ptr; isci_request->io_request_completion = completion_ptr;
isci_request->status = newstate; isci_request->status = newstate;
} }
spin_unlock_irqrestore(&isci_request->state_lock, flags); spin_unlock_irqrestore(&isci_request->state_lock, flags);
dev_dbg(&isci_request->isci_host->pdev->dev, dev_dbg(&isci_request->isci_host->pdev->dev,
...@@ -635,13 +649,13 @@ static inline enum isci_request_status isci_request_change_started_to_newstate( ...@@ -635,13 +649,13 @@ static inline enum isci_request_status isci_request_change_started_to_newstate(
* *
* state previous to any change. * state previous to any change.
*/ */
static inline enum isci_request_status isci_request_change_started_to_aborted( static inline enum isci_request_status
struct isci_request *isci_request, isci_request_change_started_to_aborted(struct isci_request *isci_request,
struct completion *completion_ptr) struct completion *completion_ptr)
{ {
return isci_request_change_started_to_newstate( return isci_request_change_started_to_newstate(isci_request,
isci_request, completion_ptr, aborted completion_ptr,
); aborted);
} }
/** /**
* isci_request_free() - This function frees the request object. * isci_request_free() - This function frees the request object.
...@@ -649,62 +663,33 @@ static inline enum isci_request_status isci_request_change_started_to_aborted( ...@@ -649,62 +663,33 @@ static inline enum isci_request_status isci_request_change_started_to_aborted(
* @isci_request: This parameter points to the isci_request object * @isci_request: This parameter points to the isci_request object
* *
*/ */
static inline void isci_request_free( static inline void isci_request_free(struct isci_host *isci_host,
struct isci_host *isci_host, struct isci_request *isci_request)
struct isci_request *isci_request)
{ {
if (!isci_request) if (!isci_request)
return; return;
/* release the dma memory if we fail. */ /* release the dma memory if we fail. */
dma_pool_free(isci_host->dma_pool, isci_request, dma_pool_free(isci_host->dma_pool,
isci_request,
isci_request->request_daddr); isci_request->request_daddr);
} }
#define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr)
/* #define ISCI_REQUEST_VALIDATE_ACCESS #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr)
*/
#ifdef ISCI_REQUEST_VALIDATE_ACCESS
static inline
struct sas_task *isci_request_access_task(struct isci_request *isci_request)
{
BUG_ON(isci_request->ttype != io_task);
return isci_request->ttype_ptr.io_task_ptr;
}
static inline
struct isci_tmf *isci_request_access_tmf(struct isci_request *isci_request)
{
BUG_ON(isci_request->ttype != tmf_task);
return isci_request->ttype_ptr.tmf_task_ptr;
}
#else /* not ISCI_REQUEST_VALIDATE_ACCESS */
#define isci_request_access_task(RequestPtr) \
((RequestPtr)->ttype_ptr.io_task_ptr)
#define isci_request_access_tmf(RequestPtr) \
((RequestPtr)->ttype_ptr.tmf_task_ptr)
#endif /* not ISCI_REQUEST_VALIDATE_ACCESS */
int isci_request_alloc_tmf( int isci_request_alloc_tmf(struct isci_host *isci_host,
struct isci_host *isci_host, struct isci_tmf *isci_tmf,
struct isci_tmf *isci_tmf, struct isci_request **isci_request,
struct isci_request **isci_request, struct isci_remote_device *isci_device,
struct isci_remote_device *isci_device, gfp_t gfp_flags);
gfp_t gfp_flags);
int isci_request_execute( int isci_request_execute(struct isci_host *isci_host,
struct isci_host *isci_host, struct sas_task *task,
struct sas_task *task, struct isci_request **request,
struct isci_request **request, gfp_t gfp_flags);
gfp_t gfp_flags);
/** /**
* isci_request_unmap_sgl() - This function unmaps the DMA address of a given * isci_request_unmap_sgl() - This function unmaps the DMA address of a given
...@@ -713,9 +698,8 @@ int isci_request_execute( ...@@ -713,9 +698,8 @@ int isci_request_execute(
* @*pdev: This Parameter is the pci_device struct for the controller * @*pdev: This Parameter is the pci_device struct for the controller
* *
*/ */
static inline void isci_request_unmap_sgl( static inline void
struct isci_request *request, isci_request_unmap_sgl(struct isci_request *request, struct pci_dev *pdev)
struct pci_dev *pdev)
{ {
struct sas_task *task = isci_request_access_task(request); struct sas_task *task = isci_request_access_task(request);
...@@ -758,9 +742,9 @@ static inline void isci_request_unmap_sgl( ...@@ -758,9 +742,9 @@ static inline void isci_request_unmap_sgl(
* *
* pointer to the next sge for specified request. * pointer to the next sge for specified request.
*/ */
static inline void *isci_request_io_request_get_next_sge( static inline void *
struct isci_request *request, isci_request_io_request_get_next_sge(struct isci_request *request,
void *current_sge_address) void *current_sge_address)
{ {
struct sas_task *task = isci_request_access_task(request); struct sas_task *task = isci_request_access_task(request);
void *ret = NULL; void *ret = NULL;
...@@ -791,15 +775,20 @@ static inline void *isci_request_io_request_get_next_sge( ...@@ -791,15 +775,20 @@ static inline void *isci_request_io_request_get_next_sge(
return ret; return ret;
} }
void isci_terminate_pending_requests(struct isci_host *isci_host, void
struct isci_remote_device *isci_device, isci_terminate_pending_requests(struct isci_host *isci_host,
enum isci_request_status new_request_state); struct isci_remote_device *isci_device,
enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, enum isci_request_status new_request_state);
struct scic_sds_remote_device *sci_dev, enum sci_status
u16 io_tag, scic_task_request_construct(struct scic_sds_controller *scic,
struct scic_sds_request *sci_req); struct scic_sds_remote_device *sci_dev,
enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); u16 io_tag,
enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); struct scic_sds_request *sci_req);
void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); enum sci_status
scic_task_request_construct_ssp(struct scic_sds_request *sci_req);
enum sci_status
scic_task_request_construct_sata(struct scic_sds_request *sci_req);
void
scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag);
void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req);
#endif /* !defined(_ISCI_REQUEST_H_) */ #endif /* !defined(_ISCI_REQUEST_H_) */
...@@ -127,16 +127,7 @@ void sci_base_state_machine_stop( ...@@ -127,16 +127,7 @@ void sci_base_state_machine_stop(
sci_state_machine_exit_state(sm); sci_state_machine_exit_state(sm);
} }
/** void sci_change_state(struct sci_base_state_machine *sm, u32 next_state)
* This method performs an update to the current state of the state machine.
* @sm: This parameter specifies the state machine for which
* the caller wishes to perform a state change.
* @next_state: This parameter specifies the new state for the state machine.
*
*/
void sci_base_state_machine_change_state(
struct sci_base_state_machine *sm,
u32 next_state)
{ {
sci_state_machine_exit_state(sm); sci_state_machine_exit_state(sm);
...@@ -145,18 +136,3 @@ void sci_base_state_machine_change_state( ...@@ -145,18 +136,3 @@ void sci_base_state_machine_change_state(
sci_state_machine_enter_state(sm); sci_state_machine_enter_state(sm);
} }
/**
* This method simply returns the current state of the state machine to the
* caller.
* @sm: This parameter specifies the state machine for which to
* retrieve the current state.
*
* This method returns a u32 value indicating the current state for the
* supplied state machine.
*/
u32 sci_base_state_machine_get_state(struct sci_base_state_machine *sm)
{
return sm->current_state_id;
}
...@@ -117,8 +117,6 @@ void sci_base_state_machine_construct(struct sci_base_state_machine *sm, ...@@ -117,8 +117,6 @@ void sci_base_state_machine_construct(struct sci_base_state_machine *sm,
u32 initial_state); u32 initial_state);
void sci_base_state_machine_start(struct sci_base_state_machine *sm); void sci_base_state_machine_start(struct sci_base_state_machine *sm);
void sci_base_state_machine_stop(struct sci_base_state_machine *sm); void sci_base_state_machine_stop(struct sci_base_state_machine *sm);
void sci_base_state_machine_change_state(struct sci_base_state_machine *sm, void sci_change_state(struct sci_base_state_machine *sm, u32 next_state);
u32 next_state);
u32 sci_base_state_machine_get_state(struct sci_base_state_machine *sm);
#endif /* _SCI_BASE_STATE_MACHINE_H_ */ #endif /* _SCI_BASE_STATE_MACHINE_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment