Skip to content

Commit b75ca5e

Browse files
author
Stefan Richter
committed
firewire: sbp2: omit Scsi_Host lock from queuecommand
firewire-sbp2 already takes care for internal serialization where required (ORB list accesses), and it does not use cmd->serial_number internally. Hence it is safe to not grab the shost lock around queuecommand. While we are at housekeeping, drop a redundant struct member: sbp2_command_orb.done is set once in a hot path and dereferenced once in a hot path. We can as well dereference sbp2_command_orb.cmd->scsi_done instead. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 6ea9e7b commit b75ca5e

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

‎drivers/firewire/sbp2.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
125125
", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
126126
", or a combination)");
127127

128-
/* I don't know why the SCSI stack doesn't define something like this... */
129-
typedef void (*scsi_done_fn_t)(struct scsi_cmnd *);
130-
131128
static const char sbp2_driver_name[] = "sbp2";
132129

133130
/*
@@ -314,7 +311,6 @@ struct sbp2_command_orb {
314311
u8 command_block[SBP2_MAX_CDB_SIZE];
315312
} request;
316313
struct scsi_cmnd *cmd;
317-
scsi_done_fn_t done;
318314
struct sbp2_logical_unit *lu;
319315

320316
struct sbp2_pointer page_table[SG_ALL] __attribute__((aligned(8)));
@@ -1398,7 +1394,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
13981394
sbp2_unmap_scatterlist(device->card->device, orb);
13991395

14001396
orb->cmd->result = result;
1401-
orb->done(orb->cmd);
1397+
orb->cmd->scsi_done(orb->cmd);
14021398
}
14031399

14041400
static int sbp2_map_scatterlist(struct sbp2_command_orb *orb,
@@ -1463,7 +1459,8 @@ static int sbp2_map_scatterlist(struct sbp2_command_orb *orb,
14631459

14641460
/* SCSI stack integration */
14651461

1466-
static int sbp2_scsi_queuecommand_lck(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1462+
static int sbp2_scsi_queuecommand(struct Scsi_Host *shost,
1463+
struct scsi_cmnd *cmd)
14671464
{
14681465
struct sbp2_logical_unit *lu = cmd->device->hostdata;
14691466
struct fw_device *device = target_device(lu->tgt);
@@ -1477,7 +1474,7 @@ static int sbp2_scsi_queuecommand_lck(struct scsi_cmnd *cmd, scsi_done_fn_t done
14771474
if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
14781475
fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
14791476
cmd->result = DID_ERROR << 16;
1480-
done(cmd);
1477+
cmd->scsi_done(cmd);
14811478
return 0;
14821479
}
14831480

@@ -1490,11 +1487,8 @@ static int sbp2_scsi_queuecommand_lck(struct scsi_cmnd *cmd, scsi_done_fn_t done
14901487
/* Initialize rcode to something not RCODE_COMPLETE. */
14911488
orb->base.rcode = -1;
14921489
kref_init(&orb->base.kref);
1493-
1494-
orb->lu = lu;
1495-
orb->done = done;
1496-
orb->cmd = cmd;
1497-
1490+
orb->lu = lu;
1491+
orb->cmd = cmd;
14981492
orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL);
14991493
orb->request.misc = cpu_to_be32(
15001494
COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
@@ -1529,8 +1523,6 @@ static int sbp2_scsi_queuecommand_lck(struct scsi_cmnd *cmd, scsi_done_fn_t done
15291523
return retval;
15301524
}
15311525

1532-
static DEF_SCSI_QCMD(sbp2_scsi_queuecommand)
1533-
15341526
static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
15351527
{
15361528
struct sbp2_logical_unit *lu = sdev->hostdata;

0 commit comments

Comments
 (0)