From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omzsmtpe01.verizonbusiness.com ([199.249.25.210]:55178 "EHLO omzsmtpe01.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752967AbdCQAui (ORCPT ); Thu, 16 Mar 2017 20:50:38 -0400 From: alexander.levin@verizon.com To: "gregkh@linuxfoundation.org" CC: "stable@vger.kernel.org" Subject: [PATCH v2 for-4.9 07/40] scsi: ibmvscsis: Rearrange functions for future patches Date: Fri, 17 Mar 2017 00:48:21 +0000 Message-ID: <20170317004812.26960-7-alexander.levin@verizon.com> References: <20170317004812.26960-1-alexander.levin@verizon.com> In-Reply-To: <20170317004812.26960-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Michael Cyr [ Upstream commit 79fac9c9b74f4951c9ce82b22e714bcc34ae4a56 ] This patch reorders functions in a manner necessary for a follow-on patch. It also makes some minor styling changes (mostly removing extra spaces) and fixes some typos. There are no code changes in this patch, with one exception: due to the reordering of the functions, I needed to explicitly declare a function at the top of the file. However, this will be removed in the next patch, since the code requiring the predeclaration will be removed. Signed-off-by: Michael Cyr Signed-off-by: Bryant G. Ly Tested-by: Steven Royer Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 796 ++++++++++++++++-----------= ---- 1 file changed, 399 insertions(+), 397 deletions(-) diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvsc= si_tgt/ibmvscsi_tgt.c index e4cd8ff..4feae43 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -22,7 +22,7 @@ * *************************************************************************= ***/ =20 -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 #include #include @@ -62,6 +62,8 @@ static long ibmvscsis_parse_command(struct scsi_info *vsc= si, =20 static void ibmvscsis_adapter_idle(struct scsi_info *vscsi); =20 +static void ibmvscsis_reset_queue(struct scsi_info *vscsi, uint new_state)= ; + static void ibmvscsis_determine_resid(struct se_cmd *se_cmd, struct srp_rsp *rsp) { @@ -82,7 +84,7 @@ static void ibmvscsis_determine_resid(struct se_cmd *se_c= md, } } else if (se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) { if (se_cmd->data_direction =3D=3D DMA_TO_DEVICE) { - /* residual data from an overflow write */ + /* residual data from an overflow write */ rsp->flags =3D SRP_RSP_FLAG_DOOVER; rsp->data_out_res_cnt =3D cpu_to_be32(residual_count); } else if (se_cmd->data_direction =3D=3D DMA_FROM_DEVICE) { @@ -102,7 +104,7 @@ static void ibmvscsis_determine_resid(struct se_cmd *se= _cmd, * and the function returns TRUE. * * EXECUTION ENVIRONMENT: - * Interrupt or Process environment + * Interrupt or Process environment */ static bool connection_broken(struct scsi_info *vscsi) { @@ -325,7 +327,7 @@ static struct viosrp_crq *ibmvscsis_cmd_q_dequeue(uint = mask, } =20 /** - * ibmvscsis_send_init_message() - send initialize message to the client + * ibmvscsis_send_init_message() - send initialize message to the client * @vscsi: Pointer to our adapter structure * @format: Which Init Message format to send * @@ -383,13 +385,13 @@ static long ibmvscsis_check_init_msg(struct scsi_info= *vscsi, uint *format) vscsi->cmd_q.base_addr); if (crq) { *format =3D (uint)(crq->format); - rc =3D ERROR; + rc =3D ERROR; crq->valid =3D INVALIDATE_CMD_RESP_EL; dma_rmb(); } } else { *format =3D (uint)(crq->format); - rc =3D ERROR; + rc =3D ERROR; crq->valid =3D INVALIDATE_CMD_RESP_EL; dma_rmb(); } @@ -398,166 +400,6 @@ static long ibmvscsis_check_init_msg(struct scsi_info= *vscsi, uint *format) } =20 /** - * ibmvscsis_establish_new_q() - Establish new CRQ queue - * @vscsi: Pointer to our adapter structure - * @new_state: New state being established after resetting the queue - * - * Must be called with interrupt lock held. - */ -static long ibmvscsis_establish_new_q(struct scsi_info *vscsi, uint new_s= tate) -{ - long rc =3D ADAPT_SUCCESS; - uint format; - - vscsi->flags &=3D PRESERVE_FLAG_FIELDS; - vscsi->rsp_q_timer.timer_pops =3D 0; - vscsi->debit =3D 0; - vscsi->credit =3D 0; - - rc =3D vio_enable_interrupts(vscsi->dma_dev); - if (rc) { - pr_warn("reset_queue: failed to enable interrupts, rc %ld\n", - rc); - return rc; - } - - rc =3D ibmvscsis_check_init_msg(vscsi, &format); - if (rc) { - dev_err(&vscsi->dev, "reset_queue: check_init_msg failed, rc %ld\n", - rc); - return rc; - } - - if (format =3D=3D UNUSED_FORMAT && new_state =3D=3D WAIT_CONNECTION) { - rc =3D ibmvscsis_send_init_message(vscsi, INIT_MSG); - switch (rc) { - case H_SUCCESS: - case H_DROPPED: - case H_CLOSED: - rc =3D ADAPT_SUCCESS; - break; - - case H_PARAMETER: - case H_HARDWARE: - break; - - default: - vscsi->state =3D UNDEFINED; - rc =3D H_HARDWARE; - break; - } - } - - return rc; -} - -/** - * ibmvscsis_reset_queue() - Reset CRQ Queue - * @vscsi: Pointer to our adapter structure - * @new_state: New state to establish after resetting the queue - * - * This function calls h_free_q and then calls h_reg_q and does all - * of the bookkeeping to get us back to where we can communicate. - * - * Actually, we don't always call h_free_crq. A problem was discovered - * where one partition would close and reopen his queue, which would - * cause his partner to get a transport event, which would cause him to - * close and reopen his queue, which would cause the original partition - * to get a transport event, etc., etc. To prevent this, we don't - * actually close our queue if the client initiated the reset, (i.e. - * either we got a transport event or we have detected that the client's - * queue is gone) - * - * EXECUTION ENVIRONMENT: - * Process environment, called with interrupt lock held - */ -static void ibmvscsis_reset_queue(struct scsi_info *vscsi, uint new_state) -{ - int bytes; - long rc =3D ADAPT_SUCCESS; - - pr_debug("reset_queue: flags 0x%x\n", vscsi->flags); - - /* don't reset, the client did it for us */ - if (vscsi->flags & (CLIENT_FAILED | TRANS_EVENT)) { - vscsi->flags &=3D PRESERVE_FLAG_FIELDS; - vscsi->rsp_q_timer.timer_pops =3D 0; - vscsi->debit =3D 0; - vscsi->credit =3D 0; - vscsi->state =3D new_state; - vio_enable_interrupts(vscsi->dma_dev); - } else { - rc =3D ibmvscsis_free_command_q(vscsi); - if (rc =3D=3D ADAPT_SUCCESS) { - vscsi->state =3D new_state; - - bytes =3D vscsi->cmd_q.size * PAGE_SIZE; - rc =3D h_reg_crq(vscsi->dds.unit_id, - vscsi->cmd_q.crq_token, bytes); - if (rc =3D=3D H_CLOSED || rc =3D=3D H_SUCCESS) { - rc =3D ibmvscsis_establish_new_q(vscsi, - new_state); - } - - if (rc !=3D ADAPT_SUCCESS) { - pr_debug("reset_queue: reg_crq rc %ld\n", rc); - - vscsi->state =3D ERR_DISCONNECTED; - vscsi->flags |=3D RESPONSE_Q_DOWN; - ibmvscsis_free_command_q(vscsi); - } - } else { - vscsi->state =3D ERR_DISCONNECTED; - vscsi->flags |=3D RESPONSE_Q_DOWN; - } - } -} - -/** - * ibmvscsis_free_cmd_resources() - Free command resources - * @vscsi: Pointer to our adapter structure - * @cmd: Command which is not longer in use - * - * Must be called with interrupt lock held. - */ -static void ibmvscsis_free_cmd_resources(struct scsi_info *vscsi, - struct ibmvscsis_cmd *cmd) -{ - struct iu_entry *iue =3D cmd->iue; - - switch (cmd->type) { - case TASK_MANAGEMENT: - case SCSI_CDB: - /* - * When the queue goes down this value is cleared, so it - * cannot be cleared in this general purpose function. - */ - if (vscsi->debit) - vscsi->debit -=3D 1; - break; - case ADAPTER_MAD: - vscsi->flags &=3D ~PROCESSING_MAD; - break; - case UNSET_TYPE: - break; - default: - dev_err(&vscsi->dev, "free_cmd_resources unknown type %d\n", - cmd->type); - break; - } - - cmd->iue =3D NULL; - list_add_tail(&cmd->list, &vscsi->free_cmd); - srp_iu_put(iue); - - if (list_empty(&vscsi->active_q) && list_empty(&vscsi->schedule_q) && - list_empty(&vscsi->waiting_rsp) && (vscsi->flags & WAIT_FOR_IDLE)) { - vscsi->flags &=3D ~WAIT_FOR_IDLE; - complete(&vscsi->wait_idle); - } -} - -/** * ibmvscsis_disconnect() - Helper function to disconnect * @work: Pointer to work_struct, gives access to our adapter structure * @@ -590,7 +432,7 @@ static void ibmvscsis_disconnect(struct work_struct *wo= rk) * should transitition to the new state */ switch (vscsi->state) { - /* Should never be called while in this state. */ + /* Should never be called while in this state. */ case NO_QUEUE: /* * Can never transition from this state; @@ -726,84 +568,394 @@ static void ibmvscsis_disconnect(struct work_struct = *work) * the new state (if the one passed in is more "severe" than the * previous one). * - * PRECONDITION: - * interrupt lock is held + * PRECONDITION: + * interrupt lock is held + */ +static void ibmvscsis_post_disconnect(struct scsi_info *vscsi, uint new_st= ate, + uint flag_bits) +{ + uint state; + + /* check the validity of the new state */ + switch (new_state) { + case UNCONFIGURING: + case ERR_DISCONNECT: + case ERR_DISCONNECT_RECONNECT: + case WAIT_IDLE: + break; + + default: + dev_err(&vscsi->dev, "post_disconnect: Invalid new state %d\n", + new_state); + return; + } + + vscsi->flags |=3D flag_bits; + + pr_debug("post_disconnect: new_state 0x%x, flag_bits 0x%x, vscsi->flags 0= x%x, state %hx\n", + new_state, flag_bits, vscsi->flags, vscsi->state); + + if (!(vscsi->flags & (DISCONNECT_SCHEDULED | SCHEDULE_DISCONNECT))) { + vscsi->flags |=3D SCHEDULE_DISCONNECT; + vscsi->new_state =3D new_state; + + INIT_WORK(&vscsi->proc_work, ibmvscsis_disconnect); + (void)queue_work(vscsi->work_q, &vscsi->proc_work); + } else { + if (vscsi->new_state) + state =3D vscsi->new_state; + else + state =3D vscsi->state; + + switch (state) { + case NO_QUEUE: + case UNCONFIGURING: + break; + + case ERR_DISCONNECTED: + case ERR_DISCONNECT: + case UNDEFINED: + if (new_state =3D=3D UNCONFIGURING) + vscsi->new_state =3D new_state; + break; + + case ERR_DISCONNECT_RECONNECT: + switch (new_state) { + case UNCONFIGURING: + case ERR_DISCONNECT: + vscsi->new_state =3D new_state; + break; + default: + break; + } + break; + + case WAIT_ENABLED: + case PART_UP_WAIT_ENAB: + case WAIT_IDLE: + case WAIT_CONNECTION: + case CONNECTED: + case SRP_PROCESSING: + vscsi->new_state =3D new_state; + break; + + default: + break; + } + } + + pr_debug("Leaving post_disconnect: flags 0x%x, new_state 0x%x\n", + vscsi->flags, vscsi->new_state); +} + +/** + * ibmvscsis_handle_init_compl_msg() - Respond to an Init Complete Message + * @vscsi: Pointer to our adapter structure + * + * Must be called with interrupt lock held. + */ +static long ibmvscsis_handle_init_compl_msg(struct scsi_info *vscsi) +{ + long rc =3D ADAPT_SUCCESS; + + switch (vscsi->state) { + case NO_QUEUE: + case ERR_DISCONNECT: + case ERR_DISCONNECT_RECONNECT: + case ERR_DISCONNECTED: + case UNCONFIGURING: + case UNDEFINED: + rc =3D ERROR; + break; + + case WAIT_CONNECTION: + vscsi->state =3D CONNECTED; + break; + + case WAIT_IDLE: + case SRP_PROCESSING: + case CONNECTED: + case WAIT_ENABLED: + case PART_UP_WAIT_ENAB: + default: + rc =3D ERROR; + dev_err(&vscsi->dev, "init_msg: invalid state %d to get init compl msg\n= ", + vscsi->state); + ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, 0); + break; + } + + return rc; +} + +/** + * ibmvscsis_handle_init_msg() - Respond to an Init Message + * @vscsi: Pointer to our adapter structure + * + * Must be called with interrupt lock held. + */ +static long ibmvscsis_handle_init_msg(struct scsi_info *vscsi) +{ + long rc =3D ADAPT_SUCCESS; + + switch (vscsi->state) { + case WAIT_ENABLED: + vscsi->state =3D PART_UP_WAIT_ENAB; + break; + + case WAIT_CONNECTION: + rc =3D ibmvscsis_send_init_message(vscsi, INIT_COMPLETE_MSG); + switch (rc) { + case H_SUCCESS: + vscsi->state =3D CONNECTED; + break; + + case H_PARAMETER: + dev_err(&vscsi->dev, "init_msg: failed to send, rc %ld\n", + rc); + ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT, 0); + break; + + case H_DROPPED: + dev_err(&vscsi->dev, "init_msg: failed to send, rc %ld\n", + rc); + rc =3D ERROR; + ibmvscsis_post_disconnect(vscsi, + ERR_DISCONNECT_RECONNECT, 0); + break; + + case H_CLOSED: + pr_warn("init_msg: failed to send, rc %ld\n", rc); + rc =3D 0; + break; + } + break; + + case UNDEFINED: + rc =3D ERROR; + break; + + case UNCONFIGURING: + break; + + case PART_UP_WAIT_ENAB: + case CONNECTED: + case SRP_PROCESSING: + case WAIT_IDLE: + case NO_QUEUE: + case ERR_DISCONNECT: + case ERR_DISCONNECT_RECONNECT: + case ERR_DISCONNECTED: + default: + rc =3D ERROR; + dev_err(&vscsi->dev, "init_msg: invalid state %d to get init msg\n", + vscsi->state); + ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, 0); + break; + } + + return rc; +} + +/** + * ibmvscsis_init_msg() - Respond to an init message + * @vscsi: Pointer to our adapter structure + * @crq: Pointer to CRQ element containing the Init Message + * + * EXECUTION ENVIRONMENT: + * Interrupt, interrupt lock held + */ +static long ibmvscsis_init_msg(struct scsi_info *vscsi, struct viosrp_crq = *crq) +{ + long rc =3D ADAPT_SUCCESS; + + pr_debug("init_msg: state 0x%hx\n", vscsi->state); + + rc =3D h_vioctl(vscsi->dds.unit_id, H_GET_PARTNER_INFO, + (u64)vscsi->map_ioba | ((u64)PAGE_SIZE << 32), 0, 0, 0, + 0); + if (rc =3D=3D H_SUCCESS) { + vscsi->client_data.partition_number =3D + be64_to_cpu(*(u64 *)vscsi->map_buf); + pr_debug("init_msg, part num %d\n", + vscsi->client_data.partition_number); + } else { + pr_debug("init_msg h_vioctl rc %ld\n", rc); + rc =3D ADAPT_SUCCESS; + } + + if (crq->format =3D=3D INIT_MSG) { + rc =3D ibmvscsis_handle_init_msg(vscsi); + } else if (crq->format =3D=3D INIT_COMPLETE_MSG) { + rc =3D ibmvscsis_handle_init_compl_msg(vscsi); + } else { + rc =3D ERROR; + dev_err(&vscsi->dev, "init_msg: invalid format %d\n", + (uint)crq->format); + ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, 0); + } + + return rc; +} + +/** + * ibmvscsis_establish_new_q() - Establish new CRQ queue + * @vscsi: Pointer to our adapter structure + * @new_state: New state being established after resetting the queue + * + * Must be called with interrupt lock held. + */ +static long ibmvscsis_establish_new_q(struct scsi_info *vscsi, uint new_st= ate) +{ + long rc =3D ADAPT_SUCCESS; + uint format; + + vscsi->flags &=3D PRESERVE_FLAG_FIELDS; + vscsi->rsp_q_timer.timer_pops =3D 0; + vscsi->debit =3D 0; + vscsi->credit =3D 0; + + rc =3D vio_enable_interrupts(vscsi->dma_dev); + if (rc) { + pr_warn("reset_queue: failed to enable interrupts, rc %ld\n", + rc); + return rc; + } + + rc =3D ibmvscsis_check_init_msg(vscsi, &format); + if (rc) { + dev_err(&vscsi->dev, "reset_queue: check_init_msg failed, rc %ld\n", + rc); + return rc; + } + + if (format =3D=3D UNUSED_FORMAT && new_state =3D=3D WAIT_CONNECTION) { + rc =3D ibmvscsis_send_init_message(vscsi, INIT_MSG); + switch (rc) { + case H_SUCCESS: + case H_DROPPED: + case H_CLOSED: + rc =3D ADAPT_SUCCESS; + break; + + case H_PARAMETER: + case H_HARDWARE: + break; + + default: + vscsi->state =3D UNDEFINED; + rc =3D H_HARDWARE; + break; + } + } + + return rc; +} + +/** + * ibmvscsis_reset_queue() - Reset CRQ Queue + * @vscsi: Pointer to our adapter structure + * @new_state: New state to establish after resetting the queue + * + * This function calls h_free_q and then calls h_reg_q and does all + * of the bookkeeping to get us back to where we can communicate. + * + * Actually, we don't always call h_free_crq. A problem was discovered + * where one partition would close and reopen his queue, which would + * cause his partner to get a transport event, which would cause him to + * close and reopen his queue, which would cause the original partition + * to get a transport event, etc., etc. To prevent this, we don't + * actually close our queue if the client initiated the reset, (i.e. + * either we got a transport event or we have detected that the client's + * queue is gone) + * + * EXECUTION ENVIRONMENT: + * Process environment, called with interrupt lock held + */ +static void ibmvscsis_reset_queue(struct scsi_info *vscsi, uint new_state) +{ + int bytes; + long rc =3D ADAPT_SUCCESS; + + pr_debug("reset_queue: flags 0x%x\n", vscsi->flags); + + /* don't reset, the client did it for us */ + if (vscsi->flags & (CLIENT_FAILED | TRANS_EVENT)) { + vscsi->flags &=3D PRESERVE_FLAG_FIELDS; + vscsi->rsp_q_timer.timer_pops =3D 0; + vscsi->debit =3D 0; + vscsi->credit =3D 0; + vscsi->state =3D new_state; + vio_enable_interrupts(vscsi->dma_dev); + } else { + rc =3D ibmvscsis_free_command_q(vscsi); + if (rc =3D=3D ADAPT_SUCCESS) { + vscsi->state =3D new_state; + + bytes =3D vscsi->cmd_q.size * PAGE_SIZE; + rc =3D h_reg_crq(vscsi->dds.unit_id, + vscsi->cmd_q.crq_token, bytes); + if (rc =3D=3D H_CLOSED || rc =3D=3D H_SUCCESS) { + rc =3D ibmvscsis_establish_new_q(vscsi, + new_state); + } + + if (rc !=3D ADAPT_SUCCESS) { + pr_debug("reset_queue: reg_crq rc %ld\n", rc); + + vscsi->state =3D ERR_DISCONNECTED; + vscsi->flags |=3D RESPONSE_Q_DOWN; + ibmvscsis_free_command_q(vscsi); + } + } else { + vscsi->state =3D ERR_DISCONNECTED; + vscsi->flags |=3D RESPONSE_Q_DOWN; + } + } +} + +/** + * ibmvscsis_free_cmd_resources() - Free command resources + * @vscsi: Pointer to our adapter structure + * @cmd: Command which is not longer in use + * + * Must be called with interrupt lock held. */ -static void ibmvscsis_post_disconnect(struct scsi_info *vscsi, uint new_st= ate, - uint flag_bits) +static void ibmvscsis_free_cmd_resources(struct scsi_info *vscsi, + struct ibmvscsis_cmd *cmd) { - uint state; + struct iu_entry *iue =3D cmd->iue; =20 - /* check the validity of the new state */ - switch (new_state) { - case UNCONFIGURING: - case ERR_DISCONNECT: - case ERR_DISCONNECT_RECONNECT: - case WAIT_IDLE: + switch (cmd->type) { + case TASK_MANAGEMENT: + case SCSI_CDB: + /* + * When the queue goes down this value is cleared, so it + * cannot be cleared in this general purpose function. + */ + if (vscsi->debit) + vscsi->debit -=3D 1; + break; + case ADAPTER_MAD: + vscsi->flags &=3D ~PROCESSING_MAD; + break; + case UNSET_TYPE: break; - default: - dev_err(&vscsi->dev, "post_disconnect: Invalid new state %d\n", - new_state); - return; + dev_err(&vscsi->dev, "free_cmd_resources unknown type %d\n", + cmd->type); + break; } =20 - vscsi->flags |=3D flag_bits; - - pr_debug("post_disconnect: new_state 0x%x, flag_bits 0x%x, vscsi->flags 0= x%x, state %hx\n", - new_state, flag_bits, vscsi->flags, vscsi->state); - - if (!(vscsi->flags & (DISCONNECT_SCHEDULED | SCHEDULE_DISCONNECT))) { - vscsi->flags |=3D SCHEDULE_DISCONNECT; - vscsi->new_state =3D new_state; - - INIT_WORK(&vscsi->proc_work, ibmvscsis_disconnect); - (void)queue_work(vscsi->work_q, &vscsi->proc_work); - } else { - if (vscsi->new_state) - state =3D vscsi->new_state; - else - state =3D vscsi->state; - - switch (state) { - case NO_QUEUE: - case UNCONFIGURING: - break; - - case ERR_DISCONNECTED: - case ERR_DISCONNECT: - case UNDEFINED: - if (new_state =3D=3D UNCONFIGURING) - vscsi->new_state =3D new_state; - break; - - case ERR_DISCONNECT_RECONNECT: - switch (new_state) { - case UNCONFIGURING: - case ERR_DISCONNECT: - vscsi->new_state =3D new_state; - break; - default: - break; - } - break; - - case WAIT_ENABLED: - case PART_UP_WAIT_ENAB: - case WAIT_IDLE: - case WAIT_CONNECTION: - case CONNECTED: - case SRP_PROCESSING: - vscsi->new_state =3D new_state; - break; + cmd->iue =3D NULL; + list_add_tail(&cmd->list, &vscsi->free_cmd); + srp_iu_put(iue); =20 - default: - break; - } + if (list_empty(&vscsi->active_q) && list_empty(&vscsi->schedule_q) && + list_empty(&vscsi->waiting_rsp) && (vscsi->flags & WAIT_FOR_IDLE)) { + vscsi->flags &=3D ~WAIT_FOR_IDLE; + complete(&vscsi->wait_idle); } - - pr_debug("Leaving post_disconnect: flags 0x%x, new_state 0x%x\n", - vscsi->flags, vscsi->new_state); } =20 /** @@ -896,7 +1048,7 @@ static long ibmvscsis_trans_event(struct scsi_info *vs= csi, } } =20 - rc =3D vscsi->flags & SCHEDULE_DISCONNECT; + rc =3D vscsi->flags & SCHEDULE_DISCONNECT; =20 pr_debug("Leaving trans_event: flags 0x%x, state 0x%hx, rc %ld\n", vscsi->flags, vscsi->state, rc); @@ -1221,7 +1373,7 @@ static long ibmvscsis_copy_crq_packet(struct scsi_inf= o *vscsi, * @iue: Information Unit containing the Adapter Info MAD request * * EXECUTION ENVIRONMENT: - * Interrupt adpater lock is held + * Interrupt adapter lock is held */ static long ibmvscsis_adapter_info(struct scsi_info *vscsi, struct iu_entry *iue) @@ -1692,7 +1844,7 @@ static void ibmvscsis_send_mad_resp(struct scsi_info = *vscsi, * @crq: Pointer to the CRQ entry containing the MAD request * * EXECUTION ENVIRONMENT: - * Interrupt called with adapter lock held + * Interrupt, called with adapter lock held */ static long ibmvscsis_mad(struct scsi_info *vscsi, struct viosrp_crq *crq) { @@ -1858,7 +2010,7 @@ static long ibmvscsis_srp_login_rej(struct scsi_info = *vscsi, break; case H_PERMISSION: if (connection_broken(vscsi)) - flag_bits =3D RESPONSE_Q_DOWN | CLIENT_FAILED; + flag_bits =3D RESPONSE_Q_DOWN | CLIENT_FAILED; dev_err(&vscsi->dev, "login_rej: error copying to client, rc %ld\n", rc); ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, @@ -2181,156 +2333,6 @@ static long ibmvscsis_ping_response(struct scsi_inf= o *vscsi) } =20 /** - * ibmvscsis_handle_init_compl_msg() - Respond to an Init Complete Message - * @vscsi: Pointer to our adapter structure - * - * Must be called with interrupt lock held. - */ -static long ibmvscsis_handle_init_compl_msg(struct scsi_info *vscsi) -{ - long rc =3D ADAPT_SUCCESS; - - switch (vscsi->state) { - case NO_QUEUE: - case ERR_DISCONNECT: - case ERR_DISCONNECT_RECONNECT: - case ERR_DISCONNECTED: - case UNCONFIGURING: - case UNDEFINED: - rc =3D ERROR; - break; - - case WAIT_CONNECTION: - vscsi->state =3D CONNECTED; - break; - - case WAIT_IDLE: - case SRP_PROCESSING: - case CONNECTED: - case WAIT_ENABLED: - case PART_UP_WAIT_ENAB: - default: - rc =3D ERROR; - dev_err(&vscsi->dev, "init_msg: invalid state %d to get init compl msg\n= ", - vscsi->state); - ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, 0); - break; - } - - return rc; -} - -/** - * ibmvscsis_handle_init_msg() - Respond to an Init Message - * @vscsi: Pointer to our adapter structure - * - * Must be called with interrupt lock held. - */ -static long ibmvscsis_handle_init_msg(struct scsi_info *vscsi) -{ - long rc =3D ADAPT_SUCCESS; - - switch (vscsi->state) { - case WAIT_ENABLED: - vscsi->state =3D PART_UP_WAIT_ENAB; - break; - - case WAIT_CONNECTION: - rc =3D ibmvscsis_send_init_message(vscsi, INIT_COMPLETE_MSG); - switch (rc) { - case H_SUCCESS: - vscsi->state =3D CONNECTED; - break; - - case H_PARAMETER: - dev_err(&vscsi->dev, "init_msg: failed to send, rc %ld\n", - rc); - ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT, 0); - break; - - case H_DROPPED: - dev_err(&vscsi->dev, "init_msg: failed to send, rc %ld\n", - rc); - rc =3D ERROR; - ibmvscsis_post_disconnect(vscsi, - ERR_DISCONNECT_RECONNECT, 0); - break; - - case H_CLOSED: - pr_warn("init_msg: failed to send, rc %ld\n", rc); - rc =3D 0; - break; - } - break; - - case UNDEFINED: - rc =3D ERROR; - break; - - case UNCONFIGURING: - break; - - case PART_UP_WAIT_ENAB: - case CONNECTED: - case SRP_PROCESSING: - case WAIT_IDLE: - case NO_QUEUE: - case ERR_DISCONNECT: - case ERR_DISCONNECT_RECONNECT: - case ERR_DISCONNECTED: - default: - rc =3D ERROR; - dev_err(&vscsi->dev, "init_msg: invalid state %d to get init msg\n", - vscsi->state); - ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, 0); - break; - } - - return rc; -} - -/** - * ibmvscsis_init_msg() - Respond to an init message - * @vscsi: Pointer to our adapter structure - * @crq: Pointer to CRQ element containing the Init Message - * - * EXECUTION ENVIRONMENT: - * Interrupt, interrupt lock held - */ -static long ibmvscsis_init_msg(struct scsi_info *vscsi, struct viosrp_crq = *crq) -{ - long rc =3D ADAPT_SUCCESS; - - pr_debug("init_msg: state 0x%hx\n", vscsi->state); - - rc =3D h_vioctl(vscsi->dds.unit_id, H_GET_PARTNER_INFO, - (u64)vscsi->map_ioba | ((u64)PAGE_SIZE << 32), 0, 0, 0, - 0); - if (rc =3D=3D H_SUCCESS) { - vscsi->client_data.partition_number =3D - be64_to_cpu(*(u64 *)vscsi->map_buf); - pr_debug("init_msg, part num %d\n", - vscsi->client_data.partition_number); - } else { - pr_debug("init_msg h_vioctl rc %ld\n", rc); - rc =3D ADAPT_SUCCESS; - } - - if (crq->format =3D=3D INIT_MSG) { - rc =3D ibmvscsis_handle_init_msg(vscsi); - } else if (crq->format =3D=3D INIT_COMPLETE_MSG) { - rc =3D ibmvscsis_handle_init_compl_msg(vscsi); - } else { - rc =3D ERROR; - dev_err(&vscsi->dev, "init_msg: invalid format %d\n", - (uint)crq->format); - ibmvscsis_post_disconnect(vscsi, ERR_DISCONNECT_RECONNECT, 0); - } - - return rc; -} - -/** * ibmvscsis_parse_command() - Parse an element taken from the cmd rsp que= ue. * @vscsi: Pointer to our adapter structure * @crq: Pointer to CRQ element containing the SRP request @@ -2385,7 +2387,7 @@ static long ibmvscsis_parse_command(struct scsi_info = *vscsi, break; =20 case VALID_TRANS_EVENT: - rc =3D ibmvscsis_trans_event(vscsi, crq); + rc =3D ibmvscsis_trans_event(vscsi, crq); break; =20 case VALID_INIT_MSG: @@ -3270,7 +3272,7 @@ static void ibmvscsis_handle_crq(unsigned long data) /* * if we are in a path where we are waiting for all pending commands * to complete because we received a transport event and anything in - * the command queue is for a new connection, do nothing + * the command queue is for a new connection, do nothing */ if (TARGET_STOP(vscsi)) { vio_enable_interrupts(vscsi->dma_dev); @@ -3314,7 +3316,7 @@ static void ibmvscsis_handle_crq(unsigned long data) * everything but transport events on the queue * * need to decrement the queue index so we can - * look at the elment again + * look at the element again */ if (vscsi->cmd_q.index) vscsi->cmd_q.index -=3D 1; @@ -3988,10 +3990,10 @@ static struct attribute *ibmvscsis_dev_attrs[] =3D = { ATTRIBUTE_GROUPS(ibmvscsis_dev); =20 static struct class ibmvscsis_class =3D { - .name =3D "ibmvscsis", - .dev_release =3D ibmvscsis_dev_release, - .class_attrs =3D ibmvscsis_class_attrs, - .dev_groups =3D ibmvscsis_dev_groups, + .name =3D "ibmvscsis", + .dev_release =3D ibmvscsis_dev_release, + .class_attrs =3D ibmvscsis_class_attrs, + .dev_groups =3D ibmvscsis_dev_groups, }; =20 static struct vio_device_id ibmvscsis_device_table[] =3D { --=20 2.9.3