Skip to content

Commit 249bc97

Browse files
hkallweitdavem330
authored andcommitted
net: phy: avoid clearing PHY interrupts twice in irq handler
On all PHY drivers that implement did_interrupt() reading the interrupt status bits clears them. This means we may loose an interrupt that is triggered between calling did_interrupt() and phy_clear_interrupt(). As part of the fix make it a requirement that did_interrupt() clears the interrupt. The Fixes tag refers to the first commit where the patch applies cleanly. Fixes: 49644e6 ("net: phy: add callback for custom interrupt handler to struct phy_driver") Reported-by: Michael Walle <[email protected]> Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 52c0d4e commit 249bc97

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

drivers/net/phy/phy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
727727
phy_trigger_machine(phydev);
728728
}
729729

730-
if (phy_clear_interrupt(phydev))
730+
/* did_interrupt() may have cleared the interrupt already */
731+
if (!phydev->drv->did_interrupt && phy_clear_interrupt(phydev))
731732
goto phy_err;
732733
return IRQ_HANDLED;
733734

include/linux/phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ struct phy_driver {
557557
/*
558558
* Checks if the PHY generated an interrupt.
559559
* For multi-PHY devices with shared PHY interrupt pin
560+
* Set interrupt bits have to be cleared.
560561
*/
561562
int (*did_interrupt)(struct phy_device *phydev);
562563

0 commit comments

Comments
 (0)