aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c59
1 files changed, 10 insertions, 49 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 8be7dc0b47b8..ff18fa7044c5 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -295,28 +295,6 @@ void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
295} 295}
296 296
297/** 297/**
298 * ata_exec - issue ATA command to host controller
299 * @ap: port to which command is being issued
300 * @tf: ATA taskfile register set
301 *
302 * Issues PIO/MMIO write to ATA command register, with proper
303 * synchronization with interrupt handler / other threads.
304 *
305 * LOCKING:
306 * Obtains host_set lock.
307 */
308
309static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
310{
311 unsigned long flags;
312
313 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
314 spin_lock_irqsave(&ap->host_set->lock, flags);
315 ap->ops->exec_command(ap, tf);
316 spin_unlock_irqrestore(&ap->host_set->lock, flags);
317}
318
319/**
320 * ata_tf_to_host - issue ATA taskfile to host controller 298 * ata_tf_to_host - issue ATA taskfile to host controller
321 * @ap: port to which command is being issued 299 * @ap: port to which command is being issued
322 * @tf: ATA taskfile register set 300 * @tf: ATA taskfile register set
@@ -326,30 +304,11 @@ static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
326 * other threads. 304 * other threads.
327 * 305 *
328 * LOCKING: 306 * LOCKING:
329 * Obtains host_set lock.
330 */
331
332static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf)
333{
334 ap->ops->tf_load(ap, tf);
335
336 ata_exec(ap, tf);
337}
338
339/**
340 * ata_tf_to_host_nolock - issue ATA taskfile to host controller
341 * @ap: port to which command is being issued
342 * @tf: ATA taskfile register set
343 *
344 * Issues ATA taskfile register set to ATA host controller,
345 * with proper synchronization with interrupt handler and
346 * other threads.
347 *
348 * LOCKING:
349 * spin_lock_irqsave(host_set lock) 307 * spin_lock_irqsave(host_set lock)
350 */ 308 */
351 309
352void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf) 310static inline void ata_tf_to_host(struct ata_port *ap,
311 const struct ata_taskfile *tf)
353{ 312{
354 ap->ops->tf_load(ap, tf); 313 ap->ops->tf_load(ap, tf);
355 ap->ops->exec_command(ap, tf); 314 ap->ops->exec_command(ap, tf);
@@ -1912,12 +1871,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1912 * 1871 *
1913 * LOCKING: 1872 * LOCKING:
1914 * PCI/etc. bus probe sem. 1873 * PCI/etc. bus probe sem.
1874 * Obtains host_set lock.
1915 * 1875 *
1916 */ 1876 */
1917 1877
1918static unsigned int ata_bus_edd(struct ata_port *ap) 1878static unsigned int ata_bus_edd(struct ata_port *ap)
1919{ 1879{
1920 struct ata_taskfile tf; 1880 struct ata_taskfile tf;
1881 unsigned long flags;
1921 1882
1922 /* set up execute-device-diag (bus reset) taskfile */ 1883 /* set up execute-device-diag (bus reset) taskfile */
1923 /* also, take interrupts to a known state (disabled) */ 1884 /* also, take interrupts to a known state (disabled) */
@@ -1928,7 +1889,9 @@ static unsigned int ata_bus_edd(struct ata_port *ap)
1928 tf.protocol = ATA_PROT_NODATA; 1889 tf.protocol = ATA_PROT_NODATA;
1929 1890
1930 /* do bus reset */ 1891 /* do bus reset */
1892 spin_lock_irqsave(&ap->host_set->lock, flags);
1931 ata_tf_to_host(ap, &tf); 1893 ata_tf_to_host(ap, &tf);
1894 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1932 1895
1933 /* spec says at least 2ms. but who knows with those 1896 /* spec says at least 2ms. but who knows with those
1934 * crazy ATAPI devices... 1897 * crazy ATAPI devices...
@@ -3555,7 +3518,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3555 3518
3556 switch (qc->tf.protocol) { 3519 switch (qc->tf.protocol) {
3557 case ATA_PROT_NODATA: 3520 case ATA_PROT_NODATA:
3558 ata_tf_to_host_nolock(ap, &qc->tf); 3521 ata_tf_to_host(ap, &qc->tf);
3559 break; 3522 break;
3560 3523
3561 case ATA_PROT_DMA: 3524 case ATA_PROT_DMA:
@@ -3566,20 +3529,20 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3566 3529
3567 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ 3530 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */
3568 ata_qc_set_polling(qc); 3531 ata_qc_set_polling(qc);
3569 ata_tf_to_host_nolock(ap, &qc->tf); 3532 ata_tf_to_host(ap, &qc->tf);
3570 ap->hsm_task_state = HSM_ST; 3533 ap->hsm_task_state = HSM_ST;
3571 queue_work(ata_wq, &ap->pio_task); 3534 queue_work(ata_wq, &ap->pio_task);
3572 break; 3535 break;
3573 3536
3574 case ATA_PROT_ATAPI: 3537 case ATA_PROT_ATAPI:
3575 ata_qc_set_polling(qc); 3538 ata_qc_set_polling(qc);
3576 ata_tf_to_host_nolock(ap, &qc->tf); 3539 ata_tf_to_host(ap, &qc->tf);
3577 queue_work(ata_wq, &ap->packet_task); 3540 queue_work(ata_wq, &ap->packet_task);
3578 break; 3541 break;
3579 3542
3580 case ATA_PROT_ATAPI_NODATA: 3543 case ATA_PROT_ATAPI_NODATA:
3581 ap->flags |= ATA_FLAG_NOINTR; 3544 ap->flags |= ATA_FLAG_NOINTR;
3582 ata_tf_to_host_nolock(ap, &qc->tf); 3545 ata_tf_to_host(ap, &qc->tf);
3583 queue_work(ata_wq, &ap->packet_task); 3546 queue_work(ata_wq, &ap->packet_task);
3584 break; 3547 break;
3585 3548
@@ -4126,8 +4089,6 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4126 host->unique_id = ata_unique_id++; 4089 host->unique_id = ata_unique_id++;
4127 host->max_cmd_len = 12; 4090 host->max_cmd_len = 12;
4128 4091
4129 scsi_assign_lock(host, &host_set->lock);
4130
4131 ap->flags = ATA_FLAG_PORT_DISABLED; 4092 ap->flags = ATA_FLAG_PORT_DISABLED;
4132 ap->id = host->unique_id; 4093 ap->id = host->unique_id;
4133 ap->host = host; 4094 ap->host = host;