From patchwork Wed Nov 17 06:29:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Garzik X-Patchwork-Id: 71528 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6760EB7173 for ; Wed, 17 Nov 2010 17:30:01 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759647Ab0KQG37 (ORCPT ); Wed, 17 Nov 2010 01:29:59 -0500 Received: from havoc.gtf.org ([69.61.125.42]:47665 "EHLO havoc.gtf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756765Ab0KQG37 (ORCPT ); Wed, 17 Nov 2010 01:29:59 -0500 Received: by havoc.gtf.org (Postfix, from userid 500) id 30FB92F804F; Wed, 17 Nov 2010 01:29:58 -0500 (EST) Date: Wed, 17 Nov 2010 01:29:58 -0500 From: Jeff Garzik To: linux-ide@vger.kernel.org Cc: linux-scsi@vger.kernel.org, LKML , Linus Torvalds Subject: [PATCH] libata: remove unlock+relock cycle in ata_scsi_queuecmd Message-ID: <20101117062958.GA2894@havoc.gtf.org> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org This is in #upstream-fixes... Each libata command is now two lock-ops less expensive... for free! Should be nice for multi-core SSD users etc. (not a pull request, Linus, just an FYI) commit 02ab5c49284c91901cad783921e816297c92ebf8 Author: Jeff Garzik Date: Wed Nov 17 01:19:11 2010 -0500 [libata] kill unlock+relock cycle in SCSI queuecommand hook Now that SCSI's ->queuecommand hook is unlocked, ATA no longer needs to unlock the SCSI host_lock prior to work, and re-lock the host_lock once our work is complete. Signed-off-by: Jeff Garzik drivers/ata/libata-scsi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 19835d3..d72340e 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3166,8 +3166,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, /** * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device + * @shost: SCSI host destination for given command * @cmd: SCSI command to be sent - * @done: Completion function, called when command is complete * * In some cases, this function translates SCSI commands into * ATA taskfiles, and queues the taskfiles to be sent to @@ -3183,36 +3183,41 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, * Return value from __ata_scsi_queuecmd() if @cmd can be queued, * 0 otherwise. */ -static int ata_scsi_queuecmd_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) +int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd) { struct ata_port *ap; struct ata_device *dev; struct scsi_device *scsidev = cmd->device; - struct Scsi_Host *shost = scsidev->host; int rc = 0; + unsigned long irq_flags; - ap = ata_shost_to_port(shost); + local_irq_save(irq_flags); + spin_lock(shost->host_lock); + scsi_cmd_get_serial(shost, cmd); spin_unlock(shost->host_lock); + + ap = ata_shost_to_port(shost); + spin_lock(ap->lock); ata_scsi_dump_cdb(ap, cmd); dev = ata_scsi_find_dev(ap, scsidev); if (likely(dev)) - rc = __ata_scsi_queuecmd(cmd, done, dev); + rc = __ata_scsi_queuecmd(cmd, cmd->scsi_done, dev); else { cmd->result = (DID_BAD_TARGET << 16); - done(cmd); + cmd->scsi_done(cmd); } spin_unlock(ap->lock); - spin_lock(shost->host_lock); + + local_irq_restore(irq_flags); + return rc; } -DEF_SCSI_QCMD(ata_scsi_queuecmd) - /** * ata_scsi_simulate - simulate SCSI command on ATA device * @dev: the target device