Skip to content

Commit a7510fb

Browse files
bvanasschemartinkpetersen
authored andcommitted
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.org Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a0c2247 commit a7510fb

File tree

1 file changed

+54
-65
lines changed

1 file changed

+54
-65
lines changed

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 54 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
560560
CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
561561
CMD_SP(sc) = (char *)io_req;
562562
CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED;
563-
sc->scsi_done = done;
564563

565564
/* create copy wq desc and enqueue it */
566565
wq = &fnic->wq_copy[0];
@@ -1051,8 +1050,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic,
10511050
}
10521051

10531052
/* Call SCSI completion function to complete the IO */
1054-
if (sc->scsi_done)
1055-
sc->scsi_done(sc);
1053+
scsi_done(sc);
10561054
}
10571055

10581056
/* fnic_fcpio_itmf_cmpl_handler
@@ -1193,28 +1191,25 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic,
11931191

11941192
fnic_release_ioreq_buf(fnic, io_req, sc);
11951193
mempool_free(io_req, fnic->io_req_pool);
1196-
if (sc->scsi_done) {
1197-
FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
1198-
sc->device->host->host_no, id,
1199-
sc,
1200-
jiffies_to_msecs(jiffies - start_time),
1201-
desc,
1202-
(((u64)hdr_status << 40) |
1203-
(u64)sc->cmnd[0] << 32 |
1204-
(u64)sc->cmnd[2] << 24 |
1205-
(u64)sc->cmnd[3] << 16 |
1206-
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
1207-
(((u64)CMD_FLAGS(sc) << 32) |
1208-
CMD_STATE(sc)));
1209-
sc->scsi_done(sc);
1210-
atomic64_dec(&fnic_stats->io_stats.active_ios);
1211-
if (atomic64_read(&fnic->io_cmpl_skip))
1212-
atomic64_dec(&fnic->io_cmpl_skip);
1213-
else
1214-
atomic64_inc(&fnic_stats->io_stats.io_completions);
1215-
}
1194+
FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler,
1195+
sc->device->host->host_no, id,
1196+
sc,
1197+
jiffies_to_msecs(jiffies - start_time),
1198+
desc,
1199+
(((u64)hdr_status << 40) |
1200+
(u64)sc->cmnd[0] << 32 |
1201+
(u64)sc->cmnd[2] << 24 |
1202+
(u64)sc->cmnd[3] << 16 |
1203+
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
1204+
(((u64)CMD_FLAGS(sc) << 32) |
1205+
CMD_STATE(sc)));
1206+
scsi_done(sc);
1207+
atomic64_dec(&fnic_stats->io_stats.active_ios);
1208+
if (atomic64_read(&fnic->io_cmpl_skip))
1209+
atomic64_dec(&fnic->io_cmpl_skip);
1210+
else
1211+
atomic64_inc(&fnic_stats->io_stats.io_completions);
12161212
}
1217-
12181213
} else if (id & FNIC_TAG_DEV_RST) {
12191214
/* Completion of device reset */
12201215
CMD_LR_STATUS(sc) = hdr_status;
@@ -1421,23 +1416,22 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data,
14211416
atomic64_inc(&fnic_stats->io_stats.io_completions);
14221417

14231418
/* Complete the command to SCSI */
1424-
if (sc->scsi_done) {
1425-
if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED))
1426-
shost_printk(KERN_ERR, fnic->lport->host,
1427-
"Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n",
1428-
tag, sc);
1429-
1430-
FNIC_TRACE(fnic_cleanup_io,
1431-
sc->device->host->host_no, tag, sc,
1432-
jiffies_to_msecs(jiffies - start_time),
1433-
0, ((u64)sc->cmnd[0] << 32 |
1434-
(u64)sc->cmnd[2] << 24 |
1435-
(u64)sc->cmnd[3] << 16 |
1436-
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
1437-
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
1438-
1439-
sc->scsi_done(sc);
1440-
}
1419+
if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED))
1420+
shost_printk(KERN_ERR, fnic->lport->host,
1421+
"Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n",
1422+
tag, sc);
1423+
1424+
FNIC_TRACE(fnic_cleanup_io,
1425+
sc->device->host->host_no, tag, sc,
1426+
jiffies_to_msecs(jiffies - start_time),
1427+
0, ((u64)sc->cmnd[0] << 32 |
1428+
(u64)sc->cmnd[2] << 24 |
1429+
(u64)sc->cmnd[3] << 16 |
1430+
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
1431+
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
1432+
1433+
scsi_done(sc);
1434+
14411435
return true;
14421436
}
14431437

@@ -1495,17 +1489,15 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq,
14951489
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:"
14961490
" DID_NO_CONNECT\n");
14971491

1498-
if (sc->scsi_done) {
1499-
FNIC_TRACE(fnic_wq_copy_cleanup_handler,
1500-
sc->device->host->host_no, id, sc,
1501-
jiffies_to_msecs(jiffies - start_time),
1502-
0, ((u64)sc->cmnd[0] << 32 |
1503-
(u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
1504-
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
1505-
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
1492+
FNIC_TRACE(fnic_wq_copy_cleanup_handler,
1493+
sc->device->host->host_no, id, sc,
1494+
jiffies_to_msecs(jiffies - start_time),
1495+
0, ((u64)sc->cmnd[0] << 32 |
1496+
(u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 |
1497+
(u64)sc->cmnd[4] << 8 | sc->cmnd[5]),
1498+
(((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc)));
15061499

1507-
sc->scsi_done(sc);
1508-
}
1500+
scsi_done(sc);
15091501
}
15101502

15111503
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)
19311923
fnic_release_ioreq_buf(fnic, io_req, sc);
19321924
mempool_free(io_req, fnic->io_req_pool);
19331925

1934-
if (sc->scsi_done) {
19351926
/* Call SCSI completion function to complete the IO */
1936-
sc->result = (DID_ABORT << 16);
1937-
sc->scsi_done(sc);
1938-
atomic64_dec(&fnic_stats->io_stats.active_ios);
1939-
if (atomic64_read(&fnic->io_cmpl_skip))
1940-
atomic64_dec(&fnic->io_cmpl_skip);
1941-
else
1942-
atomic64_inc(&fnic_stats->io_stats.io_completions);
1943-
}
1927+
sc->result = DID_ABORT << 16;
1928+
scsi_done(sc);
1929+
atomic64_dec(&fnic_stats->io_stats.active_ios);
1930+
if (atomic64_read(&fnic->io_cmpl_skip))
1931+
atomic64_dec(&fnic->io_cmpl_skip);
1932+
else
1933+
atomic64_inc(&fnic_stats->io_stats.io_completions);
19441934

19451935
fnic_abort_cmd_end:
19461936
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,
21532143
* Any IO is returned during reset, it needs to call scsi_done
21542144
* to return the scsi_cmnd to upper layer.
21552145
*/
2156-
if (sc->scsi_done) {
2157-
/* Set result to let upper SCSI layer retry */
2158-
sc->result = DID_RESET << 16;
2159-
sc->scsi_done(sc);
2160-
}
2146+
/* Set result to let upper SCSI layer retry */
2147+
sc->result = DID_RESET << 16;
2148+
scsi_done(sc);
2149+
21612150
return true;
21622151
}
21632152

0 commit comments

Comments
 (0)