aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/scsi_host.h
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2010-11-16 02:10:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-11-16 16:33:23 -0500
commitf281233d3eba15fb225d21ae2e228fd4553d824a (patch)
tree51134454ba8acb558735f90be5540f7d756483e3 /include/scsi/scsi_host.h
parentbdbd01ac444bffb3c9aefed3059d12554059b320 (diff)
SCSI host lock push-down
Move the mid-layer's ->queuecommand() invocation from being locked with the host lock to being unlocked to facilitate speeding up the critical path for drivers who don't need this lock taken anyway. The patch below presents a simple SCSI host lock push-down as an equivalent transformation. No locking or other behavior should change with this patch. All existing bugs and locking orders are preserved. Additionally, add one parameter to queuecommand, struct Scsi_Host * and remove one parameter from queuecommand, void (*done)(struct scsi_cmnd *) Scsi_Host* is a convenient pointer that most host drivers need anyway, and 'done' is redundant to struct scsi_cmnd->scsi_done. Minimal code disturbance was attempted with this change. Most drivers needed only two one-line modifications for their host lock push-down. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: James Bottomley <James.Bottomley@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/scsi/scsi_host.h')
-rw-r--r--include/scsi/scsi_host.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index d0a6a845f204..e7e385842a38 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -127,8 +127,7 @@ struct scsi_host_template {
127 * 127 *
128 * STATUS: REQUIRED 128 * STATUS: REQUIRED
129 */ 129 */
130 int (* queuecommand)(struct scsi_cmnd *, 130 int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
131 void (*done)(struct scsi_cmnd *));
132 131
133 /* 132 /*
134 * The transfer functions are used to queue a scsi command to 133 * The transfer functions are used to queue a scsi command to
@@ -505,6 +504,25 @@ struct scsi_host_template {
505}; 504};
506 505
507/* 506/*
507 * Temporary #define for host lock push down. Can be removed when all
508 * drivers have been updated to take advantage of unlocked
509 * queuecommand.
510 *
511 */
512#define DEF_SCSI_QCMD(func_name) \
513 int func_name(struct Scsi_Host *shost, struct scsi_cmnd *cmd) \
514 { \
515 unsigned long irq_flags; \
516 int rc; \
517 spin_lock_irqsave(shost->host_lock, irq_flags); \
518 scsi_cmd_get_serial(shost, cmd); \
519 rc = func_name##_lck (cmd, cmd->scsi_done); \
520 spin_unlock_irqrestore(shost->host_lock, irq_flags); \
521 return rc; \
522 }
523
524
525/*
508 * shost state: If you alter this, you also need to alter scsi_sysfs.c 526 * shost state: If you alter this, you also need to alter scsi_sysfs.c
509 * (for the ascii descriptions) and the state model enforcer: 527 * (for the ascii descriptions) and the state model enforcer:
510 * scsi_host_set_state() 528 * scsi_host_set_state()
@@ -752,6 +770,7 @@ extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
752extern void scsi_host_put(struct Scsi_Host *t); 770extern void scsi_host_put(struct Scsi_Host *t);
753extern struct Scsi_Host *scsi_host_lookup(unsigned short); 771extern struct Scsi_Host *scsi_host_lookup(unsigned short);
754extern const char *scsi_host_state_name(enum scsi_host_state); 772extern const char *scsi_host_state_name(enum scsi_host_state);
773extern void scsi_cmd_get_serial(struct Scsi_Host *, struct scsi_cmnd *);
755 774
756extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); 775extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *);
757 776