Allow the spinlock used by libata to be overridden. Signed-off-by: Brian King --- linux-2.6-bjking1/drivers/scsi/libata-core.c | 41 +++++++++++++-------------- linux-2.6-bjking1/include/linux/libata.h | 8 ++++- 2 files changed, 28 insertions(+), 21 deletions(-) diff -puN include/linux/libata.h~libata_lock_change include/linux/libata.h --- linux-2.6/include/linux/libata.h~libata_lock_change 2005-09-26 14:22:57.000000000 -0500 +++ linux-2.6-bjking1/include/linux/libata.h 2005-09-26 14:22:57.000000000 -0500 @@ -214,7 +214,8 @@ struct ata_probe_ent { }; struct ata_host_set { - spinlock_t lock; + spinlock_t *lock; + spinlock_t default_lock; struct device *dev; unsigned long irq; void __iomem *mmio_base; @@ -669,4 +670,9 @@ static inline int ata_try_flush_cache(st ata_id_has_flush_ext(dev->id); } +static inline void ata_assign_lock(struct ata_host_set *host_set, spinlock_t *lock) +{ + host_set->lock = lock; +} + #endif /* __LINUX_LIBATA_H__ */ diff -puN drivers/scsi/libata-core.c~libata_lock_change drivers/scsi/libata-core.c --- linux-2.6/drivers/scsi/libata-core.c~libata_lock_change 2005-09-26 14:22:57.000000000 -0500 +++ linux-2.6-bjking1/drivers/scsi/libata-core.c 2005-09-26 14:22:57.000000000 -0500 @@ -308,9 +308,9 @@ static inline void ata_exec(struct ata_p unsigned long flags; DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); - spin_lock_irqsave(&ap->host_set->lock, flags); + spin_lock_irqsave(ap->host_set->lock, flags); ap->ops->exec_command(ap, tf); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + spin_unlock_irqrestore(ap->host_set->lock, flags); } /** @@ -1179,9 +1179,9 @@ retry: qc->waiting = &wait; qc->complete_fn = ata_qc_complete_noop; - spin_lock_irqsave(&ap->host_set->lock, flags); + spin_lock_irqsave(ap->host_set->lock, flags); rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + spin_unlock_irqrestore(ap->host_set->lock, flags); if (rc) goto err_out; @@ -2131,9 +2131,9 @@ static void ata_dev_set_xfermode(struct qc->waiting = &wait; qc->complete_fn = ata_qc_complete_noop; - spin_lock_irqsave(&ap->host_set->lock, flags); + spin_lock_irqsave(ap->host_set->lock, flags); rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + spin_unlock_irqrestore(ap->host_set->lock, flags); if (rc) ata_port_disable(ap); @@ -2404,11 +2404,11 @@ void ata_poll_qc_complete(struct ata_que struct ata_port *ap = qc->ap; unsigned long flags; - spin_lock_irqsave(&ap->host_set->lock, flags); + spin_lock_irqsave(ap->host_set->lock, flags); ap->flags &= ~ATA_FLAG_NOINTR; ata_irq_on(ap); ata_qc_complete(qc, drv_stat); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + spin_unlock_irqrestore(ap->host_set->lock, flags); } /** @@ -2962,9 +2962,9 @@ static void atapi_request_sense(struct a qc->waiting = &wait; qc->complete_fn = ata_qc_complete_noop; - spin_lock_irqsave(&ap->host_set->lock, flags); + spin_lock_irqsave(ap->host_set->lock, flags); rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + spin_unlock_irqrestore(ap->host_set->lock, flags); if (rc) ata_port_disable(ap); @@ -3010,9 +3010,9 @@ static void ata_qc_timeout(struct ata_qu if (!(cmd->eh_eflags & SCSI_EH_CANCEL_CMD)) { /* finish completing original command */ - spin_lock_irqsave(&host_set->lock, flags); + spin_lock_irqsave(host_set->lock, flags); __ata_qc_complete(qc); - spin_unlock_irqrestore(&host_set->lock, flags); + spin_unlock_irqrestore(host_set->lock, flags); atapi_request_sense(ap, dev, cmd); @@ -3023,7 +3023,7 @@ static void ata_qc_timeout(struct ata_qu } } - spin_lock_irqsave(&host_set->lock, flags); + spin_lock_irqsave(host_set->lock, flags); /* hack alert! We cannot use the supplied completion * function from inside the ->eh_strategy_handler() thread. @@ -3059,7 +3059,7 @@ static void ata_qc_timeout(struct ata_qu break; } - spin_unlock_irqrestore(&host_set->lock, flags); + spin_unlock_irqrestore(host_set->lock, flags); out: DPRINTK("EXIT\n"); @@ -3726,7 +3726,7 @@ irqreturn_t ata_interrupt (int irq, void unsigned long flags; /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ - spin_lock_irqsave(&host_set->lock, flags); + spin_lock_irqsave(host_set->lock, flags); for (i = 0; i < host_set->n_ports; i++) { struct ata_port *ap; @@ -3743,7 +3743,7 @@ irqreturn_t ata_interrupt (int irq, void } } - spin_unlock_irqrestore(&host_set->lock, flags); + spin_unlock_irqrestore(host_set->lock, flags); return IRQ_RETVAL(handled); } @@ -3796,12 +3796,12 @@ static void atapi_packet_task(void *_dat * interrupt handler shouldn't be invoked before we're * finished. Hence, the following locking. */ - spin_lock_irqsave(&ap->host_set->lock, flags); + spin_lock_irqsave(ap->host_set->lock, flags); ap->flags &= ~ATA_FLAG_NOINTR; ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) ap->ops->bmdma_start(qc); /* initiate bmdma */ - spin_unlock_irqrestore(&ap->host_set->lock, flags); + spin_unlock_irqrestore(ap->host_set->lock, flags); } else { ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); @@ -3916,7 +3916,7 @@ static void ata_host_init(struct ata_por host->unique_id = ata_unique_id++; host->max_cmd_len = 12; - scsi_assign_lock(host, &host_set->lock); + scsi_assign_lock(host, host_set->lock); ap->flags = ATA_FLAG_PORT_DISABLED; ap->id = host->unique_id; @@ -4026,7 +4026,8 @@ int ata_device_add(struct ata_probe_ent if (!host_set) return 0; memset(host_set, 0, sizeof(struct ata_host_set) + (ent->n_ports * sizeof(void *))); - spin_lock_init(&host_set->lock); + spin_lock_init(&host_set->default_lock); + ata_assign_lock(host_set, &host_set->default_lock); host_set->dev = dev; host_set->n_ports = ent->n_ports; _