diff mbox series

[net] eth: sungem: remove .ndo_poll_controller to avoid deadlocks

Message ID 20240508134504.3560956-1-kuba@kernel.org (mailing list archive)
State Accepted
Commit ac0a230f719b02432d8c7eba7615ebd691da86f4
Delegated to: Netdev Maintainers
Headers show
Series [net] eth: sungem: remove .ndo_poll_controller to avoid deadlocks | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 926 this patch: 926
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: horms@kernel.org
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-10--18-00 (tests: 1014)

Commit Message

Jakub Kicinski May 8, 2024, 1:45 p.m. UTC
Erhard reports netpoll warnings from sungem:

  netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll (gem_start_xmit+0x0/0x398)
  WARNING: CPU: 1 PID: 1 at net/core/netpoll.c:370 netpoll_send_skb+0x1fc/0x20c

gem_poll_controller() disables interrupts, which may sleep.
We can't sleep in netpoll, it has interrupts disabled completely.
Strangely, gem_poll_controller() doesn't even poll the completions,
and instead acts as if an interrupt has fired so it just schedules
NAPI and exits. None of this has been necessary for years, since
netpoll invokes NAPI directly.

Fixes: fe09bb619096 ("sungem: Spring cleaning and GRO support")
Reported-and-tested-by: Erhard Furtner <erhard_f@mailbox.org>
Link: https://lore.kernel.org/all/20240428125306.2c3080ef@legion
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: robh@kernel.org
CC: elder@kernel.org
CC: wei.fang@nxp.com
CC: bhupesh.sharma@linaro.org
CC: benh@kernel.crashing.org
---
 drivers/net/ethernet/sun/sungem.c | 14 --------------
 1 file changed, 14 deletions(-)

Comments

Eric Dumazet May 8, 2024, 2:32 p.m. UTC | #1
On Wed, May 8, 2024 at 3:45 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Erhard reports netpoll warnings from sungem:
>
>   netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll (gem_start_xmit+0x0/0x398)
>   WARNING: CPU: 1 PID: 1 at net/core/netpoll.c:370 netpoll_send_skb+0x1fc/0x20c
>
> gem_poll_controller() disables interrupts, which may sleep.
> We can't sleep in netpoll, it has interrupts disabled completely.
> Strangely, gem_poll_controller() doesn't even poll the completions,
> and instead acts as if an interrupt has fired so it just schedules
> NAPI and exits. None of this has been necessary for years, since
> netpoll invokes NAPI directly.
>
> Fixes: fe09bb619096 ("sungem: Spring cleaning and GRO support")
> Reported-and-tested-by: Erhard Furtner <erhard_f@mailbox.org>
> Link: https://lore.kernel.org/all/20240428125306.2c3080ef@legion
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Eric Dumazet <edumazet@google.com>
Wei Fang May 9, 2024, 11:10 a.m. UTC | #2
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: 2024年5月8日 21:45
> To: davem@davemloft.net
> Cc: netdev@vger.kernel.org; edumazet@google.com; pabeni@redhat.com;
> Jakub Kicinski <kuba@kernel.org>; Erhard Furtner <erhard_f@mailbox.org>;
> robh@kernel.org; elder@kernel.org; Wei Fang <wei.fang@nxp.com>;
> bhupesh.sharma@linaro.org; benh@kernel.crashing.org
> Subject: [PATCH net] eth: sungem: remove .ndo_poll_controller to avoid
> deadlocks
> 
> Erhard reports netpoll warnings from sungem:
> 
>   netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll
> (gem_start_xmit+0x0/0x398)
>   WARNING: CPU: 1 PID: 1 at net/core/netpoll.c:370
> netpoll_send_skb+0x1fc/0x20c
> 
> gem_poll_controller() disables interrupts, which may sleep.
> We can't sleep in netpoll, it has interrupts disabled completely.
> Strangely, gem_poll_controller() doesn't even poll the completions, and
> instead acts as if an interrupt has fired so it just schedules NAPI and exits.
> None of this has been necessary for years, since netpoll invokes NAPI directly.
> 

Thanks for reminder.
The fec driver should have the same issue, but I don't know much about netpoll,
is ndo_poll_controller() no needed anymore? so it can be safely deleted from
device driver?
Jakub Kicinski May 9, 2024, 6:51 p.m. UTC | #3
On Thu, 9 May 2024 11:10:46 +0000 Wei Fang wrote:
> Thanks for reminder.
> The fec driver should have the same issue, but I don't know much about netpoll,
> is ndo_poll_controller() no needed anymore? so it can be safely deleted from
> device driver?

If the driver uses NAPI for tx completions - implementing
ndo_poll_controller is not necessary.
patchwork-bot+netdevbpf@kernel.org May 11, 2024, 1:30 a.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  8 May 2024 06:45:04 -0700 you wrote:
> Erhard reports netpoll warnings from sungem:
> 
>   netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll (gem_start_xmit+0x0/0x398)
>   WARNING: CPU: 1 PID: 1 at net/core/netpoll.c:370 netpoll_send_skb+0x1fc/0x20c
> 
> gem_poll_controller() disables interrupts, which may sleep.
> We can't sleep in netpoll, it has interrupts disabled completely.
> Strangely, gem_poll_controller() doesn't even poll the completions,
> and instead acts as if an interrupt has fired so it just schedules
> NAPI and exits. None of this has been necessary for years, since
> netpoll invokes NAPI directly.
> 
> [...]

Here is the summary with links:
  - [net] eth: sungem: remove .ndo_poll_controller to avoid deadlocks
    https://git.kernel.org/netdev/net/c/ac0a230f719b

You are awesome, thank you!
Benjamin Herrenschmidt May 23, 2024, 11:53 p.m. UTC | #5
On Sat, 2024-05-11 at 01:30 +0000, patchwork-bot+netdevbpf@kernel.org
wrote:
> Hello:
> 
> This patch was applied to netdev/net.git (main)
> by Jakub Kicinski <kuba@kernel.org>:
> 
> On Wed,  8 May 2024 06:45:04 -0700 you wrote:
> > Erhard reports netpoll warnings from sungem:
> > 
> >   netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll
> > (gem_start_xmit+0x0/0x398)
> >   WARNING: CPU: 1 PID: 1 at net/core/netpoll.c:370
> > netpoll_send_skb+0x1fc/0x20c
> > 
> > gem_poll_controller() disables interrupts, which may sleep.
> > We can't sleep in netpoll, it has interrupts disabled completely.
> > Strangely, gem_poll_controller() doesn't even poll the completions,
> > and instead acts as if an interrupt has fired so it just schedules
> > NAPI and exits. None of this has been necessary for years, since
> > netpoll invokes NAPI directly.

Well, I wrote that in 2011 so ... :-) But yeah, sounds good.

Cheers,
Ben.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 9bd1df8308d2..d3a2fbb14140 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -949,17 +949,6 @@  static irqreturn_t gem_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_NET_POLL_CONTROLLER
-static void gem_poll_controller(struct net_device *dev)
-{
-	struct gem *gp = netdev_priv(dev);
-
-	disable_irq(gp->pdev->irq);
-	gem_interrupt(gp->pdev->irq, dev);
-	enable_irq(gp->pdev->irq);
-}
-#endif
-
 static void gem_tx_timeout(struct net_device *dev, unsigned int txqueue)
 {
 	struct gem *gp = netdev_priv(dev);
@@ -2839,9 +2828,6 @@  static const struct net_device_ops gem_netdev_ops = {
 	.ndo_change_mtu		= gem_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_set_mac_address    = gem_set_mac_address,
-#ifdef CONFIG_NET_POLL_CONTROLLER
-	.ndo_poll_controller    = gem_poll_controller,
-#endif
 };
 
 static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)