aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-bmdma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libata-bmdma.c')
-rw-r--r--drivers/scsi/libata-bmdma.c161
1 files changed, 159 insertions, 2 deletions
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index 835dff0bafdc..13fab97c840e 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -652,6 +652,152 @@ void ata_bmdma_stop(struct ata_queued_cmd *qc)
652 ata_altstatus(ap); /* dummy read */ 652 ata_altstatus(ap); /* dummy read */
653} 653}
654 654
655/**
656 * ata_bmdma_freeze - Freeze BMDMA controller port
657 * @ap: port to freeze
658 *
659 * Freeze BMDMA controller port.
660 *
661 * LOCKING:
662 * Inherited from caller.
663 */
664void ata_bmdma_freeze(struct ata_port *ap)
665{
666 struct ata_ioports *ioaddr = &ap->ioaddr;
667
668 ap->ctl |= ATA_NIEN;
669 ap->last_ctl = ap->ctl;
670
671 if (ap->flags & ATA_FLAG_MMIO)
672 writeb(ap->ctl, (void __iomem *)ioaddr->ctl_addr);
673 else
674 outb(ap->ctl, ioaddr->ctl_addr);
675}
676
677/**
678 * ata_bmdma_thaw - Thaw BMDMA controller port
679 * @ap: port to thaw
680 *
681 * Thaw BMDMA controller port.
682 *
683 * LOCKING:
684 * Inherited from caller.
685 */
686void ata_bmdma_thaw(struct ata_port *ap)
687{
688 /* clear & re-enable interrupts */
689 ata_chk_status(ap);
690 ap->ops->irq_clear(ap);
691 if (ap->ioaddr.ctl_addr) /* FIXME: hack. create a hook instead */
692 ata_irq_on(ap);
693}
694
695/**
696 * ata_bmdma_drive_eh - Perform EH with given methods for BMDMA controller
697 * @ap: port to handle error for
698 * @prereset: prereset method (can be NULL)
699 * @softreset: softreset method (can be NULL)
700 * @hardreset: hardreset method (can be NULL)
701 * @postreset: postreset method (can be NULL)
702 *
703 * Handle error for ATA BMDMA controller. It can handle both
704 * PATA and SATA controllers. Many controllers should be able to
705 * use this EH as-is or with some added handling before and
706 * after.
707 *
708 * This function is intended to be used for constructing
709 * ->error_handler callback by low level drivers.
710 *
711 * LOCKING:
712 * Kernel thread context (may sleep)
713 */
714void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
715 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
716 ata_postreset_fn_t postreset)
717{
718 struct ata_host_set *host_set = ap->host_set;
719 struct ata_eh_context *ehc = &ap->eh_context;
720 struct ata_queued_cmd *qc;
721 unsigned long flags;
722 int thaw = 0;
723
724 qc = __ata_qc_from_tag(ap, ap->active_tag);
725 if (qc && !(qc->flags & ATA_QCFLAG_FAILED))
726 qc = NULL;
727
728 /* reset PIO HSM and stop DMA engine */
729 spin_lock_irqsave(&host_set->lock, flags);
730
731 ap->hsm_task_state = HSM_ST_IDLE;
732
733 if (qc && (qc->tf.protocol == ATA_PROT_DMA ||
734 qc->tf.protocol == ATA_PROT_ATAPI_DMA)) {
735 u8 host_stat;
736
737 host_stat = ata_bmdma_status(ap);
738
739 ata_ehi_push_desc(&ehc->i, "BMDMA stat 0x%x", host_stat);
740
741 /* BMDMA controllers indicate host bus error by
742 * setting DMA_ERR bit and timing out. As it wasn't
743 * really a timeout event, adjust error mask and
744 * cancel frozen state.
745 */
746 if (qc->err_mask == AC_ERR_TIMEOUT && host_stat & ATA_DMA_ERR) {
747 qc->err_mask = AC_ERR_HOST_BUS;
748 thaw = 1;
749 }
750
751 ap->ops->bmdma_stop(qc);
752 }
753
754 ata_altstatus(ap);
755 ata_chk_status(ap);
756 ap->ops->irq_clear(ap);
757
758 spin_unlock_irqrestore(&host_set->lock, flags);
759
760 if (thaw)
761 ata_eh_thaw_port(ap);
762
763 /* PIO and DMA engines have been stopped, perform recovery */
764 ata_do_eh(ap, prereset, softreset, hardreset, postreset);
765}
766
767/**
768 * ata_bmdma_error_handler - Stock error handler for BMDMA controller
769 * @ap: port to handle error for
770 *
771 * Stock error handler for BMDMA controller.
772 *
773 * LOCKING:
774 * Kernel thread context (may sleep)
775 */
776void ata_bmdma_error_handler(struct ata_port *ap)
777{
778 ata_reset_fn_t hardreset;
779
780 hardreset = NULL;
781 if (sata_scr_valid(ap))
782 hardreset = sata_std_hardreset;
783
784 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, hardreset,
785 ata_std_postreset);
786}
787
788/**
789 * ata_bmdma_post_internal_cmd - Stock post_internal_cmd for
790 * BMDMA controller
791 * @qc: internal command to clean up
792 *
793 * LOCKING:
794 * Kernel thread context (may sleep)
795 */
796void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
797{
798 ata_bmdma_stop(qc);
799}
800
655#ifdef CONFIG_PCI 801#ifdef CONFIG_PCI
656static struct ata_probe_ent * 802static struct ata_probe_ent *
657ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port) 803ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
@@ -930,10 +1076,21 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
930 1076
931 /* FIXME: check ata_device_add return */ 1077 /* FIXME: check ata_device_add return */
932 if (legacy_mode) { 1078 if (legacy_mode) {
933 if (legacy_mode & (1 << 0)) 1079 struct device *dev = &pdev->dev;
1080 struct ata_host_set *host_set = NULL;
1081
1082 if (legacy_mode & (1 << 0)) {
934 ata_device_add(probe_ent); 1083 ata_device_add(probe_ent);
935 if (legacy_mode & (1 << 1)) 1084 host_set = dev_get_drvdata(dev);
1085 }
1086
1087 if (legacy_mode & (1 << 1)) {
936 ata_device_add(probe_ent2); 1088 ata_device_add(probe_ent2);
1089 if (host_set) {
1090 host_set->next = dev_get_drvdata(dev);
1091 dev_set_drvdata(dev, host_set);
1092 }
1093 }
937 } else 1094 } else
938 ata_device_add(probe_ent); 1095 ata_device_add(probe_ent);
939 1096