diff options
-rw-r--r-- | drivers/scsi/Makefile | 2 | ||||
-rw-r--r-- | drivers/scsi/ahci.c | 159 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 55 | ||||
-rw-r--r-- | drivers/scsi/libata-bmdma.c | 703 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 1444 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 193 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 3 | ||||
-rw-r--r-- | drivers/scsi/pdc_adma.c | 5 | ||||
-rw-r--r-- | drivers/scsi/sata_mv.c | 236 | ||||
-rw-r--r-- | drivers/scsi/sata_nv.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 126 | ||||
-rw-r--r-- | drivers/scsi/sata_qstor.c | 5 | ||||
-rw-r--r-- | drivers/scsi/sata_sil.c | 10 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 83 | ||||
-rw-r--r-- | drivers/scsi/sata_sis.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_svw.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_sx4.c | 22 | ||||
-rw-r--r-- | drivers/scsi/sata_uli.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_via.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_vsc.c | 1 | ||||
-rw-r--r-- | drivers/scsi/scsi_error.c | 7 | ||||
-rw-r--r-- | include/linux/ata.h | 12 | ||||
-rw-r--r-- | include/linux/libata.h | 106 | ||||
-rw-r--r-- | include/scsi/scsi_eh.h | 3 |
24 files changed, 2040 insertions, 1140 deletions
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 320e765fa0cd..15dc2e00e1b2 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -163,7 +163,7 @@ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ | |||
163 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) | 163 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) |
164 | zalon7xx-objs := zalon.o ncr53c8xx.o | 164 | zalon7xx-objs := zalon.o ncr53c8xx.o |
165 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o | 165 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o |
166 | libata-objs := libata-core.o libata-scsi.o | 166 | libata-objs := libata-core.o libata-scsi.o libata-bmdma.o |
167 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o | 167 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o |
168 | 168 | ||
169 | # Files generated that shall be removed upon make clean | 169 | # Files generated that shall be removed upon make clean |
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index a800fb51168b..98ce6bb62ff8 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -66,6 +66,8 @@ enum { | |||
66 | AHCI_IRQ_ON_SG = (1 << 31), | 66 | AHCI_IRQ_ON_SG = (1 << 31), |
67 | AHCI_CMD_ATAPI = (1 << 5), | 67 | AHCI_CMD_ATAPI = (1 << 5), |
68 | AHCI_CMD_WRITE = (1 << 6), | 68 | AHCI_CMD_WRITE = (1 << 6), |
69 | AHCI_CMD_RESET = (1 << 8), | ||
70 | AHCI_CMD_CLR_BUSY = (1 << 10), | ||
69 | 71 | ||
70 | RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */ | 72 | RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */ |
71 | 73 | ||
@@ -85,6 +87,7 @@ enum { | |||
85 | 87 | ||
86 | /* HOST_CAP bits */ | 88 | /* HOST_CAP bits */ |
87 | HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */ | 89 | HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */ |
90 | HOST_CAP_CLO = (1 << 24), /* Command List Override support */ | ||
88 | 91 | ||
89 | /* registers for each SATA port */ | 92 | /* registers for each SATA port */ |
90 | PORT_LST_ADDR = 0x00, /* command list DMA addr */ | 93 | PORT_LST_ADDR = 0x00, /* command list DMA addr */ |
@@ -138,6 +141,7 @@ enum { | |||
138 | PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ | 141 | PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ |
139 | PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ | 142 | PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ |
140 | PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */ | 143 | PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */ |
144 | PORT_CMD_CLO = (1 << 3), /* Command list override */ | ||
141 | PORT_CMD_POWER_ON = (1 << 2), /* Power up device */ | 145 | PORT_CMD_POWER_ON = (1 << 2), /* Power up device */ |
142 | PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */ | 146 | PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */ |
143 | PORT_CMD_START = (1 << 0), /* Enable port DMA engine */ | 147 | PORT_CMD_START = (1 << 0), /* Enable port DMA engine */ |
@@ -184,7 +188,7 @@ struct ahci_port_priv { | |||
184 | static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg); | 188 | static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg); |
185 | static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 189 | static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); |
186 | static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 190 | static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
187 | static int ahci_qc_issue(struct ata_queued_cmd *qc); | 191 | static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); |
188 | static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs); | 192 | static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs); |
189 | static void ahci_phy_reset(struct ata_port *ap); | 193 | static void ahci_phy_reset(struct ata_port *ap); |
190 | static void ahci_irq_clear(struct ata_port *ap); | 194 | static void ahci_irq_clear(struct ata_port *ap); |
@@ -202,6 +206,7 @@ static struct scsi_host_template ahci_sht = { | |||
202 | .name = DRV_NAME, | 206 | .name = DRV_NAME, |
203 | .ioctl = ata_scsi_ioctl, | 207 | .ioctl = ata_scsi_ioctl, |
204 | .queuecommand = ata_scsi_queuecmd, | 208 | .queuecommand = ata_scsi_queuecmd, |
209 | .eh_timed_out = ata_scsi_timed_out, | ||
205 | .eh_strategy_handler = ata_scsi_error, | 210 | .eh_strategy_handler = ata_scsi_error, |
206 | .can_queue = ATA_DEF_QUEUE, | 211 | .can_queue = ATA_DEF_QUEUE, |
207 | .this_id = ATA_SHT_THIS_ID, | 212 | .this_id = ATA_SHT_THIS_ID, |
@@ -450,25 +455,81 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in, | |||
450 | writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); | 455 | writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); |
451 | } | 456 | } |
452 | 457 | ||
453 | static void ahci_phy_reset(struct ata_port *ap) | 458 | static int ahci_stop_engine(struct ata_port *ap) |
459 | { | ||
460 | void __iomem *mmio = ap->host_set->mmio_base; | ||
461 | void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); | ||
462 | int work; | ||
463 | u32 tmp; | ||
464 | |||
465 | tmp = readl(port_mmio + PORT_CMD); | ||
466 | tmp &= ~PORT_CMD_START; | ||
467 | writel(tmp, port_mmio + PORT_CMD); | ||
468 | |||
469 | /* wait for engine to stop. TODO: this could be | ||
470 | * as long as 500 msec | ||
471 | */ | ||
472 | work = 1000; | ||
473 | while (work-- > 0) { | ||
474 | tmp = readl(port_mmio + PORT_CMD); | ||
475 | if ((tmp & PORT_CMD_LIST_ON) == 0) | ||
476 | return 0; | ||
477 | udelay(10); | ||
478 | } | ||
479 | |||
480 | return -EIO; | ||
481 | } | ||
482 | |||
483 | static void ahci_start_engine(struct ata_port *ap) | ||
484 | { | ||
485 | void __iomem *mmio = ap->host_set->mmio_base; | ||
486 | void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); | ||
487 | u32 tmp; | ||
488 | |||
489 | tmp = readl(port_mmio + PORT_CMD); | ||
490 | tmp |= PORT_CMD_START; | ||
491 | writel(tmp, port_mmio + PORT_CMD); | ||
492 | readl(port_mmio + PORT_CMD); /* flush */ | ||
493 | } | ||
494 | |||
495 | static unsigned int ahci_dev_classify(struct ata_port *ap) | ||
454 | { | 496 | { |
455 | void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; | 497 | void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; |
456 | struct ata_taskfile tf; | 498 | struct ata_taskfile tf; |
499 | u32 tmp; | ||
500 | |||
501 | tmp = readl(port_mmio + PORT_SIG); | ||
502 | tf.lbah = (tmp >> 24) & 0xff; | ||
503 | tf.lbam = (tmp >> 16) & 0xff; | ||
504 | tf.lbal = (tmp >> 8) & 0xff; | ||
505 | tf.nsect = (tmp) & 0xff; | ||
506 | |||
507 | return ata_dev_classify(&tf); | ||
508 | } | ||
509 | |||
510 | static void ahci_fill_cmd_slot(struct ata_port *ap, u32 opts) | ||
511 | { | ||
512 | struct ahci_port_priv *pp = ap->private_data; | ||
513 | pp->cmd_slot[0].opts = cpu_to_le32(opts); | ||
514 | pp->cmd_slot[0].status = 0; | ||
515 | pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff); | ||
516 | pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16); | ||
517 | } | ||
518 | |||
519 | static void ahci_phy_reset(struct ata_port *ap) | ||
520 | { | ||
521 | void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; | ||
457 | struct ata_device *dev = &ap->device[0]; | 522 | struct ata_device *dev = &ap->device[0]; |
458 | u32 new_tmp, tmp; | 523 | u32 new_tmp, tmp; |
459 | 524 | ||
525 | ahci_stop_engine(ap); | ||
460 | __sata_phy_reset(ap); | 526 | __sata_phy_reset(ap); |
527 | ahci_start_engine(ap); | ||
461 | 528 | ||
462 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 529 | if (ap->flags & ATA_FLAG_PORT_DISABLED) |
463 | return; | 530 | return; |
464 | 531 | ||
465 | tmp = readl(port_mmio + PORT_SIG); | 532 | dev->class = ahci_dev_classify(ap); |
466 | tf.lbah = (tmp >> 24) & 0xff; | ||
467 | tf.lbam = (tmp >> 16) & 0xff; | ||
468 | tf.lbal = (tmp >> 8) & 0xff; | ||
469 | tf.nsect = (tmp) & 0xff; | ||
470 | |||
471 | dev->class = ata_dev_classify(&tf); | ||
472 | if (!ata_dev_present(dev)) { | 533 | if (!ata_dev_present(dev)) { |
473 | ata_port_disable(ap); | 534 | ata_port_disable(ap); |
474 | return; | 535 | return; |
@@ -533,42 +594,35 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) | |||
533 | { | 594 | { |
534 | struct ata_port *ap = qc->ap; | 595 | struct ata_port *ap = qc->ap; |
535 | struct ahci_port_priv *pp = ap->private_data; | 596 | struct ahci_port_priv *pp = ap->private_data; |
597 | int is_atapi = is_atapi_taskfile(&qc->tf); | ||
536 | u32 opts; | 598 | u32 opts; |
537 | const u32 cmd_fis_len = 5; /* five dwords */ | 599 | const u32 cmd_fis_len = 5; /* five dwords */ |
538 | unsigned int n_elem; | 600 | unsigned int n_elem; |
539 | 601 | ||
540 | /* | 602 | /* |
541 | * Fill in command slot information (currently only one slot, | ||
542 | * slot 0, is currently since we don't do queueing) | ||
543 | */ | ||
544 | |||
545 | opts = cmd_fis_len; | ||
546 | if (qc->tf.flags & ATA_TFLAG_WRITE) | ||
547 | opts |= AHCI_CMD_WRITE; | ||
548 | if (is_atapi_taskfile(&qc->tf)) | ||
549 | opts |= AHCI_CMD_ATAPI; | ||
550 | |||
551 | pp->cmd_slot[0].opts = cpu_to_le32(opts); | ||
552 | pp->cmd_slot[0].status = 0; | ||
553 | pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff); | ||
554 | pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16); | ||
555 | |||
556 | /* | ||
557 | * Fill in command table information. First, the header, | 603 | * Fill in command table information. First, the header, |
558 | * a SATA Register - Host to Device command FIS. | 604 | * a SATA Register - Host to Device command FIS. |
559 | */ | 605 | */ |
560 | ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0); | 606 | ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0); |
561 | if (opts & AHCI_CMD_ATAPI) { | 607 | if (is_atapi) { |
562 | memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); | 608 | memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); |
563 | memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len); | 609 | memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len); |
564 | } | 610 | } |
565 | 611 | ||
566 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | 612 | n_elem = 0; |
567 | return; | 613 | if (qc->flags & ATA_QCFLAG_DMAMAP) |
614 | n_elem = ahci_fill_sg(qc); | ||
568 | 615 | ||
569 | n_elem = ahci_fill_sg(qc); | 616 | /* |
617 | * Fill in command slot information. | ||
618 | */ | ||
619 | opts = cmd_fis_len | n_elem << 16; | ||
620 | if (qc->tf.flags & ATA_TFLAG_WRITE) | ||
621 | opts |= AHCI_CMD_WRITE; | ||
622 | if (is_atapi) | ||
623 | opts |= AHCI_CMD_ATAPI; | ||
570 | 624 | ||
571 | pp->cmd_slot[0].opts |= cpu_to_le32(n_elem << 16); | 625 | ahci_fill_cmd_slot(ap, opts); |
572 | } | 626 | } |
573 | 627 | ||
574 | static void ahci_restart_port(struct ata_port *ap, u32 irq_stat) | 628 | static void ahci_restart_port(struct ata_port *ap, u32 irq_stat) |
@@ -576,7 +630,6 @@ static void ahci_restart_port(struct ata_port *ap, u32 irq_stat) | |||
576 | void __iomem *mmio = ap->host_set->mmio_base; | 630 | void __iomem *mmio = ap->host_set->mmio_base; |
577 | void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); | 631 | void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); |
578 | u32 tmp; | 632 | u32 tmp; |
579 | int work; | ||
580 | 633 | ||
581 | if ((ap->device[0].class != ATA_DEV_ATAPI) || | 634 | if ((ap->device[0].class != ATA_DEV_ATAPI) || |
582 | ((irq_stat & PORT_IRQ_TF_ERR) == 0)) | 635 | ((irq_stat & PORT_IRQ_TF_ERR) == 0)) |
@@ -592,20 +645,7 @@ static void ahci_restart_port(struct ata_port *ap, u32 irq_stat) | |||
592 | readl(port_mmio + PORT_SCR_ERR)); | 645 | readl(port_mmio + PORT_SCR_ERR)); |
593 | 646 | ||
594 | /* stop DMA */ | 647 | /* stop DMA */ |
595 | tmp = readl(port_mmio + PORT_CMD); | 648 | ahci_stop_engine(ap); |
596 | tmp &= ~PORT_CMD_START; | ||
597 | writel(tmp, port_mmio + PORT_CMD); | ||
598 | |||
599 | /* wait for engine to stop. TODO: this could be | ||
600 | * as long as 500 msec | ||
601 | */ | ||
602 | work = 1000; | ||
603 | while (work-- > 0) { | ||
604 | tmp = readl(port_mmio + PORT_CMD); | ||
605 | if ((tmp & PORT_CMD_LIST_ON) == 0) | ||
606 | break; | ||
607 | udelay(10); | ||
608 | } | ||
609 | 649 | ||
610 | /* clear SATA phy error, if any */ | 650 | /* clear SATA phy error, if any */ |
611 | tmp = readl(port_mmio + PORT_SCR_ERR); | 651 | tmp = readl(port_mmio + PORT_SCR_ERR); |
@@ -624,10 +664,7 @@ static void ahci_restart_port(struct ata_port *ap, u32 irq_stat) | |||
624 | } | 664 | } |
625 | 665 | ||
626 | /* re-start DMA */ | 666 | /* re-start DMA */ |
627 | tmp = readl(port_mmio + PORT_CMD); | 667 | ahci_start_engine(ap); |
628 | tmp |= PORT_CMD_START; | ||
629 | writel(tmp, port_mmio + PORT_CMD); | ||
630 | readl(port_mmio + PORT_CMD); /* flush */ | ||
631 | } | 668 | } |
632 | 669 | ||
633 | static void ahci_eng_timeout(struct ata_port *ap) | 670 | static void ahci_eng_timeout(struct ata_port *ap) |
@@ -642,25 +679,13 @@ static void ahci_eng_timeout(struct ata_port *ap) | |||
642 | 679 | ||
643 | spin_lock_irqsave(&host_set->lock, flags); | 680 | spin_lock_irqsave(&host_set->lock, flags); |
644 | 681 | ||
682 | ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT)); | ||
645 | qc = ata_qc_from_tag(ap, ap->active_tag); | 683 | qc = ata_qc_from_tag(ap, ap->active_tag); |
646 | if (!qc) { | 684 | qc->err_mask |= AC_ERR_TIMEOUT; |
647 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | ||
648 | ap->id); | ||
649 | } else { | ||
650 | ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT)); | ||
651 | |||
652 | /* hack alert! We cannot use the supplied completion | ||
653 | * function from inside the ->eh_strategy_handler() thread. | ||
654 | * libata is the only user of ->eh_strategy_handler() in | ||
655 | * any kernel, so the default scsi_done() assumes it is | ||
656 | * not being called from the SCSI EH. | ||
657 | */ | ||
658 | qc->scsidone = scsi_finish_command; | ||
659 | qc->err_mask |= AC_ERR_OTHER; | ||
660 | ata_qc_complete(qc); | ||
661 | } | ||
662 | 685 | ||
663 | spin_unlock_irqrestore(&host_set->lock, flags); | 686 | spin_unlock_irqrestore(&host_set->lock, flags); |
687 | |||
688 | ata_eh_qc_complete(qc); | ||
664 | } | 689 | } |
665 | 690 | ||
666 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | 691 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) |
@@ -697,7 +722,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
697 | ahci_restart_port(ap, status); | 722 | ahci_restart_port(ap, status); |
698 | 723 | ||
699 | if (qc) { | 724 | if (qc) { |
700 | qc->err_mask |= AC_ERR_OTHER; | 725 | qc->err_mask |= err_mask; |
701 | ata_qc_complete(qc); | 726 | ata_qc_complete(qc); |
702 | } | 727 | } |
703 | } | 728 | } |
@@ -776,7 +801,7 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * | |||
776 | return IRQ_RETVAL(handled); | 801 | return IRQ_RETVAL(handled); |
777 | } | 802 | } |
778 | 803 | ||
779 | static int ahci_qc_issue(struct ata_queued_cmd *qc) | 804 | static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc) |
780 | { | 805 | { |
781 | struct ata_port *ap = qc->ap; | 806 | struct ata_port *ap = qc->ap; |
782 | void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; | 807 | void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index fc3ca051ceed..4933ba284885 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -101,9 +101,11 @@ enum { | |||
101 | ICH5_PCS = 0x92, /* port control and status */ | 101 | ICH5_PCS = 0x92, /* port control and status */ |
102 | PIIX_SCC = 0x0A, /* sub-class code register */ | 102 | PIIX_SCC = 0x0A, /* sub-class code register */ |
103 | 103 | ||
104 | PIIX_FLAG_AHCI = (1 << 28), /* AHCI possible */ | 104 | PIIX_FLAG_AHCI = (1 << 27), /* AHCI possible */ |
105 | PIIX_FLAG_CHECKINTR = (1 << 29), /* make sure PCI INTx enabled */ | 105 | PIIX_FLAG_CHECKINTR = (1 << 28), /* make sure PCI INTx enabled */ |
106 | PIIX_FLAG_COMBINED = (1 << 30), /* combined mode possible */ | 106 | PIIX_FLAG_COMBINED = (1 << 29), /* combined mode possible */ |
107 | /* ICH6/7 use different scheme for map value */ | ||
108 | PIIX_FLAG_COMBINED_ICH6 = PIIX_FLAG_COMBINED | (1 << 30), | ||
107 | 109 | ||
108 | /* combined mode. if set, PATA is channel 0. | 110 | /* combined mode. if set, PATA is channel 0. |
109 | * if clear, PATA is channel 1. | 111 | * if clear, PATA is channel 1. |
@@ -178,6 +180,7 @@ static struct scsi_host_template piix_sht = { | |||
178 | .name = DRV_NAME, | 180 | .name = DRV_NAME, |
179 | .ioctl = ata_scsi_ioctl, | 181 | .ioctl = ata_scsi_ioctl, |
180 | .queuecommand = ata_scsi_queuecmd, | 182 | .queuecommand = ata_scsi_queuecmd, |
183 | .eh_timed_out = ata_scsi_timed_out, | ||
181 | .eh_strategy_handler = ata_scsi_error, | 184 | .eh_strategy_handler = ata_scsi_error, |
182 | .can_queue = ATA_DEF_QUEUE, | 185 | .can_queue = ATA_DEF_QUEUE, |
183 | .this_id = ATA_SHT_THIS_ID, | 186 | .this_id = ATA_SHT_THIS_ID, |
@@ -297,8 +300,8 @@ static struct ata_port_info piix_port_info[] = { | |||
297 | { | 300 | { |
298 | .sht = &piix_sht, | 301 | .sht = &piix_sht, |
299 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | 302 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | |
300 | PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | | 303 | PIIX_FLAG_COMBINED_ICH6 | |
301 | ATA_FLAG_SLAVE_POSS, | 304 | PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS, |
302 | .pio_mask = 0x1f, /* pio0-4 */ | 305 | .pio_mask = 0x1f, /* pio0-4 */ |
303 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 306 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
304 | .udma_mask = 0x7f, /* udma0-6 */ | 307 | .udma_mask = 0x7f, /* udma0-6 */ |
@@ -309,8 +312,9 @@ static struct ata_port_info piix_port_info[] = { | |||
309 | { | 312 | { |
310 | .sht = &piix_sht, | 313 | .sht = &piix_sht, |
311 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | 314 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | |
312 | PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | | 315 | PIIX_FLAG_COMBINED_ICH6 | |
313 | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI, | 316 | PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS | |
317 | PIIX_FLAG_AHCI, | ||
314 | .pio_mask = 0x1f, /* pio0-4 */ | 318 | .pio_mask = 0x1f, /* pio0-4 */ |
315 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 319 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
316 | .udma_mask = 0x7f, /* udma0-6 */ | 320 | .udma_mask = 0x7f, /* udma0-6 */ |
@@ -627,6 +631,7 @@ static int piix_disable_ahci(struct pci_dev *pdev) | |||
627 | 631 | ||
628 | /** | 632 | /** |
629 | * piix_check_450nx_errata - Check for problem 450NX setup | 633 | * piix_check_450nx_errata - Check for problem 450NX setup |
634 | * @ata_dev: the PCI device to check | ||
630 | * | 635 | * |
631 | * Check for the present of 450NX errata #19 and errata #25. If | 636 | * Check for the present of 450NX errata #19 and errata #25. If |
632 | * they are found return an error code so we can turn off DMA | 637 | * they are found return an error code so we can turn off DMA |
@@ -680,6 +685,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
680 | struct ata_port_info *port_info[2]; | 685 | struct ata_port_info *port_info[2]; |
681 | unsigned int combined = 0; | 686 | unsigned int combined = 0; |
682 | unsigned int pata_chan = 0, sata_chan = 0; | 687 | unsigned int pata_chan = 0, sata_chan = 0; |
688 | unsigned long host_flags; | ||
683 | 689 | ||
684 | if (!printed_version++) | 690 | if (!printed_version++) |
685 | dev_printk(KERN_DEBUG, &pdev->dev, | 691 | dev_printk(KERN_DEBUG, &pdev->dev, |
@@ -692,7 +698,9 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
692 | port_info[0] = &piix_port_info[ent->driver_data]; | 698 | port_info[0] = &piix_port_info[ent->driver_data]; |
693 | port_info[1] = &piix_port_info[ent->driver_data]; | 699 | port_info[1] = &piix_port_info[ent->driver_data]; |
694 | 700 | ||
695 | if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { | 701 | host_flags = port_info[0]->host_flags; |
702 | |||
703 | if (host_flags & PIIX_FLAG_AHCI) { | ||
696 | u8 tmp; | 704 | u8 tmp; |
697 | pci_read_config_byte(pdev, PIIX_SCC, &tmp); | 705 | pci_read_config_byte(pdev, PIIX_SCC, &tmp); |
698 | if (tmp == PIIX_AHCI_DEVICE) { | 706 | if (tmp == PIIX_AHCI_DEVICE) { |
@@ -702,16 +710,35 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
702 | } | 710 | } |
703 | } | 711 | } |
704 | 712 | ||
705 | if (port_info[0]->host_flags & PIIX_FLAG_COMBINED) { | 713 | if (host_flags & PIIX_FLAG_COMBINED) { |
706 | u8 tmp; | 714 | u8 tmp; |
707 | pci_read_config_byte(pdev, ICH5_PMR, &tmp); | 715 | pci_read_config_byte(pdev, ICH5_PMR, &tmp); |
708 | 716 | ||
709 | if (tmp & PIIX_COMB) { | 717 | if (host_flags & PIIX_FLAG_COMBINED_ICH6) { |
710 | combined = 1; | 718 | switch (tmp & 0x3) { |
711 | if (tmp & PIIX_COMB_PATA_P0) | 719 | case 0: |
720 | break; | ||
721 | case 1: | ||
722 | combined = 1; | ||
712 | sata_chan = 1; | 723 | sata_chan = 1; |
713 | else | 724 | break; |
725 | case 2: | ||
726 | combined = 1; | ||
714 | pata_chan = 1; | 727 | pata_chan = 1; |
728 | break; | ||
729 | case 3: | ||
730 | dev_printk(KERN_WARNING, &pdev->dev, | ||
731 | "invalid MAP value %u\n", tmp); | ||
732 | break; | ||
733 | } | ||
734 | } else { | ||
735 | if (tmp & PIIX_COMB) { | ||
736 | combined = 1; | ||
737 | if (tmp & PIIX_COMB_PATA_P0) | ||
738 | sata_chan = 1; | ||
739 | else | ||
740 | pata_chan = 1; | ||
741 | } | ||
715 | } | 742 | } |
716 | } | 743 | } |
717 | 744 | ||
@@ -721,7 +748,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
721 | * MSI is disabled (and it is disabled, as we don't use | 748 | * MSI is disabled (and it is disabled, as we don't use |
722 | * message-signalled interrupts currently). | 749 | * message-signalled interrupts currently). |
723 | */ | 750 | */ |
724 | if (port_info[0]->host_flags & PIIX_FLAG_CHECKINTR) | 751 | if (host_flags & PIIX_FLAG_CHECKINTR) |
725 | pci_intx(pdev, 1); | 752 | pci_intx(pdev, 1); |
726 | 753 | ||
727 | if (combined) { | 754 | if (combined) { |
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c new file mode 100644 index 000000000000..a93336adcd23 --- /dev/null +++ b/drivers/scsi/libata-bmdma.c | |||
@@ -0,0 +1,703 @@ | |||
1 | /* | ||
2 | * libata-bmdma.c - helper library for PCI IDE BMDMA | ||
3 | * | ||
4 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> | ||
5 | * Please ALWAYS copy linux-ide@vger.kernel.org | ||
6 | * on emails. | ||
7 | * | ||
8 | * Copyright 2003-2006 Red Hat, Inc. All rights reserved. | ||
9 | * Copyright 2003-2006 Jeff Garzik | ||
10 | * | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2, or (at your option) | ||
15 | * any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; see the file COPYING. If not, write to | ||
24 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | * | ||
26 | * | ||
27 | * libata documentation is available via 'make {ps|pdf}docs', | ||
28 | * as Documentation/DocBook/libata.* | ||
29 | * | ||
30 | * Hardware documentation available from http://www.t13.org/ and | ||
31 | * http://www.sata-io.org/ | ||
32 | * | ||
33 | */ | ||
34 | |||
35 | #include <linux/config.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/pci.h> | ||
38 | #include <linux/libata.h> | ||
39 | |||
40 | #include "libata.h" | ||
41 | |||
42 | /** | ||
43 | * ata_tf_load_pio - send taskfile registers to host controller | ||
44 | * @ap: Port to which output is sent | ||
45 | * @tf: ATA taskfile register set | ||
46 | * | ||
47 | * Outputs ATA taskfile to standard ATA host controller. | ||
48 | * | ||
49 | * LOCKING: | ||
50 | * Inherited from caller. | ||
51 | */ | ||
52 | |||
53 | static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
54 | { | ||
55 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
56 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; | ||
57 | |||
58 | if (tf->ctl != ap->last_ctl) { | ||
59 | outb(tf->ctl, ioaddr->ctl_addr); | ||
60 | ap->last_ctl = tf->ctl; | ||
61 | ata_wait_idle(ap); | ||
62 | } | ||
63 | |||
64 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { | ||
65 | outb(tf->hob_feature, ioaddr->feature_addr); | ||
66 | outb(tf->hob_nsect, ioaddr->nsect_addr); | ||
67 | outb(tf->hob_lbal, ioaddr->lbal_addr); | ||
68 | outb(tf->hob_lbam, ioaddr->lbam_addr); | ||
69 | outb(tf->hob_lbah, ioaddr->lbah_addr); | ||
70 | VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", | ||
71 | tf->hob_feature, | ||
72 | tf->hob_nsect, | ||
73 | tf->hob_lbal, | ||
74 | tf->hob_lbam, | ||
75 | tf->hob_lbah); | ||
76 | } | ||
77 | |||
78 | if (is_addr) { | ||
79 | outb(tf->feature, ioaddr->feature_addr); | ||
80 | outb(tf->nsect, ioaddr->nsect_addr); | ||
81 | outb(tf->lbal, ioaddr->lbal_addr); | ||
82 | outb(tf->lbam, ioaddr->lbam_addr); | ||
83 | outb(tf->lbah, ioaddr->lbah_addr); | ||
84 | VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", | ||
85 | tf->feature, | ||
86 | tf->nsect, | ||
87 | tf->lbal, | ||
88 | tf->lbam, | ||
89 | tf->lbah); | ||
90 | } | ||
91 | |||
92 | if (tf->flags & ATA_TFLAG_DEVICE) { | ||
93 | outb(tf->device, ioaddr->device_addr); | ||
94 | VPRINTK("device 0x%X\n", tf->device); | ||
95 | } | ||
96 | |||
97 | ata_wait_idle(ap); | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * ata_tf_load_mmio - send taskfile registers to host controller | ||
102 | * @ap: Port to which output is sent | ||
103 | * @tf: ATA taskfile register set | ||
104 | * | ||
105 | * Outputs ATA taskfile to standard ATA host controller using MMIO. | ||
106 | * | ||
107 | * LOCKING: | ||
108 | * Inherited from caller. | ||
109 | */ | ||
110 | |||
111 | static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
112 | { | ||
113 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
114 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; | ||
115 | |||
116 | if (tf->ctl != ap->last_ctl) { | ||
117 | writeb(tf->ctl, (void __iomem *) ap->ioaddr.ctl_addr); | ||
118 | ap->last_ctl = tf->ctl; | ||
119 | ata_wait_idle(ap); | ||
120 | } | ||
121 | |||
122 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { | ||
123 | writeb(tf->hob_feature, (void __iomem *) ioaddr->feature_addr); | ||
124 | writeb(tf->hob_nsect, (void __iomem *) ioaddr->nsect_addr); | ||
125 | writeb(tf->hob_lbal, (void __iomem *) ioaddr->lbal_addr); | ||
126 | writeb(tf->hob_lbam, (void __iomem *) ioaddr->lbam_addr); | ||
127 | writeb(tf->hob_lbah, (void __iomem *) ioaddr->lbah_addr); | ||
128 | VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", | ||
129 | tf->hob_feature, | ||
130 | tf->hob_nsect, | ||
131 | tf->hob_lbal, | ||
132 | tf->hob_lbam, | ||
133 | tf->hob_lbah); | ||
134 | } | ||
135 | |||
136 | if (is_addr) { | ||
137 | writeb(tf->feature, (void __iomem *) ioaddr->feature_addr); | ||
138 | writeb(tf->nsect, (void __iomem *) ioaddr->nsect_addr); | ||
139 | writeb(tf->lbal, (void __iomem *) ioaddr->lbal_addr); | ||
140 | writeb(tf->lbam, (void __iomem *) ioaddr->lbam_addr); | ||
141 | writeb(tf->lbah, (void __iomem *) ioaddr->lbah_addr); | ||
142 | VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", | ||
143 | tf->feature, | ||
144 | tf->nsect, | ||
145 | tf->lbal, | ||
146 | tf->lbam, | ||
147 | tf->lbah); | ||
148 | } | ||
149 | |||
150 | if (tf->flags & ATA_TFLAG_DEVICE) { | ||
151 | writeb(tf->device, (void __iomem *) ioaddr->device_addr); | ||
152 | VPRINTK("device 0x%X\n", tf->device); | ||
153 | } | ||
154 | |||
155 | ata_wait_idle(ap); | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * ata_tf_load - send taskfile registers to host controller | ||
161 | * @ap: Port to which output is sent | ||
162 | * @tf: ATA taskfile register set | ||
163 | * | ||
164 | * Outputs ATA taskfile to standard ATA host controller using MMIO | ||
165 | * or PIO as indicated by the ATA_FLAG_MMIO flag. | ||
166 | * Writes the control, feature, nsect, lbal, lbam, and lbah registers. | ||
167 | * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect, | ||
168 | * hob_lbal, hob_lbam, and hob_lbah. | ||
169 | * | ||
170 | * This function waits for idle (!BUSY and !DRQ) after writing | ||
171 | * registers. If the control register has a new value, this | ||
172 | * function also waits for idle after writing control and before | ||
173 | * writing the remaining registers. | ||
174 | * | ||
175 | * May be used as the tf_load() entry in ata_port_operations. | ||
176 | * | ||
177 | * LOCKING: | ||
178 | * Inherited from caller. | ||
179 | */ | ||
180 | void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | ||
181 | { | ||
182 | if (ap->flags & ATA_FLAG_MMIO) | ||
183 | ata_tf_load_mmio(ap, tf); | ||
184 | else | ||
185 | ata_tf_load_pio(ap, tf); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * ata_exec_command_pio - issue ATA command to host controller | ||
190 | * @ap: port to which command is being issued | ||
191 | * @tf: ATA taskfile register set | ||
192 | * | ||
193 | * Issues PIO write to ATA command register, with proper | ||
194 | * synchronization with interrupt handler / other threads. | ||
195 | * | ||
196 | * LOCKING: | ||
197 | * spin_lock_irqsave(host_set lock) | ||
198 | */ | ||
199 | |||
200 | static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
201 | { | ||
202 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | ||
203 | |||
204 | outb(tf->command, ap->ioaddr.command_addr); | ||
205 | ata_pause(ap); | ||
206 | } | ||
207 | |||
208 | |||
209 | /** | ||
210 | * ata_exec_command_mmio - issue ATA command to host controller | ||
211 | * @ap: port to which command is being issued | ||
212 | * @tf: ATA taskfile register set | ||
213 | * | ||
214 | * Issues MMIO write to ATA command register, with proper | ||
215 | * synchronization with interrupt handler / other threads. | ||
216 | * | ||
217 | * LOCKING: | ||
218 | * spin_lock_irqsave(host_set lock) | ||
219 | */ | ||
220 | |||
221 | static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
222 | { | ||
223 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | ||
224 | |||
225 | writeb(tf->command, (void __iomem *) ap->ioaddr.command_addr); | ||
226 | ata_pause(ap); | ||
227 | } | ||
228 | |||
229 | |||
230 | /** | ||
231 | * ata_exec_command - issue ATA command to host controller | ||
232 | * @ap: port to which command is being issued | ||
233 | * @tf: ATA taskfile register set | ||
234 | * | ||
235 | * Issues PIO/MMIO write to ATA command register, with proper | ||
236 | * synchronization with interrupt handler / other threads. | ||
237 | * | ||
238 | * LOCKING: | ||
239 | * spin_lock_irqsave(host_set lock) | ||
240 | */ | ||
241 | void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) | ||
242 | { | ||
243 | if (ap->flags & ATA_FLAG_MMIO) | ||
244 | ata_exec_command_mmio(ap, tf); | ||
245 | else | ||
246 | ata_exec_command_pio(ap, tf); | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * ata_tf_read_pio - input device's ATA taskfile shadow registers | ||
251 | * @ap: Port from which input is read | ||
252 | * @tf: ATA taskfile register set for storing input | ||
253 | * | ||
254 | * Reads ATA taskfile registers for currently-selected device | ||
255 | * into @tf. | ||
256 | * | ||
257 | * LOCKING: | ||
258 | * Inherited from caller. | ||
259 | */ | ||
260 | |||
261 | static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) | ||
262 | { | ||
263 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
264 | |||
265 | tf->command = ata_check_status(ap); | ||
266 | tf->feature = inb(ioaddr->error_addr); | ||
267 | tf->nsect = inb(ioaddr->nsect_addr); | ||
268 | tf->lbal = inb(ioaddr->lbal_addr); | ||
269 | tf->lbam = inb(ioaddr->lbam_addr); | ||
270 | tf->lbah = inb(ioaddr->lbah_addr); | ||
271 | tf->device = inb(ioaddr->device_addr); | ||
272 | |||
273 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
274 | outb(tf->ctl | ATA_HOB, ioaddr->ctl_addr); | ||
275 | tf->hob_feature = inb(ioaddr->error_addr); | ||
276 | tf->hob_nsect = inb(ioaddr->nsect_addr); | ||
277 | tf->hob_lbal = inb(ioaddr->lbal_addr); | ||
278 | tf->hob_lbam = inb(ioaddr->lbam_addr); | ||
279 | tf->hob_lbah = inb(ioaddr->lbah_addr); | ||
280 | } | ||
281 | } | ||
282 | |||
283 | /** | ||
284 | * ata_tf_read_mmio - input device's ATA taskfile shadow registers | ||
285 | * @ap: Port from which input is read | ||
286 | * @tf: ATA taskfile register set for storing input | ||
287 | * | ||
288 | * Reads ATA taskfile registers for currently-selected device | ||
289 | * into @tf via MMIO. | ||
290 | * | ||
291 | * LOCKING: | ||
292 | * Inherited from caller. | ||
293 | */ | ||
294 | |||
295 | static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) | ||
296 | { | ||
297 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
298 | |||
299 | tf->command = ata_check_status(ap); | ||
300 | tf->feature = readb((void __iomem *)ioaddr->error_addr); | ||
301 | tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); | ||
302 | tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); | ||
303 | tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); | ||
304 | tf->lbah = readb((void __iomem *)ioaddr->lbah_addr); | ||
305 | tf->device = readb((void __iomem *)ioaddr->device_addr); | ||
306 | |||
307 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
308 | writeb(tf->ctl | ATA_HOB, (void __iomem *) ap->ioaddr.ctl_addr); | ||
309 | tf->hob_feature = readb((void __iomem *)ioaddr->error_addr); | ||
310 | tf->hob_nsect = readb((void __iomem *)ioaddr->nsect_addr); | ||
311 | tf->hob_lbal = readb((void __iomem *)ioaddr->lbal_addr); | ||
312 | tf->hob_lbam = readb((void __iomem *)ioaddr->lbam_addr); | ||
313 | tf->hob_lbah = readb((void __iomem *)ioaddr->lbah_addr); | ||
314 | } | ||
315 | } | ||
316 | |||
317 | |||
318 | /** | ||
319 | * ata_tf_read - input device's ATA taskfile shadow registers | ||
320 | * @ap: Port from which input is read | ||
321 | * @tf: ATA taskfile register set for storing input | ||
322 | * | ||
323 | * Reads ATA taskfile registers for currently-selected device | ||
324 | * into @tf. | ||
325 | * | ||
326 | * Reads nsect, lbal, lbam, lbah, and device. If ATA_TFLAG_LBA48 | ||
327 | * is set, also reads the hob registers. | ||
328 | * | ||
329 | * May be used as the tf_read() entry in ata_port_operations. | ||
330 | * | ||
331 | * LOCKING: | ||
332 | * Inherited from caller. | ||
333 | */ | ||
334 | void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | ||
335 | { | ||
336 | if (ap->flags & ATA_FLAG_MMIO) | ||
337 | ata_tf_read_mmio(ap, tf); | ||
338 | else | ||
339 | ata_tf_read_pio(ap, tf); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * ata_check_status_pio - Read device status reg & clear interrupt | ||
344 | * @ap: port where the device is | ||
345 | * | ||
346 | * Reads ATA taskfile status register for currently-selected device | ||
347 | * and return its value. This also clears pending interrupts | ||
348 | * from this device | ||
349 | * | ||
350 | * LOCKING: | ||
351 | * Inherited from caller. | ||
352 | */ | ||
353 | static u8 ata_check_status_pio(struct ata_port *ap) | ||
354 | { | ||
355 | return inb(ap->ioaddr.status_addr); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * ata_check_status_mmio - Read device status reg & clear interrupt | ||
360 | * @ap: port where the device is | ||
361 | * | ||
362 | * Reads ATA taskfile status register for currently-selected device | ||
363 | * via MMIO and return its value. This also clears pending interrupts | ||
364 | * from this device | ||
365 | * | ||
366 | * LOCKING: | ||
367 | * Inherited from caller. | ||
368 | */ | ||
369 | static u8 ata_check_status_mmio(struct ata_port *ap) | ||
370 | { | ||
371 | return readb((void __iomem *) ap->ioaddr.status_addr); | ||
372 | } | ||
373 | |||
374 | |||
375 | /** | ||
376 | * ata_check_status - Read device status reg & clear interrupt | ||
377 | * @ap: port where the device is | ||
378 | * | ||
379 | * Reads ATA taskfile status register for currently-selected device | ||
380 | * and return its value. This also clears pending interrupts | ||
381 | * from this device | ||
382 | * | ||
383 | * May be used as the check_status() entry in ata_port_operations. | ||
384 | * | ||
385 | * LOCKING: | ||
386 | * Inherited from caller. | ||
387 | */ | ||
388 | u8 ata_check_status(struct ata_port *ap) | ||
389 | { | ||
390 | if (ap->flags & ATA_FLAG_MMIO) | ||
391 | return ata_check_status_mmio(ap); | ||
392 | return ata_check_status_pio(ap); | ||
393 | } | ||
394 | |||
395 | |||
396 | /** | ||
397 | * ata_altstatus - Read device alternate status reg | ||
398 | * @ap: port where the device is | ||
399 | * | ||
400 | * Reads ATA taskfile alternate status register for | ||
401 | * currently-selected device and return its value. | ||
402 | * | ||
403 | * Note: may NOT be used as the check_altstatus() entry in | ||
404 | * ata_port_operations. | ||
405 | * | ||
406 | * LOCKING: | ||
407 | * Inherited from caller. | ||
408 | */ | ||
409 | u8 ata_altstatus(struct ata_port *ap) | ||
410 | { | ||
411 | if (ap->ops->check_altstatus) | ||
412 | return ap->ops->check_altstatus(ap); | ||
413 | |||
414 | if (ap->flags & ATA_FLAG_MMIO) | ||
415 | return readb((void __iomem *)ap->ioaddr.altstatus_addr); | ||
416 | return inb(ap->ioaddr.altstatus_addr); | ||
417 | } | ||
418 | |||
419 | #ifdef CONFIG_PCI | ||
420 | static struct ata_probe_ent * | ||
421 | ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port) | ||
422 | { | ||
423 | struct ata_probe_ent *probe_ent; | ||
424 | |||
425 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | ||
426 | if (!probe_ent) { | ||
427 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", | ||
428 | kobject_name(&(dev->kobj))); | ||
429 | return NULL; | ||
430 | } | ||
431 | |||
432 | INIT_LIST_HEAD(&probe_ent->node); | ||
433 | probe_ent->dev = dev; | ||
434 | |||
435 | probe_ent->sht = port->sht; | ||
436 | probe_ent->host_flags = port->host_flags; | ||
437 | probe_ent->pio_mask = port->pio_mask; | ||
438 | probe_ent->mwdma_mask = port->mwdma_mask; | ||
439 | probe_ent->udma_mask = port->udma_mask; | ||
440 | probe_ent->port_ops = port->port_ops; | ||
441 | |||
442 | return probe_ent; | ||
443 | } | ||
444 | |||
445 | |||
446 | /** | ||
447 | * ata_pci_init_native_mode - Initialize native-mode driver | ||
448 | * @pdev: pci device to be initialized | ||
449 | * @port: array[2] of pointers to port info structures. | ||
450 | * @ports: bitmap of ports present | ||
451 | * | ||
452 | * Utility function which allocates and initializes an | ||
453 | * ata_probe_ent structure for a standard dual-port | ||
454 | * PIO-based IDE controller. The returned ata_probe_ent | ||
455 | * structure can be passed to ata_device_add(). The returned | ||
456 | * ata_probe_ent structure should then be freed with kfree(). | ||
457 | * | ||
458 | * The caller need only pass the address of the primary port, the | ||
459 | * secondary will be deduced automatically. If the device has non | ||
460 | * standard secondary port mappings this function can be called twice, | ||
461 | * once for each interface. | ||
462 | */ | ||
463 | |||
464 | struct ata_probe_ent * | ||
465 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ports) | ||
466 | { | ||
467 | struct ata_probe_ent *probe_ent = | ||
468 | ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); | ||
469 | int p = 0; | ||
470 | |||
471 | if (!probe_ent) | ||
472 | return NULL; | ||
473 | |||
474 | probe_ent->irq = pdev->irq; | ||
475 | probe_ent->irq_flags = SA_SHIRQ; | ||
476 | probe_ent->private_data = port[0]->private_data; | ||
477 | |||
478 | if (ports & ATA_PORT_PRIMARY) { | ||
479 | probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0); | ||
480 | probe_ent->port[p].altstatus_addr = | ||
481 | probe_ent->port[p].ctl_addr = | ||
482 | pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS; | ||
483 | probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4); | ||
484 | ata_std_ports(&probe_ent->port[p]); | ||
485 | p++; | ||
486 | } | ||
487 | |||
488 | if (ports & ATA_PORT_SECONDARY) { | ||
489 | probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 2); | ||
490 | probe_ent->port[p].altstatus_addr = | ||
491 | probe_ent->port[p].ctl_addr = | ||
492 | pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS; | ||
493 | probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4) + 8; | ||
494 | ata_std_ports(&probe_ent->port[p]); | ||
495 | p++; | ||
496 | } | ||
497 | |||
498 | probe_ent->n_ports = p; | ||
499 | return probe_ent; | ||
500 | } | ||
501 | |||
502 | |||
503 | static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, | ||
504 | struct ata_port_info *port, int port_num) | ||
505 | { | ||
506 | struct ata_probe_ent *probe_ent; | ||
507 | |||
508 | probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port); | ||
509 | if (!probe_ent) | ||
510 | return NULL; | ||
511 | |||
512 | probe_ent->legacy_mode = 1; | ||
513 | probe_ent->n_ports = 1; | ||
514 | probe_ent->hard_port_no = port_num; | ||
515 | probe_ent->private_data = port->private_data; | ||
516 | |||
517 | switch(port_num) | ||
518 | { | ||
519 | case 0: | ||
520 | probe_ent->irq = 14; | ||
521 | probe_ent->port[0].cmd_addr = 0x1f0; | ||
522 | probe_ent->port[0].altstatus_addr = | ||
523 | probe_ent->port[0].ctl_addr = 0x3f6; | ||
524 | break; | ||
525 | case 1: | ||
526 | probe_ent->irq = 15; | ||
527 | probe_ent->port[0].cmd_addr = 0x170; | ||
528 | probe_ent->port[0].altstatus_addr = | ||
529 | probe_ent->port[0].ctl_addr = 0x376; | ||
530 | break; | ||
531 | } | ||
532 | |||
533 | probe_ent->port[0].bmdma_addr = | ||
534 | pci_resource_start(pdev, 4) + 8 * port_num; | ||
535 | ata_std_ports(&probe_ent->port[0]); | ||
536 | |||
537 | return probe_ent; | ||
538 | } | ||
539 | |||
540 | |||
541 | /** | ||
542 | * ata_pci_init_one - Initialize/register PCI IDE host controller | ||
543 | * @pdev: Controller to be initialized | ||
544 | * @port_info: Information from low-level host driver | ||
545 | * @n_ports: Number of ports attached to host controller | ||
546 | * | ||
547 | * This is a helper function which can be called from a driver's | ||
548 | * xxx_init_one() probe function if the hardware uses traditional | ||
549 | * IDE taskfile registers. | ||
550 | * | ||
551 | * This function calls pci_enable_device(), reserves its register | ||
552 | * regions, sets the dma mask, enables bus master mode, and calls | ||
553 | * ata_device_add() | ||
554 | * | ||
555 | * LOCKING: | ||
556 | * Inherited from PCI layer (may sleep). | ||
557 | * | ||
558 | * RETURNS: | ||
559 | * Zero on success, negative on errno-based value on error. | ||
560 | */ | ||
561 | |||
562 | int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | ||
563 | unsigned int n_ports) | ||
564 | { | ||
565 | struct ata_probe_ent *probe_ent = NULL, *probe_ent2 = NULL; | ||
566 | struct ata_port_info *port[2]; | ||
567 | u8 tmp8, mask; | ||
568 | unsigned int legacy_mode = 0; | ||
569 | int disable_dev_on_err = 1; | ||
570 | int rc; | ||
571 | |||
572 | DPRINTK("ENTER\n"); | ||
573 | |||
574 | port[0] = port_info[0]; | ||
575 | if (n_ports > 1) | ||
576 | port[1] = port_info[1]; | ||
577 | else | ||
578 | port[1] = port[0]; | ||
579 | |||
580 | if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0 | ||
581 | && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { | ||
582 | /* TODO: What if one channel is in native mode ... */ | ||
583 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); | ||
584 | mask = (1 << 2) | (1 << 0); | ||
585 | if ((tmp8 & mask) != mask) | ||
586 | legacy_mode = (1 << 3); | ||
587 | } | ||
588 | |||
589 | /* FIXME... */ | ||
590 | if ((!legacy_mode) && (n_ports > 2)) { | ||
591 | printk(KERN_ERR "ata: BUG: native mode, n_ports > 2\n"); | ||
592 | n_ports = 2; | ||
593 | /* For now */ | ||
594 | } | ||
595 | |||
596 | /* FIXME: Really for ATA it isn't safe because the device may be | ||
597 | multi-purpose and we want to leave it alone if it was already | ||
598 | enabled. Secondly for shared use as Arjan says we want refcounting | ||
599 | |||
600 | Checking dev->is_enabled is insufficient as this is not set at | ||
601 | boot for the primary video which is BIOS enabled | ||
602 | */ | ||
603 | |||
604 | rc = pci_enable_device(pdev); | ||
605 | if (rc) | ||
606 | return rc; | ||
607 | |||
608 | rc = pci_request_regions(pdev, DRV_NAME); | ||
609 | if (rc) { | ||
610 | disable_dev_on_err = 0; | ||
611 | goto err_out; | ||
612 | } | ||
613 | |||
614 | /* FIXME: Should use platform specific mappers for legacy port ranges */ | ||
615 | if (legacy_mode) { | ||
616 | if (!request_region(0x1f0, 8, "libata")) { | ||
617 | struct resource *conflict, res; | ||
618 | res.start = 0x1f0; | ||
619 | res.end = 0x1f0 + 8 - 1; | ||
620 | conflict = ____request_resource(&ioport_resource, &res); | ||
621 | if (!strcmp(conflict->name, "libata")) | ||
622 | legacy_mode |= (1 << 0); | ||
623 | else { | ||
624 | disable_dev_on_err = 0; | ||
625 | printk(KERN_WARNING "ata: 0x1f0 IDE port busy\n"); | ||
626 | } | ||
627 | } else | ||
628 | legacy_mode |= (1 << 0); | ||
629 | |||
630 | if (!request_region(0x170, 8, "libata")) { | ||
631 | struct resource *conflict, res; | ||
632 | res.start = 0x170; | ||
633 | res.end = 0x170 + 8 - 1; | ||
634 | conflict = ____request_resource(&ioport_resource, &res); | ||
635 | if (!strcmp(conflict->name, "libata")) | ||
636 | legacy_mode |= (1 << 1); | ||
637 | else { | ||
638 | disable_dev_on_err = 0; | ||
639 | printk(KERN_WARNING "ata: 0x170 IDE port busy\n"); | ||
640 | } | ||
641 | } else | ||
642 | legacy_mode |= (1 << 1); | ||
643 | } | ||
644 | |||
645 | /* we have legacy mode, but all ports are unavailable */ | ||
646 | if (legacy_mode == (1 << 3)) { | ||
647 | rc = -EBUSY; | ||
648 | goto err_out_regions; | ||
649 | } | ||
650 | |||
651 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | ||
652 | if (rc) | ||
653 | goto err_out_regions; | ||
654 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | ||
655 | if (rc) | ||
656 | goto err_out_regions; | ||
657 | |||
658 | if (legacy_mode) { | ||
659 | if (legacy_mode & (1 << 0)) | ||
660 | probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0); | ||
661 | if (legacy_mode & (1 << 1)) | ||
662 | probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1); | ||
663 | } else { | ||
664 | if (n_ports == 2) | ||
665 | probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | ||
666 | else | ||
667 | probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY); | ||
668 | } | ||
669 | if (!probe_ent && !probe_ent2) { | ||
670 | rc = -ENOMEM; | ||
671 | goto err_out_regions; | ||
672 | } | ||
673 | |||
674 | pci_set_master(pdev); | ||
675 | |||
676 | /* FIXME: check ata_device_add return */ | ||
677 | if (legacy_mode) { | ||
678 | if (legacy_mode & (1 << 0)) | ||
679 | ata_device_add(probe_ent); | ||
680 | if (legacy_mode & (1 << 1)) | ||
681 | ata_device_add(probe_ent2); | ||
682 | } else | ||
683 | ata_device_add(probe_ent); | ||
684 | |||
685 | kfree(probe_ent); | ||
686 | kfree(probe_ent2); | ||
687 | |||
688 | return 0; | ||
689 | |||
690 | err_out_regions: | ||
691 | if (legacy_mode & (1 << 0)) | ||
692 | release_region(0x1f0, 8); | ||
693 | if (legacy_mode & (1 << 1)) | ||
694 | release_region(0x170, 8); | ||
695 | pci_release_regions(pdev); | ||
696 | err_out: | ||
697 | if (disable_dev_on_err) | ||
698 | pci_disable_device(pdev); | ||
699 | return rc; | ||
700 | } | ||
701 | |||
702 | #endif /* CONFIG_PCI */ | ||
703 | |||
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 46c4cdbaee86..38e72c1dd689 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -61,9 +61,6 @@ | |||
61 | 61 | ||
62 | #include "libata.h" | 62 | #include "libata.h" |
63 | 63 | ||
64 | static unsigned int ata_busy_sleep (struct ata_port *ap, | ||
65 | unsigned long tmout_pat, | ||
66 | unsigned long tmout); | ||
67 | static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev); | 64 | static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev); |
68 | static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev); | 65 | static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev); |
69 | static void ata_set_mode(struct ata_port *ap); | 66 | static void ata_set_mode(struct ata_port *ap); |
@@ -73,7 +70,6 @@ static int fgb(u32 bitmap); | |||
73 | static int ata_choose_xfer_mode(const struct ata_port *ap, | 70 | static int ata_choose_xfer_mode(const struct ata_port *ap, |
74 | u8 *xfer_mode_out, | 71 | u8 *xfer_mode_out, |
75 | unsigned int *xfer_shift_out); | 72 | unsigned int *xfer_shift_out); |
76 | static void __ata_qc_complete(struct ata_queued_cmd *qc); | ||
77 | 73 | ||
78 | static unsigned int ata_unique_id = 1; | 74 | static unsigned int ata_unique_id = 1; |
79 | static struct workqueue_struct *ata_wq; | 75 | static struct workqueue_struct *ata_wq; |
@@ -87,403 +83,6 @@ MODULE_DESCRIPTION("Library module for ATA devices"); | |||
87 | MODULE_LICENSE("GPL"); | 83 | MODULE_LICENSE("GPL"); |
88 | MODULE_VERSION(DRV_VERSION); | 84 | MODULE_VERSION(DRV_VERSION); |
89 | 85 | ||
90 | /** | ||
91 | * ata_tf_load_pio - send taskfile registers to host controller | ||
92 | * @ap: Port to which output is sent | ||
93 | * @tf: ATA taskfile register set | ||
94 | * | ||
95 | * Outputs ATA taskfile to standard ATA host controller. | ||
96 | * | ||
97 | * LOCKING: | ||
98 | * Inherited from caller. | ||
99 | */ | ||
100 | |||
101 | static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
102 | { | ||
103 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
104 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; | ||
105 | |||
106 | if (tf->ctl != ap->last_ctl) { | ||
107 | outb(tf->ctl, ioaddr->ctl_addr); | ||
108 | ap->last_ctl = tf->ctl; | ||
109 | ata_wait_idle(ap); | ||
110 | } | ||
111 | |||
112 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { | ||
113 | outb(tf->hob_feature, ioaddr->feature_addr); | ||
114 | outb(tf->hob_nsect, ioaddr->nsect_addr); | ||
115 | outb(tf->hob_lbal, ioaddr->lbal_addr); | ||
116 | outb(tf->hob_lbam, ioaddr->lbam_addr); | ||
117 | outb(tf->hob_lbah, ioaddr->lbah_addr); | ||
118 | VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", | ||
119 | tf->hob_feature, | ||
120 | tf->hob_nsect, | ||
121 | tf->hob_lbal, | ||
122 | tf->hob_lbam, | ||
123 | tf->hob_lbah); | ||
124 | } | ||
125 | |||
126 | if (is_addr) { | ||
127 | outb(tf->feature, ioaddr->feature_addr); | ||
128 | outb(tf->nsect, ioaddr->nsect_addr); | ||
129 | outb(tf->lbal, ioaddr->lbal_addr); | ||
130 | outb(tf->lbam, ioaddr->lbam_addr); | ||
131 | outb(tf->lbah, ioaddr->lbah_addr); | ||
132 | VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", | ||
133 | tf->feature, | ||
134 | tf->nsect, | ||
135 | tf->lbal, | ||
136 | tf->lbam, | ||
137 | tf->lbah); | ||
138 | } | ||
139 | |||
140 | if (tf->flags & ATA_TFLAG_DEVICE) { | ||
141 | outb(tf->device, ioaddr->device_addr); | ||
142 | VPRINTK("device 0x%X\n", tf->device); | ||
143 | } | ||
144 | |||
145 | ata_wait_idle(ap); | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * ata_tf_load_mmio - send taskfile registers to host controller | ||
150 | * @ap: Port to which output is sent | ||
151 | * @tf: ATA taskfile register set | ||
152 | * | ||
153 | * Outputs ATA taskfile to standard ATA host controller using MMIO. | ||
154 | * | ||
155 | * LOCKING: | ||
156 | * Inherited from caller. | ||
157 | */ | ||
158 | |||
159 | static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
160 | { | ||
161 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
162 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; | ||
163 | |||
164 | if (tf->ctl != ap->last_ctl) { | ||
165 | writeb(tf->ctl, (void __iomem *) ap->ioaddr.ctl_addr); | ||
166 | ap->last_ctl = tf->ctl; | ||
167 | ata_wait_idle(ap); | ||
168 | } | ||
169 | |||
170 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { | ||
171 | writeb(tf->hob_feature, (void __iomem *) ioaddr->feature_addr); | ||
172 | writeb(tf->hob_nsect, (void __iomem *) ioaddr->nsect_addr); | ||
173 | writeb(tf->hob_lbal, (void __iomem *) ioaddr->lbal_addr); | ||
174 | writeb(tf->hob_lbam, (void __iomem *) ioaddr->lbam_addr); | ||
175 | writeb(tf->hob_lbah, (void __iomem *) ioaddr->lbah_addr); | ||
176 | VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", | ||
177 | tf->hob_feature, | ||
178 | tf->hob_nsect, | ||
179 | tf->hob_lbal, | ||
180 | tf->hob_lbam, | ||
181 | tf->hob_lbah); | ||
182 | } | ||
183 | |||
184 | if (is_addr) { | ||
185 | writeb(tf->feature, (void __iomem *) ioaddr->feature_addr); | ||
186 | writeb(tf->nsect, (void __iomem *) ioaddr->nsect_addr); | ||
187 | writeb(tf->lbal, (void __iomem *) ioaddr->lbal_addr); | ||
188 | writeb(tf->lbam, (void __iomem *) ioaddr->lbam_addr); | ||
189 | writeb(tf->lbah, (void __iomem *) ioaddr->lbah_addr); | ||
190 | VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", | ||
191 | tf->feature, | ||
192 | tf->nsect, | ||
193 | tf->lbal, | ||
194 | tf->lbam, | ||
195 | tf->lbah); | ||
196 | } | ||
197 | |||
198 | if (tf->flags & ATA_TFLAG_DEVICE) { | ||
199 | writeb(tf->device, (void __iomem *) ioaddr->device_addr); | ||
200 | VPRINTK("device 0x%X\n", tf->device); | ||
201 | } | ||
202 | |||
203 | ata_wait_idle(ap); | ||
204 | } | ||
205 | |||
206 | |||
207 | /** | ||
208 | * ata_tf_load - send taskfile registers to host controller | ||
209 | * @ap: Port to which output is sent | ||
210 | * @tf: ATA taskfile register set | ||
211 | * | ||
212 | * Outputs ATA taskfile to standard ATA host controller using MMIO | ||
213 | * or PIO as indicated by the ATA_FLAG_MMIO flag. | ||
214 | * Writes the control, feature, nsect, lbal, lbam, and lbah registers. | ||
215 | * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect, | ||
216 | * hob_lbal, hob_lbam, and hob_lbah. | ||
217 | * | ||
218 | * This function waits for idle (!BUSY and !DRQ) after writing | ||
219 | * registers. If the control register has a new value, this | ||
220 | * function also waits for idle after writing control and before | ||
221 | * writing the remaining registers. | ||
222 | * | ||
223 | * May be used as the tf_load() entry in ata_port_operations. | ||
224 | * | ||
225 | * LOCKING: | ||
226 | * Inherited from caller. | ||
227 | */ | ||
228 | void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | ||
229 | { | ||
230 | if (ap->flags & ATA_FLAG_MMIO) | ||
231 | ata_tf_load_mmio(ap, tf); | ||
232 | else | ||
233 | ata_tf_load_pio(ap, tf); | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * ata_exec_command_pio - issue ATA command to host controller | ||
238 | * @ap: port to which command is being issued | ||
239 | * @tf: ATA taskfile register set | ||
240 | * | ||
241 | * Issues PIO write to ATA command register, with proper | ||
242 | * synchronization with interrupt handler / other threads. | ||
243 | * | ||
244 | * LOCKING: | ||
245 | * spin_lock_irqsave(host_set lock) | ||
246 | */ | ||
247 | |||
248 | static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
249 | { | ||
250 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | ||
251 | |||
252 | outb(tf->command, ap->ioaddr.command_addr); | ||
253 | ata_pause(ap); | ||
254 | } | ||
255 | |||
256 | |||
257 | /** | ||
258 | * ata_exec_command_mmio - issue ATA command to host controller | ||
259 | * @ap: port to which command is being issued | ||
260 | * @tf: ATA taskfile register set | ||
261 | * | ||
262 | * Issues MMIO write to ATA command register, with proper | ||
263 | * synchronization with interrupt handler / other threads. | ||
264 | * | ||
265 | * LOCKING: | ||
266 | * spin_lock_irqsave(host_set lock) | ||
267 | */ | ||
268 | |||
269 | static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | ||
270 | { | ||
271 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | ||
272 | |||
273 | writeb(tf->command, (void __iomem *) ap->ioaddr.command_addr); | ||
274 | ata_pause(ap); | ||
275 | } | ||
276 | |||
277 | |||
278 | /** | ||
279 | * ata_exec_command - issue ATA command to host controller | ||
280 | * @ap: port to which command is being issued | ||
281 | * @tf: ATA taskfile register set | ||
282 | * | ||
283 | * Issues PIO/MMIO write to ATA command register, with proper | ||
284 | * synchronization with interrupt handler / other threads. | ||
285 | * | ||
286 | * LOCKING: | ||
287 | * spin_lock_irqsave(host_set lock) | ||
288 | */ | ||
289 | void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) | ||
290 | { | ||
291 | if (ap->flags & ATA_FLAG_MMIO) | ||
292 | ata_exec_command_mmio(ap, tf); | ||
293 | else | ||
294 | ata_exec_command_pio(ap, tf); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * ata_tf_to_host - issue ATA taskfile to host controller | ||
299 | * @ap: port to which command is being issued | ||
300 | * @tf: ATA taskfile register set | ||
301 | * | ||
302 | * Issues ATA taskfile register set to ATA host controller, | ||
303 | * with proper synchronization with interrupt handler and | ||
304 | * other threads. | ||
305 | * | ||
306 | * LOCKING: | ||
307 | * spin_lock_irqsave(host_set lock) | ||
308 | */ | ||
309 | |||
310 | static inline void ata_tf_to_host(struct ata_port *ap, | ||
311 | const struct ata_taskfile *tf) | ||
312 | { | ||
313 | ap->ops->tf_load(ap, tf); | ||
314 | ap->ops->exec_command(ap, tf); | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * ata_tf_read_pio - input device's ATA taskfile shadow registers | ||
319 | * @ap: Port from which input is read | ||
320 | * @tf: ATA taskfile register set for storing input | ||
321 | * | ||
322 | * Reads ATA taskfile registers for currently-selected device | ||
323 | * into @tf. | ||
324 | * | ||
325 | * LOCKING: | ||
326 | * Inherited from caller. | ||
327 | */ | ||
328 | |||
329 | static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) | ||
330 | { | ||
331 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
332 | |||
333 | tf->command = ata_check_status(ap); | ||
334 | tf->feature = inb(ioaddr->error_addr); | ||
335 | tf->nsect = inb(ioaddr->nsect_addr); | ||
336 | tf->lbal = inb(ioaddr->lbal_addr); | ||
337 | tf->lbam = inb(ioaddr->lbam_addr); | ||
338 | tf->lbah = inb(ioaddr->lbah_addr); | ||
339 | tf->device = inb(ioaddr->device_addr); | ||
340 | |||
341 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
342 | outb(tf->ctl | ATA_HOB, ioaddr->ctl_addr); | ||
343 | tf->hob_feature = inb(ioaddr->error_addr); | ||
344 | tf->hob_nsect = inb(ioaddr->nsect_addr); | ||
345 | tf->hob_lbal = inb(ioaddr->lbal_addr); | ||
346 | tf->hob_lbam = inb(ioaddr->lbam_addr); | ||
347 | tf->hob_lbah = inb(ioaddr->lbah_addr); | ||
348 | } | ||
349 | } | ||
350 | |||
351 | /** | ||
352 | * ata_tf_read_mmio - input device's ATA taskfile shadow registers | ||
353 | * @ap: Port from which input is read | ||
354 | * @tf: ATA taskfile register set for storing input | ||
355 | * | ||
356 | * Reads ATA taskfile registers for currently-selected device | ||
357 | * into @tf via MMIO. | ||
358 | * | ||
359 | * LOCKING: | ||
360 | * Inherited from caller. | ||
361 | */ | ||
362 | |||
363 | static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) | ||
364 | { | ||
365 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
366 | |||
367 | tf->command = ata_check_status(ap); | ||
368 | tf->feature = readb((void __iomem *)ioaddr->error_addr); | ||
369 | tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); | ||
370 | tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); | ||
371 | tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); | ||
372 | tf->lbah = readb((void __iomem *)ioaddr->lbah_addr); | ||
373 | tf->device = readb((void __iomem *)ioaddr->device_addr); | ||
374 | |||
375 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
376 | writeb(tf->ctl | ATA_HOB, (void __iomem *) ap->ioaddr.ctl_addr); | ||
377 | tf->hob_feature = readb((void __iomem *)ioaddr->error_addr); | ||
378 | tf->hob_nsect = readb((void __iomem *)ioaddr->nsect_addr); | ||
379 | tf->hob_lbal = readb((void __iomem *)ioaddr->lbal_addr); | ||
380 | tf->hob_lbam = readb((void __iomem *)ioaddr->lbam_addr); | ||
381 | tf->hob_lbah = readb((void __iomem *)ioaddr->lbah_addr); | ||
382 | } | ||
383 | } | ||
384 | |||
385 | |||
386 | /** | ||
387 | * ata_tf_read - input device's ATA taskfile shadow registers | ||
388 | * @ap: Port from which input is read | ||
389 | * @tf: ATA taskfile register set for storing input | ||
390 | * | ||
391 | * Reads ATA taskfile registers for currently-selected device | ||
392 | * into @tf. | ||
393 | * | ||
394 | * Reads nsect, lbal, lbam, lbah, and device. If ATA_TFLAG_LBA48 | ||
395 | * is set, also reads the hob registers. | ||
396 | * | ||
397 | * May be used as the tf_read() entry in ata_port_operations. | ||
398 | * | ||
399 | * LOCKING: | ||
400 | * Inherited from caller. | ||
401 | */ | ||
402 | void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | ||
403 | { | ||
404 | if (ap->flags & ATA_FLAG_MMIO) | ||
405 | ata_tf_read_mmio(ap, tf); | ||
406 | else | ||
407 | ata_tf_read_pio(ap, tf); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * ata_check_status_pio - Read device status reg & clear interrupt | ||
412 | * @ap: port where the device is | ||
413 | * | ||
414 | * Reads ATA taskfile status register for currently-selected device | ||
415 | * and return its value. This also clears pending interrupts | ||
416 | * from this device | ||
417 | * | ||
418 | * LOCKING: | ||
419 | * Inherited from caller. | ||
420 | */ | ||
421 | static u8 ata_check_status_pio(struct ata_port *ap) | ||
422 | { | ||
423 | return inb(ap->ioaddr.status_addr); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * ata_check_status_mmio - Read device status reg & clear interrupt | ||
428 | * @ap: port where the device is | ||
429 | * | ||
430 | * Reads ATA taskfile status register for currently-selected device | ||
431 | * via MMIO and return its value. This also clears pending interrupts | ||
432 | * from this device | ||
433 | * | ||
434 | * LOCKING: | ||
435 | * Inherited from caller. | ||
436 | */ | ||
437 | static u8 ata_check_status_mmio(struct ata_port *ap) | ||
438 | { | ||
439 | return readb((void __iomem *) ap->ioaddr.status_addr); | ||
440 | } | ||
441 | |||
442 | |||
443 | /** | ||
444 | * ata_check_status - Read device status reg & clear interrupt | ||
445 | * @ap: port where the device is | ||
446 | * | ||
447 | * Reads ATA taskfile status register for currently-selected device | ||
448 | * and return its value. This also clears pending interrupts | ||
449 | * from this device | ||
450 | * | ||
451 | * May be used as the check_status() entry in ata_port_operations. | ||
452 | * | ||
453 | * LOCKING: | ||
454 | * Inherited from caller. | ||
455 | */ | ||
456 | u8 ata_check_status(struct ata_port *ap) | ||
457 | { | ||
458 | if (ap->flags & ATA_FLAG_MMIO) | ||
459 | return ata_check_status_mmio(ap); | ||
460 | return ata_check_status_pio(ap); | ||
461 | } | ||
462 | |||
463 | |||
464 | /** | ||
465 | * ata_altstatus - Read device alternate status reg | ||
466 | * @ap: port where the device is | ||
467 | * | ||
468 | * Reads ATA taskfile alternate status register for | ||
469 | * currently-selected device and return its value. | ||
470 | * | ||
471 | * Note: may NOT be used as the check_altstatus() entry in | ||
472 | * ata_port_operations. | ||
473 | * | ||
474 | * LOCKING: | ||
475 | * Inherited from caller. | ||
476 | */ | ||
477 | u8 ata_altstatus(struct ata_port *ap) | ||
478 | { | ||
479 | if (ap->ops->check_altstatus) | ||
480 | return ap->ops->check_altstatus(ap); | ||
481 | |||
482 | if (ap->flags & ATA_FLAG_MMIO) | ||
483 | return readb((void __iomem *)ap->ioaddr.altstatus_addr); | ||
484 | return inb(ap->ioaddr.altstatus_addr); | ||
485 | } | ||
486 | |||
487 | 86 | ||
488 | /** | 87 | /** |
489 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure | 88 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure |
@@ -834,6 +433,7 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf) | |||
834 | * ata_dev_try_classify - Parse returned ATA device signature | 433 | * ata_dev_try_classify - Parse returned ATA device signature |
835 | * @ap: ATA channel to examine | 434 | * @ap: ATA channel to examine |
836 | * @device: Device to examine (starting at zero) | 435 | * @device: Device to examine (starting at zero) |
436 | * @r_err: Value of error register on completion | ||
837 | * | 437 | * |
838 | * After an event -- SRST, E.D.D., or SATA COMRESET -- occurs, | 438 | * After an event -- SRST, E.D.D., or SATA COMRESET -- occurs, |
839 | * an ATA/ATAPI-defined set of values is placed in the ATA | 439 | * an ATA/ATAPI-defined set of values is placed in the ATA |
@@ -846,11 +446,14 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf) | |||
846 | * | 446 | * |
847 | * LOCKING: | 447 | * LOCKING: |
848 | * caller. | 448 | * caller. |
449 | * | ||
450 | * RETURNS: | ||
451 | * Device type - %ATA_DEV_ATA, %ATA_DEV_ATAPI or %ATA_DEV_NONE. | ||
849 | */ | 452 | */ |
850 | 453 | ||
851 | static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) | 454 | static unsigned int |
455 | ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err) | ||
852 | { | 456 | { |
853 | struct ata_device *dev = &ap->device[device]; | ||
854 | struct ata_taskfile tf; | 457 | struct ata_taskfile tf; |
855 | unsigned int class; | 458 | unsigned int class; |
856 | u8 err; | 459 | u8 err; |
@@ -861,8 +464,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) | |||
861 | 464 | ||
862 | ap->ops->tf_read(ap, &tf); | 465 | ap->ops->tf_read(ap, &tf); |
863 | err = tf.feature; | 466 | err = tf.feature; |
864 | 467 | if (r_err) | |
865 | dev->class = ATA_DEV_NONE; | 468 | *r_err = err; |
866 | 469 | ||
867 | /* see if device passed diags */ | 470 | /* see if device passed diags */ |
868 | if (err == 1) | 471 | if (err == 1) |
@@ -870,18 +473,16 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) | |||
870 | else if ((device == 0) && (err == 0x81)) | 473 | else if ((device == 0) && (err == 0x81)) |
871 | /* do nothing */ ; | 474 | /* do nothing */ ; |
872 | else | 475 | else |
873 | return err; | 476 | return ATA_DEV_NONE; |
874 | 477 | ||
875 | /* determine if device if ATA or ATAPI */ | 478 | /* determine if device is ATA or ATAPI */ |
876 | class = ata_dev_classify(&tf); | 479 | class = ata_dev_classify(&tf); |
480 | |||
877 | if (class == ATA_DEV_UNKNOWN) | 481 | if (class == ATA_DEV_UNKNOWN) |
878 | return err; | 482 | return ATA_DEV_NONE; |
879 | if ((class == ATA_DEV_ATA) && (ata_chk_status(ap) == 0)) | 483 | if ((class == ATA_DEV_ATA) && (ata_chk_status(ap) == 0)) |
880 | return err; | 484 | return ATA_DEV_NONE; |
881 | 485 | return class; | |
882 | dev->class = class; | ||
883 | |||
884 | return err; | ||
885 | } | 486 | } |
886 | 487 | ||
887 | /** | 488 | /** |
@@ -1073,24 +674,77 @@ static unsigned int ata_pio_modes(const struct ata_device *adev) | |||
1073 | timing API will get this right anyway */ | 674 | timing API will get this right anyway */ |
1074 | } | 675 | } |
1075 | 676 | ||
1076 | struct ata_exec_internal_arg { | 677 | static inline void |
1077 | unsigned int err_mask; | 678 | ata_queue_packet_task(struct ata_port *ap) |
1078 | struct ata_taskfile *tf; | 679 | { |
1079 | struct completion *waiting; | 680 | if (!(ap->flags & ATA_FLAG_FLUSH_PIO_TASK)) |
1080 | }; | 681 | queue_work(ata_wq, &ap->packet_task); |
682 | } | ||
1081 | 683 | ||
1082 | int ata_qc_complete_internal(struct ata_queued_cmd *qc) | 684 | static inline void |
685 | ata_queue_pio_task(struct ata_port *ap) | ||
1083 | { | 686 | { |
1084 | struct ata_exec_internal_arg *arg = qc->private_data; | 687 | if (!(ap->flags & ATA_FLAG_FLUSH_PIO_TASK)) |
1085 | struct completion *waiting = arg->waiting; | 688 | queue_work(ata_wq, &ap->pio_task); |
689 | } | ||
1086 | 690 | ||
1087 | if (!(qc->err_mask & ~AC_ERR_DEV)) | 691 | static inline void |
1088 | qc->ap->ops->tf_read(qc->ap, arg->tf); | 692 | ata_queue_delayed_pio_task(struct ata_port *ap, unsigned long delay) |
1089 | arg->err_mask = qc->err_mask; | 693 | { |
1090 | arg->waiting = NULL; | 694 | if (!(ap->flags & ATA_FLAG_FLUSH_PIO_TASK)) |
1091 | complete(waiting); | 695 | queue_delayed_work(ata_wq, &ap->pio_task, delay); |
696 | } | ||
1092 | 697 | ||
1093 | return 0; | 698 | /** |
699 | * ata_flush_pio_tasks - Flush pio_task and packet_task | ||
700 | * @ap: the target ata_port | ||
701 | * | ||
702 | * After this function completes, pio_task and packet_task are | ||
703 | * guranteed not to be running or scheduled. | ||
704 | * | ||
705 | * LOCKING: | ||
706 | * Kernel thread context (may sleep) | ||
707 | */ | ||
708 | |||
709 | static void ata_flush_pio_tasks(struct ata_port *ap) | ||
710 | { | ||
711 | int tmp = 0; | ||
712 | unsigned long flags; | ||
713 | |||
714 | DPRINTK("ENTER\n"); | ||
715 | |||
716 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
717 | ap->flags |= ATA_FLAG_FLUSH_PIO_TASK; | ||
718 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
719 | |||
720 | DPRINTK("flush #1\n"); | ||
721 | flush_workqueue(ata_wq); | ||
722 | |||
723 | /* | ||
724 | * At this point, if a task is running, it's guaranteed to see | ||
725 | * the FLUSH flag; thus, it will never queue pio tasks again. | ||
726 | * Cancel and flush. | ||
727 | */ | ||
728 | tmp |= cancel_delayed_work(&ap->pio_task); | ||
729 | tmp |= cancel_delayed_work(&ap->packet_task); | ||
730 | if (!tmp) { | ||
731 | DPRINTK("flush #2\n"); | ||
732 | flush_workqueue(ata_wq); | ||
733 | } | ||
734 | |||
735 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
736 | ap->flags &= ~ATA_FLAG_FLUSH_PIO_TASK; | ||
737 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
738 | |||
739 | DPRINTK("EXIT\n"); | ||
740 | } | ||
741 | |||
742 | void ata_qc_complete_internal(struct ata_queued_cmd *qc) | ||
743 | { | ||
744 | struct completion *waiting = qc->private_data; | ||
745 | |||
746 | qc->ap->ops->tf_read(qc->ap, &qc->tf); | ||
747 | complete(waiting); | ||
1094 | } | 748 | } |
1095 | 749 | ||
1096 | /** | 750 | /** |
@@ -1121,7 +775,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
1121 | struct ata_queued_cmd *qc; | 775 | struct ata_queued_cmd *qc; |
1122 | DECLARE_COMPLETION(wait); | 776 | DECLARE_COMPLETION(wait); |
1123 | unsigned long flags; | 777 | unsigned long flags; |
1124 | struct ata_exec_internal_arg arg; | 778 | unsigned int err_mask; |
1125 | 779 | ||
1126 | spin_lock_irqsave(&ap->host_set->lock, flags); | 780 | spin_lock_irqsave(&ap->host_set->lock, flags); |
1127 | 781 | ||
@@ -1135,13 +789,12 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
1135 | qc->nsect = buflen / ATA_SECT_SIZE; | 789 | qc->nsect = buflen / ATA_SECT_SIZE; |
1136 | } | 790 | } |
1137 | 791 | ||
1138 | arg.waiting = &wait; | 792 | qc->private_data = &wait; |
1139 | arg.tf = tf; | ||
1140 | qc->private_data = &arg; | ||
1141 | qc->complete_fn = ata_qc_complete_internal; | 793 | qc->complete_fn = ata_qc_complete_internal; |
1142 | 794 | ||
1143 | if (ata_qc_issue(qc)) | 795 | qc->err_mask = ata_qc_issue(qc); |
1144 | goto issue_fail; | 796 | if (qc->err_mask) |
797 | ata_qc_complete(qc); | ||
1145 | 798 | ||
1146 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 799 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
1147 | 800 | ||
@@ -1154,8 +807,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
1154 | * before the caller cleans up, it will result in a | 807 | * before the caller cleans up, it will result in a |
1155 | * spurious interrupt. We can live with that. | 808 | * spurious interrupt. We can live with that. |
1156 | */ | 809 | */ |
1157 | if (arg.waiting) { | 810 | if (qc->flags & ATA_QCFLAG_ACTIVE) { |
1158 | qc->err_mask = AC_ERR_OTHER; | 811 | qc->err_mask = AC_ERR_TIMEOUT; |
1159 | ata_qc_complete(qc); | 812 | ata_qc_complete(qc); |
1160 | printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n", | 813 | printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n", |
1161 | ap->id, command); | 814 | ap->id, command); |
@@ -1164,12 +817,12 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
1164 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 817 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
1165 | } | 818 | } |
1166 | 819 | ||
1167 | return arg.err_mask; | 820 | *tf = qc->tf; |
821 | err_mask = qc->err_mask; | ||
1168 | 822 | ||
1169 | issue_fail: | ||
1170 | ata_qc_free(qc); | 823 | ata_qc_free(qc); |
1171 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 824 | |
1172 | return AC_ERR_OTHER; | 825 | return err_mask; |
1173 | } | 826 | } |
1174 | 827 | ||
1175 | /** | 828 | /** |
@@ -1439,12 +1092,11 @@ static inline u8 ata_dev_knobble(const struct ata_port *ap) | |||
1439 | } | 1092 | } |
1440 | 1093 | ||
1441 | /** | 1094 | /** |
1442 | * ata_dev_config - Run device specific handlers and check for | 1095 | * ata_dev_config - Run device specific handlers & check for SATA->PATA bridges |
1443 | * SATA->PATA bridges | 1096 | * @ap: Bus |
1444 | * @ap: Bus | 1097 | * @i: Device |
1445 | * @i: Device | ||
1446 | * | 1098 | * |
1447 | * LOCKING: | 1099 | * LOCKING: |
1448 | */ | 1100 | */ |
1449 | 1101 | ||
1450 | void ata_dev_config(struct ata_port *ap, unsigned int i) | 1102 | void ata_dev_config(struct ata_port *ap, unsigned int i) |
@@ -1482,7 +1134,24 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1482 | { | 1134 | { |
1483 | unsigned int i, found = 0; | 1135 | unsigned int i, found = 0; |
1484 | 1136 | ||
1485 | ap->ops->phy_reset(ap); | 1137 | if (ap->ops->probe_reset) { |
1138 | unsigned int classes[ATA_MAX_DEVICES]; | ||
1139 | int rc; | ||
1140 | |||
1141 | ata_port_probe(ap); | ||
1142 | |||
1143 | rc = ap->ops->probe_reset(ap, classes); | ||
1144 | if (rc == 0) { | ||
1145 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
1146 | ap->device[i].class = classes[i]; | ||
1147 | } else { | ||
1148 | printk(KERN_ERR "ata%u: probe reset failed, " | ||
1149 | "disabling port\n", ap->id); | ||
1150 | ata_port_disable(ap); | ||
1151 | } | ||
1152 | } else | ||
1153 | ap->ops->phy_reset(ap); | ||
1154 | |||
1486 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1155 | if (ap->flags & ATA_FLAG_PORT_DISABLED) |
1487 | goto err_out; | 1156 | goto err_out; |
1488 | 1157 | ||
@@ -1526,6 +1195,41 @@ void ata_port_probe(struct ata_port *ap) | |||
1526 | } | 1195 | } |
1527 | 1196 | ||
1528 | /** | 1197 | /** |
1198 | * sata_print_link_status - Print SATA link status | ||
1199 | * @ap: SATA port to printk link status about | ||
1200 | * | ||
1201 | * This function prints link speed and status of a SATA link. | ||
1202 | * | ||
1203 | * LOCKING: | ||
1204 | * None. | ||
1205 | */ | ||
1206 | static void sata_print_link_status(struct ata_port *ap) | ||
1207 | { | ||
1208 | u32 sstatus, tmp; | ||
1209 | const char *speed; | ||
1210 | |||
1211 | if (!ap->ops->scr_read) | ||
1212 | return; | ||
1213 | |||
1214 | sstatus = scr_read(ap, SCR_STATUS); | ||
1215 | |||
1216 | if (sata_dev_present(ap)) { | ||
1217 | tmp = (sstatus >> 4) & 0xf; | ||
1218 | if (tmp & (1 << 0)) | ||
1219 | speed = "1.5"; | ||
1220 | else if (tmp & (1 << 1)) | ||
1221 | speed = "3.0"; | ||
1222 | else | ||
1223 | speed = "<unknown>"; | ||
1224 | printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", | ||
1225 | ap->id, speed, sstatus); | ||
1226 | } else { | ||
1227 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", | ||
1228 | ap->id, sstatus); | ||
1229 | } | ||
1230 | } | ||
1231 | |||
1232 | /** | ||
1529 | * __sata_phy_reset - Wake/reset a low-level SATA PHY | 1233 | * __sata_phy_reset - Wake/reset a low-level SATA PHY |
1530 | * @ap: SATA port associated with target SATA PHY. | 1234 | * @ap: SATA port associated with target SATA PHY. |
1531 | * | 1235 | * |
@@ -1559,27 +1263,14 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1559 | break; | 1263 | break; |
1560 | } while (time_before(jiffies, timeout)); | 1264 | } while (time_before(jiffies, timeout)); |
1561 | 1265 | ||
1562 | /* TODO: phy layer with polling, timeouts, etc. */ | 1266 | /* print link status */ |
1563 | sstatus = scr_read(ap, SCR_STATUS); | 1267 | sata_print_link_status(ap); |
1564 | if (sata_dev_present(ap)) { | ||
1565 | const char *speed; | ||
1566 | u32 tmp; | ||
1567 | 1268 | ||
1568 | tmp = (sstatus >> 4) & 0xf; | 1269 | /* TODO: phy layer with polling, timeouts, etc. */ |
1569 | if (tmp & (1 << 0)) | 1270 | if (sata_dev_present(ap)) |
1570 | speed = "1.5"; | ||
1571 | else if (tmp & (1 << 1)) | ||
1572 | speed = "3.0"; | ||
1573 | else | ||
1574 | speed = "<unknown>"; | ||
1575 | printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", | ||
1576 | ap->id, speed, sstatus); | ||
1577 | ata_port_probe(ap); | 1271 | ata_port_probe(ap); |
1578 | } else { | 1272 | else |
1579 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", | ||
1580 | ap->id, sstatus); | ||
1581 | ata_port_disable(ap); | 1273 | ata_port_disable(ap); |
1582 | } | ||
1583 | 1274 | ||
1584 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1275 | if (ap->flags & ATA_FLAG_PORT_DISABLED) |
1585 | return; | 1276 | return; |
@@ -1752,9 +1443,9 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1752 | ata_timing_quantize(t, t, T, UT); | 1443 | ata_timing_quantize(t, t, T, UT); |
1753 | 1444 | ||
1754 | /* | 1445 | /* |
1755 | * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T | 1446 | * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, |
1756 | * and some other commands. We have to ensure that the DMA cycle timing is | 1447 | * S.M.A.R.T * and some other commands. We have to ensure that the |
1757 | * slower/equal than the fastest PIO timing. | 1448 | * DMA cycle timing is slower/equal than the fastest PIO timing. |
1758 | */ | 1449 | */ |
1759 | 1450 | ||
1760 | if (speed > XFER_PIO_4) { | 1451 | if (speed > XFER_PIO_4) { |
@@ -1763,7 +1454,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1763 | } | 1454 | } |
1764 | 1455 | ||
1765 | /* | 1456 | /* |
1766 | * Lenghten active & recovery time so that cycle time is correct. | 1457 | * Lengthen active & recovery time so that cycle time is correct. |
1767 | */ | 1458 | */ |
1768 | 1459 | ||
1769 | if (t->act8b + t->rec8b < t->cyc8b) { | 1460 | if (t->act8b + t->rec8b < t->cyc8b) { |
@@ -1882,7 +1573,6 @@ static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode, | |||
1882 | * | 1573 | * |
1883 | * LOCKING: | 1574 | * LOCKING: |
1884 | * PCI/etc. bus probe sem. | 1575 | * PCI/etc. bus probe sem. |
1885 | * | ||
1886 | */ | 1576 | */ |
1887 | static void ata_set_mode(struct ata_port *ap) | 1577 | static void ata_set_mode(struct ata_port *ap) |
1888 | { | 1578 | { |
@@ -1922,6 +1612,26 @@ err_out: | |||
1922 | } | 1612 | } |
1923 | 1613 | ||
1924 | /** | 1614 | /** |
1615 | * ata_tf_to_host - issue ATA taskfile to host controller | ||
1616 | * @ap: port to which command is being issued | ||
1617 | * @tf: ATA taskfile register set | ||
1618 | * | ||
1619 | * Issues ATA taskfile register set to ATA host controller, | ||
1620 | * with proper synchronization with interrupt handler and | ||
1621 | * other threads. | ||
1622 | * | ||
1623 | * LOCKING: | ||
1624 | * spin_lock_irqsave(host_set lock) | ||
1625 | */ | ||
1626 | |||
1627 | static inline void ata_tf_to_host(struct ata_port *ap, | ||
1628 | const struct ata_taskfile *tf) | ||
1629 | { | ||
1630 | ap->ops->tf_load(ap, tf); | ||
1631 | ap->ops->exec_command(ap, tf); | ||
1632 | } | ||
1633 | |||
1634 | /** | ||
1925 | * ata_busy_sleep - sleep until BSY clears, or timeout | 1635 | * ata_busy_sleep - sleep until BSY clears, or timeout |
1926 | * @ap: port containing status register to be polled | 1636 | * @ap: port containing status register to be polled |
1927 | * @tmout_pat: impatience timeout | 1637 | * @tmout_pat: impatience timeout |
@@ -1931,12 +1641,10 @@ err_out: | |||
1931 | * or a timeout occurs. | 1641 | * or a timeout occurs. |
1932 | * | 1642 | * |
1933 | * LOCKING: None. | 1643 | * LOCKING: None. |
1934 | * | ||
1935 | */ | 1644 | */ |
1936 | 1645 | ||
1937 | static unsigned int ata_busy_sleep (struct ata_port *ap, | 1646 | unsigned int ata_busy_sleep (struct ata_port *ap, |
1938 | unsigned long tmout_pat, | 1647 | unsigned long tmout_pat, unsigned long tmout) |
1939 | unsigned long tmout) | ||
1940 | { | 1648 | { |
1941 | unsigned long timer_start, timeout; | 1649 | unsigned long timer_start, timeout; |
1942 | u8 status; | 1650 | u8 status; |
@@ -2155,9 +1863,9 @@ void ata_bus_reset(struct ata_port *ap) | |||
2155 | /* | 1863 | /* |
2156 | * determine by signature whether we have ATA or ATAPI devices | 1864 | * determine by signature whether we have ATA or ATAPI devices |
2157 | */ | 1865 | */ |
2158 | err = ata_dev_try_classify(ap, 0); | 1866 | ap->device[0].class = ata_dev_try_classify(ap, 0, &err); |
2159 | if ((slave_possible) && (err != 0x81)) | 1867 | if ((slave_possible) && (err != 0x81)) |
2160 | ata_dev_try_classify(ap, 1); | 1868 | ap->device[1].class = ata_dev_try_classify(ap, 1, &err); |
2161 | 1869 | ||
2162 | /* re-enable interrupts */ | 1870 | /* re-enable interrupts */ |
2163 | if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */ | 1871 | if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */ |
@@ -2192,6 +1900,335 @@ err_out: | |||
2192 | DPRINTK("EXIT\n"); | 1900 | DPRINTK("EXIT\n"); |
2193 | } | 1901 | } |
2194 | 1902 | ||
1903 | static int sata_phy_resume(struct ata_port *ap) | ||
1904 | { | ||
1905 | unsigned long timeout = jiffies + (HZ * 5); | ||
1906 | u32 sstatus; | ||
1907 | |||
1908 | scr_write_flush(ap, SCR_CONTROL, 0x300); | ||
1909 | |||
1910 | /* Wait for phy to become ready, if necessary. */ | ||
1911 | do { | ||
1912 | msleep(200); | ||
1913 | sstatus = scr_read(ap, SCR_STATUS); | ||
1914 | if ((sstatus & 0xf) != 1) | ||
1915 | return 0; | ||
1916 | } while (time_before(jiffies, timeout)); | ||
1917 | |||
1918 | return -1; | ||
1919 | } | ||
1920 | |||
1921 | /** | ||
1922 | * ata_std_probeinit - initialize probing | ||
1923 | * @ap: port to be probed | ||
1924 | * | ||
1925 | * @ap is about to be probed. Initialize it. This function is | ||
1926 | * to be used as standard callback for ata_drive_probe_reset(). | ||
1927 | * | ||
1928 | * NOTE!!! Do not use this function as probeinit if a low level | ||
1929 | * driver implements only hardreset. Just pass NULL as probeinit | ||
1930 | * in that case. Using this function is probably okay but doing | ||
1931 | * so makes reset sequence different from the original | ||
1932 | * ->phy_reset implementation and Jeff nervous. :-P | ||
1933 | */ | ||
1934 | extern void ata_std_probeinit(struct ata_port *ap) | ||
1935 | { | ||
1936 | if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read) { | ||
1937 | sata_phy_resume(ap); | ||
1938 | if (sata_dev_present(ap)) | ||
1939 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | ||
1940 | } | ||
1941 | } | ||
1942 | |||
1943 | /** | ||
1944 | * ata_std_softreset - reset host port via ATA SRST | ||
1945 | * @ap: port to reset | ||
1946 | * @verbose: fail verbosely | ||
1947 | * @classes: resulting classes of attached devices | ||
1948 | * | ||
1949 | * Reset host port using ATA SRST. This function is to be used | ||
1950 | * as standard callback for ata_drive_*_reset() functions. | ||
1951 | * | ||
1952 | * LOCKING: | ||
1953 | * Kernel thread context (may sleep) | ||
1954 | * | ||
1955 | * RETURNS: | ||
1956 | * 0 on success, -errno otherwise. | ||
1957 | */ | ||
1958 | int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | ||
1959 | { | ||
1960 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | ||
1961 | unsigned int devmask = 0, err_mask; | ||
1962 | u8 err; | ||
1963 | |||
1964 | DPRINTK("ENTER\n"); | ||
1965 | |||
1966 | if (ap->ops->scr_read && !sata_dev_present(ap)) { | ||
1967 | classes[0] = ATA_DEV_NONE; | ||
1968 | goto out; | ||
1969 | } | ||
1970 | |||
1971 | /* determine if device 0/1 are present */ | ||
1972 | if (ata_devchk(ap, 0)) | ||
1973 | devmask |= (1 << 0); | ||
1974 | if (slave_possible && ata_devchk(ap, 1)) | ||
1975 | devmask |= (1 << 1); | ||
1976 | |||
1977 | /* select device 0 again */ | ||
1978 | ap->ops->dev_select(ap, 0); | ||
1979 | |||
1980 | /* issue bus reset */ | ||
1981 | DPRINTK("about to softreset, devmask=%x\n", devmask); | ||
1982 | err_mask = ata_bus_softreset(ap, devmask); | ||
1983 | if (err_mask) { | ||
1984 | if (verbose) | ||
1985 | printk(KERN_ERR "ata%u: SRST failed (err_mask=0x%x)\n", | ||
1986 | ap->id, err_mask); | ||
1987 | else | ||
1988 | DPRINTK("EXIT, softreset failed (err_mask=0x%x)\n", | ||
1989 | err_mask); | ||
1990 | return -EIO; | ||
1991 | } | ||
1992 | |||
1993 | /* determine by signature whether we have ATA or ATAPI devices */ | ||
1994 | classes[0] = ata_dev_try_classify(ap, 0, &err); | ||
1995 | if (slave_possible && err != 0x81) | ||
1996 | classes[1] = ata_dev_try_classify(ap, 1, &err); | ||
1997 | |||
1998 | out: | ||
1999 | DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); | ||
2000 | return 0; | ||
2001 | } | ||
2002 | |||
2003 | /** | ||
2004 | * sata_std_hardreset - reset host port via SATA phy reset | ||
2005 | * @ap: port to reset | ||
2006 | * @verbose: fail verbosely | ||
2007 | * @class: resulting class of attached device | ||
2008 | * | ||
2009 | * SATA phy-reset host port using DET bits of SControl register. | ||
2010 | * This function is to be used as standard callback for | ||
2011 | * ata_drive_*_reset(). | ||
2012 | * | ||
2013 | * LOCKING: | ||
2014 | * Kernel thread context (may sleep) | ||
2015 | * | ||
2016 | * RETURNS: | ||
2017 | * 0 on success, -errno otherwise. | ||
2018 | */ | ||
2019 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | ||
2020 | { | ||
2021 | DPRINTK("ENTER\n"); | ||
2022 | |||
2023 | /* Issue phy wake/reset */ | ||
2024 | scr_write_flush(ap, SCR_CONTROL, 0x301); | ||
2025 | |||
2026 | /* | ||
2027 | * Couldn't find anything in SATA I/II specs, but AHCI-1.1 | ||
2028 | * 10.4.2 says at least 1 ms. | ||
2029 | */ | ||
2030 | msleep(1); | ||
2031 | |||
2032 | /* Bring phy back */ | ||
2033 | sata_phy_resume(ap); | ||
2034 | |||
2035 | /* TODO: phy layer with polling, timeouts, etc. */ | ||
2036 | if (!sata_dev_present(ap)) { | ||
2037 | *class = ATA_DEV_NONE; | ||
2038 | DPRINTK("EXIT, link offline\n"); | ||
2039 | return 0; | ||
2040 | } | ||
2041 | |||
2042 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { | ||
2043 | if (verbose) | ||
2044 | printk(KERN_ERR "ata%u: COMRESET failed " | ||
2045 | "(device not ready)\n", ap->id); | ||
2046 | else | ||
2047 | DPRINTK("EXIT, device not ready\n"); | ||
2048 | return -EIO; | ||
2049 | } | ||
2050 | |||
2051 | ap->ops->dev_select(ap, 0); /* probably unnecessary */ | ||
2052 | |||
2053 | *class = ata_dev_try_classify(ap, 0, NULL); | ||
2054 | |||
2055 | DPRINTK("EXIT, class=%u\n", *class); | ||
2056 | return 0; | ||
2057 | } | ||
2058 | |||
2059 | /** | ||
2060 | * ata_std_postreset - standard postreset callback | ||
2061 | * @ap: the target ata_port | ||
2062 | * @classes: classes of attached devices | ||
2063 | * | ||
2064 | * This function is invoked after a successful reset. Note that | ||
2065 | * the device might have been reset more than once using | ||
2066 | * different reset methods before postreset is invoked. | ||
2067 | * postreset is also reponsible for setting cable type. | ||
2068 | * | ||
2069 | * This function is to be used as standard callback for | ||
2070 | * ata_drive_*_reset(). | ||
2071 | * | ||
2072 | * LOCKING: | ||
2073 | * Kernel thread context (may sleep) | ||
2074 | */ | ||
2075 | void ata_std_postreset(struct ata_port *ap, unsigned int *classes) | ||
2076 | { | ||
2077 | DPRINTK("ENTER\n"); | ||
2078 | |||
2079 | /* set cable type */ | ||
2080 | if (ap->cbl == ATA_CBL_NONE && ap->flags & ATA_FLAG_SATA) | ||
2081 | ap->cbl = ATA_CBL_SATA; | ||
2082 | |||
2083 | /* print link status */ | ||
2084 | if (ap->cbl == ATA_CBL_SATA) | ||
2085 | sata_print_link_status(ap); | ||
2086 | |||
2087 | /* re-enable interrupts */ | ||
2088 | if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */ | ||
2089 | ata_irq_on(ap); | ||
2090 | |||
2091 | /* is double-select really necessary? */ | ||
2092 | if (classes[0] != ATA_DEV_NONE) | ||
2093 | ap->ops->dev_select(ap, 1); | ||
2094 | if (classes[1] != ATA_DEV_NONE) | ||
2095 | ap->ops->dev_select(ap, 0); | ||
2096 | |||
2097 | /* bail out if no device is present */ | ||
2098 | if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { | ||
2099 | DPRINTK("EXIT, no device\n"); | ||
2100 | return; | ||
2101 | } | ||
2102 | |||
2103 | /* set up device control */ | ||
2104 | if (ap->ioaddr.ctl_addr) { | ||
2105 | if (ap->flags & ATA_FLAG_MMIO) | ||
2106 | writeb(ap->ctl, (void __iomem *) ap->ioaddr.ctl_addr); | ||
2107 | else | ||
2108 | outb(ap->ctl, ap->ioaddr.ctl_addr); | ||
2109 | } | ||
2110 | |||
2111 | DPRINTK("EXIT\n"); | ||
2112 | } | ||
2113 | |||
2114 | /** | ||
2115 | * ata_std_probe_reset - standard probe reset method | ||
2116 | * @ap: prot to perform probe-reset | ||
2117 | * @classes: resulting classes of attached devices | ||
2118 | * | ||
2119 | * The stock off-the-shelf ->probe_reset method. | ||
2120 | * | ||
2121 | * LOCKING: | ||
2122 | * Kernel thread context (may sleep) | ||
2123 | * | ||
2124 | * RETURNS: | ||
2125 | * 0 on success, -errno otherwise. | ||
2126 | */ | ||
2127 | int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes) | ||
2128 | { | ||
2129 | ata_reset_fn_t hardreset; | ||
2130 | |||
2131 | hardreset = NULL; | ||
2132 | if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read) | ||
2133 | hardreset = sata_std_hardreset; | ||
2134 | |||
2135 | return ata_drive_probe_reset(ap, ata_std_probeinit, | ||
2136 | ata_std_softreset, hardreset, | ||
2137 | ata_std_postreset, classes); | ||
2138 | } | ||
2139 | |||
2140 | static int do_probe_reset(struct ata_port *ap, ata_reset_fn_t reset, | ||
2141 | ata_postreset_fn_t postreset, | ||
2142 | unsigned int *classes) | ||
2143 | { | ||
2144 | int i, rc; | ||
2145 | |||
2146 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
2147 | classes[i] = ATA_DEV_UNKNOWN; | ||
2148 | |||
2149 | rc = reset(ap, 0, classes); | ||
2150 | if (rc) | ||
2151 | return rc; | ||
2152 | |||
2153 | /* If any class isn't ATA_DEV_UNKNOWN, consider classification | ||
2154 | * is complete and convert all ATA_DEV_UNKNOWN to | ||
2155 | * ATA_DEV_NONE. | ||
2156 | */ | ||
2157 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
2158 | if (classes[i] != ATA_DEV_UNKNOWN) | ||
2159 | break; | ||
2160 | |||
2161 | if (i < ATA_MAX_DEVICES) | ||
2162 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
2163 | if (classes[i] == ATA_DEV_UNKNOWN) | ||
2164 | classes[i] = ATA_DEV_NONE; | ||
2165 | |||
2166 | if (postreset) | ||
2167 | postreset(ap, classes); | ||
2168 | |||
2169 | return classes[0] != ATA_DEV_UNKNOWN ? 0 : -ENODEV; | ||
2170 | } | ||
2171 | |||
2172 | /** | ||
2173 | * ata_drive_probe_reset - Perform probe reset with given methods | ||
2174 | * @ap: port to reset | ||
2175 | * @probeinit: probeinit method (can be NULL) | ||
2176 | * @softreset: softreset method (can be NULL) | ||
2177 | * @hardreset: hardreset method (can be NULL) | ||
2178 | * @postreset: postreset method (can be NULL) | ||
2179 | * @classes: resulting classes of attached devices | ||
2180 | * | ||
2181 | * Reset the specified port and classify attached devices using | ||
2182 | * given methods. This function prefers softreset but tries all | ||
2183 | * possible reset sequences to reset and classify devices. This | ||
2184 | * function is intended to be used for constructing ->probe_reset | ||
2185 | * callback by low level drivers. | ||
2186 | * | ||
2187 | * Reset methods should follow the following rules. | ||
2188 | * | ||
2189 | * - Return 0 on sucess, -errno on failure. | ||
2190 | * - If classification is supported, fill classes[] with | ||
2191 | * recognized class codes. | ||
2192 | * - If classification is not supported, leave classes[] alone. | ||
2193 | * - If verbose is non-zero, print error message on failure; | ||
2194 | * otherwise, shut up. | ||
2195 | * | ||
2196 | * LOCKING: | ||
2197 | * Kernel thread context (may sleep) | ||
2198 | * | ||
2199 | * RETURNS: | ||
2200 | * 0 on success, -EINVAL if no reset method is avaliable, -ENODEV | ||
2201 | * if classification fails, and any error code from reset | ||
2202 | * methods. | ||
2203 | */ | ||
2204 | int ata_drive_probe_reset(struct ata_port *ap, ata_probeinit_fn_t probeinit, | ||
2205 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | ||
2206 | ata_postreset_fn_t postreset, unsigned int *classes) | ||
2207 | { | ||
2208 | int rc = -EINVAL; | ||
2209 | |||
2210 | if (probeinit) | ||
2211 | probeinit(ap); | ||
2212 | |||
2213 | if (softreset) { | ||
2214 | rc = do_probe_reset(ap, softreset, postreset, classes); | ||
2215 | if (rc == 0) | ||
2216 | return 0; | ||
2217 | } | ||
2218 | |||
2219 | if (!hardreset) | ||
2220 | return rc; | ||
2221 | |||
2222 | rc = do_probe_reset(ap, hardreset, postreset, classes); | ||
2223 | if (rc == 0 || rc != -ENODEV) | ||
2224 | return rc; | ||
2225 | |||
2226 | if (softreset) | ||
2227 | rc = do_probe_reset(ap, softreset, postreset, classes); | ||
2228 | |||
2229 | return rc; | ||
2230 | } | ||
2231 | |||
2195 | static void ata_pr_blacklisted(const struct ata_port *ap, | 2232 | static void ata_pr_blacklisted(const struct ata_port *ap, |
2196 | const struct ata_device *dev) | 2233 | const struct ata_device *dev) |
2197 | { | 2234 | { |
@@ -2869,7 +2906,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc) | |||
2869 | } | 2906 | } |
2870 | 2907 | ||
2871 | /** | 2908 | /** |
2872 | * ata_pio_poll - | 2909 | * ata_pio_poll - poll using PIO, depending on current state |
2873 | * @ap: the target ata_port | 2910 | * @ap: the target ata_port |
2874 | * | 2911 | * |
2875 | * LOCKING: | 2912 | * LOCKING: |
@@ -2908,7 +2945,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
2908 | status = ata_chk_status(ap); | 2945 | status = ata_chk_status(ap); |
2909 | if (status & ATA_BUSY) { | 2946 | if (status & ATA_BUSY) { |
2910 | if (time_after(jiffies, ap->pio_task_timeout)) { | 2947 | if (time_after(jiffies, ap->pio_task_timeout)) { |
2911 | qc->err_mask |= AC_ERR_ATA_BUS; | 2948 | qc->err_mask |= AC_ERR_TIMEOUT; |
2912 | ap->hsm_task_state = HSM_ST_TMOUT; | 2949 | ap->hsm_task_state = HSM_ST_TMOUT; |
2913 | return 0; | 2950 | return 0; |
2914 | } | 2951 | } |
@@ -2976,7 +3013,7 @@ static int ata_pio_complete (struct ata_port *ap) | |||
2976 | 3013 | ||
2977 | 3014 | ||
2978 | /** | 3015 | /** |
2979 | * swap_buf_le16 - swap halves of 16-words in place | 3016 | * swap_buf_le16 - swap halves of 16-bit words in place |
2980 | * @buf: Buffer to swap | 3017 | * @buf: Buffer to swap |
2981 | * @buf_words: Number of 16-bit words in buffer. | 3018 | * @buf_words: Number of 16-bit words in buffer. |
2982 | * | 3019 | * |
@@ -3286,7 +3323,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
3286 | err_out: | 3323 | err_out: |
3287 | printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", | 3324 | printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", |
3288 | ap->id, dev->devno); | 3325 | ap->id, dev->devno); |
3289 | qc->err_mask |= AC_ERR_ATA_BUS; | 3326 | qc->err_mask |= AC_ERR_HSM; |
3290 | ap->hsm_task_state = HSM_ST_ERR; | 3327 | ap->hsm_task_state = HSM_ST_ERR; |
3291 | } | 3328 | } |
3292 | 3329 | ||
@@ -3344,7 +3381,7 @@ static void ata_pio_block(struct ata_port *ap) | |||
3344 | } else { | 3381 | } else { |
3345 | /* handle BSY=0, DRQ=0 as error */ | 3382 | /* handle BSY=0, DRQ=0 as error */ |
3346 | if ((status & ATA_DRQ) == 0) { | 3383 | if ((status & ATA_DRQ) == 0) { |
3347 | qc->err_mask |= AC_ERR_ATA_BUS; | 3384 | qc->err_mask |= AC_ERR_HSM; |
3348 | ap->hsm_task_state = HSM_ST_ERR; | 3385 | ap->hsm_task_state = HSM_ST_ERR; |
3349 | return; | 3386 | return; |
3350 | } | 3387 | } |
@@ -3406,7 +3443,7 @@ fsm_start: | |||
3406 | } | 3443 | } |
3407 | 3444 | ||
3408 | if (timeout) | 3445 | if (timeout) |
3409 | queue_delayed_work(ata_wq, &ap->pio_task, timeout); | 3446 | ata_queue_delayed_pio_task(ap, timeout); |
3410 | else if (!qc_completed) | 3447 | else if (!qc_completed) |
3411 | goto fsm_start; | 3448 | goto fsm_start; |
3412 | } | 3449 | } |
@@ -3439,15 +3476,10 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3439 | 3476 | ||
3440 | DPRINTK("ENTER\n"); | 3477 | DPRINTK("ENTER\n"); |
3441 | 3478 | ||
3442 | spin_lock_irqsave(&host_set->lock, flags); | 3479 | ata_flush_pio_tasks(ap); |
3480 | ap->hsm_task_state = HSM_ST_IDLE; | ||
3443 | 3481 | ||
3444 | /* hack alert! We cannot use the supplied completion | 3482 | spin_lock_irqsave(&host_set->lock, flags); |
3445 | * function from inside the ->eh_strategy_handler() thread. | ||
3446 | * libata is the only user of ->eh_strategy_handler() in | ||
3447 | * any kernel, so the default scsi_done() assumes it is | ||
3448 | * not being called from the SCSI EH. | ||
3449 | */ | ||
3450 | qc->scsidone = scsi_finish_command; | ||
3451 | 3483 | ||
3452 | switch (qc->tf.protocol) { | 3484 | switch (qc->tf.protocol) { |
3453 | 3485 | ||
@@ -3472,12 +3504,13 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3472 | 3504 | ||
3473 | /* complete taskfile transaction */ | 3505 | /* complete taskfile transaction */ |
3474 | qc->err_mask |= ac_err_mask(drv_stat); | 3506 | qc->err_mask |= ac_err_mask(drv_stat); |
3475 | ata_qc_complete(qc); | ||
3476 | break; | 3507 | break; |
3477 | } | 3508 | } |
3478 | 3509 | ||
3479 | spin_unlock_irqrestore(&host_set->lock, flags); | 3510 | spin_unlock_irqrestore(&host_set->lock, flags); |
3480 | 3511 | ||
3512 | ata_eh_qc_complete(qc); | ||
3513 | |||
3481 | DPRINTK("EXIT\n"); | 3514 | DPRINTK("EXIT\n"); |
3482 | } | 3515 | } |
3483 | 3516 | ||
@@ -3502,20 +3535,10 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3502 | 3535 | ||
3503 | void ata_eng_timeout(struct ata_port *ap) | 3536 | void ata_eng_timeout(struct ata_port *ap) |
3504 | { | 3537 | { |
3505 | struct ata_queued_cmd *qc; | ||
3506 | |||
3507 | DPRINTK("ENTER\n"); | 3538 | DPRINTK("ENTER\n"); |
3508 | 3539 | ||
3509 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3540 | ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag)); |
3510 | if (qc) | ||
3511 | ata_qc_timeout(qc); | ||
3512 | else { | ||
3513 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | ||
3514 | ap->id); | ||
3515 | goto out; | ||
3516 | } | ||
3517 | 3541 | ||
3518 | out: | ||
3519 | DPRINTK("EXIT\n"); | 3542 | DPRINTK("EXIT\n"); |
3520 | } | 3543 | } |
3521 | 3544 | ||
@@ -3571,11 +3594,23 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | |||
3571 | return qc; | 3594 | return qc; |
3572 | } | 3595 | } |
3573 | 3596 | ||
3574 | static void __ata_qc_complete(struct ata_queued_cmd *qc) | 3597 | /** |
3598 | * ata_qc_free - free unused ata_queued_cmd | ||
3599 | * @qc: Command to complete | ||
3600 | * | ||
3601 | * Designed to free unused ata_queued_cmd object | ||
3602 | * in case something prevents using it. | ||
3603 | * | ||
3604 | * LOCKING: | ||
3605 | * spin_lock_irqsave(host_set lock) | ||
3606 | */ | ||
3607 | void ata_qc_free(struct ata_queued_cmd *qc) | ||
3575 | { | 3608 | { |
3576 | struct ata_port *ap = qc->ap; | 3609 | struct ata_port *ap = qc->ap; |
3577 | unsigned int tag; | 3610 | unsigned int tag; |
3578 | 3611 | ||
3612 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | ||
3613 | |||
3579 | qc->flags = 0; | 3614 | qc->flags = 0; |
3580 | tag = qc->tag; | 3615 | tag = qc->tag; |
3581 | if (likely(ata_tag_valid(tag))) { | 3616 | if (likely(ata_tag_valid(tag))) { |
@@ -3586,21 +3621,22 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
3586 | } | 3621 | } |
3587 | } | 3622 | } |
3588 | 3623 | ||
3589 | /** | 3624 | inline void __ata_qc_complete(struct ata_queued_cmd *qc) |
3590 | * ata_qc_free - free unused ata_queued_cmd | ||
3591 | * @qc: Command to complete | ||
3592 | * | ||
3593 | * Designed to free unused ata_queued_cmd object | ||
3594 | * in case something prevents using it. | ||
3595 | * | ||
3596 | * LOCKING: | ||
3597 | * spin_lock_irqsave(host_set lock) | ||
3598 | */ | ||
3599 | void ata_qc_free(struct ata_queued_cmd *qc) | ||
3600 | { | 3625 | { |
3601 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | 3626 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ |
3627 | assert(qc->flags & ATA_QCFLAG_ACTIVE); | ||
3602 | 3628 | ||
3603 | __ata_qc_complete(qc); | 3629 | if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) |
3630 | ata_sg_clean(qc); | ||
3631 | |||
3632 | /* atapi: mark qc as inactive to prevent the interrupt handler | ||
3633 | * from completing the command twice later, before the error handler | ||
3634 | * is called. (when rc != 0 and atapi request sense is needed) | ||
3635 | */ | ||
3636 | qc->flags &= ~ATA_QCFLAG_ACTIVE; | ||
3637 | |||
3638 | /* call completion callback */ | ||
3639 | qc->complete_fn(qc); | ||
3604 | } | 3640 | } |
3605 | 3641 | ||
3606 | /** | 3642 | /** |
@@ -3614,35 +3650,12 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
3614 | * LOCKING: | 3650 | * LOCKING: |
3615 | * spin_lock_irqsave(host_set lock) | 3651 | * spin_lock_irqsave(host_set lock) |
3616 | */ | 3652 | */ |
3617 | |||
3618 | void ata_qc_complete(struct ata_queued_cmd *qc) | 3653 | void ata_qc_complete(struct ata_queued_cmd *qc) |
3619 | { | 3654 | { |
3620 | int rc; | 3655 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) |
3621 | |||
3622 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | ||
3623 | assert(qc->flags & ATA_QCFLAG_ACTIVE); | ||
3624 | |||
3625 | if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
3626 | ata_sg_clean(qc); | ||
3627 | |||
3628 | /* atapi: mark qc as inactive to prevent the interrupt handler | ||
3629 | * from completing the command twice later, before the error handler | ||
3630 | * is called. (when rc != 0 and atapi request sense is needed) | ||
3631 | */ | ||
3632 | qc->flags &= ~ATA_QCFLAG_ACTIVE; | ||
3633 | |||
3634 | /* call completion callback */ | ||
3635 | rc = qc->complete_fn(qc); | ||
3636 | |||
3637 | /* if callback indicates not to complete command (non-zero), | ||
3638 | * return immediately | ||
3639 | */ | ||
3640 | if (rc != 0) | ||
3641 | return; | 3656 | return; |
3642 | 3657 | ||
3643 | __ata_qc_complete(qc); | 3658 | __ata_qc_complete(qc); |
3644 | |||
3645 | VPRINTK("EXIT\n"); | ||
3646 | } | 3659 | } |
3647 | 3660 | ||
3648 | static inline int ata_should_dma_map(struct ata_queued_cmd *qc) | 3661 | static inline int ata_should_dma_map(struct ata_queued_cmd *qc) |
@@ -3682,20 +3695,20 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc) | |||
3682 | * spin_lock_irqsave(host_set lock) | 3695 | * spin_lock_irqsave(host_set lock) |
3683 | * | 3696 | * |
3684 | * RETURNS: | 3697 | * RETURNS: |
3685 | * Zero on success, negative on error. | 3698 | * Zero on success, AC_ERR_* mask on failure |
3686 | */ | 3699 | */ |
3687 | 3700 | ||
3688 | int ata_qc_issue(struct ata_queued_cmd *qc) | 3701 | unsigned int ata_qc_issue(struct ata_queued_cmd *qc) |
3689 | { | 3702 | { |
3690 | struct ata_port *ap = qc->ap; | 3703 | struct ata_port *ap = qc->ap; |
3691 | 3704 | ||
3692 | if (ata_should_dma_map(qc)) { | 3705 | if (ata_should_dma_map(qc)) { |
3693 | if (qc->flags & ATA_QCFLAG_SG) { | 3706 | if (qc->flags & ATA_QCFLAG_SG) { |
3694 | if (ata_sg_setup(qc)) | 3707 | if (ata_sg_setup(qc)) |
3695 | goto err_out; | 3708 | goto sg_err; |
3696 | } else if (qc->flags & ATA_QCFLAG_SINGLE) { | 3709 | } else if (qc->flags & ATA_QCFLAG_SINGLE) { |
3697 | if (ata_sg_setup_one(qc)) | 3710 | if (ata_sg_setup_one(qc)) |
3698 | goto err_out; | 3711 | goto sg_err; |
3699 | } | 3712 | } |
3700 | } else { | 3713 | } else { |
3701 | qc->flags &= ~ATA_QCFLAG_DMAMAP; | 3714 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
@@ -3708,8 +3721,9 @@ int ata_qc_issue(struct ata_queued_cmd *qc) | |||
3708 | 3721 | ||
3709 | return ap->ops->qc_issue(qc); | 3722 | return ap->ops->qc_issue(qc); |
3710 | 3723 | ||
3711 | err_out: | 3724 | sg_err: |
3712 | return -1; | 3725 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
3726 | return AC_ERR_SYSTEM; | ||
3713 | } | 3727 | } |
3714 | 3728 | ||
3715 | 3729 | ||
@@ -3728,10 +3742,10 @@ err_out: | |||
3728 | * spin_lock_irqsave(host_set lock) | 3742 | * spin_lock_irqsave(host_set lock) |
3729 | * | 3743 | * |
3730 | * RETURNS: | 3744 | * RETURNS: |
3731 | * Zero on success, negative on error. | 3745 | * Zero on success, AC_ERR_* mask on failure |
3732 | */ | 3746 | */ |
3733 | 3747 | ||
3734 | int ata_qc_issue_prot(struct ata_queued_cmd *qc) | 3748 | unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) |
3735 | { | 3749 | { |
3736 | struct ata_port *ap = qc->ap; | 3750 | struct ata_port *ap = qc->ap; |
3737 | 3751 | ||
@@ -3752,31 +3766,31 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
3752 | ata_qc_set_polling(qc); | 3766 | ata_qc_set_polling(qc); |
3753 | ata_tf_to_host(ap, &qc->tf); | 3767 | ata_tf_to_host(ap, &qc->tf); |
3754 | ap->hsm_task_state = HSM_ST; | 3768 | ap->hsm_task_state = HSM_ST; |
3755 | queue_work(ata_wq, &ap->pio_task); | 3769 | ata_queue_pio_task(ap); |
3756 | break; | 3770 | break; |
3757 | 3771 | ||
3758 | case ATA_PROT_ATAPI: | 3772 | case ATA_PROT_ATAPI: |
3759 | ata_qc_set_polling(qc); | 3773 | ata_qc_set_polling(qc); |
3760 | ata_tf_to_host(ap, &qc->tf); | 3774 | ata_tf_to_host(ap, &qc->tf); |
3761 | queue_work(ata_wq, &ap->packet_task); | 3775 | ata_queue_packet_task(ap); |
3762 | break; | 3776 | break; |
3763 | 3777 | ||
3764 | case ATA_PROT_ATAPI_NODATA: | 3778 | case ATA_PROT_ATAPI_NODATA: |
3765 | ap->flags |= ATA_FLAG_NOINTR; | 3779 | ap->flags |= ATA_FLAG_NOINTR; |
3766 | ata_tf_to_host(ap, &qc->tf); | 3780 | ata_tf_to_host(ap, &qc->tf); |
3767 | queue_work(ata_wq, &ap->packet_task); | 3781 | ata_queue_packet_task(ap); |
3768 | break; | 3782 | break; |
3769 | 3783 | ||
3770 | case ATA_PROT_ATAPI_DMA: | 3784 | case ATA_PROT_ATAPI_DMA: |
3771 | ap->flags |= ATA_FLAG_NOINTR; | 3785 | ap->flags |= ATA_FLAG_NOINTR; |
3772 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | 3786 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ |
3773 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | 3787 | ap->ops->bmdma_setup(qc); /* set up bmdma */ |
3774 | queue_work(ata_wq, &ap->packet_task); | 3788 | ata_queue_packet_task(ap); |
3775 | break; | 3789 | break; |
3776 | 3790 | ||
3777 | default: | 3791 | default: |
3778 | WARN_ON(1); | 3792 | WARN_ON(1); |
3779 | return -1; | 3793 | return AC_ERR_SYSTEM; |
3780 | } | 3794 | } |
3781 | 3795 | ||
3782 | return 0; | 3796 | return 0; |
@@ -4166,14 +4180,14 @@ static void atapi_packet_task(void *_data) | |||
4166 | /* sleep-wait for BSY to clear */ | 4180 | /* sleep-wait for BSY to clear */ |
4167 | DPRINTK("busy wait\n"); | 4181 | DPRINTK("busy wait\n"); |
4168 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { | 4182 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { |
4169 | qc->err_mask |= AC_ERR_ATA_BUS; | 4183 | qc->err_mask |= AC_ERR_TIMEOUT; |
4170 | goto err_out; | 4184 | goto err_out; |
4171 | } | 4185 | } |
4172 | 4186 | ||
4173 | /* make sure DRQ is set */ | 4187 | /* make sure DRQ is set */ |
4174 | status = ata_chk_status(ap); | 4188 | status = ata_chk_status(ap); |
4175 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { | 4189 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { |
4176 | qc->err_mask |= AC_ERR_ATA_BUS; | 4190 | qc->err_mask |= AC_ERR_HSM; |
4177 | goto err_out; | 4191 | goto err_out; |
4178 | } | 4192 | } |
4179 | 4193 | ||
@@ -4202,7 +4216,7 @@ static void atapi_packet_task(void *_data) | |||
4202 | 4216 | ||
4203 | /* PIO commands are handled by polling */ | 4217 | /* PIO commands are handled by polling */ |
4204 | ap->hsm_task_state = HSM_ST; | 4218 | ap->hsm_task_state = HSM_ST; |
4205 | queue_work(ata_wq, &ap->pio_task); | 4219 | ata_queue_pio_task(ap); |
4206 | } | 4220 | } |
4207 | 4221 | ||
4208 | return; | 4222 | return; |
@@ -4212,19 +4226,6 @@ err_out: | |||
4212 | } | 4226 | } |
4213 | 4227 | ||
4214 | 4228 | ||
4215 | /** | ||
4216 | * ata_port_start - Set port up for dma. | ||
4217 | * @ap: Port to initialize | ||
4218 | * | ||
4219 | * Called just after data structures for each port are | ||
4220 | * initialized. Allocates space for PRD table. | ||
4221 | * | ||
4222 | * May be used as the port_start() entry in ata_port_operations. | ||
4223 | * | ||
4224 | * LOCKING: | ||
4225 | * Inherited from caller. | ||
4226 | */ | ||
4227 | |||
4228 | /* | 4229 | /* |
4229 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, | 4230 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, |
4230 | * without filling any other registers | 4231 | * without filling any other registers |
@@ -4276,6 +4277,8 @@ static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) | |||
4276 | 4277 | ||
4277 | /** | 4278 | /** |
4278 | * ata_device_resume - wakeup a previously suspended devices | 4279 | * ata_device_resume - wakeup a previously suspended devices |
4280 | * @ap: port the device is connected to | ||
4281 | * @dev: the device to resume | ||
4279 | * | 4282 | * |
4280 | * Kick the drive back into action, by sending it an idle immediate | 4283 | * Kick the drive back into action, by sending it an idle immediate |
4281 | * command and making sure its transfer mode matches between drive | 4284 | * command and making sure its transfer mode matches between drive |
@@ -4298,10 +4301,11 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | |||
4298 | 4301 | ||
4299 | /** | 4302 | /** |
4300 | * ata_device_suspend - prepare a device for suspend | 4303 | * ata_device_suspend - prepare a device for suspend |
4304 | * @ap: port the device is connected to | ||
4305 | * @dev: the device to suspend | ||
4301 | * | 4306 | * |
4302 | * Flush the cache on the drive, if appropriate, then issue a | 4307 | * Flush the cache on the drive, if appropriate, then issue a |
4303 | * standbynow command. | 4308 | * standbynow command. |
4304 | * | ||
4305 | */ | 4309 | */ |
4306 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) | 4310 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) |
4307 | { | 4311 | { |
@@ -4315,6 +4319,19 @@ int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) | |||
4315 | return 0; | 4319 | return 0; |
4316 | } | 4320 | } |
4317 | 4321 | ||
4322 | /** | ||
4323 | * ata_port_start - Set port up for dma. | ||
4324 | * @ap: Port to initialize | ||
4325 | * | ||
4326 | * Called just after data structures for each port are | ||
4327 | * initialized. Allocates space for PRD table. | ||
4328 | * | ||
4329 | * May be used as the port_start() entry in ata_port_operations. | ||
4330 | * | ||
4331 | * LOCKING: | ||
4332 | * Inherited from caller. | ||
4333 | */ | ||
4334 | |||
4318 | int ata_port_start (struct ata_port *ap) | 4335 | int ata_port_start (struct ata_port *ap) |
4319 | { | 4336 | { |
4320 | struct device *dev = ap->host_set->dev; | 4337 | struct device *dev = ap->host_set->dev; |
@@ -4430,6 +4447,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4430 | 4447 | ||
4431 | INIT_WORK(&ap->packet_task, atapi_packet_task, ap); | 4448 | INIT_WORK(&ap->packet_task, atapi_packet_task, ap); |
4432 | INIT_WORK(&ap->pio_task, ata_pio_task, ap); | 4449 | INIT_WORK(&ap->pio_task, ata_pio_task, ap); |
4450 | INIT_LIST_HEAD(&ap->eh_done_q); | ||
4433 | 4451 | ||
4434 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 4452 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
4435 | ap->device[i].devno = i; | 4453 | ap->device[i].devno = i; |
@@ -4571,9 +4589,9 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
4571 | 4589 | ||
4572 | ap = host_set->ports[i]; | 4590 | ap = host_set->ports[i]; |
4573 | 4591 | ||
4574 | DPRINTK("ata%u: probe begin\n", ap->id); | 4592 | DPRINTK("ata%u: bus probe begin\n", ap->id); |
4575 | rc = ata_bus_probe(ap); | 4593 | rc = ata_bus_probe(ap); |
4576 | DPRINTK("ata%u: probe end\n", ap->id); | 4594 | DPRINTK("ata%u: bus probe end\n", ap->id); |
4577 | 4595 | ||
4578 | if (rc) { | 4596 | if (rc) { |
4579 | /* FIXME: do something useful here? | 4597 | /* FIXME: do something useful here? |
@@ -4597,7 +4615,7 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
4597 | } | 4615 | } |
4598 | 4616 | ||
4599 | /* probes are done, now scan each port's disk(s) */ | 4617 | /* probes are done, now scan each port's disk(s) */ |
4600 | DPRINTK("probe begin\n"); | 4618 | DPRINTK("host probe begin\n"); |
4601 | for (i = 0; i < count; i++) { | 4619 | for (i = 0; i < count; i++) { |
4602 | struct ata_port *ap = host_set->ports[i]; | 4620 | struct ata_port *ap = host_set->ports[i]; |
4603 | 4621 | ||
@@ -4719,32 +4737,6 @@ void ata_std_ports(struct ata_ioports *ioaddr) | |||
4719 | ioaddr->command_addr = ioaddr->cmd_addr + ATA_REG_CMD; | 4737 | ioaddr->command_addr = ioaddr->cmd_addr + ATA_REG_CMD; |
4720 | } | 4738 | } |
4721 | 4739 | ||
4722 | static struct ata_probe_ent * | ||
4723 | ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port) | ||
4724 | { | ||
4725 | struct ata_probe_ent *probe_ent; | ||
4726 | |||
4727 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | ||
4728 | if (!probe_ent) { | ||
4729 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", | ||
4730 | kobject_name(&(dev->kobj))); | ||
4731 | return NULL; | ||
4732 | } | ||
4733 | |||
4734 | INIT_LIST_HEAD(&probe_ent->node); | ||
4735 | probe_ent->dev = dev; | ||
4736 | |||
4737 | probe_ent->sht = port->sht; | ||
4738 | probe_ent->host_flags = port->host_flags; | ||
4739 | probe_ent->pio_mask = port->pio_mask; | ||
4740 | probe_ent->mwdma_mask = port->mwdma_mask; | ||
4741 | probe_ent->udma_mask = port->udma_mask; | ||
4742 | probe_ent->port_ops = port->port_ops; | ||
4743 | |||
4744 | return probe_ent; | ||
4745 | } | ||
4746 | |||
4747 | |||
4748 | 4740 | ||
4749 | #ifdef CONFIG_PCI | 4741 | #ifdef CONFIG_PCI |
4750 | 4742 | ||
@@ -4756,256 +4748,6 @@ void ata_pci_host_stop (struct ata_host_set *host_set) | |||
4756 | } | 4748 | } |
4757 | 4749 | ||
4758 | /** | 4750 | /** |
4759 | * ata_pci_init_native_mode - Initialize native-mode driver | ||
4760 | * @pdev: pci device to be initialized | ||
4761 | * @port: array[2] of pointers to port info structures. | ||
4762 | * @ports: bitmap of ports present | ||
4763 | * | ||
4764 | * Utility function which allocates and initializes an | ||
4765 | * ata_probe_ent structure for a standard dual-port | ||
4766 | * PIO-based IDE controller. The returned ata_probe_ent | ||
4767 | * structure can be passed to ata_device_add(). The returned | ||
4768 | * ata_probe_ent structure should then be freed with kfree(). | ||
4769 | * | ||
4770 | * The caller need only pass the address of the primary port, the | ||
4771 | * secondary will be deduced automatically. If the device has non | ||
4772 | * standard secondary port mappings this function can be called twice, | ||
4773 | * once for each interface. | ||
4774 | */ | ||
4775 | |||
4776 | struct ata_probe_ent * | ||
4777 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ports) | ||
4778 | { | ||
4779 | struct ata_probe_ent *probe_ent = | ||
4780 | ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); | ||
4781 | int p = 0; | ||
4782 | |||
4783 | if (!probe_ent) | ||
4784 | return NULL; | ||
4785 | |||
4786 | probe_ent->irq = pdev->irq; | ||
4787 | probe_ent->irq_flags = SA_SHIRQ; | ||
4788 | probe_ent->private_data = port[0]->private_data; | ||
4789 | |||
4790 | if (ports & ATA_PORT_PRIMARY) { | ||
4791 | probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0); | ||
4792 | probe_ent->port[p].altstatus_addr = | ||
4793 | probe_ent->port[p].ctl_addr = | ||
4794 | pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS; | ||
4795 | probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4); | ||
4796 | ata_std_ports(&probe_ent->port[p]); | ||
4797 | p++; | ||
4798 | } | ||
4799 | |||
4800 | if (ports & ATA_PORT_SECONDARY) { | ||
4801 | probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 2); | ||
4802 | probe_ent->port[p].altstatus_addr = | ||
4803 | probe_ent->port[p].ctl_addr = | ||
4804 | pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS; | ||
4805 | probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4) + 8; | ||
4806 | ata_std_ports(&probe_ent->port[p]); | ||
4807 | p++; | ||
4808 | } | ||
4809 | |||
4810 | probe_ent->n_ports = p; | ||
4811 | return probe_ent; | ||
4812 | } | ||
4813 | |||
4814 | static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info *port, int port_num) | ||
4815 | { | ||
4816 | struct ata_probe_ent *probe_ent; | ||
4817 | |||
4818 | probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port); | ||
4819 | if (!probe_ent) | ||
4820 | return NULL; | ||
4821 | |||
4822 | probe_ent->legacy_mode = 1; | ||
4823 | probe_ent->n_ports = 1; | ||
4824 | probe_ent->hard_port_no = port_num; | ||
4825 | probe_ent->private_data = port->private_data; | ||
4826 | |||
4827 | switch(port_num) | ||
4828 | { | ||
4829 | case 0: | ||
4830 | probe_ent->irq = 14; | ||
4831 | probe_ent->port[0].cmd_addr = 0x1f0; | ||
4832 | probe_ent->port[0].altstatus_addr = | ||
4833 | probe_ent->port[0].ctl_addr = 0x3f6; | ||
4834 | break; | ||
4835 | case 1: | ||
4836 | probe_ent->irq = 15; | ||
4837 | probe_ent->port[0].cmd_addr = 0x170; | ||
4838 | probe_ent->port[0].altstatus_addr = | ||
4839 | probe_ent->port[0].ctl_addr = 0x376; | ||
4840 | break; | ||
4841 | } | ||
4842 | probe_ent->port[0].bmdma_addr = pci_resource_start(pdev, 4) + 8 * port_num; | ||
4843 | ata_std_ports(&probe_ent->port[0]); | ||
4844 | return probe_ent; | ||
4845 | } | ||
4846 | |||
4847 | /** | ||
4848 | * ata_pci_init_one - Initialize/register PCI IDE host controller | ||
4849 | * @pdev: Controller to be initialized | ||
4850 | * @port_info: Information from low-level host driver | ||
4851 | * @n_ports: Number of ports attached to host controller | ||
4852 | * | ||
4853 | * This is a helper function which can be called from a driver's | ||
4854 | * xxx_init_one() probe function if the hardware uses traditional | ||
4855 | * IDE taskfile registers. | ||
4856 | * | ||
4857 | * This function calls pci_enable_device(), reserves its register | ||
4858 | * regions, sets the dma mask, enables bus master mode, and calls | ||
4859 | * ata_device_add() | ||
4860 | * | ||
4861 | * LOCKING: | ||
4862 | * Inherited from PCI layer (may sleep). | ||
4863 | * | ||
4864 | * RETURNS: | ||
4865 | * Zero on success, negative on errno-based value on error. | ||
4866 | */ | ||
4867 | |||
4868 | int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | ||
4869 | unsigned int n_ports) | ||
4870 | { | ||
4871 | struct ata_probe_ent *probe_ent = NULL, *probe_ent2 = NULL; | ||
4872 | struct ata_port_info *port[2]; | ||
4873 | u8 tmp8, mask; | ||
4874 | unsigned int legacy_mode = 0; | ||
4875 | int disable_dev_on_err = 1; | ||
4876 | int rc; | ||
4877 | |||
4878 | DPRINTK("ENTER\n"); | ||
4879 | |||
4880 | port[0] = port_info[0]; | ||
4881 | if (n_ports > 1) | ||
4882 | port[1] = port_info[1]; | ||
4883 | else | ||
4884 | port[1] = port[0]; | ||
4885 | |||
4886 | if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0 | ||
4887 | && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { | ||
4888 | /* TODO: What if one channel is in native mode ... */ | ||
4889 | pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); | ||
4890 | mask = (1 << 2) | (1 << 0); | ||
4891 | if ((tmp8 & mask) != mask) | ||
4892 | legacy_mode = (1 << 3); | ||
4893 | } | ||
4894 | |||
4895 | /* FIXME... */ | ||
4896 | if ((!legacy_mode) && (n_ports > 2)) { | ||
4897 | printk(KERN_ERR "ata: BUG: native mode, n_ports > 2\n"); | ||
4898 | n_ports = 2; | ||
4899 | /* For now */ | ||
4900 | } | ||
4901 | |||
4902 | /* FIXME: Really for ATA it isn't safe because the device may be | ||
4903 | multi-purpose and we want to leave it alone if it was already | ||
4904 | enabled. Secondly for shared use as Arjan says we want refcounting | ||
4905 | |||
4906 | Checking dev->is_enabled is insufficient as this is not set at | ||
4907 | boot for the primary video which is BIOS enabled | ||
4908 | */ | ||
4909 | |||
4910 | rc = pci_enable_device(pdev); | ||
4911 | if (rc) | ||
4912 | return rc; | ||
4913 | |||
4914 | rc = pci_request_regions(pdev, DRV_NAME); | ||
4915 | if (rc) { | ||
4916 | disable_dev_on_err = 0; | ||
4917 | goto err_out; | ||
4918 | } | ||
4919 | |||
4920 | /* FIXME: Should use platform specific mappers for legacy port ranges */ | ||
4921 | if (legacy_mode) { | ||
4922 | if (!request_region(0x1f0, 8, "libata")) { | ||
4923 | struct resource *conflict, res; | ||
4924 | res.start = 0x1f0; | ||
4925 | res.end = 0x1f0 + 8 - 1; | ||
4926 | conflict = ____request_resource(&ioport_resource, &res); | ||
4927 | if (!strcmp(conflict->name, "libata")) | ||
4928 | legacy_mode |= (1 << 0); | ||
4929 | else { | ||
4930 | disable_dev_on_err = 0; | ||
4931 | printk(KERN_WARNING "ata: 0x1f0 IDE port busy\n"); | ||
4932 | } | ||
4933 | } else | ||
4934 | legacy_mode |= (1 << 0); | ||
4935 | |||
4936 | if (!request_region(0x170, 8, "libata")) { | ||
4937 | struct resource *conflict, res; | ||
4938 | res.start = 0x170; | ||
4939 | res.end = 0x170 + 8 - 1; | ||
4940 | conflict = ____request_resource(&ioport_resource, &res); | ||
4941 | if (!strcmp(conflict->name, "libata")) | ||
4942 | legacy_mode |= (1 << 1); | ||
4943 | else { | ||
4944 | disable_dev_on_err = 0; | ||
4945 | printk(KERN_WARNING "ata: 0x170 IDE port busy\n"); | ||
4946 | } | ||
4947 | } else | ||
4948 | legacy_mode |= (1 << 1); | ||
4949 | } | ||
4950 | |||
4951 | /* we have legacy mode, but all ports are unavailable */ | ||
4952 | if (legacy_mode == (1 << 3)) { | ||
4953 | rc = -EBUSY; | ||
4954 | goto err_out_regions; | ||
4955 | } | ||
4956 | |||
4957 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | ||
4958 | if (rc) | ||
4959 | goto err_out_regions; | ||
4960 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | ||
4961 | if (rc) | ||
4962 | goto err_out_regions; | ||
4963 | |||
4964 | if (legacy_mode) { | ||
4965 | if (legacy_mode & (1 << 0)) | ||
4966 | probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0); | ||
4967 | if (legacy_mode & (1 << 1)) | ||
4968 | probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1); | ||
4969 | } else { | ||
4970 | if (n_ports == 2) | ||
4971 | probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | ||
4972 | else | ||
4973 | probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY); | ||
4974 | } | ||
4975 | if (!probe_ent && !probe_ent2) { | ||
4976 | rc = -ENOMEM; | ||
4977 | goto err_out_regions; | ||
4978 | } | ||
4979 | |||
4980 | pci_set_master(pdev); | ||
4981 | |||
4982 | /* FIXME: check ata_device_add return */ | ||
4983 | if (legacy_mode) { | ||
4984 | if (legacy_mode & (1 << 0)) | ||
4985 | ata_device_add(probe_ent); | ||
4986 | if (legacy_mode & (1 << 1)) | ||
4987 | ata_device_add(probe_ent2); | ||
4988 | } else | ||
4989 | ata_device_add(probe_ent); | ||
4990 | |||
4991 | kfree(probe_ent); | ||
4992 | kfree(probe_ent2); | ||
4993 | |||
4994 | return 0; | ||
4995 | |||
4996 | err_out_regions: | ||
4997 | if (legacy_mode & (1 << 0)) | ||
4998 | release_region(0x1f0, 8); | ||
4999 | if (legacy_mode & (1 << 1)) | ||
5000 | release_region(0x170, 8); | ||
5001 | pci_release_regions(pdev); | ||
5002 | err_out: | ||
5003 | if (disable_dev_on_err) | ||
5004 | pci_disable_device(pdev); | ||
5005 | return rc; | ||
5006 | } | ||
5007 | |||
5008 | /** | ||
5009 | * ata_pci_remove_one - PCI layer callback for device removal | 4751 | * ata_pci_remove_one - PCI layer callback for device removal |
5010 | * @pdev: PCI device that was removed | 4752 | * @pdev: PCI device that was removed |
5011 | * | 4753 | * |
@@ -5161,10 +4903,18 @@ EXPORT_SYMBOL_GPL(ata_port_probe); | |||
5161 | EXPORT_SYMBOL_GPL(sata_phy_reset); | 4903 | EXPORT_SYMBOL_GPL(sata_phy_reset); |
5162 | EXPORT_SYMBOL_GPL(__sata_phy_reset); | 4904 | EXPORT_SYMBOL_GPL(__sata_phy_reset); |
5163 | EXPORT_SYMBOL_GPL(ata_bus_reset); | 4905 | EXPORT_SYMBOL_GPL(ata_bus_reset); |
4906 | EXPORT_SYMBOL_GPL(ata_std_probeinit); | ||
4907 | EXPORT_SYMBOL_GPL(ata_std_softreset); | ||
4908 | EXPORT_SYMBOL_GPL(sata_std_hardreset); | ||
4909 | EXPORT_SYMBOL_GPL(ata_std_postreset); | ||
4910 | EXPORT_SYMBOL_GPL(ata_std_probe_reset); | ||
4911 | EXPORT_SYMBOL_GPL(ata_drive_probe_reset); | ||
5164 | EXPORT_SYMBOL_GPL(ata_port_disable); | 4912 | EXPORT_SYMBOL_GPL(ata_port_disable); |
5165 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 4913 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
4914 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | ||
5166 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | 4915 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); |
5167 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); | 4916 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); |
4917 | EXPORT_SYMBOL_GPL(ata_scsi_timed_out); | ||
5168 | EXPORT_SYMBOL_GPL(ata_scsi_error); | 4918 | EXPORT_SYMBOL_GPL(ata_scsi_error); |
5169 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); | 4919 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); |
5170 | EXPORT_SYMBOL_GPL(ata_scsi_release); | 4920 | EXPORT_SYMBOL_GPL(ata_scsi_release); |
@@ -5173,6 +4923,8 @@ EXPORT_SYMBOL_GPL(ata_dev_classify); | |||
5173 | EXPORT_SYMBOL_GPL(ata_dev_id_string); | 4923 | EXPORT_SYMBOL_GPL(ata_dev_id_string); |
5174 | EXPORT_SYMBOL_GPL(ata_dev_config); | 4924 | EXPORT_SYMBOL_GPL(ata_dev_config); |
5175 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); | 4925 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
4926 | EXPORT_SYMBOL_GPL(ata_eh_qc_complete); | ||
4927 | EXPORT_SYMBOL_GPL(ata_eh_qc_retry); | ||
5176 | 4928 | ||
5177 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); | 4929 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); |
5178 | EXPORT_SYMBOL_GPL(ata_timing_compute); | 4930 | EXPORT_SYMBOL_GPL(ata_timing_compute); |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 07b1e7cc61df..9d67c6768335 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -151,7 +151,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
151 | struct scsi_sense_hdr sshdr; | 151 | struct scsi_sense_hdr sshdr; |
152 | enum dma_data_direction data_dir; | 152 | enum dma_data_direction data_dir; |
153 | 153 | ||
154 | if (NULL == (void *)arg) | 154 | if (arg == NULL) |
155 | return -EINVAL; | 155 | return -EINVAL; |
156 | 156 | ||
157 | if (copy_from_user(args, arg, sizeof(args))) | 157 | if (copy_from_user(args, arg, sizeof(args))) |
@@ -201,7 +201,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
201 | /* Need code to retrieve data from check condition? */ | 201 | /* Need code to retrieve data from check condition? */ |
202 | 202 | ||
203 | if ((argbuf) | 203 | if ((argbuf) |
204 | && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) | 204 | && copy_to_user(arg + sizeof(args), argbuf, argsize)) |
205 | rc = -EFAULT; | 205 | rc = -EFAULT; |
206 | error: | 206 | error: |
207 | if (argbuf) | 207 | if (argbuf) |
@@ -228,7 +228,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
228 | u8 args[7]; | 228 | u8 args[7]; |
229 | struct scsi_sense_hdr sshdr; | 229 | struct scsi_sense_hdr sshdr; |
230 | 230 | ||
231 | if (NULL == (void *)arg) | 231 | if (arg == NULL) |
232 | return -EINVAL; | 232 | return -EINVAL; |
233 | 233 | ||
234 | if (copy_from_user(args, arg, sizeof(args))) | 234 | if (copy_from_user(args, arg, sizeof(args))) |
@@ -717,6 +717,47 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
717 | } | 717 | } |
718 | 718 | ||
719 | /** | 719 | /** |
720 | * ata_scsi_timed_out - SCSI layer time out callback | ||
721 | * @cmd: timed out SCSI command | ||
722 | * | ||
723 | * Handles SCSI layer timeout. We race with normal completion of | ||
724 | * the qc for @cmd. If the qc is already gone, we lose and let | ||
725 | * the scsi command finish (EH_HANDLED). Otherwise, the qc has | ||
726 | * timed out and EH should be invoked. Prevent ata_qc_complete() | ||
727 | * from finishing it by setting EH_SCHEDULED and return | ||
728 | * EH_NOT_HANDLED. | ||
729 | * | ||
730 | * LOCKING: | ||
731 | * Called from timer context | ||
732 | * | ||
733 | * RETURNS: | ||
734 | * EH_HANDLED or EH_NOT_HANDLED | ||
735 | */ | ||
736 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) | ||
737 | { | ||
738 | struct Scsi_Host *host = cmd->device->host; | ||
739 | struct ata_port *ap = (struct ata_port *) &host->hostdata[0]; | ||
740 | unsigned long flags; | ||
741 | struct ata_queued_cmd *qc; | ||
742 | enum scsi_eh_timer_return ret = EH_HANDLED; | ||
743 | |||
744 | DPRINTK("ENTER\n"); | ||
745 | |||
746 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
747 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
748 | if (qc) { | ||
749 | assert(qc->scsicmd == cmd); | ||
750 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; | ||
751 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
752 | ret = EH_NOT_HANDLED; | ||
753 | } | ||
754 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
755 | |||
756 | DPRINTK("EXIT, ret=%d\n", ret); | ||
757 | return ret; | ||
758 | } | ||
759 | |||
760 | /** | ||
720 | * ata_scsi_error - SCSI layer error handler callback | 761 | * ata_scsi_error - SCSI layer error handler callback |
721 | * @host: SCSI host on which error occurred | 762 | * @host: SCSI host on which error occurred |
722 | * | 763 | * |
@@ -732,23 +773,82 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
732 | int ata_scsi_error(struct Scsi_Host *host) | 773 | int ata_scsi_error(struct Scsi_Host *host) |
733 | { | 774 | { |
734 | struct ata_port *ap; | 775 | struct ata_port *ap; |
776 | unsigned long flags; | ||
735 | 777 | ||
736 | DPRINTK("ENTER\n"); | 778 | DPRINTK("ENTER\n"); |
737 | 779 | ||
738 | ap = (struct ata_port *) &host->hostdata[0]; | 780 | ap = (struct ata_port *) &host->hostdata[0]; |
781 | |||
782 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
783 | assert(!(ap->flags & ATA_FLAG_IN_EH)); | ||
784 | ap->flags |= ATA_FLAG_IN_EH; | ||
785 | assert(ata_qc_from_tag(ap, ap->active_tag) != NULL); | ||
786 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
787 | |||
739 | ap->ops->eng_timeout(ap); | 788 | ap->ops->eng_timeout(ap); |
740 | 789 | ||
741 | /* TODO: this is per-command; when queueing is supported | 790 | assert(host->host_failed == 0 && list_empty(&host->eh_cmd_q)); |
742 | * this code will either change or move to a more | 791 | |
743 | * appropriate place | 792 | scsi_eh_flush_done_q(&ap->eh_done_q); |
744 | */ | 793 | |
745 | host->host_failed--; | 794 | spin_lock_irqsave(&ap->host_set->lock, flags); |
746 | INIT_LIST_HEAD(&host->eh_cmd_q); | 795 | ap->flags &= ~ATA_FLAG_IN_EH; |
796 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
747 | 797 | ||
748 | DPRINTK("EXIT\n"); | 798 | DPRINTK("EXIT\n"); |
749 | return 0; | 799 | return 0; |
750 | } | 800 | } |
751 | 801 | ||
802 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) | ||
803 | { | ||
804 | /* nada */ | ||
805 | } | ||
806 | |||
807 | static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
808 | { | ||
809 | struct ata_port *ap = qc->ap; | ||
810 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
811 | unsigned long flags; | ||
812 | |||
813 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
814 | qc->scsidone = ata_eh_scsidone; | ||
815 | __ata_qc_complete(qc); | ||
816 | assert(!ata_tag_valid(qc->tag)); | ||
817 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
818 | |||
819 | scsi_eh_finish_cmd(scmd, &ap->eh_done_q); | ||
820 | } | ||
821 | |||
822 | /** | ||
823 | * ata_eh_qc_complete - Complete an active ATA command from EH | ||
824 | * @qc: Command to complete | ||
825 | * | ||
826 | * Indicate to the mid and upper layers that an ATA command has | ||
827 | * completed. To be used from EH. | ||
828 | */ | ||
829 | void ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
830 | { | ||
831 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
832 | scmd->retries = scmd->allowed; | ||
833 | __ata_eh_qc_complete(qc); | ||
834 | } | ||
835 | |||
836 | /** | ||
837 | * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH | ||
838 | * @qc: Command to retry | ||
839 | * | ||
840 | * Indicate to the mid and upper layers that an ATA command | ||
841 | * should be retried. To be used from EH. | ||
842 | * | ||
843 | * SCSI midlayer limits the number of retries to scmd->allowed. | ||
844 | * This function might need to adjust scmd->retries for commands | ||
845 | * which get retried due to unrelated NCQ failures. | ||
846 | */ | ||
847 | void ata_eh_qc_retry(struct ata_queued_cmd *qc) | ||
848 | { | ||
849 | __ata_eh_qc_complete(qc); | ||
850 | } | ||
851 | |||
752 | /** | 852 | /** |
753 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command | 853 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command |
754 | * @qc: Storage for translated ATA taskfile | 854 | * @qc: Storage for translated ATA taskfile |
@@ -985,9 +1085,13 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc | |||
985 | if (dev->flags & ATA_DFLAG_LBA) { | 1085 | if (dev->flags & ATA_DFLAG_LBA) { |
986 | tf->flags |= ATA_TFLAG_LBA; | 1086 | tf->flags |= ATA_TFLAG_LBA; |
987 | 1087 | ||
988 | if (dev->flags & ATA_DFLAG_LBA48) { | 1088 | if (lba_28_ok(block, n_block)) { |
989 | if (n_block > (64 * 1024)) | 1089 | /* use LBA28 */ |
990 | goto invalid_fld; | 1090 | tf->command = ATA_CMD_VERIFY; |
1091 | tf->device |= (block >> 24) & 0xf; | ||
1092 | } else if (lba_48_ok(block, n_block)) { | ||
1093 | if (!(dev->flags & ATA_DFLAG_LBA48)) | ||
1094 | goto out_of_range; | ||
991 | 1095 | ||
992 | /* use LBA48 */ | 1096 | /* use LBA48 */ |
993 | tf->flags |= ATA_TFLAG_LBA48; | 1097 | tf->flags |= ATA_TFLAG_LBA48; |
@@ -998,15 +1102,9 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc | |||
998 | tf->hob_lbah = (block >> 40) & 0xff; | 1102 | tf->hob_lbah = (block >> 40) & 0xff; |
999 | tf->hob_lbam = (block >> 32) & 0xff; | 1103 | tf->hob_lbam = (block >> 32) & 0xff; |
1000 | tf->hob_lbal = (block >> 24) & 0xff; | 1104 | tf->hob_lbal = (block >> 24) & 0xff; |
1001 | } else { | 1105 | } else |
1002 | if (n_block > 256) | 1106 | /* request too large even for LBA48 */ |
1003 | goto invalid_fld; | 1107 | goto out_of_range; |
1004 | |||
1005 | /* use LBA28 */ | ||
1006 | tf->command = ATA_CMD_VERIFY; | ||
1007 | |||
1008 | tf->device |= (block >> 24) & 0xf; | ||
1009 | } | ||
1010 | 1108 | ||
1011 | tf->nsect = n_block & 0xff; | 1109 | tf->nsect = n_block & 0xff; |
1012 | 1110 | ||
@@ -1019,8 +1117,8 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc | |||
1019 | /* CHS */ | 1117 | /* CHS */ |
1020 | u32 sect, head, cyl, track; | 1118 | u32 sect, head, cyl, track; |
1021 | 1119 | ||
1022 | if (n_block > 256) | 1120 | if (!lba_28_ok(block, n_block)) |
1023 | goto invalid_fld; | 1121 | goto out_of_range; |
1024 | 1122 | ||
1025 | /* Convert LBA to CHS */ | 1123 | /* Convert LBA to CHS */ |
1026 | track = (u32)block / dev->sectors; | 1124 | track = (u32)block / dev->sectors; |
@@ -1139,9 +1237,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1139 | if (dev->flags & ATA_DFLAG_LBA) { | 1237 | if (dev->flags & ATA_DFLAG_LBA) { |
1140 | tf->flags |= ATA_TFLAG_LBA; | 1238 | tf->flags |= ATA_TFLAG_LBA; |
1141 | 1239 | ||
1142 | if (dev->flags & ATA_DFLAG_LBA48) { | 1240 | if (lba_28_ok(block, n_block)) { |
1143 | /* The request -may- be too large for LBA48. */ | 1241 | /* use LBA28 */ |
1144 | if ((block >> 48) || (n_block > 65536)) | 1242 | tf->device |= (block >> 24) & 0xf; |
1243 | } else if (lba_48_ok(block, n_block)) { | ||
1244 | if (!(dev->flags & ATA_DFLAG_LBA48)) | ||
1145 | goto out_of_range; | 1245 | goto out_of_range; |
1146 | 1246 | ||
1147 | /* use LBA48 */ | 1247 | /* use LBA48 */ |
@@ -1152,15 +1252,9 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1152 | tf->hob_lbah = (block >> 40) & 0xff; | 1252 | tf->hob_lbah = (block >> 40) & 0xff; |
1153 | tf->hob_lbam = (block >> 32) & 0xff; | 1253 | tf->hob_lbam = (block >> 32) & 0xff; |
1154 | tf->hob_lbal = (block >> 24) & 0xff; | 1254 | tf->hob_lbal = (block >> 24) & 0xff; |
1155 | } else { | 1255 | } else |
1156 | /* use LBA28 */ | 1256 | /* request too large even for LBA48 */ |
1157 | 1257 | goto out_of_range; | |
1158 | /* The request -may- be too large for LBA28. */ | ||
1159 | if ((block >> 28) || (n_block > 256)) | ||
1160 | goto out_of_range; | ||
1161 | |||
1162 | tf->device |= (block >> 24) & 0xf; | ||
1163 | } | ||
1164 | 1258 | ||
1165 | if (unlikely(ata_rwcmd_protocol(qc) < 0)) | 1259 | if (unlikely(ata_rwcmd_protocol(qc) < 0)) |
1166 | goto invalid_fld; | 1260 | goto invalid_fld; |
@@ -1178,7 +1272,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1178 | u32 sect, head, cyl, track; | 1272 | u32 sect, head, cyl, track; |
1179 | 1273 | ||
1180 | /* The request -may- be too large for CHS addressing. */ | 1274 | /* The request -may- be too large for CHS addressing. */ |
1181 | if ((block >> 28) || (n_block > 256)) | 1275 | if (!lba_28_ok(block, n_block)) |
1182 | goto out_of_range; | 1276 | goto out_of_range; |
1183 | 1277 | ||
1184 | if (unlikely(ata_rwcmd_protocol(qc) < 0)) | 1278 | if (unlikely(ata_rwcmd_protocol(qc) < 0)) |
@@ -1225,7 +1319,7 @@ nothing_to_do: | |||
1225 | return 1; | 1319 | return 1; |
1226 | } | 1320 | } |
1227 | 1321 | ||
1228 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) | 1322 | static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) |
1229 | { | 1323 | { |
1230 | struct scsi_cmnd *cmd = qc->scsicmd; | 1324 | struct scsi_cmnd *cmd = qc->scsicmd; |
1231 | u8 *cdb = cmd->cmnd; | 1325 | u8 *cdb = cmd->cmnd; |
@@ -1262,7 +1356,7 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1262 | 1356 | ||
1263 | qc->scsidone(cmd); | 1357 | qc->scsidone(cmd); |
1264 | 1358 | ||
1265 | return 0; | 1359 | ata_qc_free(qc); |
1266 | } | 1360 | } |
1267 | 1361 | ||
1268 | /** | 1362 | /** |
@@ -1328,8 +1422,9 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev, | |||
1328 | goto early_finish; | 1422 | goto early_finish; |
1329 | 1423 | ||
1330 | /* select device, send command to hardware */ | 1424 | /* select device, send command to hardware */ |
1331 | if (ata_qc_issue(qc)) | 1425 | qc->err_mask = ata_qc_issue(qc); |
1332 | goto err_did; | 1426 | if (qc->err_mask) |
1427 | ata_qc_complete(qc); | ||
1333 | 1428 | ||
1334 | VPRINTK("EXIT\n"); | 1429 | VPRINTK("EXIT\n"); |
1335 | return; | 1430 | return; |
@@ -2013,7 +2108,7 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 | |||
2013 | done(cmd); | 2108 | done(cmd); |
2014 | } | 2109 | } |
2015 | 2110 | ||
2016 | static int atapi_sense_complete(struct ata_queued_cmd *qc) | 2111 | static void atapi_sense_complete(struct ata_queued_cmd *qc) |
2017 | { | 2112 | { |
2018 | if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) | 2113 | if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) |
2019 | /* FIXME: not quite right; we don't want the | 2114 | /* FIXME: not quite right; we don't want the |
@@ -2024,7 +2119,7 @@ static int atapi_sense_complete(struct ata_queued_cmd *qc) | |||
2024 | ata_gen_ata_desc_sense(qc); | 2119 | ata_gen_ata_desc_sense(qc); |
2025 | 2120 | ||
2026 | qc->scsidone(qc->scsicmd); | 2121 | qc->scsidone(qc->scsicmd); |
2027 | return 0; | 2122 | ata_qc_free(qc); |
2028 | } | 2123 | } |
2029 | 2124 | ||
2030 | /* is it pointless to prefer PIO for "safety reasons"? */ | 2125 | /* is it pointless to prefer PIO for "safety reasons"? */ |
@@ -2073,15 +2168,14 @@ static void atapi_request_sense(struct ata_queued_cmd *qc) | |||
2073 | 2168 | ||
2074 | qc->complete_fn = atapi_sense_complete; | 2169 | qc->complete_fn = atapi_sense_complete; |
2075 | 2170 | ||
2076 | if (ata_qc_issue(qc)) { | 2171 | qc->err_mask = ata_qc_issue(qc); |
2077 | qc->err_mask |= AC_ERR_OTHER; | 2172 | if (qc->err_mask) |
2078 | ata_qc_complete(qc); | 2173 | ata_qc_complete(qc); |
2079 | } | ||
2080 | 2174 | ||
2081 | DPRINTK("EXIT\n"); | 2175 | DPRINTK("EXIT\n"); |
2082 | } | 2176 | } |
2083 | 2177 | ||
2084 | static int atapi_qc_complete(struct ata_queued_cmd *qc) | 2178 | static void atapi_qc_complete(struct ata_queued_cmd *qc) |
2085 | { | 2179 | { |
2086 | struct scsi_cmnd *cmd = qc->scsicmd; | 2180 | struct scsi_cmnd *cmd = qc->scsicmd; |
2087 | unsigned int err_mask = qc->err_mask; | 2181 | unsigned int err_mask = qc->err_mask; |
@@ -2091,7 +2185,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc) | |||
2091 | if (unlikely(err_mask & AC_ERR_DEV)) { | 2185 | if (unlikely(err_mask & AC_ERR_DEV)) { |
2092 | cmd->result = SAM_STAT_CHECK_CONDITION; | 2186 | cmd->result = SAM_STAT_CHECK_CONDITION; |
2093 | atapi_request_sense(qc); | 2187 | atapi_request_sense(qc); |
2094 | return 1; | 2188 | return; |
2095 | } | 2189 | } |
2096 | 2190 | ||
2097 | else if (unlikely(err_mask)) | 2191 | else if (unlikely(err_mask)) |
@@ -2131,7 +2225,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc) | |||
2131 | } | 2225 | } |
2132 | 2226 | ||
2133 | qc->scsidone(cmd); | 2227 | qc->scsidone(cmd); |
2134 | return 0; | 2228 | ata_qc_free(qc); |
2135 | } | 2229 | } |
2136 | /** | 2230 | /** |
2137 | * atapi_xlat - Initialize PACKET taskfile | 2231 | * atapi_xlat - Initialize PACKET taskfile |
@@ -2517,7 +2611,8 @@ out_unlock: | |||
2517 | 2611 | ||
2518 | /** | 2612 | /** |
2519 | * ata_scsi_simulate - simulate SCSI command on ATA device | 2613 | * ata_scsi_simulate - simulate SCSI command on ATA device |
2520 | * @id: current IDENTIFY data for target device. | 2614 | * @ap: port the device is connected to |
2615 | * @dev: the target device | ||
2521 | * @cmd: SCSI command being sent to device. | 2616 | * @cmd: SCSI command being sent to device. |
2522 | * @done: SCSI command completion function. | 2617 | * @done: SCSI command completion function. |
2523 | * | 2618 | * |
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index e03ce48b7b4b..1cd071a32e93 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -45,7 +45,8 @@ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | |||
45 | struct ata_device *dev); | 45 | struct ata_device *dev); |
46 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); | 46 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); |
47 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 47 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
48 | extern int ata_qc_issue(struct ata_queued_cmd *qc); | 48 | extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc); |
49 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | ||
49 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 50 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |
50 | extern void ata_dev_select(struct ata_port *ap, unsigned int device, | 51 | extern void ata_dev_select(struct ata_port *ap, unsigned int device, |
51 | unsigned int wait, unsigned int can_sleep); | 52 | unsigned int wait, unsigned int can_sleep); |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index e8df0c9ec1e6..d0ad3ebe9685 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -131,7 +131,7 @@ static void adma_host_stop(struct ata_host_set *host_set); | |||
131 | static void adma_port_stop(struct ata_port *ap); | 131 | static void adma_port_stop(struct ata_port *ap); |
132 | static void adma_phy_reset(struct ata_port *ap); | 132 | static void adma_phy_reset(struct ata_port *ap); |
133 | static void adma_qc_prep(struct ata_queued_cmd *qc); | 133 | static void adma_qc_prep(struct ata_queued_cmd *qc); |
134 | static int adma_qc_issue(struct ata_queued_cmd *qc); | 134 | static unsigned int adma_qc_issue(struct ata_queued_cmd *qc); |
135 | static int adma_check_atapi_dma(struct ata_queued_cmd *qc); | 135 | static int adma_check_atapi_dma(struct ata_queued_cmd *qc); |
136 | static void adma_bmdma_stop(struct ata_queued_cmd *qc); | 136 | static void adma_bmdma_stop(struct ata_queued_cmd *qc); |
137 | static u8 adma_bmdma_status(struct ata_port *ap); | 137 | static u8 adma_bmdma_status(struct ata_port *ap); |
@@ -143,6 +143,7 @@ static struct scsi_host_template adma_ata_sht = { | |||
143 | .name = DRV_NAME, | 143 | .name = DRV_NAME, |
144 | .ioctl = ata_scsi_ioctl, | 144 | .ioctl = ata_scsi_ioctl, |
145 | .queuecommand = ata_scsi_queuecmd, | 145 | .queuecommand = ata_scsi_queuecmd, |
146 | .eh_timed_out = ata_scsi_timed_out, | ||
146 | .eh_strategy_handler = ata_scsi_error, | 147 | .eh_strategy_handler = ata_scsi_error, |
147 | .can_queue = ATA_DEF_QUEUE, | 148 | .can_queue = ATA_DEF_QUEUE, |
148 | .this_id = ATA_SHT_THIS_ID, | 149 | .this_id = ATA_SHT_THIS_ID, |
@@ -419,7 +420,7 @@ static inline void adma_packet_start(struct ata_queued_cmd *qc) | |||
419 | writew(aPIOMD4 | aGO, chan + ADMA_CONTROL); | 420 | writew(aPIOMD4 | aGO, chan + ADMA_CONTROL); |
420 | } | 421 | } |
421 | 422 | ||
422 | static int adma_qc_issue(struct ata_queued_cmd *qc) | 423 | static unsigned int adma_qc_issue(struct ata_queued_cmd *qc) |
423 | { | 424 | { |
424 | struct adma_port_priv *pp = qc->ap->private_data; | 425 | struct adma_port_priv *pp = qc->ap->private_data; |
425 | 426 | ||
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index 6fddf17a3b70..6c80527ddd21 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | 38 | ||
39 | #define DRV_NAME "sata_mv" | 39 | #define DRV_NAME "sata_mv" |
40 | #define DRV_VERSION "0.5" | 40 | #define DRV_VERSION "0.6" |
41 | 41 | ||
42 | enum { | 42 | enum { |
43 | /* BAR's are enumerated in terms of pci_resource_start() terms */ | 43 | /* BAR's are enumerated in terms of pci_resource_start() terms */ |
@@ -228,7 +228,9 @@ enum { | |||
228 | MV_HP_ERRATA_50XXB2 = (1 << 2), | 228 | MV_HP_ERRATA_50XXB2 = (1 << 2), |
229 | MV_HP_ERRATA_60X1B2 = (1 << 3), | 229 | MV_HP_ERRATA_60X1B2 = (1 << 3), |
230 | MV_HP_ERRATA_60X1C0 = (1 << 4), | 230 | MV_HP_ERRATA_60X1C0 = (1 << 4), |
231 | MV_HP_50XX = (1 << 5), | 231 | MV_HP_ERRATA_XX42A0 = (1 << 5), |
232 | MV_HP_50XX = (1 << 6), | ||
233 | MV_HP_GEN_IIE = (1 << 7), | ||
232 | 234 | ||
233 | /* Port private flags (pp_flags) */ | 235 | /* Port private flags (pp_flags) */ |
234 | MV_PP_FLAG_EDMA_EN = (1 << 0), | 236 | MV_PP_FLAG_EDMA_EN = (1 << 0), |
@@ -237,6 +239,9 @@ enum { | |||
237 | 239 | ||
238 | #define IS_50XX(hpriv) ((hpriv)->hp_flags & MV_HP_50XX) | 240 | #define IS_50XX(hpriv) ((hpriv)->hp_flags & MV_HP_50XX) |
239 | #define IS_60XX(hpriv) (((hpriv)->hp_flags & MV_HP_50XX) == 0) | 241 | #define IS_60XX(hpriv) (((hpriv)->hp_flags & MV_HP_50XX) == 0) |
242 | #define IS_GEN_I(hpriv) IS_50XX(hpriv) | ||
243 | #define IS_GEN_II(hpriv) IS_60XX(hpriv) | ||
244 | #define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) | ||
240 | 245 | ||
241 | enum { | 246 | enum { |
242 | /* Our DMA boundary is determined by an ePRD being unable to handle | 247 | /* Our DMA boundary is determined by an ePRD being unable to handle |
@@ -255,6 +260,8 @@ enum chip_type { | |||
255 | chip_5080, | 260 | chip_5080, |
256 | chip_604x, | 261 | chip_604x, |
257 | chip_608x, | 262 | chip_608x, |
263 | chip_6042, | ||
264 | chip_7042, | ||
258 | }; | 265 | }; |
259 | 266 | ||
260 | /* Command ReQuest Block: 32B */ | 267 | /* Command ReQuest Block: 32B */ |
@@ -265,6 +272,14 @@ struct mv_crqb { | |||
265 | u16 ata_cmd[11]; | 272 | u16 ata_cmd[11]; |
266 | }; | 273 | }; |
267 | 274 | ||
275 | struct mv_crqb_iie { | ||
276 | u32 addr; | ||
277 | u32 addr_hi; | ||
278 | u32 flags; | ||
279 | u32 len; | ||
280 | u32 ata_cmd[4]; | ||
281 | }; | ||
282 | |||
268 | /* Command ResPonse Block: 8B */ | 283 | /* Command ResPonse Block: 8B */ |
269 | struct mv_crpb { | 284 | struct mv_crpb { |
270 | u16 id; | 285 | u16 id; |
@@ -328,7 +343,8 @@ static void mv_host_stop(struct ata_host_set *host_set); | |||
328 | static int mv_port_start(struct ata_port *ap); | 343 | static int mv_port_start(struct ata_port *ap); |
329 | static void mv_port_stop(struct ata_port *ap); | 344 | static void mv_port_stop(struct ata_port *ap); |
330 | static void mv_qc_prep(struct ata_queued_cmd *qc); | 345 | static void mv_qc_prep(struct ata_queued_cmd *qc); |
331 | static int mv_qc_issue(struct ata_queued_cmd *qc); | 346 | static void mv_qc_prep_iie(struct ata_queued_cmd *qc); |
347 | static unsigned int mv_qc_issue(struct ata_queued_cmd *qc); | ||
332 | static irqreturn_t mv_interrupt(int irq, void *dev_instance, | 348 | static irqreturn_t mv_interrupt(int irq, void *dev_instance, |
333 | struct pt_regs *regs); | 349 | struct pt_regs *regs); |
334 | static void mv_eng_timeout(struct ata_port *ap); | 350 | static void mv_eng_timeout(struct ata_port *ap); |
@@ -362,6 +378,7 @@ static struct scsi_host_template mv_sht = { | |||
362 | .name = DRV_NAME, | 378 | .name = DRV_NAME, |
363 | .ioctl = ata_scsi_ioctl, | 379 | .ioctl = ata_scsi_ioctl, |
364 | .queuecommand = ata_scsi_queuecmd, | 380 | .queuecommand = ata_scsi_queuecmd, |
381 | .eh_timed_out = ata_scsi_timed_out, | ||
365 | .eh_strategy_handler = ata_scsi_error, | 382 | .eh_strategy_handler = ata_scsi_error, |
366 | .can_queue = MV_USE_Q_DEPTH, | 383 | .can_queue = MV_USE_Q_DEPTH, |
367 | .this_id = ATA_SHT_THIS_ID, | 384 | .this_id = ATA_SHT_THIS_ID, |
@@ -430,6 +447,33 @@ static const struct ata_port_operations mv6_ops = { | |||
430 | .host_stop = mv_host_stop, | 447 | .host_stop = mv_host_stop, |
431 | }; | 448 | }; |
432 | 449 | ||
450 | static const struct ata_port_operations mv_iie_ops = { | ||
451 | .port_disable = ata_port_disable, | ||
452 | |||
453 | .tf_load = ata_tf_load, | ||
454 | .tf_read = ata_tf_read, | ||
455 | .check_status = ata_check_status, | ||
456 | .exec_command = ata_exec_command, | ||
457 | .dev_select = ata_std_dev_select, | ||
458 | |||
459 | .phy_reset = mv_phy_reset, | ||
460 | |||
461 | .qc_prep = mv_qc_prep_iie, | ||
462 | .qc_issue = mv_qc_issue, | ||
463 | |||
464 | .eng_timeout = mv_eng_timeout, | ||
465 | |||
466 | .irq_handler = mv_interrupt, | ||
467 | .irq_clear = mv_irq_clear, | ||
468 | |||
469 | .scr_read = mv_scr_read, | ||
470 | .scr_write = mv_scr_write, | ||
471 | |||
472 | .port_start = mv_port_start, | ||
473 | .port_stop = mv_port_stop, | ||
474 | .host_stop = mv_host_stop, | ||
475 | }; | ||
476 | |||
433 | static const struct ata_port_info mv_port_info[] = { | 477 | static const struct ata_port_info mv_port_info[] = { |
434 | { /* chip_504x */ | 478 | { /* chip_504x */ |
435 | .sht = &mv_sht, | 479 | .sht = &mv_sht, |
@@ -467,6 +511,21 @@ static const struct ata_port_info mv_port_info[] = { | |||
467 | .udma_mask = 0x7f, /* udma0-6 */ | 511 | .udma_mask = 0x7f, /* udma0-6 */ |
468 | .port_ops = &mv6_ops, | 512 | .port_ops = &mv6_ops, |
469 | }, | 513 | }, |
514 | { /* chip_6042 */ | ||
515 | .sht = &mv_sht, | ||
516 | .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS), | ||
517 | .pio_mask = 0x1f, /* pio0-4 */ | ||
518 | .udma_mask = 0x7f, /* udma0-6 */ | ||
519 | .port_ops = &mv_iie_ops, | ||
520 | }, | ||
521 | { /* chip_7042 */ | ||
522 | .sht = &mv_sht, | ||
523 | .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS | | ||
524 | MV_FLAG_DUAL_HC), | ||
525 | .pio_mask = 0x1f, /* pio0-4 */ | ||
526 | .udma_mask = 0x7f, /* udma0-6 */ | ||
527 | .port_ops = &mv_iie_ops, | ||
528 | }, | ||
470 | }; | 529 | }; |
471 | 530 | ||
472 | static const struct pci_device_id mv_pci_tbl[] = { | 531 | static const struct pci_device_id mv_pci_tbl[] = { |
@@ -477,6 +536,7 @@ static const struct pci_device_id mv_pci_tbl[] = { | |||
477 | 536 | ||
478 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x}, | 537 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x}, |
479 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x}, | 538 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x}, |
539 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6042), 0, 0, chip_6042}, | ||
480 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x}, | 540 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x}, |
481 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x}, | 541 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x}, |
482 | 542 | ||
@@ -773,6 +833,33 @@ static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) | |||
773 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); | 833 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); |
774 | } | 834 | } |
775 | 835 | ||
836 | static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio) | ||
837 | { | ||
838 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); | ||
839 | |||
840 | /* set up non-NCQ EDMA configuration */ | ||
841 | cfg &= ~0x1f; /* clear queue depth */ | ||
842 | cfg &= ~EDMA_CFG_NCQ; /* clear NCQ mode */ | ||
843 | cfg &= ~(1 << 9); /* disable equeue */ | ||
844 | |||
845 | if (IS_GEN_I(hpriv)) | ||
846 | cfg |= (1 << 8); /* enab config burst size mask */ | ||
847 | |||
848 | else if (IS_GEN_II(hpriv)) | ||
849 | cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; | ||
850 | |||
851 | else if (IS_GEN_IIE(hpriv)) { | ||
852 | cfg |= (1 << 23); /* dis RX PM port mask */ | ||
853 | cfg &= ~(1 << 16); /* dis FIS-based switching (for now) */ | ||
854 | cfg &= ~(1 << 19); /* dis 128-entry queue (for now?) */ | ||
855 | cfg |= (1 << 18); /* enab early completion */ | ||
856 | cfg |= (1 << 17); /* enab host q cache */ | ||
857 | cfg |= (1 << 22); /* enab cutthrough */ | ||
858 | } | ||
859 | |||
860 | writelfl(cfg, port_mmio + EDMA_CFG_OFS); | ||
861 | } | ||
862 | |||
776 | /** | 863 | /** |
777 | * mv_port_start - Port specific init/start routine. | 864 | * mv_port_start - Port specific init/start routine. |
778 | * @ap: ATA channel to manipulate | 865 | * @ap: ATA channel to manipulate |
@@ -786,6 +873,7 @@ static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) | |||
786 | static int mv_port_start(struct ata_port *ap) | 873 | static int mv_port_start(struct ata_port *ap) |
787 | { | 874 | { |
788 | struct device *dev = ap->host_set->dev; | 875 | struct device *dev = ap->host_set->dev; |
876 | struct mv_host_priv *hpriv = ap->host_set->private_data; | ||
789 | struct mv_port_priv *pp; | 877 | struct mv_port_priv *pp; |
790 | void __iomem *port_mmio = mv_ap_base(ap); | 878 | void __iomem *port_mmio = mv_ap_base(ap); |
791 | void *mem; | 879 | void *mem; |
@@ -829,17 +917,26 @@ static int mv_port_start(struct ata_port *ap) | |||
829 | pp->sg_tbl = mem; | 917 | pp->sg_tbl = mem; |
830 | pp->sg_tbl_dma = mem_dma; | 918 | pp->sg_tbl_dma = mem_dma; |
831 | 919 | ||
832 | writelfl(EDMA_CFG_Q_DEPTH | EDMA_CFG_RD_BRST_EXT | | 920 | mv_edma_cfg(hpriv, port_mmio); |
833 | EDMA_CFG_WR_BUFF_LEN, port_mmio + EDMA_CFG_OFS); | ||
834 | 921 | ||
835 | writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); | 922 | writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); |
836 | writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK, | 923 | writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK, |
837 | port_mmio + EDMA_REQ_Q_IN_PTR_OFS); | 924 | port_mmio + EDMA_REQ_Q_IN_PTR_OFS); |
838 | 925 | ||
839 | writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); | 926 | if (hpriv->hp_flags & MV_HP_ERRATA_XX42A0) |
840 | writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); | 927 | writelfl(pp->crqb_dma & 0xffffffff, |
928 | port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); | ||
929 | else | ||
930 | writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); | ||
841 | 931 | ||
842 | writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); | 932 | writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); |
933 | |||
934 | if (hpriv->hp_flags & MV_HP_ERRATA_XX42A0) | ||
935 | writelfl(pp->crpb_dma & 0xffffffff, | ||
936 | port_mmio + EDMA_RSP_Q_IN_PTR_OFS); | ||
937 | else | ||
938 | writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); | ||
939 | |||
843 | writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK, | 940 | writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK, |
844 | port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); | 941 | port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); |
845 | 942 | ||
@@ -960,9 +1057,8 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
960 | struct ata_taskfile *tf; | 1057 | struct ata_taskfile *tf; |
961 | u16 flags = 0; | 1058 | u16 flags = 0; |
962 | 1059 | ||
963 | if (ATA_PROT_DMA != qc->tf.protocol) { | 1060 | if (ATA_PROT_DMA != qc->tf.protocol) |
964 | return; | 1061 | return; |
965 | } | ||
966 | 1062 | ||
967 | /* the req producer index should be the same as we remember it */ | 1063 | /* the req producer index should be the same as we remember it */ |
968 | assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> | 1064 | assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> |
@@ -971,9 +1067,8 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
971 | 1067 | ||
972 | /* Fill in command request block | 1068 | /* Fill in command request block |
973 | */ | 1069 | */ |
974 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) { | 1070 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) |
975 | flags |= CRQB_FLAG_READ; | 1071 | flags |= CRQB_FLAG_READ; |
976 | } | ||
977 | assert(MV_MAX_Q_DEPTH > qc->tag); | 1072 | assert(MV_MAX_Q_DEPTH > qc->tag); |
978 | flags |= qc->tag << CRQB_TAG_SHIFT; | 1073 | flags |= qc->tag << CRQB_TAG_SHIFT; |
979 | 1074 | ||
@@ -1028,9 +1123,76 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1028 | mv_crqb_pack_cmd(cw++, tf->device, ATA_REG_DEVICE, 0); | 1123 | mv_crqb_pack_cmd(cw++, tf->device, ATA_REG_DEVICE, 0); |
1029 | mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */ | 1124 | mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */ |
1030 | 1125 | ||
1031 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) { | 1126 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) |
1127 | return; | ||
1128 | mv_fill_sg(qc); | ||
1129 | } | ||
1130 | |||
1131 | /** | ||
1132 | * mv_qc_prep_iie - Host specific command preparation. | ||
1133 | * @qc: queued command to prepare | ||
1134 | * | ||
1135 | * This routine simply redirects to the general purpose routine | ||
1136 | * if command is not DMA. Else, it handles prep of the CRQB | ||
1137 | * (command request block), does some sanity checking, and calls | ||
1138 | * the SG load routine. | ||
1139 | * | ||
1140 | * LOCKING: | ||
1141 | * Inherited from caller. | ||
1142 | */ | ||
1143 | static void mv_qc_prep_iie(struct ata_queued_cmd *qc) | ||
1144 | { | ||
1145 | struct ata_port *ap = qc->ap; | ||
1146 | struct mv_port_priv *pp = ap->private_data; | ||
1147 | struct mv_crqb_iie *crqb; | ||
1148 | struct ata_taskfile *tf; | ||
1149 | u32 flags = 0; | ||
1150 | |||
1151 | if (ATA_PROT_DMA != qc->tf.protocol) | ||
1152 | return; | ||
1153 | |||
1154 | /* the req producer index should be the same as we remember it */ | ||
1155 | assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> | ||
1156 | EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == | ||
1157 | pp->req_producer); | ||
1158 | |||
1159 | /* Fill in Gen IIE command request block | ||
1160 | */ | ||
1161 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) | ||
1162 | flags |= CRQB_FLAG_READ; | ||
1163 | |||
1164 | assert(MV_MAX_Q_DEPTH > qc->tag); | ||
1165 | flags |= qc->tag << CRQB_TAG_SHIFT; | ||
1166 | |||
1167 | crqb = (struct mv_crqb_iie *) &pp->crqb[pp->req_producer]; | ||
1168 | crqb->addr = cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); | ||
1169 | crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); | ||
1170 | crqb->flags = cpu_to_le32(flags); | ||
1171 | |||
1172 | tf = &qc->tf; | ||
1173 | crqb->ata_cmd[0] = cpu_to_le32( | ||
1174 | (tf->command << 16) | | ||
1175 | (tf->feature << 24) | ||
1176 | ); | ||
1177 | crqb->ata_cmd[1] = cpu_to_le32( | ||
1178 | (tf->lbal << 0) | | ||
1179 | (tf->lbam << 8) | | ||
1180 | (tf->lbah << 16) | | ||
1181 | (tf->device << 24) | ||
1182 | ); | ||
1183 | crqb->ata_cmd[2] = cpu_to_le32( | ||
1184 | (tf->hob_lbal << 0) | | ||
1185 | (tf->hob_lbam << 8) | | ||
1186 | (tf->hob_lbah << 16) | | ||
1187 | (tf->hob_feature << 24) | ||
1188 | ); | ||
1189 | crqb->ata_cmd[3] = cpu_to_le32( | ||
1190 | (tf->nsect << 0) | | ||
1191 | (tf->hob_nsect << 8) | ||
1192 | ); | ||
1193 | |||
1194 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
1032 | return; | 1195 | return; |
1033 | } | ||
1034 | mv_fill_sg(qc); | 1196 | mv_fill_sg(qc); |
1035 | } | 1197 | } |
1036 | 1198 | ||
@@ -1046,7 +1208,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1046 | * LOCKING: | 1208 | * LOCKING: |
1047 | * Inherited from caller. | 1209 | * Inherited from caller. |
1048 | */ | 1210 | */ |
1049 | static int mv_qc_issue(struct ata_queued_cmd *qc) | 1211 | static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) |
1050 | { | 1212 | { |
1051 | void __iomem *port_mmio = mv_ap_base(qc->ap); | 1213 | void __iomem *port_mmio = mv_ap_base(qc->ap); |
1052 | struct mv_port_priv *pp = qc->ap->private_data; | 1214 | struct mv_port_priv *pp = qc->ap->private_data; |
@@ -1680,6 +1842,12 @@ static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, | |||
1680 | m2 |= hpriv->signal[port].pre; | 1842 | m2 |= hpriv->signal[port].pre; |
1681 | m2 &= ~(1 << 16); | 1843 | m2 &= ~(1 << 16); |
1682 | 1844 | ||
1845 | /* according to mvSata 3.6.1, some IIE values are fixed */ | ||
1846 | if (IS_GEN_IIE(hpriv)) { | ||
1847 | m2 &= ~0xC30FF01F; | ||
1848 | m2 |= 0x0000900F; | ||
1849 | } | ||
1850 | |||
1683 | writel(m2, port_mmio + PHY_MODE2); | 1851 | writel(m2, port_mmio + PHY_MODE2); |
1684 | } | 1852 | } |
1685 | 1853 | ||
@@ -1845,7 +2013,6 @@ static void mv_phy_reset(struct ata_port *ap) | |||
1845 | static void mv_eng_timeout(struct ata_port *ap) | 2013 | static void mv_eng_timeout(struct ata_port *ap) |
1846 | { | 2014 | { |
1847 | struct ata_queued_cmd *qc; | 2015 | struct ata_queued_cmd *qc; |
1848 | unsigned long flags; | ||
1849 | 2016 | ||
1850 | printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id); | 2017 | printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id); |
1851 | DPRINTK("All regs @ start of eng_timeout\n"); | 2018 | DPRINTK("All regs @ start of eng_timeout\n"); |
@@ -1860,22 +2027,8 @@ static void mv_eng_timeout(struct ata_port *ap) | |||
1860 | mv_err_intr(ap); | 2027 | mv_err_intr(ap); |
1861 | mv_stop_and_reset(ap); | 2028 | mv_stop_and_reset(ap); |
1862 | 2029 | ||
1863 | if (!qc) { | 2030 | qc->err_mask |= AC_ERR_TIMEOUT; |
1864 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | 2031 | ata_eh_qc_complete(qc); |
1865 | ap->id); | ||
1866 | } else { | ||
1867 | /* hack alert! We cannot use the supplied completion | ||
1868 | * function from inside the ->eh_strategy_handler() thread. | ||
1869 | * libata is the only user of ->eh_strategy_handler() in | ||
1870 | * any kernel, so the default scsi_done() assumes it is | ||
1871 | * not being called from the SCSI EH. | ||
1872 | */ | ||
1873 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1874 | qc->scsidone = scsi_finish_command; | ||
1875 | qc->err_mask |= AC_ERR_OTHER; | ||
1876 | ata_qc_complete(qc); | ||
1877 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1878 | } | ||
1879 | } | 2032 | } |
1880 | 2033 | ||
1881 | /** | 2034 | /** |
@@ -1994,6 +2147,27 @@ static int mv_chip_id(struct pci_dev *pdev, struct mv_host_priv *hpriv, | |||
1994 | } | 2147 | } |
1995 | break; | 2148 | break; |
1996 | 2149 | ||
2150 | case chip_7042: | ||
2151 | case chip_6042: | ||
2152 | hpriv->ops = &mv6xxx_ops; | ||
2153 | |||
2154 | hp_flags |= MV_HP_GEN_IIE; | ||
2155 | |||
2156 | switch (rev_id) { | ||
2157 | case 0x0: | ||
2158 | hp_flags |= MV_HP_ERRATA_XX42A0; | ||
2159 | break; | ||
2160 | case 0x1: | ||
2161 | hp_flags |= MV_HP_ERRATA_60X1C0; | ||
2162 | break; | ||
2163 | default: | ||
2164 | dev_printk(KERN_WARNING, &pdev->dev, | ||
2165 | "Applying 60X1C0 workarounds to unknown rev\n"); | ||
2166 | hp_flags |= MV_HP_ERRATA_60X1C0; | ||
2167 | break; | ||
2168 | } | ||
2169 | break; | ||
2170 | |||
1997 | default: | 2171 | default: |
1998 | printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); | 2172 | printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); |
1999 | return 1; | 2173 | return 1; |
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index bbbb55eeb73a..cdfeb9aa600b 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c | |||
@@ -229,6 +229,7 @@ static struct scsi_host_template nv_sht = { | |||
229 | .name = DRV_NAME, | 229 | .name = DRV_NAME, |
230 | .ioctl = ata_scsi_ioctl, | 230 | .ioctl = ata_scsi_ioctl, |
231 | .queuecommand = ata_scsi_queuecmd, | 231 | .queuecommand = ata_scsi_queuecmd, |
232 | .eh_timed_out = ata_scsi_timed_out, | ||
232 | .eh_strategy_handler = ata_scsi_error, | 233 | .eh_strategy_handler = ata_scsi_error, |
233 | .can_queue = ATA_DEF_QUEUE, | 234 | .can_queue = ATA_DEF_QUEUE, |
234 | .this_id = ATA_SHT_THIS_ID, | 235 | .this_id = ATA_SHT_THIS_ID, |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index b0b0a69b3563..c9dfd9370919 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include "sata_promise.h" | 46 | #include "sata_promise.h" |
47 | 47 | ||
48 | #define DRV_NAME "sata_promise" | 48 | #define DRV_NAME "sata_promise" |
49 | #define DRV_VERSION "1.03" | 49 | #define DRV_VERSION "1.04" |
50 | 50 | ||
51 | 51 | ||
52 | enum { | 52 | enum { |
@@ -58,6 +58,7 @@ enum { | |||
58 | PDC_GLOBAL_CTL = 0x48, /* Global control/status (per port) */ | 58 | PDC_GLOBAL_CTL = 0x48, /* Global control/status (per port) */ |
59 | PDC_CTLSTAT = 0x60, /* IDE control and status (per port) */ | 59 | PDC_CTLSTAT = 0x60, /* IDE control and status (per port) */ |
60 | PDC_SATA_PLUG_CSR = 0x6C, /* SATA Plug control/status reg */ | 60 | PDC_SATA_PLUG_CSR = 0x6C, /* SATA Plug control/status reg */ |
61 | PDC2_SATA_PLUG_CSR = 0x60, /* SATAII Plug control/status reg */ | ||
61 | PDC_SLEW_CTL = 0x470, /* slew rate control reg */ | 62 | PDC_SLEW_CTL = 0x470, /* slew rate control reg */ |
62 | 63 | ||
63 | PDC_ERR_MASK = (1<<19) | (1<<20) | (1<<21) | (1<<22) | | 64 | PDC_ERR_MASK = (1<<19) | (1<<20) | (1<<21) | (1<<22) | |
@@ -67,8 +68,10 @@ enum { | |||
67 | board_20319 = 1, /* FastTrak S150 TX4 */ | 68 | board_20319 = 1, /* FastTrak S150 TX4 */ |
68 | board_20619 = 2, /* FastTrak TX4000 */ | 69 | board_20619 = 2, /* FastTrak TX4000 */ |
69 | board_20771 = 3, /* FastTrak TX2300 */ | 70 | board_20771 = 3, /* FastTrak TX2300 */ |
71 | board_2057x = 4, /* SATAII150 Tx2plus */ | ||
72 | board_40518 = 5, /* SATAII150 Tx4 */ | ||
70 | 73 | ||
71 | PDC_HAS_PATA = (1 << 1), /* PDC20375 has PATA */ | 74 | PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */ |
72 | 75 | ||
73 | PDC_RESET = (1 << 11), /* HDMA reset */ | 76 | PDC_RESET = (1 << 11), /* HDMA reset */ |
74 | 77 | ||
@@ -82,6 +85,10 @@ struct pdc_port_priv { | |||
82 | dma_addr_t pkt_dma; | 85 | dma_addr_t pkt_dma; |
83 | }; | 86 | }; |
84 | 87 | ||
88 | struct pdc_host_priv { | ||
89 | int hotplug_offset; | ||
90 | }; | ||
91 | |||
85 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); | 92 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); |
86 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 93 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); |
87 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 94 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
@@ -95,7 +102,8 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc); | |||
95 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 102 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
96 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 103 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
97 | static void pdc_irq_clear(struct ata_port *ap); | 104 | static void pdc_irq_clear(struct ata_port *ap); |
98 | static int pdc_qc_issue_prot(struct ata_queued_cmd *qc); | 105 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); |
106 | static void pdc_host_stop(struct ata_host_set *host_set); | ||
99 | 107 | ||
100 | 108 | ||
101 | static struct scsi_host_template pdc_ata_sht = { | 109 | static struct scsi_host_template pdc_ata_sht = { |
@@ -103,6 +111,7 @@ static struct scsi_host_template pdc_ata_sht = { | |||
103 | .name = DRV_NAME, | 111 | .name = DRV_NAME, |
104 | .ioctl = ata_scsi_ioctl, | 112 | .ioctl = ata_scsi_ioctl, |
105 | .queuecommand = ata_scsi_queuecmd, | 113 | .queuecommand = ata_scsi_queuecmd, |
114 | .eh_timed_out = ata_scsi_timed_out, | ||
106 | .eh_strategy_handler = ata_scsi_error, | 115 | .eh_strategy_handler = ata_scsi_error, |
107 | .can_queue = ATA_DEF_QUEUE, | 116 | .can_queue = ATA_DEF_QUEUE, |
108 | .this_id = ATA_SHT_THIS_ID, | 117 | .this_id = ATA_SHT_THIS_ID, |
@@ -137,7 +146,7 @@ static const struct ata_port_operations pdc_sata_ops = { | |||
137 | .scr_write = pdc_sata_scr_write, | 146 | .scr_write = pdc_sata_scr_write, |
138 | .port_start = pdc_port_start, | 147 | .port_start = pdc_port_start, |
139 | .port_stop = pdc_port_stop, | 148 | .port_stop = pdc_port_stop, |
140 | .host_stop = ata_pci_host_stop, | 149 | .host_stop = pdc_host_stop, |
141 | }; | 150 | }; |
142 | 151 | ||
143 | static const struct ata_port_operations pdc_pata_ops = { | 152 | static const struct ata_port_operations pdc_pata_ops = { |
@@ -158,7 +167,7 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
158 | 167 | ||
159 | .port_start = pdc_port_start, | 168 | .port_start = pdc_port_start, |
160 | .port_stop = pdc_port_stop, | 169 | .port_stop = pdc_port_stop, |
161 | .host_stop = ata_pci_host_stop, | 170 | .host_stop = pdc_host_stop, |
162 | }; | 171 | }; |
163 | 172 | ||
164 | static const struct ata_port_info pdc_port_info[] = { | 173 | static const struct ata_port_info pdc_port_info[] = { |
@@ -201,6 +210,26 @@ static const struct ata_port_info pdc_port_info[] = { | |||
201 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 210 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
202 | .port_ops = &pdc_sata_ops, | 211 | .port_ops = &pdc_sata_ops, |
203 | }, | 212 | }, |
213 | |||
214 | /* board_2057x */ | ||
215 | { | ||
216 | .sht = &pdc_ata_sht, | ||
217 | .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, | ||
218 | .pio_mask = 0x1f, /* pio0-4 */ | ||
219 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
220 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | ||
221 | .port_ops = &pdc_sata_ops, | ||
222 | }, | ||
223 | |||
224 | /* board_40518 */ | ||
225 | { | ||
226 | .sht = &pdc_ata_sht, | ||
227 | .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA, | ||
228 | .pio_mask = 0x1f, /* pio0-4 */ | ||
229 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
230 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | ||
231 | .port_ops = &pdc_sata_ops, | ||
232 | }, | ||
204 | }; | 233 | }; |
205 | 234 | ||
206 | static const struct pci_device_id pdc_ata_pci_tbl[] = { | 235 | static const struct pci_device_id pdc_ata_pci_tbl[] = { |
@@ -217,9 +246,9 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = { | |||
217 | { PCI_VENDOR_ID_PROMISE, 0x3376, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 246 | { PCI_VENDOR_ID_PROMISE, 0x3376, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
218 | board_2037x }, | 247 | board_2037x }, |
219 | { PCI_VENDOR_ID_PROMISE, 0x3574, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 248 | { PCI_VENDOR_ID_PROMISE, 0x3574, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
220 | board_2037x }, | 249 | board_2057x }, |
221 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 250 | { PCI_VENDOR_ID_PROMISE, 0x3d75, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
222 | board_2037x }, | 251 | board_2057x }, |
223 | { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 252 | { PCI_VENDOR_ID_PROMISE, 0x3d73, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
224 | board_2037x }, | 253 | board_2037x }, |
225 | 254 | ||
@@ -232,7 +261,7 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = { | |||
232 | { PCI_VENDOR_ID_PROMISE, 0x3d17, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 261 | { PCI_VENDOR_ID_PROMISE, 0x3d17, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
233 | board_20319 }, | 262 | board_20319 }, |
234 | { PCI_VENDOR_ID_PROMISE, 0x3d18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 263 | { PCI_VENDOR_ID_PROMISE, 0x3d18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
235 | board_20319 }, | 264 | board_40518 }, |
236 | 265 | ||
237 | { PCI_VENDOR_ID_PROMISE, 0x6629, PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 266 | { PCI_VENDOR_ID_PROMISE, 0x6629, PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
238 | board_20619 }, | 267 | board_20619 }, |
@@ -261,12 +290,11 @@ static int pdc_port_start(struct ata_port *ap) | |||
261 | if (rc) | 290 | if (rc) |
262 | return rc; | 291 | return rc; |
263 | 292 | ||
264 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); | 293 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); |
265 | if (!pp) { | 294 | if (!pp) { |
266 | rc = -ENOMEM; | 295 | rc = -ENOMEM; |
267 | goto err_out; | 296 | goto err_out; |
268 | } | 297 | } |
269 | memset(pp, 0, sizeof(*pp)); | ||
270 | 298 | ||
271 | pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); | 299 | pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); |
272 | if (!pp->pkt) { | 300 | if (!pp->pkt) { |
@@ -298,6 +326,16 @@ static void pdc_port_stop(struct ata_port *ap) | |||
298 | } | 326 | } |
299 | 327 | ||
300 | 328 | ||
329 | static void pdc_host_stop(struct ata_host_set *host_set) | ||
330 | { | ||
331 | struct pdc_host_priv *hp = host_set->private_data; | ||
332 | |||
333 | ata_pci_host_stop(host_set); | ||
334 | |||
335 | kfree(hp); | ||
336 | } | ||
337 | |||
338 | |||
301 | static void pdc_reset_port(struct ata_port *ap) | 339 | static void pdc_reset_port(struct ata_port *ap) |
302 | { | 340 | { |
303 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; | 341 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; |
@@ -394,19 +432,6 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
394 | spin_lock_irqsave(&host_set->lock, flags); | 432 | spin_lock_irqsave(&host_set->lock, flags); |
395 | 433 | ||
396 | qc = ata_qc_from_tag(ap, ap->active_tag); | 434 | qc = ata_qc_from_tag(ap, ap->active_tag); |
397 | if (!qc) { | ||
398 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | ||
399 | ap->id); | ||
400 | goto out; | ||
401 | } | ||
402 | |||
403 | /* hack alert! We cannot use the supplied completion | ||
404 | * function from inside the ->eh_strategy_handler() thread. | ||
405 | * libata is the only user of ->eh_strategy_handler() in | ||
406 | * any kernel, so the default scsi_done() assumes it is | ||
407 | * not being called from the SCSI EH. | ||
408 | */ | ||
409 | qc->scsidone = scsi_finish_command; | ||
410 | 435 | ||
411 | switch (qc->tf.protocol) { | 436 | switch (qc->tf.protocol) { |
412 | case ATA_PROT_DMA: | 437 | case ATA_PROT_DMA: |
@@ -414,7 +439,6 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
414 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 439 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
415 | drv_stat = ata_wait_idle(ap); | 440 | drv_stat = ata_wait_idle(ap); |
416 | qc->err_mask |= __ac_err_mask(drv_stat); | 441 | qc->err_mask |= __ac_err_mask(drv_stat); |
417 | ata_qc_complete(qc); | ||
418 | break; | 442 | break; |
419 | 443 | ||
420 | default: | 444 | default: |
@@ -424,12 +448,11 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
424 | ap->id, qc->tf.command, drv_stat); | 448 | ap->id, qc->tf.command, drv_stat); |
425 | 449 | ||
426 | qc->err_mask |= ac_err_mask(drv_stat); | 450 | qc->err_mask |= ac_err_mask(drv_stat); |
427 | ata_qc_complete(qc); | ||
428 | break; | 451 | break; |
429 | } | 452 | } |
430 | 453 | ||
431 | out: | ||
432 | spin_unlock_irqrestore(&host_set->lock, flags); | 454 | spin_unlock_irqrestore(&host_set->lock, flags); |
455 | ata_eh_qc_complete(qc); | ||
433 | DPRINTK("EXIT\n"); | 456 | DPRINTK("EXIT\n"); |
434 | } | 457 | } |
435 | 458 | ||
@@ -495,14 +518,15 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r | |||
495 | VPRINTK("QUICK EXIT 2\n"); | 518 | VPRINTK("QUICK EXIT 2\n"); |
496 | return IRQ_NONE; | 519 | return IRQ_NONE; |
497 | } | 520 | } |
521 | |||
522 | spin_lock(&host_set->lock); | ||
523 | |||
498 | mask &= 0xffff; /* only 16 tags possible */ | 524 | mask &= 0xffff; /* only 16 tags possible */ |
499 | if (!mask) { | 525 | if (!mask) { |
500 | VPRINTK("QUICK EXIT 3\n"); | 526 | VPRINTK("QUICK EXIT 3\n"); |
501 | return IRQ_NONE; | 527 | goto done_irq; |
502 | } | 528 | } |
503 | 529 | ||
504 | spin_lock(&host_set->lock); | ||
505 | |||
506 | writel(mask, mmio_base + PDC_INT_SEQMASK); | 530 | writel(mask, mmio_base + PDC_INT_SEQMASK); |
507 | 531 | ||
508 | for (i = 0; i < host_set->n_ports; i++) { | 532 | for (i = 0; i < host_set->n_ports; i++) { |
@@ -519,10 +543,10 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r | |||
519 | } | 543 | } |
520 | } | 544 | } |
521 | 545 | ||
522 | spin_unlock(&host_set->lock); | ||
523 | |||
524 | VPRINTK("EXIT\n"); | 546 | VPRINTK("EXIT\n"); |
525 | 547 | ||
548 | done_irq: | ||
549 | spin_unlock(&host_set->lock); | ||
526 | return IRQ_RETVAL(handled); | 550 | return IRQ_RETVAL(handled); |
527 | } | 551 | } |
528 | 552 | ||
@@ -544,7 +568,7 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc) | |||
544 | readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ | 568 | readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ |
545 | } | 569 | } |
546 | 570 | ||
547 | static int pdc_qc_issue_prot(struct ata_queued_cmd *qc) | 571 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) |
548 | { | 572 | { |
549 | switch (qc->tf.protocol) { | 573 | switch (qc->tf.protocol) { |
550 | case ATA_PROT_DMA: | 574 | case ATA_PROT_DMA: |
@@ -600,6 +624,8 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) | |||
600 | static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | 624 | static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) |
601 | { | 625 | { |
602 | void __iomem *mmio = pe->mmio_base; | 626 | void __iomem *mmio = pe->mmio_base; |
627 | struct pdc_host_priv *hp = pe->private_data; | ||
628 | int hotplug_offset = hp->hotplug_offset; | ||
603 | u32 tmp; | 629 | u32 tmp; |
604 | 630 | ||
605 | /* | 631 | /* |
@@ -614,12 +640,12 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | |||
614 | writel(tmp, mmio + PDC_FLASH_CTL); | 640 | writel(tmp, mmio + PDC_FLASH_CTL); |
615 | 641 | ||
616 | /* clear plug/unplug flags for all ports */ | 642 | /* clear plug/unplug flags for all ports */ |
617 | tmp = readl(mmio + PDC_SATA_PLUG_CSR); | 643 | tmp = readl(mmio + hotplug_offset); |
618 | writel(tmp | 0xff, mmio + PDC_SATA_PLUG_CSR); | 644 | writel(tmp | 0xff, mmio + hotplug_offset); |
619 | 645 | ||
620 | /* mask plug/unplug ints */ | 646 | /* mask plug/unplug ints */ |
621 | tmp = readl(mmio + PDC_SATA_PLUG_CSR); | 647 | tmp = readl(mmio + hotplug_offset); |
622 | writel(tmp | 0xff0000, mmio + PDC_SATA_PLUG_CSR); | 648 | writel(tmp | 0xff0000, mmio + hotplug_offset); |
623 | 649 | ||
624 | /* reduce TBG clock to 133 Mhz. */ | 650 | /* reduce TBG clock to 133 Mhz. */ |
625 | tmp = readl(mmio + PDC_TBG_MODE); | 651 | tmp = readl(mmio + PDC_TBG_MODE); |
@@ -641,6 +667,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
641 | { | 667 | { |
642 | static int printed_version; | 668 | static int printed_version; |
643 | struct ata_probe_ent *probe_ent = NULL; | 669 | struct ata_probe_ent *probe_ent = NULL; |
670 | struct pdc_host_priv *hp; | ||
644 | unsigned long base; | 671 | unsigned long base; |
645 | void __iomem *mmio_base; | 672 | void __iomem *mmio_base; |
646 | unsigned int board_idx = (unsigned int) ent->driver_data; | 673 | unsigned int board_idx = (unsigned int) ent->driver_data; |
@@ -671,13 +698,12 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
671 | if (rc) | 698 | if (rc) |
672 | goto err_out_regions; | 699 | goto err_out_regions; |
673 | 700 | ||
674 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 701 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); |
675 | if (probe_ent == NULL) { | 702 | if (probe_ent == NULL) { |
676 | rc = -ENOMEM; | 703 | rc = -ENOMEM; |
677 | goto err_out_regions; | 704 | goto err_out_regions; |
678 | } | 705 | } |
679 | 706 | ||
680 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
681 | probe_ent->dev = pci_dev_to_dev(pdev); | 707 | probe_ent->dev = pci_dev_to_dev(pdev); |
682 | INIT_LIST_HEAD(&probe_ent->node); | 708 | INIT_LIST_HEAD(&probe_ent->node); |
683 | 709 | ||
@@ -688,6 +714,16 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
688 | } | 714 | } |
689 | base = (unsigned long) mmio_base; | 715 | base = (unsigned long) mmio_base; |
690 | 716 | ||
717 | hp = kzalloc(sizeof(*hp), GFP_KERNEL); | ||
718 | if (hp == NULL) { | ||
719 | rc = -ENOMEM; | ||
720 | goto err_out_free_ent; | ||
721 | } | ||
722 | |||
723 | /* Set default hotplug offset */ | ||
724 | hp->hotplug_offset = PDC_SATA_PLUG_CSR; | ||
725 | probe_ent->private_data = hp; | ||
726 | |||
691 | probe_ent->sht = pdc_port_info[board_idx].sht; | 727 | probe_ent->sht = pdc_port_info[board_idx].sht; |
692 | probe_ent->host_flags = pdc_port_info[board_idx].host_flags; | 728 | probe_ent->host_flags = pdc_port_info[board_idx].host_flags; |
693 | probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; | 729 | probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; |
@@ -707,6 +743,10 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
707 | 743 | ||
708 | /* notice 4-port boards */ | 744 | /* notice 4-port boards */ |
709 | switch (board_idx) { | 745 | switch (board_idx) { |
746 | case board_40518: | ||
747 | /* Override hotplug offset for SATAII150 */ | ||
748 | hp->hotplug_offset = PDC2_SATA_PLUG_CSR; | ||
749 | /* Fall through */ | ||
710 | case board_20319: | 750 | case board_20319: |
711 | probe_ent->n_ports = 4; | 751 | probe_ent->n_ports = 4; |
712 | 752 | ||
@@ -716,6 +756,10 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
716 | probe_ent->port[2].scr_addr = base + 0x600; | 756 | probe_ent->port[2].scr_addr = base + 0x600; |
717 | probe_ent->port[3].scr_addr = base + 0x700; | 757 | probe_ent->port[3].scr_addr = base + 0x700; |
718 | break; | 758 | break; |
759 | case board_2057x: | ||
760 | /* Override hotplug offset for SATAII150 */ | ||
761 | hp->hotplug_offset = PDC2_SATA_PLUG_CSR; | ||
762 | /* Fall through */ | ||
719 | case board_2037x: | 763 | case board_2037x: |
720 | probe_ent->n_ports = 2; | 764 | probe_ent->n_ports = 2; |
721 | break; | 765 | break; |
@@ -741,8 +785,10 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
741 | /* initialize adapter */ | 785 | /* initialize adapter */ |
742 | pdc_host_init(board_idx, probe_ent); | 786 | pdc_host_init(board_idx, probe_ent); |
743 | 787 | ||
744 | /* FIXME: check ata_device_add return value */ | 788 | /* FIXME: Need any other frees than hp? */ |
745 | ata_device_add(probe_ent); | 789 | if (!ata_device_add(probe_ent)) |
790 | kfree(hp); | ||
791 | |||
746 | kfree(probe_ent); | 792 | kfree(probe_ent); |
747 | 793 | ||
748 | return 0; | 794 | return 0; |
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index de05e2883f9c..82c3df7048ea 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -120,7 +120,7 @@ static void qs_host_stop(struct ata_host_set *host_set); | |||
120 | static void qs_port_stop(struct ata_port *ap); | 120 | static void qs_port_stop(struct ata_port *ap); |
121 | static void qs_phy_reset(struct ata_port *ap); | 121 | static void qs_phy_reset(struct ata_port *ap); |
122 | static void qs_qc_prep(struct ata_queued_cmd *qc); | 122 | static void qs_qc_prep(struct ata_queued_cmd *qc); |
123 | static int qs_qc_issue(struct ata_queued_cmd *qc); | 123 | static unsigned int qs_qc_issue(struct ata_queued_cmd *qc); |
124 | static int qs_check_atapi_dma(struct ata_queued_cmd *qc); | 124 | static int qs_check_atapi_dma(struct ata_queued_cmd *qc); |
125 | static void qs_bmdma_stop(struct ata_queued_cmd *qc); | 125 | static void qs_bmdma_stop(struct ata_queued_cmd *qc); |
126 | static u8 qs_bmdma_status(struct ata_port *ap); | 126 | static u8 qs_bmdma_status(struct ata_port *ap); |
@@ -132,6 +132,7 @@ static struct scsi_host_template qs_ata_sht = { | |||
132 | .name = DRV_NAME, | 132 | .name = DRV_NAME, |
133 | .ioctl = ata_scsi_ioctl, | 133 | .ioctl = ata_scsi_ioctl, |
134 | .queuecommand = ata_scsi_queuecmd, | 134 | .queuecommand = ata_scsi_queuecmd, |
135 | .eh_timed_out = ata_scsi_timed_out, | ||
135 | .eh_strategy_handler = ata_scsi_error, | 136 | .eh_strategy_handler = ata_scsi_error, |
136 | .can_queue = ATA_DEF_QUEUE, | 137 | .can_queue = ATA_DEF_QUEUE, |
137 | .this_id = ATA_SHT_THIS_ID, | 138 | .this_id = ATA_SHT_THIS_ID, |
@@ -352,7 +353,7 @@ static inline void qs_packet_start(struct ata_queued_cmd *qc) | |||
352 | readl(chan + QS_CCT_CFF); /* flush */ | 353 | readl(chan + QS_CCT_CFF); /* flush */ |
353 | } | 354 | } |
354 | 355 | ||
355 | static int qs_qc_issue(struct ata_queued_cmd *qc) | 356 | static unsigned int qs_qc_issue(struct ata_queued_cmd *qc) |
356 | { | 357 | { |
357 | struct qs_port_priv *pp = qc->ap->private_data; | 358 | struct qs_port_priv *pp = qc->ap->private_data; |
358 | 359 | ||
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 17f74d3c10e7..bd2887741d78 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -135,6 +135,7 @@ static struct scsi_host_template sil_sht = { | |||
135 | .name = DRV_NAME, | 135 | .name = DRV_NAME, |
136 | .ioctl = ata_scsi_ioctl, | 136 | .ioctl = ata_scsi_ioctl, |
137 | .queuecommand = ata_scsi_queuecmd, | 137 | .queuecommand = ata_scsi_queuecmd, |
138 | .eh_timed_out = ata_scsi_timed_out, | ||
138 | .eh_strategy_handler = ata_scsi_error, | 139 | .eh_strategy_handler = ata_scsi_error, |
139 | .can_queue = ATA_DEF_QUEUE, | 140 | .can_queue = ATA_DEF_QUEUE, |
140 | .this_id = ATA_SHT_THIS_ID, | 141 | .this_id = ATA_SHT_THIS_ID, |
@@ -157,7 +158,7 @@ static const struct ata_port_operations sil_ops = { | |||
157 | .check_status = ata_check_status, | 158 | .check_status = ata_check_status, |
158 | .exec_command = ata_exec_command, | 159 | .exec_command = ata_exec_command, |
159 | .dev_select = ata_std_dev_select, | 160 | .dev_select = ata_std_dev_select, |
160 | .phy_reset = sata_phy_reset, | 161 | .probe_reset = ata_std_probe_reset, |
161 | .post_set_mode = sil_post_set_mode, | 162 | .post_set_mode = sil_post_set_mode, |
162 | .bmdma_setup = ata_bmdma_setup, | 163 | .bmdma_setup = ata_bmdma_setup, |
163 | .bmdma_start = ata_bmdma_start, | 164 | .bmdma_start = ata_bmdma_start, |
@@ -180,7 +181,7 @@ static const struct ata_port_info sil_port_info[] = { | |||
180 | { | 181 | { |
181 | .sht = &sil_sht, | 182 | .sht = &sil_sht, |
182 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 183 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
183 | ATA_FLAG_SRST | ATA_FLAG_MMIO, | 184 | ATA_FLAG_MMIO, |
184 | .pio_mask = 0x1f, /* pio0-4 */ | 185 | .pio_mask = 0x1f, /* pio0-4 */ |
185 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 186 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
186 | .udma_mask = 0x3f, /* udma0-5 */ | 187 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -189,8 +190,7 @@ static const struct ata_port_info sil_port_info[] = { | |||
189 | { | 190 | { |
190 | .sht = &sil_sht, | 191 | .sht = &sil_sht, |
191 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 192 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
192 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | 193 | ATA_FLAG_MMIO | SIL_FLAG_MOD15WRITE, |
193 | SIL_FLAG_MOD15WRITE, | ||
194 | .pio_mask = 0x1f, /* pio0-4 */ | 194 | .pio_mask = 0x1f, /* pio0-4 */ |
195 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 195 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
196 | .udma_mask = 0x3f, /* udma0-5 */ | 196 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -199,7 +199,7 @@ static const struct ata_port_info sil_port_info[] = { | |||
199 | { | 199 | { |
200 | .sht = &sil_sht, | 200 | .sht = &sil_sht, |
201 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 201 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
202 | ATA_FLAG_SRST | ATA_FLAG_MMIO, | 202 | ATA_FLAG_MMIO, |
203 | .pio_mask = 0x1f, /* pio0-4 */ | 203 | .pio_mask = 0x1f, /* pio0-4 */ |
204 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 204 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
205 | .udma_mask = 0x3f, /* udma0-5 */ | 205 | .udma_mask = 0x3f, /* udma0-5 */ |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index 923130185a9e..228a7fabffff 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -249,9 +249,9 @@ static u8 sil24_check_status(struct ata_port *ap); | |||
249 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); | 249 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); |
250 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); | 250 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); |
251 | static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 251 | static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
252 | static void sil24_phy_reset(struct ata_port *ap); | 252 | static int sil24_probe_reset(struct ata_port *ap, unsigned int *classes); |
253 | static void sil24_qc_prep(struct ata_queued_cmd *qc); | 253 | static void sil24_qc_prep(struct ata_queued_cmd *qc); |
254 | static int sil24_qc_issue(struct ata_queued_cmd *qc); | 254 | static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); |
255 | static void sil24_irq_clear(struct ata_port *ap); | 255 | static void sil24_irq_clear(struct ata_port *ap); |
256 | static void sil24_eng_timeout(struct ata_port *ap); | 256 | static void sil24_eng_timeout(struct ata_port *ap); |
257 | static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *regs); | 257 | static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *regs); |
@@ -280,6 +280,7 @@ static struct scsi_host_template sil24_sht = { | |||
280 | .name = DRV_NAME, | 280 | .name = DRV_NAME, |
281 | .ioctl = ata_scsi_ioctl, | 281 | .ioctl = ata_scsi_ioctl, |
282 | .queuecommand = ata_scsi_queuecmd, | 282 | .queuecommand = ata_scsi_queuecmd, |
283 | .eh_timed_out = ata_scsi_timed_out, | ||
283 | .eh_strategy_handler = ata_scsi_error, | 284 | .eh_strategy_handler = ata_scsi_error, |
284 | .can_queue = ATA_DEF_QUEUE, | 285 | .can_queue = ATA_DEF_QUEUE, |
285 | .this_id = ATA_SHT_THIS_ID, | 286 | .this_id = ATA_SHT_THIS_ID, |
@@ -305,7 +306,7 @@ static const struct ata_port_operations sil24_ops = { | |||
305 | 306 | ||
306 | .tf_read = sil24_tf_read, | 307 | .tf_read = sil24_tf_read, |
307 | 308 | ||
308 | .phy_reset = sil24_phy_reset, | 309 | .probe_reset = sil24_probe_reset, |
309 | 310 | ||
310 | .qc_prep = sil24_qc_prep, | 311 | .qc_prep = sil24_qc_prep, |
311 | .qc_issue = sil24_qc_issue, | 312 | .qc_issue = sil24_qc_issue, |
@@ -335,8 +336,8 @@ static struct ata_port_info sil24_port_info[] = { | |||
335 | { | 336 | { |
336 | .sht = &sil24_sht, | 337 | .sht = &sil24_sht, |
337 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 338 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
338 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | 339 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | |
339 | ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(4), | 340 | SIL24_NPORTS2FLAG(4), |
340 | .pio_mask = 0x1f, /* pio0-4 */ | 341 | .pio_mask = 0x1f, /* pio0-4 */ |
341 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 342 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
342 | .udma_mask = 0x3f, /* udma0-5 */ | 343 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -346,8 +347,8 @@ static struct ata_port_info sil24_port_info[] = { | |||
346 | { | 347 | { |
347 | .sht = &sil24_sht, | 348 | .sht = &sil24_sht, |
348 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 349 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
349 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | 350 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | |
350 | ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(2), | 351 | SIL24_NPORTS2FLAG(2), |
351 | .pio_mask = 0x1f, /* pio0-4 */ | 352 | .pio_mask = 0x1f, /* pio0-4 */ |
352 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 353 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
353 | .udma_mask = 0x3f, /* udma0-5 */ | 354 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -357,8 +358,8 @@ static struct ata_port_info sil24_port_info[] = { | |||
357 | { | 358 | { |
358 | .sht = &sil24_sht, | 359 | .sht = &sil24_sht, |
359 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 360 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
360 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | 361 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | |
361 | ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(1), | 362 | SIL24_NPORTS2FLAG(1), |
362 | .pio_mask = 0x1f, /* pio0-4 */ | 363 | .pio_mask = 0x1f, /* pio0-4 */ |
363 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 364 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
364 | .udma_mask = 0x3f, /* udma0-5 */ | 365 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -427,7 +428,8 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
427 | *tf = pp->tf; | 428 | *tf = pp->tf; |
428 | } | 429 | } |
429 | 430 | ||
430 | static int sil24_issue_SRST(struct ata_port *ap) | 431 | static int sil24_softreset(struct ata_port *ap, int verbose, |
432 | unsigned int *class) | ||
431 | { | 433 | { |
432 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; | 434 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
433 | struct sil24_port_priv *pp = ap->private_data; | 435 | struct sil24_port_priv *pp = ap->private_data; |
@@ -436,6 +438,8 @@ static int sil24_issue_SRST(struct ata_port *ap) | |||
436 | u32 irq_enable, irq_stat; | 438 | u32 irq_enable, irq_stat; |
437 | int cnt; | 439 | int cnt; |
438 | 440 | ||
441 | DPRINTK("ENTER\n"); | ||
442 | |||
439 | /* temporarily turn off IRQs during SRST */ | 443 | /* temporarily turn off IRQs during SRST */ |
440 | irq_enable = readl(port + PORT_IRQ_ENABLE_SET); | 444 | irq_enable = readl(port + PORT_IRQ_ENABLE_SET); |
441 | writel(irq_enable, port + PORT_IRQ_ENABLE_CLR); | 445 | writel(irq_enable, port + PORT_IRQ_ENABLE_CLR); |
@@ -465,30 +469,36 @@ static int sil24_issue_SRST(struct ata_port *ap) | |||
465 | /* restore IRQs */ | 469 | /* restore IRQs */ |
466 | writel(irq_enable, port + PORT_IRQ_ENABLE_SET); | 470 | writel(irq_enable, port + PORT_IRQ_ENABLE_SET); |
467 | 471 | ||
468 | if (!(irq_stat & PORT_IRQ_COMPLETE)) | 472 | if (sata_dev_present(ap)) { |
469 | return -1; | 473 | if (!(irq_stat & PORT_IRQ_COMPLETE)) { |
474 | DPRINTK("EXIT, srst failed\n"); | ||
475 | return -EIO; | ||
476 | } | ||
470 | 477 | ||
471 | /* update TF */ | 478 | sil24_update_tf(ap); |
472 | sil24_update_tf(ap); | 479 | *class = ata_dev_classify(&pp->tf); |
480 | } | ||
481 | if (*class == ATA_DEV_UNKNOWN) | ||
482 | *class = ATA_DEV_NONE; | ||
483 | |||
484 | DPRINTK("EXIT, class=%u\n", *class); | ||
473 | return 0; | 485 | return 0; |
474 | } | 486 | } |
475 | 487 | ||
476 | static void sil24_phy_reset(struct ata_port *ap) | 488 | static int sil24_hardreset(struct ata_port *ap, int verbose, |
489 | unsigned int *class) | ||
477 | { | 490 | { |
478 | struct sil24_port_priv *pp = ap->private_data; | 491 | unsigned int dummy_class; |
479 | |||
480 | __sata_phy_reset(ap); | ||
481 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | ||
482 | return; | ||
483 | 492 | ||
484 | if (sil24_issue_SRST(ap) < 0) { | 493 | /* sil24 doesn't report device signature after hard reset */ |
485 | printk(KERN_ERR DRV_NAME | 494 | return sata_std_hardreset(ap, verbose, &dummy_class); |
486 | " ata%u: SRST failed, disabling port\n", ap->id); | 495 | } |
487 | ap->ops->port_disable(ap); | ||
488 | return; | ||
489 | } | ||
490 | 496 | ||
491 | ap->device->class = ata_dev_classify(&pp->tf); | 497 | static int sil24_probe_reset(struct ata_port *ap, unsigned int *classes) |
498 | { | ||
499 | return ata_drive_probe_reset(ap, ata_std_probeinit, | ||
500 | sil24_softreset, sil24_hardreset, | ||
501 | ata_std_postreset, classes); | ||
492 | } | 502 | } |
493 | 503 | ||
494 | static inline void sil24_fill_sg(struct ata_queued_cmd *qc, | 504 | static inline void sil24_fill_sg(struct ata_queued_cmd *qc, |
@@ -557,7 +567,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
557 | sil24_fill_sg(qc, sge); | 567 | sil24_fill_sg(qc, sge); |
558 | } | 568 | } |
559 | 569 | ||
560 | static int sil24_qc_issue(struct ata_queued_cmd *qc) | 570 | static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc) |
561 | { | 571 | { |
562 | struct ata_port *ap = qc->ap; | 572 | struct ata_port *ap = qc->ap; |
563 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; | 573 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
@@ -638,23 +648,10 @@ static void sil24_eng_timeout(struct ata_port *ap) | |||
638 | struct ata_queued_cmd *qc; | 648 | struct ata_queued_cmd *qc; |
639 | 649 | ||
640 | qc = ata_qc_from_tag(ap, ap->active_tag); | 650 | qc = ata_qc_from_tag(ap, ap->active_tag); |
641 | if (!qc) { | ||
642 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | ||
643 | ap->id); | ||
644 | return; | ||
645 | } | ||
646 | 651 | ||
647 | /* | ||
648 | * hack alert! We cannot use the supplied completion | ||
649 | * function from inside the ->eh_strategy_handler() thread. | ||
650 | * libata is the only user of ->eh_strategy_handler() in | ||
651 | * any kernel, so the default scsi_done() assumes it is | ||
652 | * not being called from the SCSI EH. | ||
653 | */ | ||
654 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 652 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
655 | qc->scsidone = scsi_finish_command; | 653 | qc->err_mask |= AC_ERR_TIMEOUT; |
656 | qc->err_mask |= AC_ERR_OTHER; | 654 | ata_eh_qc_complete(qc); |
657 | ata_qc_complete(qc); | ||
658 | 655 | ||
659 | sil24_reset_controller(ap); | 656 | sil24_reset_controller(ap); |
660 | } | 657 | } |
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 2df8c5632ac3..2f1815715705 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c | |||
@@ -87,6 +87,7 @@ static struct scsi_host_template sis_sht = { | |||
87 | .name = DRV_NAME, | 87 | .name = DRV_NAME, |
88 | .ioctl = ata_scsi_ioctl, | 88 | .ioctl = ata_scsi_ioctl, |
89 | .queuecommand = ata_scsi_queuecmd, | 89 | .queuecommand = ata_scsi_queuecmd, |
90 | .eh_timed_out = ata_scsi_timed_out, | ||
90 | .eh_strategy_handler = ata_scsi_error, | 91 | .eh_strategy_handler = ata_scsi_error, |
91 | .can_queue = ATA_DEF_QUEUE, | 92 | .can_queue = ATA_DEF_QUEUE, |
92 | .this_id = ATA_SHT_THIS_ID, | 93 | .this_id = ATA_SHT_THIS_ID, |
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index d8472563fde8..f369c3003adf 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c | |||
@@ -288,6 +288,7 @@ static struct scsi_host_template k2_sata_sht = { | |||
288 | .name = DRV_NAME, | 288 | .name = DRV_NAME, |
289 | .ioctl = ata_scsi_ioctl, | 289 | .ioctl = ata_scsi_ioctl, |
290 | .queuecommand = ata_scsi_queuecmd, | 290 | .queuecommand = ata_scsi_queuecmd, |
291 | .eh_timed_out = ata_scsi_timed_out, | ||
291 | .eh_strategy_handler = ata_scsi_error, | 292 | .eh_strategy_handler = ata_scsi_error, |
292 | .can_queue = ATA_DEF_QUEUE, | 293 | .can_queue = ATA_DEF_QUEUE, |
293 | .this_id = ATA_SHT_THIS_ID, | 294 | .this_id = ATA_SHT_THIS_ID, |
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index bc87c16c80d2..212cff4fe5f5 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -174,7 +174,7 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, | |||
174 | static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, | 174 | static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, |
175 | void *psource, u32 offset, u32 size); | 175 | void *psource, u32 offset, u32 size); |
176 | static void pdc20621_irq_clear(struct ata_port *ap); | 176 | static void pdc20621_irq_clear(struct ata_port *ap); |
177 | static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc); | 177 | static unsigned int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc); |
178 | 178 | ||
179 | 179 | ||
180 | static struct scsi_host_template pdc_sata_sht = { | 180 | static struct scsi_host_template pdc_sata_sht = { |
@@ -182,6 +182,7 @@ static struct scsi_host_template pdc_sata_sht = { | |||
182 | .name = DRV_NAME, | 182 | .name = DRV_NAME, |
183 | .ioctl = ata_scsi_ioctl, | 183 | .ioctl = ata_scsi_ioctl, |
184 | .queuecommand = ata_scsi_queuecmd, | 184 | .queuecommand = ata_scsi_queuecmd, |
185 | .eh_timed_out = ata_scsi_timed_out, | ||
185 | .eh_strategy_handler = ata_scsi_error, | 186 | .eh_strategy_handler = ata_scsi_error, |
186 | .can_queue = ATA_DEF_QUEUE, | 187 | .can_queue = ATA_DEF_QUEUE, |
187 | .this_id = ATA_SHT_THIS_ID, | 188 | .this_id = ATA_SHT_THIS_ID, |
@@ -678,7 +679,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) | |||
678 | } | 679 | } |
679 | } | 680 | } |
680 | 681 | ||
681 | static int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc) | 682 | static unsigned int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc) |
682 | { | 683 | { |
683 | switch (qc->tf.protocol) { | 684 | switch (qc->tf.protocol) { |
684 | case ATA_PROT_DMA: | 685 | case ATA_PROT_DMA: |
@@ -866,26 +867,12 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
866 | spin_lock_irqsave(&host_set->lock, flags); | 867 | spin_lock_irqsave(&host_set->lock, flags); |
867 | 868 | ||
868 | qc = ata_qc_from_tag(ap, ap->active_tag); | 869 | qc = ata_qc_from_tag(ap, ap->active_tag); |
869 | if (!qc) { | ||
870 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | ||
871 | ap->id); | ||
872 | goto out; | ||
873 | } | ||
874 | |||
875 | /* hack alert! We cannot use the supplied completion | ||
876 | * function from inside the ->eh_strategy_handler() thread. | ||
877 | * libata is the only user of ->eh_strategy_handler() in | ||
878 | * any kernel, so the default scsi_done() assumes it is | ||
879 | * not being called from the SCSI EH. | ||
880 | */ | ||
881 | qc->scsidone = scsi_finish_command; | ||
882 | 870 | ||
883 | switch (qc->tf.protocol) { | 871 | switch (qc->tf.protocol) { |
884 | case ATA_PROT_DMA: | 872 | case ATA_PROT_DMA: |
885 | case ATA_PROT_NODATA: | 873 | case ATA_PROT_NODATA: |
886 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 874 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
887 | qc->err_mask |= __ac_err_mask(ata_wait_idle(ap)); | 875 | qc->err_mask |= __ac_err_mask(ata_wait_idle(ap)); |
888 | ata_qc_complete(qc); | ||
889 | break; | 876 | break; |
890 | 877 | ||
891 | default: | 878 | default: |
@@ -895,12 +882,11 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
895 | ap->id, qc->tf.command, drv_stat); | 882 | ap->id, qc->tf.command, drv_stat); |
896 | 883 | ||
897 | qc->err_mask |= ac_err_mask(drv_stat); | 884 | qc->err_mask |= ac_err_mask(drv_stat); |
898 | ata_qc_complete(qc); | ||
899 | break; | 885 | break; |
900 | } | 886 | } |
901 | 887 | ||
902 | out: | ||
903 | spin_unlock_irqrestore(&host_set->lock, flags); | 888 | spin_unlock_irqrestore(&host_set->lock, flags); |
889 | ata_eh_qc_complete(qc); | ||
904 | DPRINTK("EXIT\n"); | 890 | DPRINTK("EXIT\n"); |
905 | } | 891 | } |
906 | 892 | ||
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index 9635ca700977..c500f2490902 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c | |||
@@ -75,6 +75,7 @@ static struct scsi_host_template uli_sht = { | |||
75 | .name = DRV_NAME, | 75 | .name = DRV_NAME, |
76 | .ioctl = ata_scsi_ioctl, | 76 | .ioctl = ata_scsi_ioctl, |
77 | .queuecommand = ata_scsi_queuecmd, | 77 | .queuecommand = ata_scsi_queuecmd, |
78 | .eh_timed_out = ata_scsi_timed_out, | ||
78 | .eh_strategy_handler = ata_scsi_error, | 79 | .eh_strategy_handler = ata_scsi_error, |
79 | .can_queue = ATA_DEF_QUEUE, | 80 | .can_queue = ATA_DEF_QUEUE, |
80 | .this_id = ATA_SHT_THIS_ID, | 81 | .this_id = ATA_SHT_THIS_ID, |
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index 6d5b0a794cfd..2e20887dc88f 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c | |||
@@ -94,6 +94,7 @@ static struct scsi_host_template svia_sht = { | |||
94 | .name = DRV_NAME, | 94 | .name = DRV_NAME, |
95 | .ioctl = ata_scsi_ioctl, | 95 | .ioctl = ata_scsi_ioctl, |
96 | .queuecommand = ata_scsi_queuecmd, | 96 | .queuecommand = ata_scsi_queuecmd, |
97 | .eh_timed_out = ata_scsi_timed_out, | ||
97 | .eh_strategy_handler = ata_scsi_error, | 98 | .eh_strategy_handler = ata_scsi_error, |
98 | .can_queue = ATA_DEF_QUEUE, | 99 | .can_queue = ATA_DEF_QUEUE, |
99 | .this_id = ATA_SHT_THIS_ID, | 100 | .this_id = ATA_SHT_THIS_ID, |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index 2e2c3b7acb0c..cf1f8a61bda0 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -223,6 +223,7 @@ static struct scsi_host_template vsc_sata_sht = { | |||
223 | .name = DRV_NAME, | 223 | .name = DRV_NAME, |
224 | .ioctl = ata_scsi_ioctl, | 224 | .ioctl = ata_scsi_ioctl, |
225 | .queuecommand = ata_scsi_queuecmd, | 225 | .queuecommand = ata_scsi_queuecmd, |
226 | .eh_timed_out = ata_scsi_timed_out, | ||
226 | .eh_strategy_handler = ata_scsi_error, | 227 | .eh_strategy_handler = ata_scsi_error, |
227 | .can_queue = ATA_DEF_QUEUE, | 228 | .can_queue = ATA_DEF_QUEUE, |
228 | .this_id = ATA_SHT_THIS_ID, | 229 | .this_id = ATA_SHT_THIS_ID, |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 5cc97b721661..50f8057be75d 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -584,8 +584,7 @@ static int scsi_request_sense(struct scsi_cmnd *scmd) | |||
584 | * keep a list of pending commands for final completion, and once we | 584 | * keep a list of pending commands for final completion, and once we |
585 | * are ready to leave error handling we handle completion for real. | 585 | * are ready to leave error handling we handle completion for real. |
586 | **/ | 586 | **/ |
587 | static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, | 587 | void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q) |
588 | struct list_head *done_q) | ||
589 | { | 588 | { |
590 | scmd->device->host->host_failed--; | 589 | scmd->device->host->host_failed--; |
591 | scmd->eh_eflags = 0; | 590 | scmd->eh_eflags = 0; |
@@ -597,6 +596,7 @@ static void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, | |||
597 | scsi_setup_cmd_retry(scmd); | 596 | scsi_setup_cmd_retry(scmd); |
598 | list_move_tail(&scmd->eh_entry, done_q); | 597 | list_move_tail(&scmd->eh_entry, done_q); |
599 | } | 598 | } |
599 | EXPORT_SYMBOL(scsi_eh_finish_cmd); | ||
600 | 600 | ||
601 | /** | 601 | /** |
602 | * scsi_eh_get_sense - Get device sense data. | 602 | * scsi_eh_get_sense - Get device sense data. |
@@ -1425,7 +1425,7 @@ static void scsi_eh_ready_devs(struct Scsi_Host *shost, | |||
1425 | * @done_q: list_head of processed commands. | 1425 | * @done_q: list_head of processed commands. |
1426 | * | 1426 | * |
1427 | **/ | 1427 | **/ |
1428 | static void scsi_eh_flush_done_q(struct list_head *done_q) | 1428 | void scsi_eh_flush_done_q(struct list_head *done_q) |
1429 | { | 1429 | { |
1430 | struct scsi_cmnd *scmd, *next; | 1430 | struct scsi_cmnd *scmd, *next; |
1431 | 1431 | ||
@@ -1454,6 +1454,7 @@ static void scsi_eh_flush_done_q(struct list_head *done_q) | |||
1454 | } | 1454 | } |
1455 | } | 1455 | } |
1456 | } | 1456 | } |
1457 | EXPORT_SYMBOL(scsi_eh_flush_done_q); | ||
1457 | 1458 | ||
1458 | /** | 1459 | /** |
1459 | * scsi_unjam_host - Attempt to fix a host which has a cmd that failed. | 1460 | * scsi_unjam_host - Attempt to fix a host which has a cmd that failed. |
diff --git a/include/linux/ata.h b/include/linux/ata.h index 94f77cce27fa..a8155ca4947f 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -302,4 +302,16 @@ static inline int ata_ok(u8 status) | |||
302 | == ATA_DRDY); | 302 | == ATA_DRDY); |
303 | } | 303 | } |
304 | 304 | ||
305 | static inline int lba_28_ok(u64 block, u32 n_block) | ||
306 | { | ||
307 | /* check the ending block number */ | ||
308 | return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256); | ||
309 | } | ||
310 | |||
311 | static inline int lba_48_ok(u64 block, u32 n_block) | ||
312 | { | ||
313 | /* check the ending block number */ | ||
314 | return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); | ||
315 | } | ||
316 | |||
305 | #endif /* __LINUX_ATA_H__ */ | 317 | #endif /* __LINUX_ATA_H__ */ |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 9e5db2949c58..c1e198655bb1 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -35,7 +35,8 @@ | |||
35 | #include <linux/workqueue.h> | 35 | #include <linux/workqueue.h> |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * compile-time options | 38 | * compile-time options: to be removed as soon as all the drivers are |
39 | * converted to the new debugging mechanism | ||
39 | */ | 40 | */ |
40 | #undef ATA_DEBUG /* debugging output */ | 41 | #undef ATA_DEBUG /* debugging output */ |
41 | #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ | 42 | #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ |
@@ -71,6 +72,38 @@ | |||
71 | } | 72 | } |
72 | #endif | 73 | #endif |
73 | 74 | ||
75 | /* NEW: debug levels */ | ||
76 | #define HAVE_LIBATA_MSG 1 | ||
77 | |||
78 | enum { | ||
79 | ATA_MSG_DRV = 0x0001, | ||
80 | ATA_MSG_INFO = 0x0002, | ||
81 | ATA_MSG_PROBE = 0x0004, | ||
82 | ATA_MSG_WARN = 0x0008, | ||
83 | ATA_MSG_MALLOC = 0x0010, | ||
84 | ATA_MSG_CTL = 0x0020, | ||
85 | ATA_MSG_INTR = 0x0040, | ||
86 | ATA_MSG_ERR = 0x0080, | ||
87 | }; | ||
88 | |||
89 | #define ata_msg_drv(p) ((p)->msg_enable & ATA_MSG_DRV) | ||
90 | #define ata_msg_info(p) ((p)->msg_enable & ATA_MSG_INFO) | ||
91 | #define ata_msg_probe(p) ((p)->msg_enable & ATA_MSG_PROBE) | ||
92 | #define ata_msg_warn(p) ((p)->msg_enable & ATA_MSG_WARN) | ||
93 | #define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC) | ||
94 | #define ata_msg_ctl(p) ((p)->msg_enable & ATA_MSG_CTL) | ||
95 | #define ata_msg_intr(p) ((p)->msg_enable & ATA_MSG_INTR) | ||
96 | #define ata_msg_err(p) ((p)->msg_enable & ATA_MSG_ERR) | ||
97 | |||
98 | static inline u32 ata_msg_init(int dval, int default_msg_enable_bits) | ||
99 | { | ||
100 | if (dval < 0 || dval >= (sizeof(u32) * 8)) | ||
101 | return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */ | ||
102 | if (!dval) | ||
103 | return 0; | ||
104 | return (1 << dval) - 1; | ||
105 | } | ||
106 | |||
74 | /* defines only for the constants which don't work well as enums */ | 107 | /* defines only for the constants which don't work well as enums */ |
75 | #define ATA_TAG_POISON 0xfafbfcfdU | 108 | #define ATA_TAG_POISON 0xfafbfcfdU |
76 | 109 | ||
@@ -115,9 +148,9 @@ enum { | |||
115 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ | 148 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ |
116 | ATA_FLAG_SATA = (1 << 3), | 149 | ATA_FLAG_SATA = (1 << 3), |
117 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ | 150 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ |
118 | ATA_FLAG_SRST = (1 << 5), /* use ATA SRST, not E.D.D. */ | 151 | ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ |
119 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ | 152 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ |
120 | ATA_FLAG_SATA_RESET = (1 << 7), /* use COMRESET */ | 153 | ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ |
121 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 154 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ |
122 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 155 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once |
123 | * proper HSM is in place. */ | 156 | * proper HSM is in place. */ |
@@ -129,10 +162,14 @@ enum { | |||
129 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ | 162 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ |
130 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ | 163 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ |
131 | 164 | ||
165 | ATA_FLAG_FLUSH_PIO_TASK = (1 << 15), /* Flush PIO task */ | ||
166 | ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ | ||
167 | |||
132 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 168 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ |
133 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 169 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ |
134 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ | 170 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ |
135 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 171 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
172 | ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ | ||
136 | 173 | ||
137 | /* various lengths of time */ | 174 | /* various lengths of time */ |
138 | ATA_TMOUT_EDD = 5 * HZ, /* heuristic */ | 175 | ATA_TMOUT_EDD = 5 * HZ, /* heuristic */ |
@@ -189,10 +226,15 @@ enum hsm_task_states { | |||
189 | }; | 226 | }; |
190 | 227 | ||
191 | enum ata_completion_errors { | 228 | enum ata_completion_errors { |
192 | AC_ERR_OTHER = (1 << 0), | 229 | AC_ERR_DEV = (1 << 0), /* device reported error */ |
193 | AC_ERR_DEV = (1 << 1), | 230 | AC_ERR_HSM = (1 << 1), /* host state machine violation */ |
194 | AC_ERR_ATA_BUS = (1 << 2), | 231 | AC_ERR_TIMEOUT = (1 << 2), /* timeout */ |
195 | AC_ERR_HOST_BUS = (1 << 3), | 232 | AC_ERR_MEDIA = (1 << 3), /* media error */ |
233 | AC_ERR_ATA_BUS = (1 << 4), /* ATA bus error */ | ||
234 | AC_ERR_HOST_BUS = (1 << 5), /* host bus error */ | ||
235 | AC_ERR_SYSTEM = (1 << 6), /* system error */ | ||
236 | AC_ERR_INVALID = (1 << 7), /* invalid argument */ | ||
237 | AC_ERR_OTHER = (1 << 8), /* unknown */ | ||
196 | }; | 238 | }; |
197 | 239 | ||
198 | /* forward declarations */ | 240 | /* forward declarations */ |
@@ -202,7 +244,10 @@ struct ata_port; | |||
202 | struct ata_queued_cmd; | 244 | struct ata_queued_cmd; |
203 | 245 | ||
204 | /* typedefs */ | 246 | /* typedefs */ |
205 | typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 247 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
248 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | ||
249 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | ||
250 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | ||
206 | 251 | ||
207 | struct ata_ioports { | 252 | struct ata_ioports { |
208 | unsigned long cmd_addr; | 253 | unsigned long cmd_addr; |
@@ -359,6 +404,9 @@ struct ata_port { | |||
359 | unsigned int hsm_task_state; | 404 | unsigned int hsm_task_state; |
360 | unsigned long pio_task_timeout; | 405 | unsigned long pio_task_timeout; |
361 | 406 | ||
407 | u32 msg_enable; | ||
408 | struct list_head eh_done_q; | ||
409 | |||
362 | void *private_data; | 410 | void *private_data; |
363 | }; | 411 | }; |
364 | 412 | ||
@@ -378,7 +426,9 @@ struct ata_port_operations { | |||
378 | u8 (*check_altstatus)(struct ata_port *ap); | 426 | u8 (*check_altstatus)(struct ata_port *ap); |
379 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 427 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
380 | 428 | ||
381 | void (*phy_reset) (struct ata_port *ap); | 429 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ |
430 | int (*probe_reset) (struct ata_port *ap, unsigned int *classes); | ||
431 | |||
382 | void (*post_set_mode) (struct ata_port *ap); | 432 | void (*post_set_mode) (struct ata_port *ap); |
383 | 433 | ||
384 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | 434 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); |
@@ -387,7 +437,7 @@ struct ata_port_operations { | |||
387 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 437 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
388 | 438 | ||
389 | void (*qc_prep) (struct ata_queued_cmd *qc); | 439 | void (*qc_prep) (struct ata_queued_cmd *qc); |
390 | int (*qc_issue) (struct ata_queued_cmd *qc); | 440 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
391 | 441 | ||
392 | void (*eng_timeout) (struct ata_port *ap); | 442 | void (*eng_timeout) (struct ata_port *ap); |
393 | 443 | ||
@@ -435,6 +485,16 @@ extern void ata_port_probe(struct ata_port *); | |||
435 | extern void __sata_phy_reset(struct ata_port *ap); | 485 | extern void __sata_phy_reset(struct ata_port *ap); |
436 | extern void sata_phy_reset(struct ata_port *ap); | 486 | extern void sata_phy_reset(struct ata_port *ap); |
437 | extern void ata_bus_reset(struct ata_port *ap); | 487 | extern void ata_bus_reset(struct ata_port *ap); |
488 | extern int ata_drive_probe_reset(struct ata_port *ap, | ||
489 | ata_probeinit_fn_t probeinit, | ||
490 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | ||
491 | ata_postreset_fn_t postreset, unsigned int *classes); | ||
492 | extern void ata_std_probeinit(struct ata_port *ap); | ||
493 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | ||
494 | unsigned int *classes); | ||
495 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
496 | unsigned int *class); | ||
497 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | ||
438 | extern void ata_port_disable(struct ata_port *); | 498 | extern void ata_port_disable(struct ata_port *); |
439 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 499 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
440 | #ifdef CONFIG_PCI | 500 | #ifdef CONFIG_PCI |
@@ -449,7 +509,10 @@ extern void ata_host_set_remove(struct ata_host_set *host_set); | |||
449 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 509 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
450 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 510 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
451 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 511 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
512 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
452 | extern int ata_scsi_error(struct Scsi_Host *host); | 513 | extern int ata_scsi_error(struct Scsi_Host *host); |
514 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
515 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
453 | extern int ata_scsi_release(struct Scsi_Host *host); | 516 | extern int ata_scsi_release(struct Scsi_Host *host); |
454 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 517 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
455 | extern int ata_scsi_device_resume(struct scsi_device *); | 518 | extern int ata_scsi_device_resume(struct scsi_device *); |
@@ -457,6 +520,9 @@ extern int ata_scsi_device_suspend(struct scsi_device *); | |||
457 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 520 | extern int ata_device_resume(struct ata_port *, struct ata_device *); |
458 | extern int ata_device_suspend(struct ata_port *, struct ata_device *); | 521 | extern int ata_device_suspend(struct ata_port *, struct ata_device *); |
459 | extern int ata_ratelimit(void); | 522 | extern int ata_ratelimit(void); |
523 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | ||
524 | unsigned long timeout_pat, | ||
525 | unsigned long timeout); | ||
460 | 526 | ||
461 | /* | 527 | /* |
462 | * Default driver ops implementations | 528 | * Default driver ops implementations |
@@ -470,12 +536,13 @@ extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); | |||
470 | extern u8 ata_check_status(struct ata_port *ap); | 536 | extern u8 ata_check_status(struct ata_port *ap); |
471 | extern u8 ata_altstatus(struct ata_port *ap); | 537 | extern u8 ata_altstatus(struct ata_port *ap); |
472 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | 538 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
539 | extern int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes); | ||
473 | extern int ata_port_start (struct ata_port *ap); | 540 | extern int ata_port_start (struct ata_port *ap); |
474 | extern void ata_port_stop (struct ata_port *ap); | 541 | extern void ata_port_stop (struct ata_port *ap); |
475 | extern void ata_host_stop (struct ata_host_set *host_set); | 542 | extern void ata_host_stop (struct ata_host_set *host_set); |
476 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); | 543 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); |
477 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 544 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
478 | extern int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 545 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); |
479 | extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, | 546 | extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, |
480 | unsigned int buflen); | 547 | unsigned int buflen); |
481 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 548 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
@@ -645,9 +712,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap) | |||
645 | 712 | ||
646 | if (status & (ATA_BUSY | ATA_DRQ)) { | 713 | if (status & (ATA_BUSY | ATA_DRQ)) { |
647 | unsigned long l = ap->ioaddr.status_addr; | 714 | unsigned long l = ap->ioaddr.status_addr; |
648 | printk(KERN_WARNING | 715 | if (ata_msg_warn(ap)) |
649 | "ATA: abnormal status 0x%X on port 0x%lX\n", | 716 | printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n", |
650 | status, l); | 717 | status, l); |
651 | } | 718 | } |
652 | 719 | ||
653 | return status; | 720 | return status; |
@@ -739,7 +806,8 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
739 | 806 | ||
740 | status = ata_busy_wait(ap, bits, 1000); | 807 | status = ata_busy_wait(ap, bits, 1000); |
741 | if (status & bits) | 808 | if (status & bits) |
742 | DPRINTK("abnormal status 0x%X\n", status); | 809 | if (ata_msg_err(ap)) |
810 | printk(KERN_ERR "abnormal status 0x%X\n", status); | ||
743 | 811 | ||
744 | /* get controller status; clear intr, err bits */ | 812 | /* get controller status; clear intr, err bits */ |
745 | if (ap->flags & ATA_FLAG_MMIO) { | 813 | if (ap->flags & ATA_FLAG_MMIO) { |
@@ -757,8 +825,10 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
757 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | 825 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); |
758 | } | 826 | } |
759 | 827 | ||
760 | VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", | 828 | if (ata_msg_intr(ap)) |
761 | host_stat, post_stat, status); | 829 | printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", |
830 | __FUNCTION__, | ||
831 | host_stat, post_stat, status); | ||
762 | 832 | ||
763 | return status; | 833 | return status; |
764 | } | 834 | } |
@@ -795,7 +865,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) | |||
795 | static inline unsigned int ac_err_mask(u8 status) | 865 | static inline unsigned int ac_err_mask(u8 status) |
796 | { | 866 | { |
797 | if (status & ATA_BUSY) | 867 | if (status & ATA_BUSY) |
798 | return AC_ERR_ATA_BUS; | 868 | return AC_ERR_HSM; |
799 | if (status & (ATA_ERR | ATA_DF)) | 869 | if (status & (ATA_ERR | ATA_DF)) |
800 | return AC_ERR_DEV; | 870 | return AC_ERR_DEV; |
801 | return 0; | 871 | return 0; |
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index fabd879c2f2e..d160880b2a87 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h | |||
@@ -35,6 +35,9 @@ static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr) | |||
35 | } | 35 | } |
36 | 36 | ||
37 | 37 | ||
38 | extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, | ||
39 | struct list_head *done_q); | ||
40 | extern void scsi_eh_flush_done_q(struct list_head *done_q); | ||
38 | extern void scsi_report_bus_reset(struct Scsi_Host *, int); | 41 | extern void scsi_report_bus_reset(struct Scsi_Host *, int); |
39 | extern void scsi_report_device_reset(struct Scsi_Host *, int, int); | 42 | extern void scsi_report_device_reset(struct Scsi_Host *, int, int); |
40 | extern int scsi_block_when_processing_errors(struct scsi_device *); | 43 | extern int scsi_block_when_processing_errors(struct scsi_device *); |