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.c80
1 files changed, 28 insertions, 52 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 5ca97605ff35..8be7dc0b47b8 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -372,7 +372,7 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf)
372 struct ata_ioports *ioaddr = &ap->ioaddr; 372 struct ata_ioports *ioaddr = &ap->ioaddr;
373 373
374 tf->command = ata_check_status(ap); 374 tf->command = ata_check_status(ap);
375 tf->feature = ata_chk_err(ap); 375 tf->feature = inb(ioaddr->error_addr);
376 tf->nsect = inb(ioaddr->nsect_addr); 376 tf->nsect = inb(ioaddr->nsect_addr);
377 tf->lbal = inb(ioaddr->lbal_addr); 377 tf->lbal = inb(ioaddr->lbal_addr);
378 tf->lbam = inb(ioaddr->lbam_addr); 378 tf->lbam = inb(ioaddr->lbam_addr);
@@ -406,7 +406,7 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf)
406 struct ata_ioports *ioaddr = &ap->ioaddr; 406 struct ata_ioports *ioaddr = &ap->ioaddr;
407 407
408 tf->command = ata_check_status(ap); 408 tf->command = ata_check_status(ap);
409 tf->feature = ata_chk_err(ap); 409 tf->feature = readb((void __iomem *)ioaddr->error_addr);
410 tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); 410 tf->nsect = readb((void __iomem *)ioaddr->nsect_addr);
411 tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); 411 tf->lbal = readb((void __iomem *)ioaddr->lbal_addr);
412 tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); 412 tf->lbam = readb((void __iomem *)ioaddr->lbam_addr);
@@ -527,30 +527,6 @@ u8 ata_altstatus(struct ata_port *ap)
527 527
528 528
529/** 529/**
530 * ata_chk_err - Read device error reg
531 * @ap: port where the device is
532 *
533 * Reads ATA taskfile error register for
534 * currently-selected device and return its value.
535 *
536 * Note: may NOT be used as the check_err() entry in
537 * ata_port_operations.
538 *
539 * LOCKING:
540 * Inherited from caller.
541 */
542u8 ata_chk_err(struct ata_port *ap)
543{
544 if (ap->ops->check_err)
545 return ap->ops->check_err(ap);
546
547 if (ap->flags & ATA_FLAG_MMIO) {
548 return readb((void __iomem *) ap->ioaddr.error_addr);
549 }
550 return inb(ap->ioaddr.error_addr);
551}
552
553/**
554 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure 530 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
555 * @tf: Taskfile to convert 531 * @tf: Taskfile to convert
556 * @fis: Buffer into which data will output 532 * @fis: Buffer into which data will output
@@ -902,8 +878,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
902 878
903 memset(&tf, 0, sizeof(tf)); 879 memset(&tf, 0, sizeof(tf));
904 880
905 err = ata_chk_err(ap);
906 ap->ops->tf_read(ap, &tf); 881 ap->ops->tf_read(ap, &tf);
882 err = tf.feature;
907 883
908 dev->class = ATA_DEV_NONE; 884 dev->class = ATA_DEV_NONE;
909 885
@@ -1140,7 +1116,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1140 unsigned int major_version; 1116 unsigned int major_version;
1141 u16 tmp; 1117 u16 tmp;
1142 unsigned long xfer_modes; 1118 unsigned long xfer_modes;
1143 u8 status;
1144 unsigned int using_edd; 1119 unsigned int using_edd;
1145 DECLARE_COMPLETION(wait); 1120 DECLARE_COMPLETION(wait);
1146 struct ata_queued_cmd *qc; 1121 struct ata_queued_cmd *qc;
@@ -1194,8 +1169,11 @@ retry:
1194 else 1169 else
1195 wait_for_completion(&wait); 1170 wait_for_completion(&wait);
1196 1171
1197 status = ata_chk_status(ap); 1172 spin_lock_irqsave(&ap->host_set->lock, flags);
1198 if (status & ATA_ERR) { 1173 ap->ops->tf_read(ap, &qc->tf);
1174 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1175
1176 if (qc->tf.command & ATA_ERR) {
1199 /* 1177 /*
1200 * arg! EDD works for all test cases, but seems to return 1178 * arg! EDD works for all test cases, but seems to return
1201 * the ATA signature for some ATAPI devices. Until the 1179 * the ATA signature for some ATAPI devices. Until the
@@ -1208,7 +1186,7 @@ retry:
1208 * to have this problem. 1186 * to have this problem.
1209 */ 1187 */
1210 if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { 1188 if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) {
1211 u8 err = ata_chk_err(ap); 1189 u8 err = qc->tf.feature;
1212 if (err & ATA_ABORTED) { 1190 if (err & ATA_ABORTED) {
1213 dev->class = ATA_DEV_ATAPI; 1191 dev->class = ATA_DEV_ATAPI;
1214 qc->cursg = 0; 1192 qc->cursg = 0;
@@ -2685,7 +2663,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2685 * None. (grabs host lock) 2663 * None. (grabs host lock)
2686 */ 2664 */
2687 2665
2688void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 2666void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2689{ 2667{
2690 struct ata_port *ap = qc->ap; 2668 struct ata_port *ap = qc->ap;
2691 unsigned long flags; 2669 unsigned long flags;
@@ -2693,7 +2671,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2693 spin_lock_irqsave(&ap->host_set->lock, flags); 2671 spin_lock_irqsave(&ap->host_set->lock, flags);
2694 ap->flags &= ~ATA_FLAG_NOINTR; 2672 ap->flags &= ~ATA_FLAG_NOINTR;
2695 ata_irq_on(ap); 2673 ata_irq_on(ap);
2696 ata_qc_complete(qc, drv_stat); 2674 ata_qc_complete(qc, err_mask);
2697 spin_unlock_irqrestore(&ap->host_set->lock, flags); 2675 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2698} 2676}
2699 2677
@@ -2790,7 +2768,7 @@ static int ata_pio_complete (struct ata_port *ap)
2790 2768
2791 ap->hsm_task_state = HSM_ST_IDLE; 2769 ap->hsm_task_state = HSM_ST_IDLE;
2792 2770
2793 ata_poll_qc_complete(qc, drv_stat); 2771 ata_poll_qc_complete(qc, 0);
2794 2772
2795 /* another command may start at this point */ 2773 /* another command may start at this point */
2796 2774
@@ -3158,18 +3136,15 @@ static void ata_pio_block(struct ata_port *ap)
3158static void ata_pio_error(struct ata_port *ap) 3136static void ata_pio_error(struct ata_port *ap)
3159{ 3137{
3160 struct ata_queued_cmd *qc; 3138 struct ata_queued_cmd *qc;
3161 u8 drv_stat; 3139
3140 printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
3162 3141
3163 qc = ata_qc_from_tag(ap, ap->active_tag); 3142 qc = ata_qc_from_tag(ap, ap->active_tag);
3164 assert(qc != NULL); 3143 assert(qc != NULL);
3165 3144
3166 drv_stat = ata_chk_status(ap);
3167 printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n",
3168 ap->id, drv_stat);
3169
3170 ap->hsm_task_state = HSM_ST_IDLE; 3145 ap->hsm_task_state = HSM_ST_IDLE;
3171 3146
3172 ata_poll_qc_complete(qc, drv_stat | ATA_ERR); 3147 ata_poll_qc_complete(qc, AC_ERR_ATA_BUS);
3173} 3148}
3174 3149
3175static void ata_pio_task(void *_data) 3150static void ata_pio_task(void *_data)
@@ -3292,7 +3267,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3292 ap->id, qc->tf.command, drv_stat, host_stat); 3267 ap->id, qc->tf.command, drv_stat, host_stat);
3293 3268
3294 /* complete taskfile transaction */ 3269 /* complete taskfile transaction */
3295 ata_qc_complete(qc, drv_stat); 3270 ata_qc_complete(qc, ac_err_mask(drv_stat));
3296 break; 3271 break;
3297 } 3272 }
3298 3273
@@ -3397,7 +3372,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3397 return qc; 3372 return qc;
3398} 3373}
3399 3374
3400int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) 3375int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
3401{ 3376{
3402 return 0; 3377 return 0;
3403} 3378}
@@ -3456,7 +3431,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3456 * spin_lock_irqsave(host_set lock) 3431 * spin_lock_irqsave(host_set lock)
3457 */ 3432 */
3458 3433
3459void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3434void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
3460{ 3435{
3461 int rc; 3436 int rc;
3462 3437
@@ -3473,7 +3448,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
3473 qc->flags &= ~ATA_QCFLAG_ACTIVE; 3448 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3474 3449
3475 /* call completion callback */ 3450 /* call completion callback */
3476 rc = qc->complete_fn(qc, drv_stat); 3451 rc = qc->complete_fn(qc, err_mask);
3477 3452
3478 /* if callback indicates not to complete command (non-zero), 3453 /* if callback indicates not to complete command (non-zero),
3479 * return immediately 3454 * return immediately
@@ -3911,7 +3886,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
3911 ap->ops->irq_clear(ap); 3886 ap->ops->irq_clear(ap);
3912 3887
3913 /* complete taskfile transaction */ 3888 /* complete taskfile transaction */
3914 ata_qc_complete(qc, status); 3889 ata_qc_complete(qc, ac_err_mask(status));
3915 break; 3890 break;
3916 3891
3917 default: 3892 default:
@@ -4006,7 +3981,7 @@ static void atapi_packet_task(void *_data)
4006 /* sleep-wait for BSY to clear */ 3981 /* sleep-wait for BSY to clear */
4007 DPRINTK("busy wait\n"); 3982 DPRINTK("busy wait\n");
4008 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) 3983 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB))
4009 goto err_out; 3984 goto err_out_status;
4010 3985
4011 /* make sure DRQ is set */ 3986 /* make sure DRQ is set */
4012 status = ata_chk_status(ap); 3987 status = ata_chk_status(ap);
@@ -4043,8 +4018,10 @@ static void atapi_packet_task(void *_data)
4043 4018
4044 return; 4019 return;
4045 4020
4021err_out_status:
4022 status = ata_chk_status(ap);
4046err_out: 4023err_out:
4047 ata_poll_qc_complete(qc, ATA_ERR); 4024 ata_poll_qc_complete(qc, __ac_err_mask(status));
4048} 4025}
4049 4026
4050 4027
@@ -4550,11 +4527,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
4550 return probe_ent; 4527 return probe_ent;
4551} 4528}
4552 4529
4553static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info **port, int port_num) 4530static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info *port, int port_num)
4554{ 4531{
4555 struct ata_probe_ent *probe_ent; 4532 struct ata_probe_ent *probe_ent;
4556 4533
4557 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); 4534 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
4558 if (!probe_ent) 4535 if (!probe_ent)
4559 return NULL; 4536 return NULL;
4560 4537
@@ -4701,9 +4678,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4701 4678
4702 if (legacy_mode) { 4679 if (legacy_mode) {
4703 if (legacy_mode & (1 << 0)) 4680 if (legacy_mode & (1 << 0))
4704 probe_ent = ata_pci_init_legacy_port(pdev, port, 0); 4681 probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0);
4705 if (legacy_mode & (1 << 1)) 4682 if (legacy_mode & (1 << 1))
4706 probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); 4683 probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1);
4707 } else { 4684 } else {
4708 if (n_ports == 2) 4685 if (n_ports == 2)
4709 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 4686 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
@@ -4867,7 +4844,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis);
4867EXPORT_SYMBOL_GPL(ata_tf_from_fis); 4844EXPORT_SYMBOL_GPL(ata_tf_from_fis);
4868EXPORT_SYMBOL_GPL(ata_check_status); 4845EXPORT_SYMBOL_GPL(ata_check_status);
4869EXPORT_SYMBOL_GPL(ata_altstatus); 4846EXPORT_SYMBOL_GPL(ata_altstatus);
4870EXPORT_SYMBOL_GPL(ata_chk_err);
4871EXPORT_SYMBOL_GPL(ata_exec_command); 4847EXPORT_SYMBOL_GPL(ata_exec_command);
4872EXPORT_SYMBOL_GPL(ata_port_start); 4848EXPORT_SYMBOL_GPL(ata_port_start);
4873EXPORT_SYMBOL_GPL(ata_port_stop); 4849EXPORT_SYMBOL_GPL(ata_port_stop);