Deleted Added
full compact
27c27
< * $FreeBSD: head/sys/dev/twa/tw_cl_io.c 208969 2010-06-09 21:40:38Z delphij $
---
> * $FreeBSD: head/sys/dev/twa/tw_cl_io.c 212008 2010-08-30 19:15:04Z delphij $
77c77
< TW_INT32 error;
---
> TW_INT32 error = TW_CL_ERR_REQ_SUCCESS;
83,88d82
< if (ctlr->reset_in_progress) {
< tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(),
< "I/O during reset: returning busy.");
< return(TW_OSL_EBUSY);
< }
<
148c142,147
< if ((error = tw_cli_submit_cmd(req))) {
---
> if (((TW_CL_Q_FIRST_ITEM(&(ctlr->req_q_head[TW_CLI_PENDING_Q]))) != TW_CL_NULL) ||
> (ctlr->reset_in_progress)) {
> tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q);
> TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle,
> TWA_CONTROL_UNMASK_COMMAND_INTERRUPT);
> } else if ((error = tw_cli_submit_cmd(req))) {
174c173
< TW_INT32 error;
---
> TW_INT32 error = 0;
188d186
< /* Check to see if we can post a command. */
190,192d187
< if ((error = tw_cli_check_ctlr_state(ctlr, status_reg)))
< goto out;
<
210d204
< error = 0;
217d210
< tw_osl_ctlr_busy(ctlr_handle, req->req_handle);
249c242
< out:
---
>
280c273
< TW_INT32 error;
---
> TW_INT32 error = TW_CL_ERR_REQ_SUCCESS;
286,291d278
< if (ctlr->reset_in_progress) {
< tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(),
< "Passthru request during reset: returning busy.");
< return(TW_OSL_EBUSY);
< }
<
304c291
< req->flags |= (TW_CLI_REQ_FLAGS_EXTERNAL | TW_CLI_REQ_FLAGS_PASSTHRU);
---
> req->flags |= TW_CLI_REQ_FLAGS_PASSTHRU;
351c338,343
< if ((error = tw_cli_submit_cmd(req))) {
---
> if (((TW_CL_Q_FIRST_ITEM(&(ctlr->req_q_head[TW_CLI_PENDING_Q]))) != TW_CL_NULL) ||
> (ctlr->reset_in_progress)) {
> tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q);
> TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle,
> TWA_CONTROL_UNMASK_COMMAND_INTERRUPT);
> } else if ((error = tw_cli_submit_cmd(req))) {
763,764c755
< cmd->param.request_id =
< (TW_UINT8)(TW_CL_SWAP16(req->request_id));
---
> cmd->param.request_id = (TW_UINT8)(TW_CL_SWAP16(req->request_id));
792,794d782
< if (error == TW_OSL_ETIMEDOUT)
< /* Clean-up done by tw_cli_submit_and_poll_request. */
< return(error);
797a786
> #if 0
800a790
> #endif // 0
908c898
< /* There's no call back; wait till the command completes. */
---
> /* There's no call back; wait till the command completes. */
910,913c900
< TW_CLI_REQUEST_TIMEOUT_PERIOD);
< if (error == TW_OSL_ETIMEDOUT)
< /* Clean-up done by tw_cli_submit_and_poll_request. */
< return(error);
---
> TW_CLI_REQUEST_TIMEOUT_PERIOD);
916a904
> #if 0
919a908
> #endif // 0
1025,1027c1014
< if (req->state != TW_CLI_REQ_STATE_PENDING)
< tw_cl_reset_ctlr(ctlr->ctlr_handle);
< else {
---
> if (req->state == TW_CLI_REQ_STATE_PENDING) {
1055a1043
> * req_handle -- ptr to request handle
1065a1054
> struct tw_cli_req_context *req;
1067c1056
< TW_INT32 error;
---
> TW_INT32 error = 0;
1072c1061
< xpt_freeze_simq(sc->sim, 1);
---
> twa_teardown_intr(sc);
1074d1062
< tw_cli_disable_interrupts(ctlr);
1083,1084d1070
< tw_cli_dbg_printf(2, ctlr_handle, tw_osl_cur_func(),
< "Draining all queues following reset");
1092,1103c1078,1087
< try_reset:
< if ((error = tw_cli_soft_reset(ctlr))) {
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
< TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT,
< 0x1105, 0x1, TW_CL_SEVERITY_ERROR_STRING,
< "Controller reset failed",
< "error = %d; attempt %d", error, reset_attempt++);
< if (reset_attempt <= TW_CLI_MAX_RESET_ATTEMPTS)
< goto try_reset;
< else
< goto out;
< }
---
> while (reset_attempt <= TW_CLI_MAX_RESET_ATTEMPTS) {
> if ((error = tw_cli_soft_reset(ctlr))) {
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
> TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT,
> 0x1105, 0x1, TW_CL_SEVERITY_ERROR_STRING,
> "Controller reset failed",
> "error = %d; attempt %d", error, reset_attempt++);
> reset_attempt++;
> continue;
> }
1105,1110c1089,1104
< /* Re-establish logical connection with the controller. */
< if ((error = tw_cli_init_connection(ctlr,
< (TW_UINT16)(ctlr->max_simult_reqs),
< 0, 0, 0, 0, 0, TW_CL_NULL, TW_CL_NULL, TW_CL_NULL,
< TW_CL_NULL, TW_CL_NULL))) {
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
---
> /* Re-establish logical connection with the controller. */
> if ((error = tw_cli_init_connection(ctlr,
> (TW_UINT16)(ctlr->max_simult_reqs),
> 0, 0, 0, 0, 0, TW_CL_NULL, TW_CL_NULL, TW_CL_NULL,
> TW_CL_NULL, TW_CL_NULL))) {
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
> TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT,
> 0x1106, 0x1, TW_CL_SEVERITY_ERROR_STRING,
> "Can't initialize connection after reset",
> "error = %d", error);
> reset_attempt++;
> continue;
> }
>
> #ifdef TW_OSL_DEBUG
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
1112,1115c1106,1115
< 0x1106, 0x1, TW_CL_SEVERITY_ERROR_STRING,
< "Can't initialize connection after reset",
< "error = %d", error);
< goto out;
---
> 0x1107, 0x3, TW_CL_SEVERITY_INFO_STRING,
> "Controller reset done!", " ");
> #endif /* TW_OSL_DEBUG */
> break;
> } /* End of while */
>
> /* Move commands from the reset queue to the pending queue. */
> while ((req = tw_cli_req_q_remove_head(ctlr, TW_CLI_RESET_Q)) != TW_CL_NULL) {
> tw_osl_timeout(req->req_handle);
> tw_cli_req_q_insert_tail(req, TW_CLI_PENDING_Q);
1118,1124c1118,1122
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
< TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT,
< 0x1107, 0x3, TW_CL_SEVERITY_INFO_STRING,
< "Controller reset done!",
< " ");
<
< out:
---
> twa_setup_intr(sc);
> tw_cli_enable_interrupts(ctlr);
> if ((TW_CL_Q_FIRST_ITEM(&(ctlr->req_q_head[TW_CLI_PENDING_Q]))) != TW_CL_NULL)
> TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle,
> TWA_CONTROL_UNMASK_COMMAND_INTERRUPT);
1126c1124
< xpt_release_simq(sc->sim, 1);
---
> ctlr->reset_needed = TW_CL_FALSE;
1128,1132d1125
< /*
< * Enable interrupts, and also clear attention and response interrupts.
< */
< tw_cli_enable_interrupts(ctlr);
<
1134,1135c1127,1128
< if (!error)
< tw_osl_scan_bus(ctlr_handle);
---
> tw_osl_scan_bus(ctlr_handle);
>
1138a1132,1136
> TW_VOID
> tw_cl_set_reset_needed(struct tw_cl_ctlr_handle *ctlr_handle)
> {
> struct tw_cli_ctlr_context *ctlr =
> (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt);
1139a1138,1139
> ctlr->reset_needed = TW_CL_TRUE;
> }
1140a1141,1161
> TW_INT32
> tw_cl_is_reset_needed(struct tw_cl_ctlr_handle *ctlr_handle)
> {
> struct tw_cli_ctlr_context *ctlr =
> (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt);
>
> return(ctlr->reset_needed);
> }
>
> TW_INT32
> tw_cl_is_active(struct tw_cl_ctlr_handle *ctlr_handle)
> {
> struct tw_cli_ctlr_context *ctlr =
> (struct tw_cli_ctlr_context *)
> (ctlr_handle->cl_ctlr_ctxt);
>
> return(ctlr->active);
> }
>
>
>
1154d1174
< TW_UINT32 status_reg;
1161c1181
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
---
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
1196c1216
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
---
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
1213c1233
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
---
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
1247c1267
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
---
> tw_cl_create_event(ctlr_handle, TW_CL_FALSE,
1254,1266c1274
<
< status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr_handle);
<
< if ((error = TW_CLI_STATUS_ERRORS(status_reg)) ||
< (error = tw_cli_check_ctlr_state(ctlr, status_reg))) {
< tw_cl_create_event(ctlr_handle, TW_CL_TRUE,
< TW_CL_MESSAGE_SOURCE_COMMON_LAYER_EVENT,
< 0x110D, 0x1, TW_CL_SEVERITY_ERROR_STRING,
< "Controller errors detected after reset",
< "error = %d", error);
< return(error);
< }
<
---
>