aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-30 23:31:48 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-10-30 23:31:48 -0500
commit005a5a06a6dd13a0ca3f2c6a0218e8d94ed36d8a (patch)
tree5b270817df4bc9661365d789d51c04f3774c3ddd /drivers
parente533825447dcb60a82b7cc9d73d06423c849b9a2 (diff)
[libata] locking rewrite (== fix)
A lot of power packed into a little patch. This change eliminates the sharing between our controller-wide spinlock and the SCSI core's Scsi_Host lock. As the locking in libata was already highly compartmentalized, always referencing our own lock, and never scsi_host::host_lock. As a side effect, this change eliminates a deadlock from calling scsi_finish_command() while inside our spinlock.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/libata-core.c2
-rw-r--r--drivers/scsi/libata-scsi.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index a17e12032f65..ff18fa7044c5 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -4089,8 +4089,6 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4089 host->unique_id = ata_unique_id++; 4089 host->unique_id = ata_unique_id++;
4090 host->max_cmd_len = 12; 4090 host->max_cmd_len = 12;
4091 4091
4092 scsi_assign_lock(host, &host_set->lock);
4093
4094 ap->flags = ATA_FLAG_PORT_DISABLED; 4092 ap->flags = ATA_FLAG_PORT_DISABLED;
4095 ap->id = host->unique_id; 4093 ap->id = host->unique_id;
4096 ap->host = host; 4094 ap->host = host;
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 1e3792f86fcf..248baae96486 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -39,6 +39,7 @@
39#include <scsi/scsi.h> 39#include <scsi/scsi.h>
40#include "scsi.h" 40#include "scsi.h"
41#include <scsi/scsi_host.h> 41#include <scsi/scsi_host.h>
42#include <scsi/scsi_device.h>
42#include <linux/libata.h> 43#include <linux/libata.h>
43#include <linux/hdreg.h> 44#include <linux/hdreg.h>
44#include <asm/uaccess.h> 45#include <asm/uaccess.h>
@@ -2405,8 +2406,12 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
2405 struct ata_port *ap; 2406 struct ata_port *ap;
2406 struct ata_device *dev; 2407 struct ata_device *dev;
2407 struct scsi_device *scsidev = cmd->device; 2408 struct scsi_device *scsidev = cmd->device;
2409 struct Scsi_Host *shost = scsidev->host;
2408 2410
2409 ap = (struct ata_port *) &scsidev->host->hostdata[0]; 2411 ap = (struct ata_port *) &shost->hostdata[0];
2412
2413 spin_unlock(shost->host_lock);
2414 spin_lock(&ap->host_set->lock);
2410 2415
2411 ata_scsi_dump_cdb(ap, cmd); 2416 ata_scsi_dump_cdb(ap, cmd);
2412 2417
@@ -2429,6 +2434,8 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
2429 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); 2434 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
2430 2435
2431out_unlock: 2436out_unlock:
2437 spin_unlock(&ap->host_set->lock);
2438 spin_lock(shost->host_lock);
2432 return 0; 2439 return 0;
2433} 2440}
2434 2441