Commit a7510fbd authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: fnic: Call scsi_done() directly

Conditional statements are faster than indirect calls. Hence call
scsi_done() directly.

Link: https://lore.kernel.org/r/20211007202923.2174984-36-bvanassche@acm.orgSigned-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a0c22474
...@@ -560,7 +560,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_ ...@@ -560,7 +560,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
CMD_SP(sc) = (char *)io_req; CMD_SP(sc) = (char *)io_req;
CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED; CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED;
sc->scsi_done = done;
/* create copy wq desc and enqueue it */ /* create copy wq desc and enqueue it */
wq = &fnic->wq_copy[0]; wq = &fnic->wq_copy[0];
...@@ -1051,8 +1050,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, ...@@ -1051,8 +1050,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
} }
/* Call SCSI completion function to complete the IO */ /* Call SCSI completion function to complete the IO */
if (sc->scsi_done) scsi_done(sc);
sc->scsi_done(sc);
} }
/* fnic_fcpio_itmf_cmpl_handler /* fnic_fcpio_itmf_cmpl_handler
...@@ -1193,28 +1191,25 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, ...@@ -1193,28 +1191,25 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
fnic_release_ioreq_buf(fnic, io_req, sc); fnic_release_ioreq_buf(fnic, io_req, sc);
mempool_free(io_req, fnic->io_req_pool); mempool_free(io_req, fnic->io_req_pool);
if (sc->scsi_done) { FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, sc->device->host->host_no, id,
sc->device->host->host_no, id, sc,
sc, jiffies_to_msecs(jiffies - start_time),
jiffies_to_msecs(jiffies - start_time), desc,
desc, (((u64)hdr_status << 40) |
(((u64)hdr_status << 40) | (u64)sc->cmnd[0] << 32 |
(u64)sc->cmnd[0] << 32 | (u64)sc->cmnd[2] << 24 |
(u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
(u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]), (((u64)CMD_FLAGS(sc) << 32) |
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
CMD_STATE(sc))); scsi_done(sc);
sc->scsi_done(sc); atomic64_dec(&fnic_stats->io_stats.active_ios);
atomic64_dec(&fnic_stats->io_stats.active_ios); if (atomic64_read(&fnic->io_cmpl_skip))
if (atomic64_read(&fnic->io_cmpl_skip)) atomic64_dec(&fnic->io_cmpl_skip);
atomic64_dec(&fnic->io_cmpl_skip); else
else atomic64_inc(&fnic_stats->io_stats.io_completions);
atomic64_inc(&fnic_stats->io_stats.io_completions);
}
} }
} else if (id & FNIC_TAG_DEV_RST) { } else if (id & FNIC_TAG_DEV_RST) {
/* Completion of device reset */ /* Completion of device reset */
CMD_LR_STATUS(sc) = hdr_status; CMD_LR_STATUS(sc) = hdr_status;
...@@ -1421,23 +1416,22 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data, ...@@ -1421,23 +1416,22 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data,
atomic64_inc(&fnic_stats->io_stats.io_completions); atomic64_inc(&fnic_stats->io_stats.io_completions);
/* Complete the command to SCSI */ /* Complete the command to SCSI */
if (sc->scsi_done) { if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED))
if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) shost_printk(KERN_ERR, fnic->lport->host,
shost_printk(KERN_ERR, fnic->lport->host, "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n",
"Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n", tag, sc);
tag, sc);
FNIC_TRACE(fnic_cleanup_io,
FNIC_TRACE(fnic_cleanup_io, sc->device->host->host_no, tag, sc,
sc->device->host->host_no, tag, sc, jiffies_to_msecs(jiffies - start_time),
jiffies_to_msecs(jiffies - start_time), 0, ((u64)sc->cmnd[0] << 32 |
0, ((u64)sc->cmnd[0] << 32 | (u64)sc->cmnd[2] << 24 |
(u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
(u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]), (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
scsi_done(sc);
sc->scsi_done(sc);
}
return true; return true;
} }
...@@ -1495,17 +1489,15 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, ...@@ -1495,17 +1489,15 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:"
" DID_NO_CONNECT\n"); " DID_NO_CONNECT\n");
if (sc->scsi_done) { FNIC_TRACE(fnic_wq_copy_cleanup_handler,
FNIC_TRACE(fnic_wq_copy_cleanup_handler, sc->device->host->host_no, id, sc,
sc->device->host->host_no, id, sc, jiffies_to_msecs(jiffies - start_time),
jiffies_to_msecs(jiffies - start_time), 0, ((u64)sc->cmnd[0] << 32 |
0, ((u64)sc->cmnd[0] << 32 | (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
(u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]), (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
sc->scsi_done(sc); scsi_done(sc);
}
} }
static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag,
...@@ -1931,16 +1923,14 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) ...@@ -1931,16 +1923,14 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
fnic_release_ioreq_buf(fnic, io_req, sc); fnic_release_ioreq_buf(fnic, io_req, sc);
mempool_free(io_req, fnic->io_req_pool); mempool_free(io_req, fnic->io_req_pool);
if (sc->scsi_done) {
/* Call SCSI completion function to complete the IO */ /* Call SCSI completion function to complete the IO */
sc->result = (DID_ABORT << 16); sc->result = DID_ABORT << 16;
sc->scsi_done(sc); scsi_done(sc);
atomic64_dec(&fnic_stats->io_stats.active_ios); atomic64_dec(&fnic_stats->io_stats.active_ios);
if (atomic64_read(&fnic->io_cmpl_skip)) if (atomic64_read(&fnic->io_cmpl_skip))
atomic64_dec(&fnic->io_cmpl_skip); atomic64_dec(&fnic->io_cmpl_skip);
else else
atomic64_inc(&fnic_stats->io_stats.io_completions); atomic64_inc(&fnic_stats->io_stats.io_completions);
}
fnic_abort_cmd_end: fnic_abort_cmd_end:
FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no, tag, sc, FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no, tag, sc,
...@@ -2153,11 +2143,10 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, ...@@ -2153,11 +2143,10 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc,
* Any IO is returned during reset, it needs to call scsi_done * Any IO is returned during reset, it needs to call scsi_done
* to return the scsi_cmnd to upper layer. * to return the scsi_cmnd to upper layer.
*/ */
if (sc->scsi_done) { /* Set result to let upper SCSI layer retry */
/* Set result to let upper SCSI layer retry */ sc->result = DID_RESET << 16;
sc->result = DID_RESET << 16; scsi_done(sc);
sc->scsi_done(sc);
}
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment