/* * Function name: twa_interrupt * Description: Interrupt handler. Determines the kind of interrupt, * and returns TW_CL_TRUE if it recognizes the interrupt. * * Input: ctlr_handle -- controller handle * Output: None * Return value: TW_CL_TRUE -- interrupt recognized * TW_CL_FALSE-- interrupt not recognized */ TW_INT32 tw_cl_interrupt(struct tw_cl_ctlr_handle *ctlr_handle) { struct tw_cli_ctlr_context *ctlr = (struct tw_cli_ctlr_context *)(ctlr_handle->cl_ctlr_ctxt); TW_UINT32 status_reg; TW_INT32 rc = TW_CL_FALSE; tw_cli_dbg_printf(10, ctlr_handle, tw_osl_cur_func(), "entered"); /* If we don't have controller context, bail */ if (ctlr == NULL) goto out; /* * Bail If we get an interrupt while resetting, or shutting down. */ if (ctlr->reset_in_progress || !(ctlr->active)) goto out; /* Read the status register to determine the type of interrupt. */ status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr_handle); if (tw_cli_check_ctlr_state(ctlr, status_reg)) goto out; /* Clear the interrupt. */ if (status_reg & TWA_STATUS_HOST_INTERRUPT) { tw_cli_dbg_printf(6, ctlr_handle, tw_osl_cur_func(), "Host interrupt"); TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle, TWA_CONTROL_CLEAR_HOST_INTERRUPT); } if (status_reg & TWA_STATUS_ATTENTION_INTERRUPT) { tw_cli_dbg_printf(6, ctlr_handle, tw_osl_cur_func(), "Attention interrupt"); rc |= TW_CL_TRUE; /* request for a deferred isr call */ tw_cli_process_attn_intr(ctlr); TW_CLI_WRITE_CONTROL_REGISTER(ctlr_handle, TWA_CONTROL_CLEAR_ATTENTION_INTERRUPT); } if (status_reg & TWA_STATUS_COMMAND_INTERRUPT) { tw_cli_dbg_printf(6, ctlr_handle, tw_osl_cur_func(), "Command interrupt"); rc |= TW_CL_TRUE; /* request for a deferred isr call */ tw_cli_process_cmd_intr(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_MASK_COMMAND_INTERRUPT); } if (status_reg & TWA_STATUS_RESPONSE_INTERRUPT) { tw_cli_dbg_printf(10, ctlr_handle, tw_osl_cur_func(), "Response interrupt"); rc |= TW_CL_TRUE; /* request for a deferred isr call */ tw_cli_process_resp_intr(ctlr); } out: return(rc); }
/* * Function name: tw_cli_process_resp_intr * Description: Looks for cmd completions from fw; queues cmds completed * by fw into complete queue. * * Input: ctlr -- ptr to CL internal ctlr context * Output: None * Return value: 0 -- no ctlr error * non-zero-- ctlr error */ TW_INT32 tw_cli_process_resp_intr(struct tw_cli_ctlr_context *ctlr) { TW_UINT32 resp; struct tw_cli_req_context *req; TW_INT32 error; TW_UINT32 status_reg; tw_cli_dbg_printf(10, ctlr->ctlr_handle, tw_osl_cur_func(), "entered"); for (;;) { status_reg = TW_CLI_READ_STATUS_REGISTER(ctlr->ctlr_handle); if ((error = tw_cli_check_ctlr_state(ctlr, status_reg))) break; if (status_reg & TWA_STATUS_RESPONSE_QUEUE_EMPTY) { tw_cli_dbg_printf(7, ctlr->ctlr_handle, tw_osl_cur_func(), "Response queue empty"); break; } /* Response queue is not empty. */ resp = TW_CLI_READ_RESPONSE_QUEUE(ctlr->ctlr_handle); { req = &(ctlr->req_ctxt_buf[GET_RESP_ID(resp)]); } if (req->state != TW_CLI_REQ_STATE_BUSY) { tw_cl_create_event(ctlr->ctlr_handle, TW_CL_FALSE, TW_CL_MESSAGE_SOURCE_COMMON_LAYER_ERROR, 0x1201, 0x1, TW_CL_SEVERITY_ERROR_STRING, "Unposted command completed!!", "request = %p, status = %d", req, req->state); #ifdef TW_OSL_DEBUG tw_cl_print_ctlr_stats(ctlr->ctlr_handle); #endif /* TW_OSL_DEBUG */ tw_cl_reset_ctlr(ctlr->ctlr_handle); return(TW_OSL_EIO); } /* * Remove the request from the busy queue, mark it as complete, * and enqueue it in the complete queue. */ tw_cli_req_q_remove_item(req, TW_CLI_BUSY_Q); req->state = TW_CLI_REQ_STATE_COMPLETE; tw_cli_req_q_insert_tail(req, TW_CLI_COMPLETE_Q); } /* Complete this, and other requests in the complete queue. */ tw_cli_process_complete_queue(ctlr); return(error); }