diff options
-rw-r--r-- | drivers/ata/libata-sff.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 561dec2481cb..277477251a86 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -1667,6 +1667,7 @@ unsigned int ata_sff_host_intr(struct ata_port *ap, | |||
1667 | { | 1667 | { |
1668 | struct ata_eh_info *ehi = &ap->link.eh_info; | 1668 | struct ata_eh_info *ehi = &ap->link.eh_info; |
1669 | u8 status, host_stat = 0; | 1669 | u8 status, host_stat = 0; |
1670 | bool bmdma_stopped = false; | ||
1670 | 1671 | ||
1671 | VPRINTK("ata%u: protocol %d task_state %d\n", | 1672 | VPRINTK("ata%u: protocol %d task_state %d\n", |
1672 | ap->print_id, qc->tf.protocol, ap->hsm_task_state); | 1673 | ap->print_id, qc->tf.protocol, ap->hsm_task_state); |
@@ -1699,6 +1700,7 @@ unsigned int ata_sff_host_intr(struct ata_port *ap, | |||
1699 | 1700 | ||
1700 | /* before we do anything else, clear DMA-Start bit */ | 1701 | /* before we do anything else, clear DMA-Start bit */ |
1701 | ap->ops->bmdma_stop(qc); | 1702 | ap->ops->bmdma_stop(qc); |
1703 | bmdma_stopped = true; | ||
1702 | 1704 | ||
1703 | if (unlikely(host_stat & ATA_DMA_ERR)) { | 1705 | if (unlikely(host_stat & ATA_DMA_ERR)) { |
1704 | /* error when transfering data to/from memory */ | 1706 | /* error when transfering data to/from memory */ |
@@ -1716,8 +1718,14 @@ unsigned int ata_sff_host_intr(struct ata_port *ap, | |||
1716 | 1718 | ||
1717 | /* check main status, clearing INTRQ if needed */ | 1719 | /* check main status, clearing INTRQ if needed */ |
1718 | status = ata_sff_irq_status(ap); | 1720 | status = ata_sff_irq_status(ap); |
1719 | if (status & ATA_BUSY) | 1721 | if (status & ATA_BUSY) { |
1720 | goto idle_irq; | 1722 | if (bmdma_stopped) { |
1723 | /* BMDMA engine is already stopped, we're screwed */ | ||
1724 | qc->err_mask |= AC_ERR_HSM; | ||
1725 | ap->hsm_task_state = HSM_ST_ERR; | ||
1726 | } else | ||
1727 | goto idle_irq; | ||
1728 | } | ||
1721 | 1729 | ||
1722 | /* ack bmdma irq events */ | 1730 | /* ack bmdma irq events */ |
1723 | ap->ops->sff_irq_clear(ap); | 1731 | ap->ops->sff_irq_clear(ap); |
@@ -1762,13 +1770,16 @@ EXPORT_SYMBOL_GPL(ata_sff_host_intr); | |||
1762 | irqreturn_t ata_sff_interrupt(int irq, void *dev_instance) | 1770 | irqreturn_t ata_sff_interrupt(int irq, void *dev_instance) |
1763 | { | 1771 | { |
1764 | struct ata_host *host = dev_instance; | 1772 | struct ata_host *host = dev_instance; |
1773 | bool retried = false; | ||
1765 | unsigned int i; | 1774 | unsigned int i; |
1766 | unsigned int handled = 0, polling = 0; | 1775 | unsigned int handled, idle, polling; |
1767 | unsigned long flags; | 1776 | unsigned long flags; |
1768 | 1777 | ||
1769 | /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ | 1778 | /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ |
1770 | spin_lock_irqsave(&host->lock, flags); | 1779 | spin_lock_irqsave(&host->lock, flags); |
1771 | 1780 | ||
1781 | retry: | ||
1782 | handled = idle = polling = 0; | ||
1772 | for (i = 0; i < host->n_ports; i++) { | 1783 | for (i = 0; i < host->n_ports; i++) { |
1773 | struct ata_port *ap = host->ports[i]; | 1784 | struct ata_port *ap = host->ports[i]; |
1774 | struct ata_queued_cmd *qc; | 1785 | struct ata_queued_cmd *qc; |
@@ -1782,7 +1793,8 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance) | |||
1782 | handled |= ata_sff_host_intr(ap, qc); | 1793 | handled |= ata_sff_host_intr(ap, qc); |
1783 | else | 1794 | else |
1784 | polling |= 1 << i; | 1795 | polling |= 1 << i; |
1785 | } | 1796 | } else |
1797 | idle |= 1 << i; | ||
1786 | } | 1798 | } |
1787 | 1799 | ||
1788 | /* | 1800 | /* |
@@ -1790,7 +1802,9 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance) | |||
1790 | * asserting IRQ line, nobody cared will ensue. Check IRQ | 1802 | * asserting IRQ line, nobody cared will ensue. Check IRQ |
1791 | * pending status if available and clear spurious IRQ. | 1803 | * pending status if available and clear spurious IRQ. |
1792 | */ | 1804 | */ |
1793 | if (!handled) { | 1805 | if (!handled && !retried) { |
1806 | bool retry = false; | ||
1807 | |||
1794 | for (i = 0; i < host->n_ports; i++) { | 1808 | for (i = 0; i < host->n_ports; i++) { |
1795 | struct ata_port *ap = host->ports[i]; | 1809 | struct ata_port *ap = host->ports[i]; |
1796 | 1810 | ||
@@ -1805,8 +1819,23 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance) | |||
1805 | ata_port_printk(ap, KERN_INFO, | 1819 | ata_port_printk(ap, KERN_INFO, |
1806 | "clearing spurious IRQ\n"); | 1820 | "clearing spurious IRQ\n"); |
1807 | 1821 | ||
1808 | ap->ops->sff_check_status(ap); | 1822 | if (idle & (1 << i)) { |
1809 | ap->ops->sff_irq_clear(ap); | 1823 | ap->ops->sff_check_status(ap); |
1824 | ap->ops->sff_irq_clear(ap); | ||
1825 | } else { | ||
1826 | /* clear INTRQ and check if BUSY cleared */ | ||
1827 | if (!(ap->ops->sff_check_status(ap) & ATA_BUSY)) | ||
1828 | retry |= true; | ||
1829 | /* | ||
1830 | * With command in flight, we can't do | ||
1831 | * sff_irq_clear() w/o racing with completion. | ||
1832 | */ | ||
1833 | } | ||
1834 | } | ||
1835 | |||
1836 | if (retry) { | ||
1837 | retried = true; | ||
1838 | goto retry; | ||
1810 | } | 1839 | } |
1811 | } | 1840 | } |
1812 | 1841 | ||