From: Nicolai Buchwitz <nb@tipi-net.de>
To: "Oliver Neukum" <oliver@neukum.org>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Sjur Brændeland" <sjur.brandeland@stericsson.com>,
"Alexey Orishko" <alexey.orishko@gmail.com>,
"Bjørn Mork" <bjorn@mork.no>,
"Greg Suarez" <gsuarez@smithmicro.com>
Cc: Breno Leitao <leitao@debian.org>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Nicolai Buchwitz <nb@tipi-net.de>,
Mikkel Eskildsen <mke@visotia.com>
Subject: [PATCH net v2 1/2] net: usb: cdc_ncm: don't enable BHs in tx_fixup under netpoll
Date: Wed, 21 Oct 2026 09:56:18 +0200 [thread overview]
Message-ID: <20261021-cdc-ncm-netpoll-v2-1-8818965bbb69@tipi-net.de> (raw)
In-Reply-To: <20261021-cdc-ncm-netpoll-v2-0-8818965bbb69@tipi-net.de>
netpoll holds the txq lock and calls ndo_start_xmit() with IRQs off but
BHs on. The spin_unlock_bh() in cdc_ncm_tx_fixup() then runs pending
softirqs. If one of them transmits, it spins on the txq lock that
netpoll holds. With netconsole on a cdc_ncm device this ends in a soft
or hard lockup.
Use spin_lock_irqsave(), which is safe both under netpoll and on the
normal xmit path.
Fixes: c84ff1d6dff3 ("cdc_ncm: reduce driver latency in the data path")
Reported-by: Mikkel Eskildsen <mke@visotia.com>
Closes: https://lore.kernel.org/netdev/PRAP189MB185019A5A8D411482BB6E0CDA9982@PRAP189MB1850.EURP189.PROD.OUTLOOK.COM/
Tested-by: Mikkel Eskildsen <mke@visotia.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/usb/cdc_ncm.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 35db38cb3e4a2..fed0b117a42f1 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1522,8 +1522,9 @@ static void cdc_ncm_txpath_bh(struct tasklet_struct *t)
struct sk_buff *
cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{
- struct sk_buff *skb_out;
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+ struct sk_buff *skb_out;
+ unsigned long irqflags;
/*
* The Ethernet API we are using does not support transmitting
@@ -1535,14 +1536,17 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
if (ctx == NULL)
goto error;
- spin_lock_bh(&ctx->mtx);
+ /* netpoll calls this with IRQs off and BHs on, so unlocking with
+ * spin_unlock_bh() would run softirqs that need the held txq lock.
+ */
+ spin_lock_irqsave(&ctx->mtx, irqflags);
if (ctx->is_ndp16)
skb_out = cdc_ncm_fill_tx_frame(dev, skb, cpu_to_le32(USB_CDC_NCM_NDP16_NOCRC_SIGN));
else
skb_out = cdc_ncm_fill_tx_frame(dev, skb, cpu_to_le32(USB_CDC_NCM_NDP32_NOCRC_SIGN));
- spin_unlock_bh(&ctx->mtx);
+ spin_unlock_irqrestore(&ctx->mtx, irqflags);
return skb_out;
error:
--
2.53.0
next prev parent reply other threads:[~2026-10-21 7:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 7:56 [PATCH net v2 0/2] net: usb: cdc_ncm/cdc_mbim: fix netpoll lockup in tx_fixup Nicolai Buchwitz
2026-10-21 7:56 ` Nicolai Buchwitz [this message]
2026-10-22 12:58 ` [PATCH net v2 1/2] net: usb: cdc_ncm: don't enable BHs in tx_fixup under netpoll Simon Horman
2026-10-21 7:56 ` [PATCH net v2 2/2] net: usb: cdc_mbim: " Nicolai Buchwitz
2026-10-22 12:58 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021-cdc-ncm-netpoll-v2-1-8818965bbb69@tipi-net.de \
--to=nb@tipi-net.de \
--cc=alexey.orishko@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gsuarez@smithmicro.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mke@visotia.com \
--cc=netdev@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=pabeni@redhat.com \
--cc=sjur.brandeland@stericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®