/** * This method will handle the event for a ATAPI device that is in * the ATAPI ERROR state. We pick up suspension events to handle specifically * to this state. We resume the RNC right away. We then complete the outstanding * IO to this device. * * @param [in] device The device received event. * @param [in] event_code The event code. * * @return SCI_STATUS */ static SCI_STATUS scic_sds_stp_remote_device_ready_atapi_error_substate_event_handler( SCIC_SDS_REMOTE_DEVICE_T * this_device, U32 event_code ) { SCI_STATUS status; status = scic_sds_remote_device_general_event_handler(this_device, event_code); if (status == SCI_SUCCESS) { if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX || scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) { status = scic_sds_remote_node_context_resume( this_device->rnc, (SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK) this_device->working_request->state_handlers->parent.complete_handler, (void *)this_device->working_request ); } } return status; }
static SCI_STATUS scic_sds_remote_node_context_resuming_state_event_handler( struct SCIC_SDS_REMOTE_NODE_CONTEXT * this_rnc, U32 event_code ) { SCI_STATUS status; if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) { status = SCI_SUCCESS; sci_base_state_machine_change_state( &this_rnc->state_machine, SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE ); } else { switch (scu_get_event_type(event_code)) { case SCU_EVENT_TYPE_RNC_SUSPEND_TX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: // We really dont care if the hardware is going to suspend // the device since it's being resumed anyway SCIC_LOG_INFO(( sci_base_object_get_logger(this_rnc->device), SCIC_LOG_OBJECT_SSP_REMOTE_TARGET | SCIC_LOG_OBJECT_SMP_REMOTE_TARGET | SCIC_LOG_OBJECT_STP_REMOTE_TARGET, "SCIC Remote Node Context 0x%x was suspeneded by hardware while being resumed.\n", this_rnc )); status = SCI_SUCCESS; break; default: SCIC_LOG_WARNING(( sci_base_object_get_logger(this_rnc->device), SCIC_LOG_OBJECT_SSP_REMOTE_TARGET | SCIC_LOG_OBJECT_SMP_REMOTE_TARGET | SCIC_LOG_OBJECT_STP_REMOTE_TARGET, "SCIC Remote Node Context 0x%x requested to process event 0x%x while in state %d.\n", this_rnc, event_code, sci_base_state_machine_get_state(&this_rnc->state_machine) )); status = SCI_FAILURE; break; } } return status; }
/** * This method will handle the event for a sata device that is in * the idle state. We pick up suspension events to handle specifically * to this state. We resume the RNC right away. * * @param [in] device The device received event. * @param [in] event_code The event code. * * @return SCI_STATUS */ static SCI_STATUS scic_sds_stp_remote_device_ready_idle_substate_event_handler( SCIC_SDS_REMOTE_DEVICE_T * this_device, U32 event_code ) { SCI_STATUS status; status = scic_sds_remote_device_general_event_handler(this_device, event_code); if (status == SCI_SUCCESS) { if ((scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX || scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) && (this_device->rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY)) { status = scic_sds_remote_node_context_resume( this_device->rnc, NULL, NULL); } } return status; }
static SCI_STATUS scic_sds_remote_node_context_await_suspension_state_event_handler( struct SCIC_SDS_REMOTE_NODE_CONTEXT * this_rnc, U32 event_code ) { SCI_STATUS status; switch (scu_get_event_type(event_code)) { case SCU_EVENT_TL_RNC_SUSPEND_TX: sci_base_state_machine_change_state( &this_rnc->state_machine, SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE ); this_rnc->suspension_code = scu_get_event_specifier(event_code); status = SCI_SUCCESS; break; case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: sci_base_state_machine_change_state( &this_rnc->state_machine, SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE ); this_rnc->suspension_code = scu_get_event_specifier(event_code); status = SCI_SUCCESS; break; default: SCIC_LOG_WARNING(( sci_base_object_get_logger(this_rnc->device), SCIC_LOG_OBJECT_SSP_REMOTE_TARGET | SCIC_LOG_OBJECT_SMP_REMOTE_TARGET | SCIC_LOG_OBJECT_STP_REMOTE_TARGET, "SCIC Remote Node Context 0x%x requested to process event 0x%x while in state %d.\n", this_rnc, event_code, sci_base_state_machine_get_state(&this_rnc->state_machine) )); status = SCI_FAILURE; break; } return status; }
enum sci_status sci_remote_node_context_event_handler(struct sci_remote_node_context *sci_rnc, u32 event_code) { enum scis_sds_remote_node_context_states state; state = sci_rnc->sm.current_state_id; switch (state) { case SCI_RNC_POSTING: switch (scu_get_event_code(event_code)) { case SCU_EVENT_POST_RNC_COMPLETE: sci_change_state(&sci_rnc->sm, SCI_RNC_READY); break; default: goto out; } break; case SCI_RNC_INVALIDATING: 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) state = SCI_RNC_INITIAL; else state = SCI_RNC_POSTING; sci_change_state(&sci_rnc->sm, state); } else { switch (scu_get_event_type(event_code)) { case SCU_EVENT_TYPE_RNC_SUSPEND_TX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: /* We really dont care if the hardware is going to suspend * the device since it's being invalidated anyway */ dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)), "%s: SCIC Remote Node Context 0x%p was " "suspeneded by hardware while being " "invalidated.\n", __func__, sci_rnc); break; default: goto out; } } break; case SCI_RNC_RESUMING: if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) { sci_change_state(&sci_rnc->sm, SCI_RNC_READY); } else { switch (scu_get_event_type(event_code)) { case SCU_EVENT_TYPE_RNC_SUSPEND_TX: case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: /* We really dont care if the hardware is going to suspend * the device since it's being resumed anyway */ dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)), "%s: SCIC Remote Node Context 0x%p was " "suspeneded by hardware while being resumed.\n", __func__, sci_rnc); break; default: goto out; } } break; case SCI_RNC_READY: switch (scu_get_event_type(event_code)) { case SCU_EVENT_TL_RNC_SUSPEND_TX: sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED); sci_rnc->suspension_code = scu_get_event_specifier(event_code); break; case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED); sci_rnc->suspension_code = scu_get_event_specifier(event_code); break; default: goto out; } break; case SCI_RNC_AWAIT_SUSPENSION: switch (scu_get_event_type(event_code)) { case SCU_EVENT_TL_RNC_SUSPEND_TX: sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED); sci_rnc->suspension_code = scu_get_event_specifier(event_code); break; case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED); sci_rnc->suspension_code = scu_get_event_specifier(event_code); break; default: goto out; } break; default: dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), "%s: invalid state %d\n", __func__, state); return SCI_FAILURE_INVALID_STATE; } return SCI_SUCCESS; out: dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), "%s: code: %#x state: %d\n", __func__, event_code, state); return SCI_FAILURE; }