diff options
Diffstat (limited to 'drivers/scsi/snic/snic_scsi.c')
| -rw-r--r-- | drivers/scsi/snic/snic_scsi.c | 94 |
1 files changed, 30 insertions, 64 deletions
diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c index b3650c989ed4..84973f0f771e 100644 --- a/drivers/scsi/snic/snic_scsi.c +++ b/drivers/scsi/snic/snic_scsi.c @@ -1,19 +1,5 @@ -/* - * Copyright 2014 Cisco Systems, Inc. All rights reserved. - * - * This program is free software; you may redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright 2014 Cisco Systems, Inc. All rights reserved. #include <linux/mempool.h> #include <linux/errno.h> @@ -33,7 +19,7 @@ #include "snic_io.h" #include "snic.h" -#define snic_cmd_tag(sc) (((struct scsi_cmnd *) sc)->request->tag) +#define snic_cmd_tag(sc) (scsi_cmd_to_rq(sc)->tag) const char *snic_state_str[] = { [SNIC_INIT] = "SNIC_INIT", @@ -342,7 +328,7 @@ snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) SNIC_HOST_ERR(shost, "Tgt %p id %d Not Ready.\n", tgt, tgt->id); atomic64_inc(&snic->s_stats.misc.tgt_not_rdy); sc->result = ret; - sc->scsi_done(sc); + scsi_done(sc); return 0; } @@ -501,7 +487,6 @@ snic_process_icmnd_cmpl_status(struct snic *snic, struct scsi_cmnd *sc) { u8 scsi_stat = icmnd_cmpl->scsi_status; - u64 xfer_len = 0; int ret = 0; /* Mark the IO as complete */ @@ -510,15 +495,11 @@ snic_process_icmnd_cmpl_status(struct snic *snic, if (likely(cmpl_stat == SNIC_STAT_IO_SUCCESS)) { sc->result = (DID_OK << 16) | scsi_stat; - xfer_len = scsi_bufflen(sc); - /* Update SCSI Cmd with resid value */ scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid)); - if (icmnd_cmpl->flags & SNIC_ICMND_CMPL_UNDR_RUN) { - xfer_len -= le32_to_cpu(icmnd_cmpl->resid); + if (icmnd_cmpl->flags & SNIC_ICMND_CMPL_UNDR_RUN) atomic64_inc(&snic->s_stats.misc.io_under_run); - } if (icmnd_cmpl->scsi_status == SAM_STAT_TASK_SET_FULL) atomic64_inc(&snic->s_stats.misc.qfull); @@ -676,8 +657,7 @@ snic_icmnd_cmpl_handler(struct snic *snic, struct snic_fw_req *fwreq) SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); - if (sc->scsi_done) - sc->scsi_done(sc); + scsi_done(sc); snic_stats_update_io_cmpl(&snic->s_stats); } /* end of snic_icmnd_cmpl_handler */ @@ -855,14 +835,12 @@ snic_process_itmf_cmpl(struct snic *snic, snic_release_req_buf(snic, rqi, sc); - if (sc->scsi_done) { - SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, - jiffies_to_msecs(jiffies - start_time), - (ulong) fwreq, SNIC_TRC_CMD(sc), - SNIC_TRC_CMD_STATE_FLAGS(sc)); + SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, + jiffies_to_msecs(jiffies - start_time), + (ulong) fwreq, SNIC_TRC_CMD(sc), + SNIC_TRC_CMD_STATE_FLAGS(sc)); - sc->scsi_done(sc); - } + scsi_done(sc); break; @@ -1387,19 +1365,15 @@ snic_issue_tm_req(struct snic *snic, } ret = snic_queue_itmf_req(snic, tmreq, sc, tmf, req_id); - if (ret) - goto tmreq_err; - - ret = 0; tmreq_err: if (ret) { SNIC_HOST_ERR(snic->shost, - "issu_tmreq: Queing ITMF(%d) Req, sc %p rqi %p req_id %d tag %x fails err = %d\n", + "issu_tmreq: Queueing ITMF(%d) Req, sc %p rqi %p req_id %d tag %x fails err = %d\n", tmf, sc, rqi, req_id, tag, ret); } else { SNIC_SCSI_DBG(snic->shost, - "issu_tmreq: Queuing ITMF(%d) Req, sc %p, rqi %p, req_id %d tag %x - Success.\n", + "issu_tmreq: Queueing ITMF(%d) Req, sc %p, rqi %p, req_id %d tag %x - Success.\n", tmf, sc, rqi, req_id, tag); } @@ -1479,7 +1453,7 @@ snic_abort_finish(struct snic *snic, struct scsi_cmnd *sc) * Call scsi_done to complete the IO. */ sc->result = (DID_ERROR << 16); - sc->scsi_done(sc); + scsi_done(sc); break; default: @@ -1640,7 +1614,7 @@ snic_abort_cmd(struct scsi_cmnd *sc) u32 start_time = jiffies; SNIC_SCSI_DBG(snic->shost, "abt_cmd:sc %p :0x%x :req = %p :tag = %d\n", - sc, sc->cmnd[0], sc->request, tag); + sc, sc->cmnd[0], scsi_cmd_to_rq(sc), tag); if (unlikely(snic_get_state(snic) != SNIC_ONLINE)) { SNIC_HOST_ERR(snic->shost, @@ -1859,7 +1833,7 @@ snic_dr_clean_single_req(struct snic *snic, snic_release_req_buf(snic, rqi, sc); sc->result = (DID_ERROR << 16); - sc->scsi_done(sc); + scsi_done(sc); ret = 0; @@ -1876,7 +1850,7 @@ snic_dr_clean_pending_req(struct snic *snic, struct scsi_cmnd *lr_sc) { struct scsi_device *lr_sdev = lr_sc->device; u32 tag = 0; - int ret = FAILED; + int ret; for (tag = 0; tag < snic->max_tag_id; tag++) { if (tag == snic_cmd_tag(lr_sc)) @@ -1885,7 +1859,6 @@ snic_dr_clean_pending_req(struct snic *snic, struct scsi_cmnd *lr_sc) ret = snic_dr_clean_single_req(snic, tag, lr_sdev); if (ret) { SNIC_HOST_ERR(snic->shost, "clean_err:tag = %d\n", tag); - goto clean_err; } } @@ -1893,24 +1866,19 @@ snic_dr_clean_pending_req(struct snic *snic, struct scsi_cmnd *lr_sc) schedule_timeout(msecs_to_jiffies(100)); /* Walk through all the cmds and check abts status. */ - if (snic_is_abts_pending(snic, lr_sc)) { - ret = FAILED; - + if (snic_is_abts_pending(snic, lr_sc)) goto clean_err; - } - ret = 0; SNIC_SCSI_DBG(snic->shost, "clean_pending_req: Success.\n"); - return ret; + return 0; clean_err: - ret = FAILED; SNIC_HOST_ERR(snic->shost, "Failed to Clean Pending IOs on %s device.\n", dev_name(&lr_sdev->sdev_gendev)); - return ret; + return FAILED; } /* end of snic_dr_clean_pending_req */ @@ -2156,7 +2124,7 @@ snic_device_reset(struct scsi_cmnd *sc) int dr_supp = 0; SNIC_SCSI_DBG(shost, "dev_reset:sc %p :0x%x :req = %p :tag = %d\n", - sc, sc->cmnd[0], sc->request, + sc, sc->cmnd[0], scsi_cmd_to_rq(sc), snic_cmd_tag(sc)); dr_supp = snic_dev_reset_supported(sc->device); if (!dr_supp) { @@ -2339,7 +2307,7 @@ snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) spin_lock_irqsave(&snic->snic_lock, flags); if (snic_get_state(snic) == SNIC_FWRESET) { spin_unlock_irqrestore(&snic->snic_lock, flags); - SNIC_HOST_INFO(shost, "reset:prev reset is in progres\n"); + SNIC_HOST_INFO(shost, "reset:prev reset is in progress\n"); msleep(SNIC_HOST_RESET_TIMEOUT); ret = SUCCESS; @@ -2387,11 +2355,11 @@ snic_host_reset(struct scsi_cmnd *sc) { struct Scsi_Host *shost = sc->device->host; u32 start_time = jiffies; - int ret = FAILED; + int ret; SNIC_SCSI_DBG(shost, "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n", - sc, sc->cmnd[0], sc->request, + sc, sc->cmnd[0], scsi_cmd_to_rq(sc), snic_cmd_tag(sc), CMD_FLAGS(sc)); ret = snic_reset(shost, sc); @@ -2498,20 +2466,18 @@ cleanup: sc->result = DID_TRANSPORT_DISRUPTED << 16; SNIC_HOST_INFO(snic->shost, "sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n", - sc, sc->request->tag, CMD_FLAGS(sc), rqi, + sc, scsi_cmd_to_rq(sc)->tag, CMD_FLAGS(sc), rqi, jiffies_to_msecs(jiffies - st_time)); /* Update IO stats */ snic_stats_update_io_cmpl(&snic->s_stats); - if (sc->scsi_done) { - SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, - jiffies_to_msecs(jiffies - st_time), 0, - SNIC_TRC_CMD(sc), - SNIC_TRC_CMD_STATE_FLAGS(sc)); + SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, + jiffies_to_msecs(jiffies - st_time), 0, + SNIC_TRC_CMD(sc), + SNIC_TRC_CMD_STATE_FLAGS(sc)); - sc->scsi_done(sc); - } + scsi_done(sc); } } /* end of snic_scsi_cleanup */ |
