stmmac: call local_irq_save other than disable_irq in poll_controller
Subsystems (4)
PATCH 1/1 stmmac: call local_irq_save other than disable_irq in poll_controller
From: Sonic Zhang <[email protected]>
It is possible that poll_controller is called from netpoll.c with irq already disabled. Unexpected interrupt may be triggered if always enable irq before returning from poll_controller.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -2
@@ -2465,9 +2465,11 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)*/ static void stmmac_poll_controller (struct net_device *dev) { -disable_irq (dev->irq); +unsigned long flags; + +local_irq_save (flags);stmmac_interrupt (dev->irq, dev); -enable_irq (dev->irq); +local_irq_restore (flags); }#endif
Signature · 1 line
1.7.9.5
David Miller
maintainerFrom: Sonic Zhang <[email protected]>
Date: Tue, 5 May 2015 15:55:53 +0800
Quoted 7 lines
From: Sonic Zhang <[email protected]>
It is possible that
poll_controlleris called fromnetpoll.cwith irq already disabled. Unexpected interrupt may be triggered if always enable irq before returning frompoll_controller.Signed-off-by Sonic Zhang <[email protected]>
Nope, this is wrong.
If you don't use disable_irq(), the interrupt handler can run in parallel on another cpu and you definitely do not want that.
There is nothing wrong with the interrupt triggering on the enable_irq() here. If that causes some problem, there is a bug in this driver.
Hi David,
Quoted 9 lines · David Miller
From: Sonic Zhang <[email protected]>
Date: Tue, 5 May 2015 15:55:53 +0800Quoted 6 lines
From: Sonic Zhang <[email protected]>
It is possible that
poll_controlleris called fromnetpoll.cwith irq already disabled. Unexpected interrupt may be triggered if always enable irq before returning frompoll_controller.
Quoted 6 lines
Quoted 1 line
Signed-off-by Sonic Zhang <[email protected]>Nope, this is wrong.
If you don't use
disable_irq(), the interrupt handler can run in parallel on another cpu and you definitely do not want that.
How about change local_irq_save(flags) tospin_lock_irqsave(&priv->lock, flags) ?
Quoted 4 lines
There is nothing wrong with the interrupt triggering on the
enable_irq()here. If that causes some problem, there is a bug in this driver.
When I debug Linux kernel via KGDB over Ethernet, KGDB calls netpoll API and stmmac_poll_controller to send UDP packets with all interrupts disabled. KGDB assumes all interrupts keeps disabled when it is active and doing UDP data transmission. Enabling interrupts in stmmac_poll_controller causes KGDB re-enter exception and system halt.
Although KGDB over Ethernet is not part of the mainline tree, I feel this patch is useful in case other kernel functions want to call netpoll API with interrupts disabled.
Regards,
Sonic
David Miller
maintainerFrom: Sonic Zhang <[email protected]>
Date: Wed, 6 May 2015 11:53:53 +0800
Quoted 5 lines
When I debug Linux kernel via KGDB over Ethernet, KGDB calls netpoll API and
stmmac_poll_controllerto send UDP packets with all interrupts disabled. KGDB assumes all interrupts keeps disabled when it is active and doing UDP data transmission. Enabling interrupts instmmac_poll_controllercauses KGDB re-enter exception and system halt.
If KGDB has disabled local cpu interrupts, that cannot happen.
What stmmac_poll_controller() is doing is enabling a specific interupt source, not "interrupts" generally. The latter is what KGDB can specifically control and should care about.