aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-sff.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-01-18 20:49:19 -0500
committerJeff Garzik <jgarzik@redhat.com>2010-03-01 14:58:44 -0500
commit27943620cbd960f710a385ff4a538e14ed3f1922 (patch)
treefae161f49c10fa488f7a5891085961f284021544 /drivers/ata/libata-sff.c
parentd88ec2e5c13261cf317b46832a7de216f6d06537 (diff)
libata: implement spurious irq handling for SFF and apply it to piix
Traditional IDE interface sucks in that it doesn't have a reliable IRQ pending bit, so if the controller raises IRQ while the driver is expecting it not to, the IRQ won't be cleared and eventually the IRQ line will be killed by interrupt subsystem. Some controllers have non-standard mechanism to indicate IRQ pending so that this condition can be detected and worked around. This patch adds an optional operation ->sff_irq_check() which will be called for each port from the ata_sff_interrupt() if an unexpected interrupt is received. If the operation returns %true, ->sff_check_status() and ->sff_irq_clear() will be cleared for the port. Note that this doesn't mark the interrupt as handled so it won't prevent IRQ subsystem from killing the IRQ if this mechanism fails to clear the spurious IRQ. This patch also implements ->sff_irq_check() for ata_piix. Note that this adds slight overhead to shared IRQ operation as IRQs which are destined for other controllers will trigger extra register accesses to check whether IDE interrupt is pending but this solves rare screaming IRQ cases and for some curious reason also helps weird BIOS related glitch on Samsung n130 as reported in bko#14314. http://bugzilla.kernel.org/show_bug.cgi?id=14314 * piix_base_ops dropped as suggested by Sergei. * Spurious IRQ detection doesn't kick in anymore if polling qc is in progress. This provides less protection but some controllers have possible data corruption issues if the wrong register is accessed while a command is in progress. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Johannes Stezenbach <js@sig21.net> Reported-by: Hans Werner <hwerner4@gmx.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-sff.c')
-rw-r--r--drivers/ata/libata-sff.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index c62ed13b059..c2661ea7033 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1763,7 +1763,7 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1763{ 1763{
1764 struct ata_host *host = dev_instance; 1764 struct ata_host *host = dev_instance;
1765 unsigned int i; 1765 unsigned int i;
1766 unsigned int handled = 0; 1766 unsigned int handled = 0, polling = 0;
1767 unsigned long flags; 1767 unsigned long flags;
1768 1768
1769 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ 1769 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
@@ -1777,8 +1777,37 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1777 continue; 1777 continue;
1778 1778
1779 qc = ata_qc_from_tag(ap, ap->link.active_tag); 1779 qc = ata_qc_from_tag(ap, ap->link.active_tag);
1780 if (qc && !(qc->tf.flags & ATA_TFLAG_POLLING)) 1780 if (qc) {
1781 handled |= ata_sff_host_intr(ap, qc); 1781 if (!(qc->tf.flags & ATA_TFLAG_POLLING))
1782 handled |= ata_sff_host_intr(ap, qc);
1783 else
1784 polling |= 1 << i;
1785 }
1786 }
1787
1788 /*
1789 * If no port was expecting IRQ but the controller is actually
1790 * asserting IRQ line, nobody cared will ensue. Check IRQ
1791 * pending status if available and clear spurious IRQ.
1792 */
1793 if (!handled) {
1794 for (i = 0; i < host->n_ports; i++) {
1795 struct ata_port *ap = host->ports[i];
1796
1797 if (polling & (1 << i))
1798 continue;
1799
1800 if (!ap->ops->sff_irq_check ||
1801 !ap->ops->sff_irq_check(ap))
1802 continue;
1803
1804 if (printk_ratelimit())
1805 ata_port_printk(ap, KERN_INFO,
1806 "clearing spurious IRQ\n");
1807
1808 ap->ops->sff_check_status(ap);
1809 ap->ops->sff_irq_clear(ap);
1810 }
1782 } 1811 }
1783 1812
1784 spin_unlock_irqrestore(&host->lock, flags); 1813 spin_unlock_irqrestore(&host->lock, flags);