ahci: give another shot at clearing all bits in irq_stat

Commit ea0c62f7cf70f13a67830471b613337bd0c9a62e tried to clear all
bits in irq_stat but it didn't actually achieve that as irq_stat was
anded with port_map right after read. This patch makes ahci driver
always use the unmasked value to clear irq_status.

While at it, add explanation on the peculiarities of ahci IRQ
clearing.

This was spotted by Linus Torvalds.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Tejun Heo and committed by Linus Torvalds d28f87aa d79df630

+13 -3
+13 -3
drivers/ata/ahci.c
··· 1777 1777 struct ahci_host_priv *hpriv; 1778 1778 unsigned int i, handled = 0; 1779 1779 void __iomem *mmio; 1780 - u32 irq_stat; 1780 + u32 irq_stat, irq_masked; 1781 1781 1782 1782 VPRINTK("ENTER\n"); 1783 1783 ··· 1786 1786 1787 1787 /* sigh. 0xffffffff is a valid return from h/w */ 1788 1788 irq_stat = readl(mmio + HOST_IRQ_STAT); 1789 - irq_stat &= hpriv->port_map; 1790 1789 if (!irq_stat) 1791 1790 return IRQ_NONE; 1791 + 1792 + irq_masked = irq_stat & hpriv->port_map; 1792 1793 1793 1794 spin_lock(&host->lock); 1794 1795 1795 1796 for (i = 0; i < host->n_ports; i++) { 1796 1797 struct ata_port *ap; 1797 1798 1798 - if (!(irq_stat & (1 << i))) 1799 + if (!(irq_masked & (1 << i))) 1799 1800 continue; 1800 1801 1801 1802 ap = host->ports[i]; ··· 1813 1812 handled = 1; 1814 1813 } 1815 1814 1815 + /* HOST_IRQ_STAT behaves as level triggered latch meaning that 1816 + * it should be cleared after all the port events are cleared; 1817 + * otherwise, it will raise a spurious interrupt after each 1818 + * valid one. Please read section 10.6.2 of ahci 1.1 for more 1819 + * information. 1820 + * 1821 + * Also, use the unmasked value to clear interrupt as spurious 1822 + * pending event on a dummy port might cause screaming IRQ. 1823 + */ 1816 1824 writel(irq_stat, mmio + HOST_IRQ_STAT); 1817 1825 1818 1826 spin_unlock(&host->lock);