struct scu_task_context *task_context)
{
dma_addr_t dma_addr;
- struct scic_sds_controller *controller;
struct scic_sds_remote_device *target_device;
struct scic_sds_port *target_port;
- controller = scic_sds_request_get_controller(sds_request);
target_device = scic_sds_request_get_device(sds_request);
target_port = scic_sds_request_get_port(sds_request);
struct scu_task_context *task_context)
{
dma_addr_t dma_addr;
- struct scic_sds_controller *controller;
struct scic_sds_remote_device *target_device;
struct scic_sds_port *target_port;
- controller = scic_sds_request_get_controller(sci_req);
target_device = scic_sds_request_get_device(sci_req);
target_port = scic_sds_request_get_port(sci_req);
scic_sds_io_request_build_ssp_command_iu(sci_req);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
return SCI_SUCCESS;
}
/* Fill in the SSP Task IU */
scic_sds_task_request_build_ssp_task_iu(sci_req);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
return SCI_SUCCESS;
}
static enum sci_status scic_io_request_construct_basic_sata(struct scic_sds_request *sci_req)
{
enum sci_status status;
- struct scic_sds_stp_request *stp_req;
bool copy = false;
struct isci_request *isci_request = sci_req_to_ireq(sci_req);
struct sas_task *task = isci_request_access_task(isci_request);
- stp_req = &sci_req->stp.req;
sci_req->protocol = SCIC_STP_PROTOCOL;
copy = (task->data_dir == DMA_NONE) ? false : true;
copy);
if (status == SCI_SUCCESS)
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
return status;
}
if (status != SCI_SUCCESS)
return status;
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
return status;
}
return ret_val;
}
-enum sci_status
-scic_sds_request_start(struct scic_sds_request *request)
+enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req)
{
- if (request->device_sequence !=
- scic_sds_remote_device_get_sequence(request->target_device))
+ struct scic_sds_controller *scic = sci_req->owning_controller;
+ struct scu_task_context *task_context;
+ enum sci_base_request_states state;
+
+ if (sci_req->device_sequence !=
+ scic_sds_remote_device_get_sequence(sci_req->target_device))
return SCI_FAILURE;
- if (request->state_handlers->start_handler)
- return request->state_handlers->start_handler(request);
+ state = sci_req->sm.current_state_id;
+ if (state != SCI_REQ_CONSTRUCTED) {
+ dev_warn(scic_to_dev(scic),
+ "%s: SCIC IO Request requested to start while in wrong "
+ "state %d\n", __func__, state);
+ return SCI_FAILURE_INVALID_STATE;
+ }
- dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request requested to start while in wrong "
- "state %d\n",
- __func__,
- sci_base_state_machine_get_state(&request->state_machine));
+ /* if necessary, allocate a TCi for the io request object and then will,
+ * if necessary, copy the constructed TC data into the actual TC buffer.
+ * If everything is successful the post context field is updated with
+ * the TCi so the controller can post the request to the hardware.
+ */
+ if (sci_req->io_tag == SCI_CONTROLLER_INVALID_IO_TAG)
+ sci_req->io_tag = scic_controller_allocate_io_tag(scic);
- return SCI_FAILURE_INVALID_STATE;
+ /* Record the IO Tag in the request */
+ if (sci_req->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) {
+ task_context = sci_req->task_context_buffer;
+
+ task_context->task_index = scic_sds_io_tag_get_index(sci_req->io_tag);
+
+ switch (task_context->protocol_type) {
+ case SCU_TASK_CONTEXT_PROTOCOL_SMP:
+ case SCU_TASK_CONTEXT_PROTOCOL_SSP:
+ /* SSP/SMP Frame */
+ task_context->type.ssp.tag = sci_req->io_tag;
+ task_context->type.ssp.target_port_transfer_tag =
+ 0xFFFF;
+ break;
+
+ case SCU_TASK_CONTEXT_PROTOCOL_STP:
+ /* STP/SATA Frame
+ * task_context->type.stp.ncq_tag = sci_req->ncq_tag;
+ */
+ break;
+
+ case SCU_TASK_CONTEXT_PROTOCOL_NONE:
+ /* / @todo When do we set no protocol type? */
+ break;
+
+ default:
+ /* This should never happen since we build the IO
+ * requests */
+ break;
+ }
+
+ /*
+ * Check to see if we need to copy the task context buffer
+ * or have been building into the task context buffer */
+ if (sci_req->was_tag_assigned_by_user == false)
+ scic_sds_controller_copy_task_context(scic, sci_req);
+
+ /* Add to the post_context the io tag value */
+ sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag);
+
+ /* Everything is good go ahead and change state */
+ sci_change_state(&sci_req->sm, SCI_REQ_STARTED);
+
+ return SCI_SUCCESS;
+ }
+
+ return SCI_FAILURE_INSUFFICIENT_RESOURCES;
}
enum sci_status
-scic_sds_io_request_terminate(struct scic_sds_request *request)
+scic_sds_io_request_terminate(struct scic_sds_request *sci_req)
{
- if (request->state_handlers->abort_handler)
- return request->state_handlers->abort_handler(request);
+ enum sci_base_request_states state;
- dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request requested to abort while in wrong "
- "state %d\n",
- __func__,
- sci_base_state_machine_get_state(&request->state_machine));
+ state = sci_req->sm.current_state_id;
+
+ switch (state) {
+ case SCI_REQ_CONSTRUCTED:
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_TASK_ABORT,
+ SCI_FAILURE_IO_TERMINATED);
+
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ return SCI_SUCCESS;
+ case SCI_REQ_STARTED:
+ case SCI_REQ_TASK_WAIT_TC_COMP:
+ case SCI_REQ_SMP_WAIT_RESP:
+ case SCI_REQ_SMP_WAIT_TC_COMP:
+ case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
+ case SCI_REQ_STP_UDMA_WAIT_D2H:
+ case SCI_REQ_STP_NON_DATA_WAIT_H2D:
+ case SCI_REQ_STP_NON_DATA_WAIT_D2H:
+ case SCI_REQ_STP_PIO_WAIT_H2D:
+ case SCI_REQ_STP_PIO_WAIT_FRAME:
+ case SCI_REQ_STP_PIO_DATA_IN:
+ case SCI_REQ_STP_PIO_DATA_OUT:
+ case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED:
+ case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG:
+ case SCI_REQ_STP_SOFT_RESET_WAIT_D2H:
+ sci_change_state(&sci_req->sm, SCI_REQ_ABORTING);
+ return SCI_SUCCESS;
+ case SCI_REQ_TASK_WAIT_TC_RESP:
+ sci_change_state(&sci_req->sm, SCI_REQ_ABORTING);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ return SCI_SUCCESS;
+ case SCI_REQ_ABORTING:
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ return SCI_SUCCESS;
+ case SCI_REQ_COMPLETED:
+ default:
+ dev_warn(scic_to_dev(sci_req->owning_controller),
+ "%s: SCIC IO Request requested to abort while in wrong "
+ "state %d\n",
+ __func__,
+ sci_req->sm.current_state_id);
+ break;
+ }
return SCI_FAILURE_INVALID_STATE;
}
-enum sci_status scic_sds_io_request_event_handler(
- struct scic_sds_request *request,
- u32 event_code)
+enum sci_status scic_sds_request_complete(struct scic_sds_request *sci_req)
{
- if (request->state_handlers->event_handler)
- return request->state_handlers->event_handler(request, event_code);
+ enum sci_base_request_states state;
+ struct scic_sds_controller *scic = sci_req->owning_controller;
- dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request given event code notification %x while "
- "in wrong state %d\n",
- __func__,
- event_code,
- sci_base_state_machine_get_state(&request->state_machine));
+ state = sci_req->sm.current_state_id;
+ if (WARN_ONCE(state != SCI_REQ_COMPLETED,
+ "isci: request completion from wrong state (%d)\n", state))
+ return SCI_FAILURE_INVALID_STATE;
- return SCI_FAILURE_INVALID_STATE;
+ if (!sci_req->was_tag_assigned_by_user)
+ scic_controller_free_io_tag(scic, sci_req->io_tag);
+
+ if (sci_req->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX)
+ scic_sds_controller_release_frame(scic,
+ sci_req->saved_rx_frame_index);
+
+ /* XXX can we just stop the machine and remove the 'final' state? */
+ sci_change_state(&sci_req->sm, SCI_REQ_FINAL);
+ return SCI_SUCCESS;
}
-/**
- *
- * @sci_req: The SCIC_SDS_IO_REQUEST_T object for which the start
- * operation is to be executed.
- * @frame_index: The frame index returned by the hardware for the reqeust
- * object.
- *
- * This method invokes the core state frame handler for the
- * SCIC_SDS_IO_REQUEST_T object. enum sci_status
- */
-enum sci_status scic_sds_io_request_frame_handler(
- struct scic_sds_request *request,
- u32 frame_index)
+enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req,
+ u32 event_code)
{
- if (request->state_handlers->frame_handler)
- return request->state_handlers->frame_handler(request, frame_index);
+ enum sci_base_request_states state;
+ struct scic_sds_controller *scic = sci_req->owning_controller;
- dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request given unexpected frame %x while in "
- "state %d\n",
- __func__,
- frame_index,
- sci_base_state_machine_get_state(&request->state_machine));
+ state = sci_req->sm.current_state_id;
- scic_sds_controller_release_frame(request->owning_controller, frame_index);
- return SCI_FAILURE_INVALID_STATE;
+ if (state != SCI_REQ_STP_PIO_DATA_IN) {
+ dev_warn(scic_to_dev(scic), "%s: (%x) in wrong state %d\n",
+ __func__, event_code, state);
+
+ return SCI_FAILURE_INVALID_STATE;
+ }
+
+ switch (scu_get_event_specifier(event_code)) {
+ case SCU_TASK_DONE_CRC_ERR << SCU_EVENT_SPECIFIC_CODE_SHIFT:
+ /* We are waiting for data and the SCU has R_ERR the data frame.
+ * Go back to waiting for the D2H Register FIS
+ */
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
+ return SCI_SUCCESS;
+ default:
+ dev_err(scic_to_dev(scic),
+ "%s: pio request unexpected event %#x\n",
+ __func__, event_code);
+
+ /* TODO Should we fail the PIO request when we get an
+ * unexpected event?
+ */
+ return SCI_FAILURE;
+ }
}
/*
memcpy(resp_buf, ssp_response->resp_data, len);
}
-/*
- * This method implements the action taken when a constructed
- * SCIC_SDS_IO_REQUEST_T object receives a scic_sds_request_start() request.
- * This method will, if necessary, allocate a TCi for the io request object and
- * then will, if necessary, copy the constructed TC data into the actual TC
- * buffer. If everything is successful the post context field is updated with
- * the TCi so the controller can post the request to the hardware. enum sci_status
- * SCI_SUCCESS SCI_FAILURE_INSUFFICIENT_RESOURCES
- */
-static enum sci_status scic_sds_request_constructed_state_start_handler(
- struct scic_sds_request *request)
-{
- struct scu_task_context *task_context;
-
- if (request->io_tag == SCI_CONTROLLER_INVALID_IO_TAG) {
- request->io_tag =
- scic_controller_allocate_io_tag(request->owning_controller);
- }
-
- /* Record the IO Tag in the request */
- if (request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) {
- task_context = request->task_context_buffer;
-
- task_context->task_index = scic_sds_io_tag_get_index(request->io_tag);
-
- switch (task_context->protocol_type) {
- case SCU_TASK_CONTEXT_PROTOCOL_SMP:
- case SCU_TASK_CONTEXT_PROTOCOL_SSP:
- /* SSP/SMP Frame */
- task_context->type.ssp.tag = request->io_tag;
- task_context->type.ssp.target_port_transfer_tag = 0xFFFF;
- break;
-
- case SCU_TASK_CONTEXT_PROTOCOL_STP:
- /*
- * STP/SATA Frame
- * task_context->type.stp.ncq_tag = request->ncq_tag; */
- break;
-
- case SCU_TASK_CONTEXT_PROTOCOL_NONE:
- /* / @todo When do we set no protocol type? */
- break;
-
- default:
- /* This should never happen since we build the IO requests */
- break;
- }
-
- /*
- * Check to see if we need to copy the task context buffer
- * or have been building into the task context buffer */
- if (request->was_tag_assigned_by_user == false) {
- scic_sds_controller_copy_task_context(
- request->owning_controller, request);
- }
-
- /* Add to the post_context the io tag value */
- request->post_context |= scic_sds_io_tag_get_index(request->io_tag);
-
- /* Everything is good go ahead and change state */
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_STARTED);
-
- return SCI_SUCCESS;
- }
-
- return SCI_FAILURE_INSUFFICIENT_RESOURCES;
-}
-
-/*
- * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_terminate() request. Since the request
- * has not yet been posted to the hardware the request transitions to the
- * completed state. enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_request_constructed_state_abort_handler(
- struct scic_sds_request *request)
-{
- /*
- * This request has been terminated by the user make sure that the correct
- * status code is returned */
- scic_sds_request_set_status(request,
- SCU_TASK_DONE_TASK_ABORT,
- SCI_FAILURE_IO_TERMINATED);
-
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
- return SCI_SUCCESS;
-}
-
-static enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req)
-{
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_ABORTING);
- return SCI_SUCCESS;
-}
-
-/*
- * scic_sds_request_started_state_tc_completion_handler() - This method process
- * TC (task context) completions for normal IO request (i.e. Task/Abort
- * Completions of type 0). This method will update the
- * SCIC_SDS_IO_REQUEST_T::status field.
- * @sci_req: This parameter specifies the request for which a completion
- * occurred.
- * @completion_code: This parameter specifies the completion code received from
- * the SCU.
- *
- */
static enum sci_status
-scic_sds_request_started_state_tc_completion_handler(struct scic_sds_request *sci_req,
- u32 completion_code)
+request_started_state_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
- u8 datapres;
struct ssp_response_iu *resp_iu;
+ u8 datapres;
- /*
- * TODO: Any SDMA return code of other than 0 is bad
- * decode 0x003C0000 to determine SDMA status
+ /* TODO: Any SDMA return code of other than 0 is bad decode 0x003C0000
+ * to determine SDMA status
*/
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
SCU_TASK_DONE_GOOD,
SCI_SUCCESS);
break;
-
- case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP):
- {
- /*
- * There are times when the SCU hardware will return an early
+ case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP): {
+ /* There are times when the SCU hardware will return an early
* response because the io request specified more data than is
* returned by the target device (mode pages, inquiry data,
* etc.). We must check the response stats to see if this is
word_cnt);
if (resp->status == 0) {
- scic_sds_request_set_status(
- sci_req,
- SCU_TASK_DONE_GOOD,
- SCI_SUCCESS_IO_DONE_EARLY);
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_GOOD,
+ SCI_SUCCESS_IO_DONE_EARLY);
} else {
- scic_sds_request_set_status(
- sci_req,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID);
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
}
+ break;
}
- break;
-
- case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE):
- {
+ case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE): {
ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);
sci_swab32_cpy(&sci_req->ssp.rsp,
}
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RESP_LEN_ERR):
- /*
- * / @todo With TASK_DONE_RESP_LEN_ERR is the response frame
+ /* TODO With TASK_DONE_RESP_LEN_ERR is the response frame
* guaranteed to be received before this completion status is
* posted?
*/
resp_iu = &sci_req->ssp.rsp;
datapres = resp_iu->datapres;
- if ((datapres == 0x01) || (datapres == 0x02)) {
- scic_sds_request_set_status(
- sci_req,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID);
+ if (datapres == 1 || datapres == 2) {
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
} else
- 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);
break;
-
/* only stp device gets suspended. */
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_PERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDB_ERR):
if (sci_req->protocol == SCIC_STP_PROTOCOL) {
- scic_sds_request_set_status(
- sci_req,
+ scic_sds_request_set_status(sci_req,
SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
SCU_COMPLETION_TL_STATUS_SHIFT,
SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED);
} else {
- scic_sds_request_set_status(
- sci_req,
+ scic_sds_request_set_status(sci_req,
SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
SCU_COMPLETION_TL_STATUS_SHIFT,
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED):
- scic_sds_request_set_status(
- sci_req,
- SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
- SCU_COMPLETION_TL_STATUS_SHIFT,
- SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED);
+ scic_sds_request_set_status(sci_req,
+ SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
+ SCU_COMPLETION_TL_STATUS_SHIFT,
+ SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED);
break;
/* neither ssp nor stp gets suspended. */
*/
/* 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_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
return SCI_SUCCESS;
}
-enum sci_status
-scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code)
-{
- if (request->state_handlers->tc_completion_handler)
- return request->state_handlers->tc_completion_handler(request, completion_code);
-
- dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request given task completion notification %x "
- "while in wrong state %d\n",
- __func__,
- completion_code,
- sci_base_state_machine_get_state(&request->state_machine));
-
- return SCI_FAILURE_INVALID_STATE;
-}
-
-/*
- * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_frame_handler() request. This method
- * first determines the frame type received. If this is a response frame then
- * the response data is copied to the io request response buffer for processing
- * at completion time. If the frame type is not a response buffer an error is
- * logged. enum sci_status SCI_SUCCESS SCI_FAILURE_INVALID_PARAMETER_VALUE
- */
static enum sci_status
-scic_sds_request_started_state_frame_handler(struct scic_sds_request *sci_req,
- u32 frame_index)
-{
- enum sci_status status;
- u32 *frame_header;
- struct ssp_frame_hdr ssp_hdr;
- ssize_t word_cnt;
-
- status = scic_sds_unsolicited_frame_control_get_header(
- &(scic_sds_request_get_controller(sci_req)->uf_control),
- frame_index,
- (void **)&frame_header);
-
- word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32);
- sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt);
-
- if (ssp_hdr.frame_type == SSP_RESPONSE) {
- struct ssp_response_iu *resp_iu;
- ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);
-
- status = scic_sds_unsolicited_frame_control_get_buffer(
- &(scic_sds_request_get_controller(sci_req)->uf_control),
- frame_index,
- (void **)&resp_iu);
-
- sci_swab32_cpy(&sci_req->ssp.rsp,
- resp_iu, word_cnt);
-
- resp_iu = &sci_req->ssp.rsp;
-
- if ((resp_iu->datapres == 0x01) ||
- (resp_iu->datapres == 0x02)) {
- scic_sds_request_set_status(
- sci_req,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
- } else
- scic_sds_request_set_status(
- sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS);
- } else {
- /* This was not a response frame why did it get forwarded? */
- dev_err(scic_to_dev(sci_req->owning_controller),
- "%s: SCIC IO Request 0x%p received unexpected "
- "frame %d type 0x%02x\n",
- __func__,
- sci_req,
- frame_index,
- ssp_hdr.frame_type);
- }
-
- /*
- * In any case we are done with this frame buffer return it to the
- * controller
- */
- scic_sds_controller_release_frame(
- sci_req->owning_controller, frame_index);
-
- return SCI_SUCCESS;
-}
-
-/*
- * *****************************************************************************
- * * COMPLETED STATE HANDLERS
- * ***************************************************************************** */
-
-
-/*
- * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_complete() request. This method frees up
- * any io request resources that have been allocated and transitions the
- * request to its final state. Consider stopping the state machine instead of
- * transitioning to the final state? enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_request_completed_state_complete_handler(
- struct scic_sds_request *request)
-{
- if (request->was_tag_assigned_by_user != true) {
- scic_controller_free_io_tag(
- request->owning_controller, request->io_tag);
- }
-
- if (request->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) {
- scic_sds_controller_release_frame(
- request->owning_controller, request->saved_rx_frame_index);
- }
-
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_FINAL);
- return SCI_SUCCESS;
-}
-
-/*
- * *****************************************************************************
- * * ABORTING STATE HANDLERS
- * ***************************************************************************** */
-
-/*
- * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_terminate() request. This method is the
- * io request aborting state abort handlers. On receipt of a multiple
- * terminate requests the io request will transition to the completed state.
- * This should not happen in normal operation. enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_request_aborting_state_abort_handler(
- struct scic_sds_request *request)
-{
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
- return SCI_SUCCESS;
-}
-
-/*
- * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_task_completion() request. This method
- * decodes the completion type waiting for the abort task complete
- * notification. When the abort task complete is received the io request
- * transitions to the completed state. enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_request_aborting_state_tc_completion_handler(
- struct scic_sds_request *sci_req,
- 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)) {
case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT):
case (SCU_TASK_DONE_TASK_ABORT << SCU_COMPLETION_TL_STATUS_SHIFT):
- scic_sds_request_set_status(
- sci_req, SCU_TASK_DONE_TASK_ABORT, SCI_FAILURE_IO_TERMINATED
- );
+ scic_sds_request_set_status(sci_req, SCU_TASK_DONE_TASK_ABORT,
+ SCI_FAILURE_IO_TERMINATED);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
default:
- /*
- * Unless we get some strange error wait for the task abort to complete
- * TODO: Should there be a state change for this completion? */
+ /* Unless we get some strange error wait for the task abort to complete
+ * TODO: Should there be a state change for this completion?
+ */
break;
}
return SCI_SUCCESS;
}
-/*
- * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_frame_handler() request. This method
- * discards the unsolicited frame since we are waiting for the abort task
- * completion. enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_request_aborting_state_frame_handler(
- struct scic_sds_request *sci_req,
- u32 frame_index)
-{
- /* TODO: Is it even possible to get an unsolicited frame in the aborting state? */
-
- scic_sds_controller_release_frame(
- sci_req->owning_controller, frame_index);
-
- return SCI_SUCCESS;
-}
-
-/**
- * This method processes the completions transport layer (TL) status to
- * determine if the RAW task management frame was sent successfully. If the
- * raw frame was sent successfully, then the state for the task request
- * transitions to waiting for a response frame.
- * @sci_req: This parameter specifies the request for which the TC
- * completion was received.
- * @completion_code: This parameter indicates the completion status information
- * for the TC.
- *
- * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
- * this method always returns success.
- */
-static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status ssp_task_request_await_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE);
+ sci_change_state(&sci_req->sm, SCI_REQ_TASK_WAIT_TC_RESP);
break;
-
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO):
- /*
- * Currently, the decision is to simply allow the task request to
- * timeout if the task IU wasn't received successfully.
- * There is a potential for receiving multiple task responses if we
- * decide to send the task IU again. */
+ /* Currently, the decision is to simply allow the task request
+ * to timeout if the task IU wasn't received successfully.
+ * There is a potential for receiving multiple task responses if
+ * we decide to send the task IU again.
+ */
dev_warn(scic_to_dev(sci_req->owning_controller),
"%s: TaskRequest:0x%p CompletionCode:%x - "
- "ACK/NAK timeout\n",
- __func__,
- sci_req,
+ "ACK/NAK timeout\n", __func__, sci_req,
completion_code);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE);
+ sci_change_state(&sci_req->sm, SCI_REQ_TASK_WAIT_TC_RESP);
break;
-
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. */
- scic_sds_request_set_status(
- sci_req,
+ * 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,
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_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return SCI_SUCCESS;
}
-/**
- * This method is responsible for processing a terminate/abort request for this
- * TC while the request is waiting for the task management response
- * unsolicited frame.
- * @sci_req: This parameter specifies the request for which the
- * termination was requested.
- *
- * This method returns an indication as to whether the abort request was
- * successfully handled. need to update to ensure the received UF doesn't cause
- * damage to subsequent requests (i.e. put the extended tag in a holding
- * pattern for this particular device).
- */
-static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler(
- struct scic_sds_request *request)
-{
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_ABORTING);
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
- return SCI_SUCCESS;
-}
-
-/**
- * This method processes an unsolicited frame while the task mgmt request is
- * waiting for a response frame. It will copy the response data, release
- * the unsolicited frame, and transition the request to the
- * SCI_BASE_REQUEST_STATE_COMPLETED state.
- * @sci_req: This parameter specifies the request for which the
- * unsolicited frame was received.
- * @frame_index: This parameter indicates the unsolicited frame index that
- * should contain the response.
- *
- * This method returns an indication of whether the TC response frame was
- * handled successfully or not. SCI_SUCCESS Currently this value is always
- * returned and indicates successful processing of the TC response. Should
- * probably update to check frame type and make sure it is a response frame.
- */
-static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler(
- struct scic_sds_request *request,
- u32 frame_index)
-{
- scic_sds_io_request_copy_response(request);
-
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
- scic_sds_controller_release_frame(request->owning_controller,
- frame_index);
- return SCI_SUCCESS;
-}
-
-/**
- * This method processes an abnormal TC completion while the SMP request is
- * waiting for a response frame. It decides what happened to the IO based
- * on TC completion status.
- * @sci_req: This parameter specifies the request for which the TC
- * completion was received.
- * @completion_code: This parameter indicates the completion status information
- * for the TC.
- *
- * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
- * this method always returns success.
- */
-static enum sci_status scic_sds_smp_request_await_response_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status
+smp_request_await_response_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
- /*
- * In the AWAIT RESPONSE state, any TC completion is unexpected.
- * but if the TC has success status, we complete the IO anyway. */
+ /* In the AWAIT RESPONSE state, any TC completion is
+ * unexpected. but if the TC has success status, we
+ * complete the IO anyway.
+ */
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_UFI_ERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_FRM_TYPE_ERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_LL_RX_ERR):
- /*
- * These status has been seen in a specific LSI expander, which sometimes
- * is not able to send smp response within 2 ms. This causes our hardware
- * break the connection and set TC completion with one of these SMP_XXX_XX_ERR
- * status. For these type of error, we ask scic user to retry the request. */
+ /* These status has been seen in a specific LSI
+ * expander, which sometimes is not able to send smp
+ * response within 2 ms. This causes our hardware break
+ * the connection and set TC completion with one of
+ * these SMP_XXX_XX_ERR status. For these type of error,
+ * we ask scic user to retry the request.
+ */
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_SMP_RESP_TO_ERR,
SCI_FAILURE_RETRY_REQUIRED);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
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. */
- scic_sds_request_set_status(
- sci_req,
- SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ /* 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,
+ SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return SCI_SUCCESS;
}
-/*
- * This function processes an unsolicited frame while the SMP request is waiting
- * for a response frame. It will copy the response data, release the
- * unsolicited frame, and transition the request to the
- * SCI_BASE_REQUEST_STATE_COMPLETED state.
- * @sci_req: This parameter specifies the request for which the
- * unsolicited frame was received.
- * @frame_index: This parameter indicates the unsolicited frame index that
- * should contain the response.
- *
- * This function returns an indication of whether the response frame was handled
- * successfully or not. SCI_SUCCESS Currently this value is always returned and
- * indicates successful processing of the TC response.
- */
static enum sci_status
-scic_sds_smp_request_await_response_frame_handler(struct scic_sds_request *sci_req,
- u32 frame_index)
-{
- enum sci_status status;
- void *frame_header;
- struct smp_resp *rsp_hdr = &sci_req->smp.rsp;
- ssize_t word_cnt = SMP_RESP_HDR_SZ / sizeof(u32);
-
- status = scic_sds_unsolicited_frame_control_get_header(
- &(scic_sds_request_get_controller(sci_req)->uf_control),
- frame_index,
- &frame_header);
-
- /* byte swap the header. */
- sci_swab32_cpy(rsp_hdr, frame_header, word_cnt);
-
- if (rsp_hdr->frame_type == SMP_RESPONSE) {
- void *smp_resp;
-
- status = scic_sds_unsolicited_frame_control_get_buffer(
- &(scic_sds_request_get_controller(sci_req)->uf_control),
- frame_index,
- &smp_resp);
-
- word_cnt = (sizeof(struct smp_req) - SMP_RESP_HDR_SZ) /
- sizeof(u32);
-
- sci_swab32_cpy(((u8 *) rsp_hdr) + SMP_RESP_HDR_SZ,
- smp_resp, word_cnt);
-
- scic_sds_request_set_status(
- sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS);
-
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION);
- } else {
- /* This was not a response frame why did it get forwarded? */
- dev_err(scic_to_dev(sci_req->owning_controller),
- "%s: SCIC SMP Request 0x%p received unexpected frame "
- "%d type 0x%02x\n",
- __func__,
- sci_req,
- frame_index,
- rsp_hdr->frame_type);
-
- scic_sds_request_set_status(
- sci_req,
- SCU_TASK_DONE_SMP_FRM_TYPE_ERR,
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
-
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
- }
-
- scic_sds_controller_release_frame(sci_req->owning_controller,
- frame_index);
-
- return SCI_SUCCESS;
-}
-
-/**
- * This method processes the completions transport layer (TL) status to
- * determine if the SMP request was sent successfully. If the SMP request
- * was sent successfully, then the state for the SMP request transits to
- * waiting for a response frame.
- * @sci_req: This parameter specifies the request for which the TC
- * completion was received.
- * @completion_code: This parameter indicates the completion status information
- * for the TC.
- *
- * Indicate if the tc completion handler was successful. SCI_SUCCESS currently
- * this method always returns success.
- */
-static enum sci_status scic_sds_smp_request_await_tc_completion_tc_completion_handler(
- struct scic_sds_request *sci_req,
- 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)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
-
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. */
- scic_sds_request_set_status(
- sci_req,
- SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ /* 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,
+ SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
- sci_base_state_machine_change_state(
- &sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return current_sgl;
}
-/**
- *
- * @sci_req:
- * @completion_code:
- *
- * This method processes a TC completion. The expected TC completion is for
- * the transmission of the H2D register FIS containing the SATA/STP non-data
- * request. This method always successfully processes the TC completion.
- * SCI_SUCCESS This value is always returned.
- */
-static enum sci_status scic_sds_stp_request_non_data_await_h2d_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status
+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)) {
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,
- SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE
- );
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H);
break;
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. */
- scic_sds_request_set_status(
- sci_req,
- SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ /* 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,
+ SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
- sci_base_state_machine_change_state(
- &sci_req->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return SCI_SUCCESS;
}
-/**
- *
- * @request: This parameter specifies the request for which a frame has been
- * received.
- * @frame_index: This parameter specifies the index of the frame that has been
- * received.
- *
- * This method processes frames received from the target while waiting for a
- * device to host register FIS. If a non-register FIS is received during this
- * time, it is treated as a protocol violation from an IO perspective. Indicate
- * if the received frame was processed successfully.
- */
-static enum sci_status scic_sds_stp_request_non_data_await_d2h_frame_handler(
- struct scic_sds_request *sci_req,
- u32 frame_index)
-{
- enum sci_status status;
- struct dev_to_host_fis *frame_header;
- u32 *frame_buffer;
- struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
- struct scic_sds_controller *scic = sci_req->owning_controller;
-
- status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
- frame_index,
- (void **)&frame_header);
-
- if (status != SCI_SUCCESS) {
- dev_err(scic_to_dev(sci_req->owning_controller),
- "%s: SCIC IO Request 0x%p could not get frame header "
- "for frame index %d, status %x\n",
- __func__, stp_req, frame_index, status);
-
- return status;
- }
-
- switch (frame_header->fis_type) {
- case FIS_REGD2H:
- scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
- frame_index,
- (void **)&frame_buffer);
-
- scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
- frame_header,
- frame_buffer);
-
- /* The command has completed with error */
- scic_sds_request_set_status(sci_req, SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID);
- break;
-
- default:
- dev_warn(scic_to_dev(scic),
- "%s: IO Request:0x%p Frame Id:%d protocol "
- "violation occurred\n", __func__, stp_req,
- frame_index);
-
- scic_sds_request_set_status(sci_req, SCU_TASK_DONE_UNEXP_FIS,
- SCI_FAILURE_PROTOCOL_VIOLATION);
- break;
- }
-
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
-
- /* Frame has been decoded return it to the controller */
- scic_sds_controller_release_frame(scic, frame_index);
-
- return status;
-}
-
#define SCU_MAX_FRAME_BUFFER_SIZE 0x400 /* 1K is the maximum SCU frame data payload */
/* transmit DATA_FIS from (current sgl + offset) for input
return status;
}
-/**
- *
- * @sci_req:
- * @completion_code:
- *
- * enum sci_status
- */
-static enum sci_status scic_sds_stp_request_pio_await_h2d_completion_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status
+stp_request_pio_await_h2d_completion_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
enum sci_status status = SCI_SUCCESS;
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
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,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE
- );
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
+ break;
+
+ 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.
+ */
+ scic_sds_request_set_status(sci_req,
+ SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
+
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ break;
+ }
+
+ return status;
+}
+
+static enum sci_status
+pio_data_out_tx_done_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
+{
+ enum sci_status status = SCI_SUCCESS;
+ bool all_frames_transferred = false;
+ struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
+
+ switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
+ case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
+ /* Transmit data */
+ if (stp_req->type.pio.pio_transfer_bytes != 0) {
+ status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req);
+ if (status == SCI_SUCCESS) {
+ if (stp_req->type.pio.pio_transfer_bytes == 0)
+ all_frames_transferred = true;
+ }
+ } else if (stp_req->type.pio.pio_transfer_bytes == 0) {
+ /*
+ * this will happen if the all data is written at the
+ * first time after the pio setup fis is received
+ */
+ all_frames_transferred = true;
+ }
+
+ /* all data transferred. */
+ if (all_frames_transferred) {
+ /*
+ * Change the state to SCI_REQ_STP_PIO_DATA_IN
+ * and wait for PIO_SETUP fis / or D2H REg fis. */
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
+ }
break;
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,
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_BASE_REQUEST_STATE_COMPLETED
- );
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return status;
}
-static enum sci_status scic_sds_stp_request_pio_await_frame_frame_handler(struct scic_sds_request *sci_req,
- u32 frame_index)
+static void scic_sds_stp_request_udma_complete_request(
+ struct scic_sds_request *request,
+ u32 scu_status,
+ enum sci_status sci_status)
+{
+ scic_sds_request_set_status(request, scu_status, sci_status);
+ sci_change_state(&request->sm, SCI_REQ_COMPLETED);
+}
+
+static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct scic_sds_request *sci_req,
+ u32 frame_index)
{
struct scic_sds_controller *scic = sci_req->owning_controller;
- struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
- struct isci_request *ireq = sci_req_to_ireq(sci_req);
- struct sas_task *task = isci_request_access_task(ireq);
struct dev_to_host_fis *frame_header;
enum sci_status status;
u32 *frame_buffer;
frame_index,
(void **)&frame_header);
- if (status != SCI_SUCCESS) {
- dev_err(scic_to_dev(scic),
- "%s: SCIC IO Request 0x%p could not get frame header "
- "for frame index %d, status %x\n",
- __func__, stp_req, frame_index, status);
- return status;
- }
-
- switch (frame_header->fis_type) {
- case FIS_PIO_SETUP:
- /* Get from the frame buffer the PIO Setup Data */
+ if ((status == SCI_SUCCESS) &&
+ (frame_header->fis_type == FIS_REGD2H)) {
scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
frame_index,
(void **)&frame_buffer);
- /* Get the data from the PIO Setup The SCU Hardware returns
- * first word in the frame_header and the rest of the data is in
- * the frame buffer so we need to back up one dword
- */
-
- /* transfer_count: first 16bits in the 4th dword */
- stp_req->type.pio.pio_transfer_bytes = frame_buffer[3] & 0xffff;
-
- /* ending_status: 4th byte in the 3rd dword */
- stp_req->type.pio.ending_status = (frame_buffer[2] >> 24) & 0xff;
-
scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
frame_header,
frame_buffer);
-
- sci_req->stp.rsp.status = stp_req->type.pio.ending_status;
-
- /* The next state is dependent on whether the
- * request was PIO Data-in or Data out
- */
- if (task->data_dir == DMA_FROM_DEVICE) {
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE);
- } else if (task->data_dir == DMA_TO_DEVICE) {
- /* Transmit data */
- status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req);
- if (status != SCI_SUCCESS)
- break;
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE);
- }
- break;
- case FIS_SETDEVBITS:
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
- break;
- case FIS_REGD2H:
- 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
- * the right state.
- */
- dev_dbg(scic_to_dev(scic),
- "%s: SCIC PIO Request 0x%p received "
- "D2H Register FIS with BSY status "
- "0x%x\n", __func__, stp_req,
- frame_header->status);
- break;
- }
-
- scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
- frame_index,
- (void **)&frame_buffer);
-
- scic_sds_controller_copy_sata_response(&sci_req->stp.req,
- frame_header,
- frame_buffer);
-
- scic_sds_request_set_status(sci_req,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID);
-
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
- break;
- default:
- /* FIXME: what do we do here? */
- break;
}
- /* Frame is decoded return it to the controller */
scic_sds_controller_release_frame(scic, frame_index);
return status;
}
-static enum sci_status scic_sds_stp_request_pio_data_in_await_data_frame_handler(struct scic_sds_request *sci_req,
- u32 frame_index)
+enum sci_status
+scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
+ u32 frame_index)
{
- enum sci_status status;
- struct dev_to_host_fis *frame_header;
- struct sata_fis_data *frame_buffer;
- struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
struct scic_sds_controller *scic = sci_req->owning_controller;
+ struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
+ enum sci_base_request_states state;
+ enum sci_status status;
+ ssize_t word_cnt;
- status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
- frame_index,
- (void **)&frame_header);
+ state = sci_req->sm.current_state_id;
+ switch (state) {
+ case SCI_REQ_STARTED: {
+ struct ssp_frame_hdr ssp_hdr;
+ void *frame_header;
+
+ scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
+ frame_index,
+ &frame_header);
+
+ word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32);
+ sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt);
+
+ if (ssp_hdr.frame_type == SSP_RESPONSE) {
+ struct ssp_response_iu *resp_iu;
+ ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);
+
+ scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
+ frame_index,
+ (void **)&resp_iu);
+
+ sci_swab32_cpy(&sci_req->ssp.rsp, resp_iu, word_cnt);
+
+ resp_iu = &sci_req->ssp.rsp;
+
+ if (resp_iu->datapres == 0x01 ||
+ resp_iu->datapres == 0x02) {
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
+ } else
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_GOOD,
+ SCI_SUCCESS);
+ } else {
+ /* not a response frame, why did it get forwarded? */
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC IO Request 0x%p received unexpected "
+ "frame %d type 0x%02x\n", __func__, sci_req,
+ frame_index, ssp_hdr.frame_type);
+ }
+
+ /*
+ * In any case we are done with this frame buffer return it to
+ * the controller
+ */
+ scic_sds_controller_release_frame(scic, frame_index);
+
+ return SCI_SUCCESS;
+ }
+
+ case SCI_REQ_TASK_WAIT_TC_RESP:
+ scic_sds_io_request_copy_response(sci_req);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ scic_sds_controller_release_frame(scic,frame_index);
+ return SCI_SUCCESS;
+
+ case SCI_REQ_SMP_WAIT_RESP: {
+ struct smp_resp *rsp_hdr = &sci_req->smp.rsp;
+ void *frame_header;
+
+ scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
+ frame_index,
+ &frame_header);
+
+ /* byte swap the header. */
+ word_cnt = SMP_RESP_HDR_SZ / sizeof(u32);
+ sci_swab32_cpy(rsp_hdr, frame_header, word_cnt);
+
+ if (rsp_hdr->frame_type == SMP_RESPONSE) {
+ void *smp_resp;
+
+ scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
+ frame_index,
+ &smp_resp);
+
+ word_cnt = (sizeof(struct smp_req) - SMP_RESP_HDR_SZ) /
+ sizeof(u32);
+
+ sci_swab32_cpy(((u8 *) rsp_hdr) + SMP_RESP_HDR_SZ,
+ smp_resp, word_cnt);
+
+ scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
+ SCI_SUCCESS);
+
+ sci_change_state(&sci_req->sm, SCI_REQ_SMP_WAIT_TC_COMP);
+ } else {
+ /*
+ * This was not a response frame why did it get
+ * forwarded?
+ */
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC SMP Request 0x%p received unexpected "
+ "frame %d type 0x%02x\n",
+ __func__,
+ sci_req,
+ frame_index,
+ rsp_hdr->frame_type);
+
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_SMP_FRM_TYPE_ERR,
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
+
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ }
+
+ scic_sds_controller_release_frame(scic, frame_index);
+
+ return SCI_SUCCESS;
+ }
+
+ case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
+ 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 */
+ status = scic_sds_stp_request_udma_general_frame_handler(sci_req,
+ frame_index);
+
+ if (status != SCI_SUCCESS)
+ return status;
+
+ scic_sds_stp_request_udma_complete_request(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
+
+ return SCI_SUCCESS;
+
+ case SCI_REQ_STP_NON_DATA_WAIT_D2H: {
+ struct dev_to_host_fis *frame_header;
+ u32 *frame_buffer;
+
+ status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
+ frame_index,
+ (void **)&frame_header);
+
+ if (status != SCI_SUCCESS) {
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC IO Request 0x%p could not get frame "
+ "header for frame index %d, status %x\n",
+ __func__,
+ stp_req,
+ frame_index,
+ status);
+
+ return status;
+ }
+
+ switch (frame_header->fis_type) {
+ case FIS_REGD2H:
+ scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
+ frame_index,
+ (void **)&frame_buffer);
+
+ scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
+ frame_header,
+ frame_buffer);
+
+ /* The command has completed with error */
+ scic_sds_request_set_status(sci_req, SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
+ break;
+
+ default:
+ dev_warn(scic_to_dev(scic),
+ "%s: IO Request:0x%p Frame Id:%d protocol "
+ "violation occurred\n", __func__, stp_req,
+ frame_index);
+
+ scic_sds_request_set_status(sci_req, SCU_TASK_DONE_UNEXP_FIS,
+ SCI_FAILURE_PROTOCOL_VIOLATION);
+ break;
+ }
+
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+
+ /* Frame has been decoded return it to the controller */
+ scic_sds_controller_release_frame(scic, frame_index);
+
+ return status;
+ }
+
+ case SCI_REQ_STP_PIO_WAIT_FRAME: {
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
+ struct sas_task *task = isci_request_access_task(ireq);
+ struct dev_to_host_fis *frame_header;
+ u32 *frame_buffer;
+
+ status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
+ frame_index,
+ (void **)&frame_header);
+
+ if (status != SCI_SUCCESS) {
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC IO Request 0x%p could not get frame "
+ "header for frame index %d, status %x\n",
+ __func__, stp_req, frame_index, status);
+ return status;
+ }
+
+ switch (frame_header->fis_type) {
+ case FIS_PIO_SETUP:
+ /* Get from the frame buffer the PIO Setup Data */
+ scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
+ frame_index,
+ (void **)&frame_buffer);
+
+ /* Get the data from the PIO Setup The SCU Hardware
+ * returns first word in the frame_header and the rest
+ * of the data is in the frame buffer so we need to
+ * back up one dword
+ */
+
+ /* transfer_count: first 16bits in the 4th dword */
+ stp_req->type.pio.pio_transfer_bytes = frame_buffer[3] & 0xffff;
+
+ /* ending_status: 4th byte in the 3rd dword */
+ stp_req->type.pio.ending_status = (frame_buffer[2] >> 24) & 0xff;
+
+ scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
+ frame_header,
+ frame_buffer);
+
+ sci_req->stp.rsp.status = stp_req->type.pio.ending_status;
+
+ /* The next state is dependent on whether the
+ * request was PIO Data-in or Data out
+ */
+ if (task->data_dir == DMA_FROM_DEVICE) {
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_DATA_IN);
+ } else if (task->data_dir == DMA_TO_DEVICE) {
+ /* Transmit data */
+ status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req);
+ if (status != SCI_SUCCESS)
+ break;
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_DATA_OUT);
+ }
+ break;
+
+ case FIS_SETDEVBITS:
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
+ break;
+
+ case FIS_REGD2H:
+ 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 the right state.
+ */
+ dev_dbg(scic_to_dev(scic),
+ "%s: SCIC PIO Request 0x%p received "
+ "D2H Register FIS with BSY status "
+ "0x%x\n",
+ __func__,
+ stp_req,
+ frame_header->status);
+ break;
+ }
+
+ scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
+ frame_index,
+ (void **)&frame_buffer);
+
+ scic_sds_controller_copy_sata_response(&sci_req->stp.req,
+ frame_header,
+ frame_buffer);
+
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
+
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+ break;
+
+ default:
+ /* FIXME: what do we do here? */
+ break;
+ }
+
+ /* Frame is decoded return it to the controller */
+ scic_sds_controller_release_frame(scic, frame_index);
- if (status != SCI_SUCCESS) {
- dev_err(scic_to_dev(scic),
- "%s: SCIC IO Request 0x%p could not get frame header "
- "for frame index %d, status %x\n",
- __func__, stp_req, frame_index, status);
return status;
}
- if (frame_header->fis_type == FIS_DATA) {
+ case SCI_REQ_STP_PIO_DATA_IN: {
+ struct dev_to_host_fis *frame_header;
+ struct sata_fis_data *frame_buffer;
+
+ status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
+ frame_index,
+ (void **)&frame_header);
+
+ if (status != SCI_SUCCESS) {
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC IO Request 0x%p could not get frame "
+ "header for frame index %d, status %x\n",
+ __func__,
+ stp_req,
+ frame_index,
+ status);
+ return status;
+ }
+
+ if (frame_header->fis_type != FIS_DATA) {
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC PIO Request 0x%p received frame %d "
+ "with fis type 0x%02x when expecting a data "
+ "fis.\n",
+ __func__,
+ stp_req,
+ frame_index,
+ frame_header->fis_type);
+
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_GOOD,
+ SCI_FAILURE_IO_REQUIRES_SCSI_ABORT);
+
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
+
+ /* Frame is decoded return it to the controller */
+ scic_sds_controller_release_frame(scic, frame_index);
+ return status;
+ }
+
if (stp_req->type.pio.request_current.sgl_pair == NULL) {
sci_req->saved_rx_frame_index = frame_index;
stp_req->type.pio.pio_transfer_bytes = 0;
SCU_TASK_DONE_CHECK_RESPONSE,
SCI_FAILURE_IO_RESPONSE_VALID);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
} else {
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE);
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_PIO_WAIT_FRAME);
}
- } else {
- dev_err(scic_to_dev(scic),
- "%s: SCIC PIO Request 0x%p received frame %d "
- "with fis type 0x%02x when expecting a data "
- "fis.\n", __func__, stp_req, frame_index,
- frame_header->fis_type);
-
- scic_sds_request_set_status(sci_req,
- SCU_TASK_DONE_GOOD,
- SCI_FAILURE_IO_REQUIRES_SCSI_ABORT);
+ return status;
+ }
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: {
+ struct dev_to_host_fis *frame_header;
+ u32 *frame_buffer;
- /* Frame is decoded return it to the controller */
- scic_sds_controller_release_frame(scic, frame_index);
- }
+ status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
+ frame_index,
+ (void **)&frame_header);
+ if (status != SCI_SUCCESS) {
+ dev_err(scic_to_dev(scic),
+ "%s: SCIC IO Request 0x%p could not get frame "
+ "header for frame index %d, status %x\n",
+ __func__,
+ stp_req,
+ frame_index,
+ status);
+ return status;
+ }
- return status;
-}
+ switch (frame_header->fis_type) {
+ case FIS_REGD2H:
+ scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
+ frame_index,
+ (void **)&frame_buffer);
+ scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
+ frame_header,
+ frame_buffer);
-/**
- *
- * @sci_req:
- * @completion_code:
- *
- * enum sci_status
- */
-static enum sci_status scic_sds_stp_request_pio_data_out_await_data_transmit_completion_tc_completion_handler(
+ /* The command has completed with error */
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
+ break;
- struct scic_sds_request *sci_req,
- u32 completion_code)
-{
- enum sci_status status = SCI_SUCCESS;
- bool all_frames_transferred = false;
- struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
+ default:
+ dev_warn(scic_to_dev(scic),
+ "%s: IO Request:0x%p Frame Id:%d protocol "
+ "violation occurred\n",
+ __func__,
+ stp_req,
+ frame_index);
- switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
- case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
- /* Transmit data */
- if (stp_req->type.pio.pio_transfer_bytes != 0) {
- status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req);
- if (status == SCI_SUCCESS) {
- if (stp_req->type.pio.pio_transfer_bytes == 0)
- all_frames_transferred = true;
- }
- } else if (stp_req->type.pio.pio_transfer_bytes == 0) {
- /*
- * this will happen if the all data is written at the
- * first time after the pio setup fis is received
- */
- all_frames_transferred = true;
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_UNEXP_FIS,
+ SCI_FAILURE_PROTOCOL_VIOLATION);
+ break;
}
- /* all data transferred. */
- if (all_frames_transferred) {
- /*
- * Change the state to SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_FRAME_SUBSTATE
- * and wait for PIO_SETUP fis / or D2H REg fis. */
- sci_base_state_machine_change_state(
- &sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE
- );
- }
- break;
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
- 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. */
- scic_sds_request_set_status(
- sci_req,
- SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ /* Frame has been decoded return it to the controller */
+ scic_sds_controller_release_frame(scic, frame_index);
- sci_base_state_machine_change_state(
- &sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED
- );
- break;
+ return status;
}
-
- return status;
-}
-
-/**
- *
- * @request: This is the request which is receiving the event.
- * @event_code: This is the event code that the request on which the request is
- * expected to take action.
- *
- * This method will handle any link layer events while waiting for the data
- * frame. enum sci_status SCI_SUCCESS SCI_FAILURE
- */
-static enum sci_status scic_sds_stp_request_pio_data_in_await_data_event_handler(
- struct scic_sds_request *request,
- u32 event_code)
-{
- enum sci_status status;
-
- switch (scu_get_event_specifier(event_code)) {
- case SCU_TASK_DONE_CRC_ERR << SCU_EVENT_SPECIFIC_CODE_SHIFT:
+ case SCI_REQ_ABORTING:
/*
- * We are waiting for data and the SCU has R_ERR the data frame.
- * Go back to waiting for the D2H Register FIS */
- sci_base_state_machine_change_state(
- &request->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE
- );
-
- status = SCI_SUCCESS;
- break;
+ * TODO: Is it even possible to get an unsolicited frame in the
+ * aborting state?
+ */
+ scic_sds_controller_release_frame(scic, frame_index);
+ return SCI_SUCCESS;
default:
- dev_err(scic_to_dev(request->owning_controller),
- "%s: SCIC PIO Request 0x%p received unexpected "
- "event 0x%08x\n",
- __func__, request, event_code);
-
- /* / @todo Should we fail the PIO request when we get an unexpected event? */
- status = SCI_FAILURE;
- break;
- }
-
- return status;
-}
-
-static void scic_sds_stp_request_udma_complete_request(
- struct scic_sds_request *request,
- u32 scu_status,
- enum sci_status sci_status)
-{
- scic_sds_request_set_status(request, scu_status, sci_status);
- sci_base_state_machine_change_state(&request->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
-}
-
-static enum sci_status scic_sds_stp_request_udma_general_frame_handler(struct scic_sds_request *sci_req,
- u32 frame_index)
-{
- struct scic_sds_controller *scic = sci_req->owning_controller;
- struct dev_to_host_fis *frame_header;
- enum sci_status status;
- u32 *frame_buffer;
-
- status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
- frame_index,
- (void **)&frame_header);
-
- if ((status == SCI_SUCCESS) &&
- (frame_header->fis_type == FIS_REGD2H)) {
- scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
- frame_index,
- (void **)&frame_buffer);
+ dev_warn(scic_to_dev(scic),
+ "%s: SCIC IO Request given unexpected frame %x while "
+ "in state %d\n",
+ __func__,
+ frame_index,
+ state);
- scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
- frame_header,
- frame_buffer);
+ scic_sds_controller_release_frame(scic, frame_index);
+ return SCI_FAILURE_INVALID_STATE;
}
-
- scic_sds_controller_release_frame(scic, frame_index);
-
- return status;
}
-static enum sci_status scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status stp_request_udma_await_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
enum sci_status status = SCI_SUCCESS;
break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_FIS):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR):
- /*
- * We must check ther response buffer to see if the D2H Register FIS was
- * received before we got the TC completion. */
+ /* We must check ther response buffer to see if the D2H
+ * Register FIS was received before we got the TC
+ * completion.
+ */
if (sci_req->stp.rsp.fis_type == FIS_REGD2H) {
scic_sds_remote_device_suspend(sci_req->target_device,
SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code)));
SCU_TASK_DONE_CHECK_RESPONSE,
SCI_FAILURE_IO_RESPONSE_VALID);
} else {
- /*
- * If we have an error completion status for the TC then we can expect a
- * D2H register FIS from the device so we must change state to wait for it */
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE);
+ /* If we have an error completion status for the
+ * TC then we can expect a D2H register FIS from
+ * the device so we must change state to wait
+ * for it
+ */
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_UDMA_WAIT_D2H);
}
break;
- /*
- * / @todo Check to see if any of these completion status need to wait for
- * / the device to host register fis. */
- /* / @todo We can retry the command for SCU_TASK_DONE_CMD_LL_R_ERR - this comes only for B0 */
+ /* TODO Check to see if any of these completion status need to
+ * wait for the device to host register fis.
+ */
+ /* TODO We can retry the command for SCU_TASK_DONE_CMD_LL_R_ERR
+ * - this comes only for B0
+ */
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_INV_FIS_LEN):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_R_ERR):
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
break;
}
-
- return status;
-}
-
-static enum sci_status scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler(
- struct scic_sds_request *sci_req,
- u32 frame_index)
-{
- enum sci_status status;
-
- /* Use the general frame handler to copy the resposne data */
- status = scic_sds_stp_request_udma_general_frame_handler(sci_req, frame_index);
-
- if (status != SCI_SUCCESS)
- return status;
-
- scic_sds_stp_request_udma_complete_request(sci_req,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID);
-
- return status;
-}
-
-enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req,
- u32 len,
- enum dma_data_direction dir)
-{
- return SCI_SUCCESS;
+
+ return status;
}
-/**
- *
- * @sci_req:
- * @completion_code:
- *
- * This method processes a TC completion. The expected TC completion is for
- * the transmission of the H2D register FIS containing the SATA/STP non-data
- * request. This method always successfully processes the TC completion.
- * SCI_SUCCESS This value is always returned.
- */
-static enum sci_status scic_sds_stp_request_soft_reset_await_h2d_asserted_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status
+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)) {
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,
- SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE
- );
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG);
break;
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. */
- scic_sds_request_set_status(
- sci_req,
- SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ * 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,
+ SCU_NORMALIZE_COMPLETION_STATUS(completion_code),
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
- sci_base_state_machine_change_state(
- &sci_req->state_machine, SCI_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return SCI_SUCCESS;
}
-/**
- *
- * @sci_req:
- * @completion_code:
- *
- * This method processes a TC completion. The expected TC completion is for
- * the transmission of the H2D register FIS containing the SATA/STP non-data
- * request. This method always successfully processes the TC completion.
- * SCI_SUCCESS This value is always returned.
- */
-static enum sci_status scic_sds_stp_request_soft_reset_await_h2d_diagnostic_tc_completion_handler(
- struct scic_sds_request *sci_req,
- u32 completion_code)
+static enum sci_status
+stp_request_soft_reset_await_h2d_diagnostic_tc_event(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
scic_sds_request_set_status(sci_req, SCU_TASK_DONE_GOOD,
SCI_SUCCESS);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE);
+ sci_change_state(&sci_req->sm, SCI_REQ_STP_SOFT_RESET_WAIT_D2H);
break;
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. */
- scic_sds_request_set_status(
- sci_req,
+ /* 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,
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_BASE_REQUEST_STATE_COMPLETED);
+ sci_change_state(&sci_req->sm, SCI_REQ_COMPLETED);
break;
}
return SCI_SUCCESS;
}
-/**
- *
- * @request: This parameter specifies the request for which a frame has been
- * received.
- * @frame_index: This parameter specifies the index of the frame that has been
- * received.
- *
- * This method processes frames received from the target while waiting for a
- * device to host register FIS. If a non-register FIS is received during this
- * time, it is treated as a protocol violation from an IO perspective. Indicate
- * if the received frame was processed successfully.
- */
-static enum sci_status scic_sds_stp_request_soft_reset_await_d2h_frame_handler(
- struct scic_sds_request *sci_req,
- u32 frame_index)
+enum sci_status
+scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req,
+ u32 completion_code)
{
- enum sci_status status;
- struct dev_to_host_fis *frame_header;
- u32 *frame_buffer;
- struct scic_sds_stp_request *stp_req = &sci_req->stp.req;
+ enum sci_base_request_states state;
struct scic_sds_controller *scic = sci_req->owning_controller;
- status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
- frame_index,
- (void **)&frame_header);
- if (status != SCI_SUCCESS) {
- dev_err(scic_to_dev(scic),
- "%s: SCIC IO Request 0x%p could not get frame header "
- "for frame index %d, status %x\n",
- __func__, stp_req, frame_index, status);
- return status;
- }
+ state = sci_req->sm.current_state_id;
- switch (frame_header->fis_type) {
- case FIS_REGD2H:
- scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
- frame_index,
- (void **)&frame_buffer);
+ switch (state) {
+ case SCI_REQ_STARTED:
+ return request_started_state_tc_event(sci_req, completion_code);
- scic_sds_controller_copy_sata_response(&sci_req->stp.rsp,
- frame_header,
- frame_buffer);
+ case SCI_REQ_TASK_WAIT_TC_COMP:
+ return ssp_task_request_await_tc_event(sci_req,
+ completion_code);
- /* The command has completed with error */
- scic_sds_request_set_status(sci_req,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID);
- break;
+ case SCI_REQ_SMP_WAIT_RESP:
+ return smp_request_await_response_tc_event(sci_req,
+ completion_code);
- default:
- dev_warn(scic_to_dev(scic),
- "%s: IO Request:0x%p Frame Id:%d protocol "
- "violation occurred\n", __func__, stp_req,
- frame_index);
+ case SCI_REQ_SMP_WAIT_TC_COMP:
+ return smp_request_await_tc_event(sci_req, completion_code);
- scic_sds_request_set_status(sci_req, SCU_TASK_DONE_UNEXP_FIS,
- SCI_FAILURE_PROTOCOL_VIOLATION);
- break;
- }
+ case SCI_REQ_STP_UDMA_WAIT_TC_COMP:
+ return stp_request_udma_await_tc_event(sci_req,
+ completion_code);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ case SCI_REQ_STP_NON_DATA_WAIT_H2D:
+ return stp_request_non_data_await_h2d_tc_event(sci_req,
+ completion_code);
- /* Frame has been decoded return it to the controller */
- scic_sds_controller_release_frame(scic, frame_index);
+ case SCI_REQ_STP_PIO_WAIT_H2D:
+ return stp_request_pio_await_h2d_completion_tc_event(sci_req,
+ completion_code);
- return status;
-}
+ case SCI_REQ_STP_PIO_DATA_OUT:
+ return pio_data_out_tx_done_tc_event(sci_req, completion_code);
-static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = {
- [SCI_BASE_REQUEST_STATE_INITIAL] = { },
- [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = {
- .start_handler = scic_sds_request_constructed_state_start_handler,
- .abort_handler = scic_sds_request_constructed_state_abort_handler,
- },
- [SCI_BASE_REQUEST_STATE_STARTED] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler,
- .frame_handler = scic_sds_request_started_state_frame_handler,
- },
- [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
- },
- [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
- .abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
- .frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
- },
- [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_smp_request_await_response_tc_completion_handler,
- .frame_handler = scic_sds_smp_request_await_response_frame_handler,
- },
- [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_smp_request_await_tc_completion_tc_completion_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_stp_request_udma_await_tc_completion_tc_completion_handler,
- .frame_handler = scic_sds_stp_request_udma_general_frame_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .frame_handler = scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_stp_request_non_data_await_h2d_tc_completion_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .frame_handler = scic_sds_stp_request_non_data_await_d2h_frame_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_stp_request_pio_await_h2d_completion_tc_completion_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .frame_handler = scic_sds_stp_request_pio_await_frame_frame_handler
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .event_handler = scic_sds_stp_request_pio_data_in_await_data_event_handler,
- .frame_handler = scic_sds_stp_request_pio_data_in_await_data_frame_handler
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_stp_request_pio_data_out_await_data_transmit_completion_tc_completion_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_asserted_tc_completion_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .tc_completion_handler = scic_sds_stp_request_soft_reset_await_h2d_diagnostic_tc_completion_handler,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = {
- .abort_handler = scic_sds_request_started_state_abort_handler,
- .frame_handler = scic_sds_stp_request_soft_reset_await_d2h_frame_handler,
- },
- [SCI_BASE_REQUEST_STATE_COMPLETED] = {
- .complete_handler = scic_sds_request_completed_state_complete_handler,
- },
- [SCI_BASE_REQUEST_STATE_ABORTING] = {
- .abort_handler = scic_sds_request_aborting_state_abort_handler,
- .tc_completion_handler = scic_sds_request_aborting_state_tc_completion_handler,
- .frame_handler = scic_sds_request_aborting_state_frame_handler,
- },
- [SCI_BASE_REQUEST_STATE_FINAL] = { },
-};
+ 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;
+ }
+}
/**
* isci_request_process_response_iu() - This function sets the status and
/* Task in the target is not done. */
*response_ptr = SAS_TASK_UNDELIVERED;
*status_ptr = SAM_STAT_TASK_ABORTED;
- request->complete_in_target = false;
- *complete_to_host_ptr = isci_perform_error_io_completion;
+ if (task->task_proto == SAS_PROTOCOL_SMP) {
+ request->complete_in_target = true;
+
+ *complete_to_host_ptr = isci_perform_normal_io_completion;
+ } else {
+ request->complete_in_target = false;
+
+ *complete_to_host_ptr = isci_perform_error_io_completion;
+ }
break;
}
}
spin_unlock(&request->state_lock);
break;
+ case dead:
+ /* This was a terminated request that timed-out during the
+ * termination process. There is no task to complete to
+ * libsas.
+ */
+ complete_to_host = isci_perform_normal_io_completion;
+ spin_unlock(&request->state_lock);
+ break;
+
default:
/* The request is done from an SCU HW perspective. */
request->complete_in_target = false;
break;
+ case SCI_FAILURE_RETRY_REQUIRED:
+
+ /* Fail the I/O so it can be retried. */
+ response = SAS_TASK_UNDELIVERED;
+ if ((isci_device->status == isci_stopping) ||
+ (isci_device->status == isci_stopped))
+ status = SAS_DEVICE_UNKNOWN;
+ else
+ status = SAS_ABORTED_TASK;
+
+ complete_to_host = isci_perform_normal_io_completion;
+ request->complete_in_target = true;
+ break;
+
+
default:
/* Catch any otherwise unhandled error codes here. */
dev_warn(&isci_host->pdev->dev,
else
status = SAS_ABORTED_TASK;
- complete_to_host = isci_perform_error_io_completion;
- request->complete_in_target = false;
+ if (SAS_PROTOCOL_SMP == task->task_proto) {
+ request->complete_in_target = true;
+ complete_to_host = isci_perform_normal_io_completion;
+ } else {
+ request->complete_in_target = false;
+ complete_to_host = isci_perform_error_io_completion;
+ }
break;
}
break;
isci_host_can_dequeue(isci_host, 1);
}
-/**
- * scic_sds_request_initial_state_enter() -
- * @object: This parameter specifies the base object for which the state
- * transition is occurring.
- *
- * This method implements the actions taken when entering the
- * SCI_BASE_REQUEST_STATE_INITIAL state. This state is entered when the initial
- * base request is constructed. Entry into the initial state sets all handlers
- * for the io request object to their default handlers. none
- */
-static void scic_sds_request_initial_state_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCI_BASE_REQUEST_STATE_INITIAL
- );
-}
-
-/**
- * scic_sds_request_constructed_state_enter() -
- * @object: The io request object that is to enter the constructed state.
- *
- * This method implements the actions taken when entering the
- * SCI_BASE_REQUEST_STATE_CONSTRUCTED state. The method sets the state handlers
- * for the the constructed state. none
- */
-static void scic_sds_request_constructed_state_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED
- );
-}
-
-static void scic_sds_request_started_state_enter(void *object)
+static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
{
- struct scic_sds_request *sci_req = object;
- struct sci_base_state_machine *sm = &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 domain_device *dev = sci_dev_to_domain(sci_req->target_device);
struct sas_task *task;
*/
task = ireq->ttype == io_task ? isci_request_access_task(ireq) : NULL;
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCI_BASE_REQUEST_STATE_STARTED
- );
-
/* all unaccelerated request types (non ssp or ncq) handled with
* substates
*/
if (!task && dev->dev_type == SAS_END_DEV) {
- sci_base_state_machine_change_state(sm,
- SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION);
+ sci_change_state(sm, SCI_REQ_TASK_WAIT_TC_COMP);
} 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_low)) {
- sci_base_state_machine_change_state(sm,
- SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE);
+ sci_change_state(sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED);
} else if (task && task->task_proto == SAS_PROTOCOL_SMP) {
- sci_base_state_machine_change_state(sm,
- SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE);
+ sci_change_state(sm, SCI_REQ_SMP_WAIT_RESP);
} else if (task && sas_protocol_ata(task->task_proto) &&
!task->ata_task.use_ncq) {
u32 state;
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)
- state = SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE;
+ state = SCI_REQ_STP_UDMA_WAIT_TC_COMP;
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);
}
}
-/**
- * scic_sds_request_completed_state_enter() -
- * @object: This parameter specifies the base object for which the state
- * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST
- * object.
- *
- * This method implements the actions taken when entering the
- * SCI_BASE_REQUEST_STATE_COMPLETED state. This state is entered when the
- * SCIC_SDS_IO_REQUEST has completed. The method will decode the request
- * completion status and convert it to an enum sci_status to return in the
- * completion callback function. none
- */
-static void scic_sds_request_completed_state_enter(void *object)
+static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm)
{
- struct scic_sds_request *sci_req = object;
- struct scic_sds_controller *scic =
- scic_sds_request_get_controller(sci_req);
+ struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
+ struct scic_sds_controller *scic = sci_req->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic);
struct isci_request *ireq = sci_req_to_ireq(sci_req);
- SET_STATE_HANDLER(sci_req,
- scic_sds_request_state_handler_table,
- SCI_BASE_REQUEST_STATE_COMPLETED);
-
/* Tell the SCI_USER that the IO request is complete */
if (sci_req->is_task_management_request == false)
isci_request_io_request_complete(ihost, ireq,
isci_task_request_complete(ihost, ireq, sci_req->sci_status);
}
-/**
- * scic_sds_request_aborting_state_enter() -
- * @object: This parameter specifies the base object for which the state
- * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST
- * object.
- *
- * This method implements the actions taken when entering the
- * SCI_BASE_REQUEST_STATE_ABORTING state. none
- */
-static void scic_sds_request_aborting_state_enter(void *object)
+static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm)
{
- struct scic_sds_request *sci_req = object;
+ 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. */
sci_req->task_context_buffer->abort = 1;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCI_BASE_REQUEST_STATE_ABORTING
- );
-}
-
-/**
- * scic_sds_request_final_state_enter() -
- * @object: This parameter specifies the base object for which the state
- * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object.
- *
- * This method implements the actions taken when entering the
- * SCI_BASE_REQUEST_STATE_FINAL state. The only action required is to put the
- * state handlers in place. none
- */
-static void scic_sds_request_final_state_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCI_BASE_REQUEST_STATE_FINAL
- );
-}
-
-static void scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
- );
-}
-
-static void scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE
- );
-}
-
-static void scic_sds_smp_request_started_await_response_substate_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE
- );
-}
-
-static void scic_sds_smp_request_started_await_tc_completion_substate_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION
- );
-}
-
-static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE
- );
-
- scic_sds_remote_device_set_working_request(
- sci_req->target_device, sci_req
- );
-}
-
-static void scic_sds_stp_request_started_non_data_await_d2h_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE
- );
-}
-
-
-
-static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE
- );
-
- scic_sds_remote_device_set_working_request(
- sci_req->target_device, sci_req);
-}
-
-static void scic_sds_stp_request_started_pio_await_frame_enter(void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE
- );
-}
-
-static void scic_sds_stp_request_started_pio_data_in_await_data_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE
- );
-}
-
-static void scic_sds_stp_request_started_pio_data_out_transmit_data_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE
- );
}
-
-
-static void scic_sds_stp_request_started_udma_await_tc_completion_enter(
- void *object)
+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 = object;
+ struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE
- );
+ scic_sds_remote_device_set_working_request(sci_req->target_device,
+ sci_req);
}
-/**
- *
- *
- * This state is entered when there is an TC completion failure. The hardware
- * received an unexpected condition while processing the IO request and now
- * will UF the D2H register FIS to complete the IO.
- */
-static void scic_sds_stp_request_started_udma_await_d2h_reg_fis_enter(
- void *object)
+static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm)
{
- struct scic_sds_request *sci_req = object;
+ struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE
- );
+ scic_sds_remote_device_set_working_request(sci_req->target_device,
+ sci_req);
}
-
-
-static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(
- void *object)
+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 = object;
+ struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE
- );
-
- scic_sds_remote_device_set_working_request(
- sci_req->target_device, sci_req
- );
+ scic_sds_remote_device_set_working_request(sci_req->target_device,
+ sci_req);
}
-static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(
- void *object)
+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 = object;
+ struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), sm);
struct scu_task_context *task_context;
struct host_to_dev_fis *h2d_fis;
enum sci_status status;
task_context->control_frame = 0;
status = scic_controller_continue_io(sci_req);
- if (status == SCI_SUCCESS) {
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE
- );
- }
-}
-
-static void scic_sds_stp_request_started_soft_reset_await_d2h_response_enter(
- void *object)
-{
- struct scic_sds_request *sci_req = object;
-
- SET_STATE_HANDLER(
- sci_req,
- scic_sds_request_state_handler_table,
- SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE
- );
+ WARN_ONCE(status != SCI_SUCCESS, "isci: continue io failure\n");
}
static const struct sci_base_state scic_sds_request_state_table[] = {
- [SCI_BASE_REQUEST_STATE_INITIAL] = {
- .enter_state = scic_sds_request_initial_state_enter,
- },
- [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = {
- .enter_state = scic_sds_request_constructed_state_enter,
- },
- [SCI_BASE_REQUEST_STATE_STARTED] = {
+ [SCI_REQ_INIT] = { },
+ [SCI_REQ_CONSTRUCTED] = { },
+ [SCI_REQ_STARTED] = {
.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,
},
- [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_non_data_await_d2h_enter,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = {
+ [SCI_REQ_STP_NON_DATA_WAIT_D2H] = { },
+ [SCI_REQ_STP_PIO_WAIT_H2D] = {
.enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter,
},
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_pio_await_frame_enter,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_pio_data_in_await_data_enter,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_pio_data_out_transmit_data_enter,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_udma_await_tc_completion_enter,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_udma_await_d2h_reg_fis_enter,
- },
- [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = {
+ [SCI_REQ_STP_PIO_WAIT_FRAME] = { },
+ [SCI_REQ_STP_PIO_DATA_IN] = { },
+ [SCI_REQ_STP_PIO_DATA_OUT] = { },
+ [SCI_REQ_STP_UDMA_WAIT_TC_COMP] = { },
+ [SCI_REQ_STP_UDMA_WAIT_D2H] = { },
+ [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED] = {
.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,
},
- [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE] = {
- .enter_state = scic_sds_stp_request_started_soft_reset_await_d2h_response_enter,
- },
- [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
- .enter_state = scic_sds_io_request_started_task_mgmt_await_tc_completion_substate_enter,
- },
- [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
- .enter_state = scic_sds_io_request_started_task_mgmt_await_task_response_substate_enter,
- },
- [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = {
- .enter_state = scic_sds_smp_request_started_await_response_substate_enter,
- },
- [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = {
- .enter_state = scic_sds_smp_request_started_await_tc_completion_substate_enter,
- },
- [SCI_BASE_REQUEST_STATE_COMPLETED] = {
+ [SCI_REQ_STP_SOFT_RESET_WAIT_D2H] = { },
+ [SCI_REQ_TASK_WAIT_TC_COMP] = { },
+ [SCI_REQ_TASK_WAIT_TC_RESP] = { },
+ [SCI_REQ_SMP_WAIT_RESP] = { },
+ [SCI_REQ_SMP_WAIT_TC_COMP] = { },
+ [SCI_REQ_COMPLETED] = {
.enter_state = scic_sds_request_completed_state_enter,
},
- [SCI_BASE_REQUEST_STATE_ABORTING] = {
+ [SCI_REQ_ABORTING] = {
.enter_state = scic_sds_request_aborting_state_enter,
},
- [SCI_BASE_REQUEST_STATE_FINAL] = {
- .enter_state = scic_sds_request_final_state_enter,
- },
+ [SCI_REQ_FINAL] = { },
};
-static void scic_sds_general_request_construct(struct scic_sds_controller *scic,
- struct scic_sds_remote_device *sci_dev,
- u16 io_tag, struct scic_sds_request *sci_req)
+static void
+scic_sds_general_request_construct(struct scic_sds_controller *scic,
+ 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_req,
- scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL);
- sci_base_state_machine_start(&sci_req->state_machine);
+ sci_init_sm(&sci_req->sm, scic_sds_request_state_table, SCI_REQ_INIT);
sci_req->io_tag = io_tag;
sci_req->owning_controller = scic;
*/
static void
scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
- struct smp_req *smp_req)
+ ssize_t req_len)
{
dma_addr_t dma_addr;
- struct scic_sds_controller *scic;
struct scic_sds_remote_device *sci_dev;
struct scic_sds_port *sci_port;
struct scu_task_context *task_context;
ssize_t word_cnt = sizeof(struct smp_req) / sizeof(u32);
/* byte swap the smp request. */
- sci_swab32_cpy(&sci_req->smp.cmd, smp_req,
+ sci_swab32_cpy(&sci_req->smp.cmd, &sci_req->smp.cmd,
word_cnt);
task_context = scic_sds_request_get_task_context(sci_req);
- scic = scic_sds_request_get_controller(sci_req);
sci_dev = scic_sds_request_get_device(sci_req);
sci_port = scic_sds_request_get_port(sci_req);
task_context->address_modifier = 0;
/* 10h */
- task_context->ssp_command_iu_length = smp_req->req_len;
+ task_context->ssp_command_iu_length = req_len;
/* 14h */
task_context->transfer_length_bytes = 0;
task_context->response_iu_lower = 0;
}
-static enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
+static enum sci_status
+scic_io_request_construct_smp(struct scic_sds_request *sci_req)
{
- struct smp_req *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL);
-
- if (!smp_req)
- return SCI_FAILURE_INSUFFICIENT_RESOURCES;
+ struct smp_req *smp_req = &sci_req->smp.cmd;
sci_req->protocol = SCIC_SMP_PROTOCOL;
- /* Construct the SMP SCU Task Context */
- memcpy(smp_req, &sci_req->smp.cmd, sizeof(*smp_req));
-
/*
* Look at the SMP requests' header fields; for certain SAS 1.x SMP
* functions under SAS 2.0, a zero request length really indicates
- * a non-zero default length. */
+ * a non-zero default length.
+ */
if (smp_req->req_len == 0) {
switch (smp_req->func) {
case SMP_DISCOVER:
}
}
- scu_smp_request_construct_task_context(sci_req, smp_req);
-
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ scu_smp_request_construct_task_context(sci_req, smp_req->req_len);
- kfree(smp_req);
+ sci_change_state(&sci_req->sm, SCI_REQ_CONSTRUCTED);
return SCI_SUCCESS;
}
* Update it's status and add it to the list in the
* remote device object.
*/
- isci_request_change_state(request, started);
list_add(&request->dev_node, &isci_device->reqs_in_process);
if (status == SCI_SUCCESS) {
/* Save the tag for possible task mgmt later. */
request->io_tag = request->sci.io_tag;
+ isci_request_change_state(request, started);
} else {
/* The request did not really start in the
* hardware, so clear the request handle
* here so no terminations will be done.
*/
request->terminated = true;
+ isci_request_change_state(request, completed);
}
spin_unlock_irqrestore(&isci_host->scic_lock, flags);