Skip to contentSkip to conversation

libata: Convert to host_lock less w/ interrupts disabled internally

PATCH In review Nicholas A. Bellinger 2 participants 3 messages Nov 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/11 libata: Convert to host_lock less w/ interrupts disabled internally

From: Nicholas Bellinger <[email protected]>

This patch changes ata_scsi_queuecmd_lck() to a host lock less ata_scsi_queuecmd() that will disable interrupts internally using ap->lock and drops the now legacy host_lock unlock.

---
 drivers/ata/libata-scsi.c |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)
drivers/ata/libata-scsi.c +4 -10
index a007c36..9614758 100644
@@ -3173,25 +3173,22 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
  *	SCSI commands.  This creates the overall effect of
  *	ATA and ATAPI devices appearing as SCSI devices.
  *
- *	LOCKING:
- *	Releases scsi-layer-held lock, and obtains host lock.
- *
  *	RETURNS:
  *	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_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 {
 	struct ata_port *ap;
 	struct ata_device *dev;
 	struct scsi_device *scsidev = cmd->device;
 	struct Scsi_Host *shost = scsidev->host;
+	unsigned long irq_flags;
 	int rc = 0;
 
 	ap = ata_shost_to_port(shost);
 
-	spin_unlock(shost->host_lock);
-	spin_lock(ap->lock);
+	spin_lock_irqsave(ap->lock, irq_flags);
 
 	ata_scsi_dump_cdb(ap, cmd);
 
@@ -3203,13 +3200,10 @@ static int ata_scsi_queuecmd_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi
 		done(cmd);
 	}
 
-	spin_unlock(ap->lock);
-	spin_lock(shost->host_lock);
+	spin_unlock_irqrestore(ap->lock, irq_flags);
 	return rc;
 }
 
-DEF_SCSI_QCMD(ata_scsi_queuecmd)
-
 /**
  *	ata_scsi_simulate - simulate SCSI command on ATA device
  *	@dev: the target device
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 16 lines · Nicholas A. Bellinger

From: Nicholas Bellinger<[email protected]>

This patch changes ata_scsi_queuecmd_lck() to a host lock less ata_scsi_queuecmd() that will disable interrupts internally using ap->lock and drops the now legacy host_lock unlock.

---
  drivers/ata/libata-scsi.c |   14 ++++----------
  1 files changed, 4 insertions(+), 10 deletions(-)
drivers/ata/libata-scsi.c +0 -0
index a007c36..9614758 100644

drivers/ata/libata-scsi.c static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, · line 3178

Quoted 6 lines
drivers/ata/libata-scsi.c +0 -3
@@ -3173,25 +3173,22 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
   *	SCSI commands.  This creates the overall effect of
   *	ATA and ATAPI devices appearing as SCSI devices.
   *
- *	LOCKING:
- *	Releases scsi-layer-held lock, and obtains host lock.
- *

The code appears correct but the comment removal is not.

Locking has not disappeared, and the ATA host lock continues to be obtained.

#2 lore raw
Quoted 26 lines · Jeff Garzik
Quoted 16 lines · Nicholas A. Bellinger

From: Nicholas Bellinger<[email protected]>

This patch changes ata_scsi_queuecmd_lck() to a host lock less ata_scsi_queuecmd() that will disable interrupts internally using ap->lock and drops the now legacy host_lock unlock.

---
  drivers/ata/libata-scsi.c |   14 ++++----------
  1 files changed, 4 insertions(+), 10 deletions(-)
drivers/ata/libata-scsi.c +0 -0
index a007c36..9614758 100644

drivers/ata/libata-scsi.c static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, · line 3178

Quoted 6 lines
drivers/ata/libata-scsi.c +0 -3
@@ -3173,25 +3173,22 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
   *	SCSI commands.  This creates the overall effect of
   *	ATA and ATAPI devices appearing as SCSI devices.
   *
- *	LOCKING:
- *	Releases scsi-layer-held lock, and obtains host lock.
- *

The code appears correct but the comment removal is not.

Quoted 3 lines

Locking has not disappeared, and the ATA host lock continues to be obtained.

My apologies for not reading this comment throughly.. Reinstating in lio-core-2.6.git/lock_less-LLDs-for-38

Thank you!

--nab