net: phy: fix interrupt handling in non-started states
Subsystems (3)
Heiner Kallweit
maintainerPATCH 1/1 net: phy: fix interrupt handling in non-started states
phylib enables interrupts before phy_start() has been called, and if we receive an interrupt in a non-started state, the interrupt handler returns IRQ_NONE. This causes problems with at least one Marvell chip as reported by Andrew.
Fix this by handling interrupts the same as in phy_mac_interrupt(), basically always running the phylib state machine. It knows when it has to do something and when not.
This change allows to handle interrupts gracefully even if they occur in a non-started state.
--- drivers/net/phy/phy.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/phy/phy.c +0 -3
@@ -762,9 +762,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) {struct phy_device *phydev = phy_dat; -if (!phy_is_started (phydev)) -return IRQ_NONE ;/* It can't be ours. */ -if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt (phydev))return IRQ_NONE ;
Signature · 1 line
2.20.1
Andrew Lunn
maintainerQuoted 22 lines · Heiner Kallweit
phylib enables interrupts before
phy_start()has been called, and if we receive an interrupt in a non-started state, the interrupt handler returnsIRQ_NONE. This causes problems with at least one Marvell chip as reported by Andrew.
Fix this by handling interrupts the same as inphy_mac_interrupt(), basically always running the phylib state machine. It knows when it has to do something and when not.
This change allows to handle interrupts gracefully even if they occur in a non-started state.Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")Reported-by Andrew Lunn <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/phy/phy.c | 3 --- 1 file changed, 3 deletions(-)drivers/net/phy/phy.c +0
-0
drivers/net/phy/phy.c static irqreturn_t phy_interrupt(int irq, void *phy_dat) · line 766
Quoted 8 lines
drivers/net/phy/phy.c +0
-3@@ -762,9 +762,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) {struct phy_device *phydev = phy_dat; -if (!phy_is_started (phydev)) -return IRQ_NONE ;/* It can't be ours. */ -if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt (phydev))return IRQ_NONE ;
Hi Heiner
Did you look at
ommit 3c3070d713d798f7f9e7ee3614e49b47655d14d8
Author: Maciej W. Rozycki <[email protected]> Date: Tue Oct 3 16:18:35 2006 +0100
[PATCH] 2.6.18: sb1250-mac: Phylib IRQ handling fixes
This patch fixes a couple of problems discovered with interrupt handling
in the phylib core, namely:
1. The driver uses timer and workqueue calls, but does not include <linux/timer.h> nor <linux/workqueue.h>.
2. The driver uses schedule_work() for handling interrupts, but does not make sure any pending work scheduled thus has been completed before driver's structures get freed from memory. This is especially important as interrupts may keep arriving if the line is shared with another PHY.
The solution is to ignore phy_interrupt() calls if the reported device has already been halted and calling flush_scheduled_work() from phy_stop_interrupts() (but guarded with current_is_keventd() in case the function has been called through keventd from the MAC device's close call to avoid a deadlock on the netlink lock).
patch-mips-2.6.18-20060920-phy-irq-16
There has been a lot of change since then, so maybe this is no longer an issue?
Thanks
Andrew
Heiner Kallweit
maintainerQuoted 34 lines · Andrew Lunn
Quoted 22 lines · Heiner Kallweit
phylib enables interrupts before
phy_start()has been called, and if we receive an interrupt in a non-started state, the interrupt handler returnsIRQ_NONE. This causes problems with at least one Marvell chip as reported by Andrew.
Fix this by handling interrupts the same as inphy_mac_interrupt(), basically always running the phylib state machine. It knows when it has to do something and when not.
This change allows to handle interrupts gracefully even if they occur in a non-started state.Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")Reported-by Andrew Lunn <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>--- drivers/net/phy/phy.c | 3 --- 1 file changed, 3 deletions(-)drivers/net/phy/phy.c +0
-0drivers/net/phy/phy.c static irqreturn_t phy_interrupt(int irq, void *phy_dat) · line 766
Quoted 8 lines
drivers/net/phy/phy.c +0
-3@@ -762,9 +762,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) {struct phy_device *phydev = phy_dat; -if (!phy_is_started (phydev)) -return IRQ_NONE ;/* It can't be ours. */ -if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt (phydev))return IRQ_NONE ;Hi Heiner
Quoted 2 lines
Did you look at
Thanks for this interesting old read.
Quoted 9 lines
ommit
3c3070d713d798f7f9e7ee3614e49b47655d14d8Author: Maciej W. Rozycki <[email protected]> Date: Tue Oct 3 16:18:35 2006 +0100[PATCH] 2.6.18: sb1250-mac: Phylib IRQ handling fixes
This patch fixes a couple of problems discovered with interrupt handling
in the phylib core, namely:
Quoted 9 lines
1. The driver uses timer and workqueue calls, but does not include <
linux/timer.h> nor <linux/workqueue.h>.2. The driver uses
schedule_work()for handling interrupts, but does not make sure any pending work scheduled thus has been completed before driver's structures get freed from memory. This is especially important as interrupts may keep arriving if the line is shared with another PHY.
Since that time this have massively changed and I *think* this doesn't apply any longer. cancel_delayed_work_sync() is called always before driver structure is freed.
Quoted 6 lines
The solution is to ignore
phy_interrupt()calls if the reported device has already been halted and callingflush_scheduled_work()fromphy_stop_interrupts()(but guarded withcurrent_is_keventd()in case the function has been called through keventd from the MAC device's close call to avoid a deadlock on the netlink lock).
Quoted 8 lines
Signed-off-by Maciej W. Rozycki <[email protected]>patch-mips-2.6.18-20060920-phy-irq-16
Signed-off-by Jeff Garzik <[email protected]>There has been a lot of change since then, so maybe this is no longer an issue?
AFAICS, yes. I'll have a closer look at the scenario described by Russell, this however should be independent of the patch here.
Quoted 3 lines
Thanks
Andrew
Heiner
Quoted 10 lines · Heiner Kallweit
phylib enables interrupts before
phy_start()has been called, and if we receive an interrupt in a non-started state, the interrupt handler returnsIRQ_NONE. This causes problems with at least one Marvell chip as reported by Andrew.
Fix this by handling interrupts the same as inphy_mac_interrupt(), basically always running the phylib state machine. It knows when it has to do something and when not.
This change allows to handle interrupts gracefully even if they occur in a non-started state.
Quoted 3 lines
Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")Reported-by Andrew Lunn <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Quoted 10 lines · Heiner Kallweit
phylib enables interrupts before
phy_start()has been called, and if we receive an interrupt in a non-started state, the interrupt handler returnsIRQ_NONE. This causes problems with at least one Marvell chip as reported by Andrew.
Fix this by handling interrupts the same as inphy_mac_interrupt(), basically always running the phylib state machine. It knows when it has to do something and when not.
This change allows to handle interrupts gracefully even if they occur in a non-started state.
Quoted 3 lines
Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")Reported-by Andrew Lunn <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>
Signature · 1 line
Florian
From: Heiner Kallweit <[email protected]>
Date: Tue, 12 Feb 2019 19:56:15 +0100
Quoted 10 lines
phylib enables interrupts before
phy_start()has been called, and if we receive an interrupt in a non-started state, the interrupt handler returnsIRQ_NONE. This causes problems with at least one Marvell chip as reported by Andrew.
Fix this by handling interrupts the same as inphy_mac_interrupt(), basically always running the phylib state machine. It knows when it has to do something and when not.
This change allows to handle interrupts gracefully even if they occur in a non-started state.
Quoted 3 lines
Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")Reported-by Andrew Lunn <[email protected]>Signed-off-by Heiner Kallweit <[email protected]>
Applied, thanks Heiner.