* FAILED: patch "[PATCH] usb: gadget: f_ncm: restart the TX timer if the TX freelist" failed to apply to 5.10-stable tree
@ 2026-11-25 11:35 gregkh
2026-11-26 15:31 ` [PATCH 5.10.y 1/3] usb: gadget: f_ncm: remove timer_force_tx field Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-11-25 11:35 UTC (permalink / raw)
To: cosmin-gabriel.tanislav.xa, gregkh, hiago.franco, leonardo.costa,
stable, tvlad744
Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 78585f90feb3bbaf3b1c642294c8c47e451dc3cf
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112552-crinkle-hurling-1987@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 78585f90feb3bbaf3b1c642294c8c47e451dc3cf Mon Sep 17 00:00:00 2001
From: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Date: Mon, 17 Aug 2026 22:26:38 +0300
Subject: [PATCH] usb: gadget: f_ncm: restart the TX timer if the TX freelist
is empty
ncm_wrap_ntb() aggregates datagrams into a pending NTB, which is sent
either when it becomes full, or after 300us since the NTB was started,
using ndo_start_xmit() (eth_start_xmit()).
ndo_start_xmit() returns NETDEV_TX_BUSY when the TX freelist is empty.
For regular packets this is fine since the networking core will requeue
them, but for timer-flushed packets there is no logic to handle this
situation, and HRTIMER_NORESTART is returned from ncm_tx_timeout()
without checking eth_start_xmit()'s return value.
Under sustained TX saturation the request freelist is empty most of the
time. Since the timer is never restarted, small packets keep getting
accumulated into the NTB, until either TX_MAX_NUM_DPE packets are stored
or NTB_DEFAULT_IN_SIZE is reached, which is an unknown amount of time.
Check the return value of ndo_start_xmit() and restart the timer after
another 300us.
Cc: stable <stable@kernel.org>
Fixes: 6d3865f9d41f ("usb: gadget: NCM: Add transmit multi-frame.")
Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Tested-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
Tested-by: Leonardo Costa <leonardo.costa@toradex.com>
Reported-by: Hiago De Franco <hiago.franco@toradex.com>
Closes: https://lore.kernel.org/all/20231204183751.64202-1-hiagofranco@gmail.com/
Link: https://patch.msgid.link/20260817192638.437798-1-cosmin-gabriel.tanislav.xa@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 500c9c19c78b..ab6da3ef8783 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1148,6 +1148,7 @@ static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
{
struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer);
struct net_device *netdev = READ_ONCE(ncm->netdev);
+ netdev_tx_t ret;
if (netdev) {
/* XXX This allowance of a NULL skb argument to ndo_start_xmit
@@ -1158,7 +1159,11 @@ static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
*
* This will call directly into u_ether's eth_start_xmit()
*/
- netdev->netdev_ops->ndo_start_xmit(NULL, netdev);
+ ret = netdev->netdev_ops->ndo_start_xmit(NULL, netdev);
+ if (ret == NETDEV_TX_BUSY) {
+ hrtimer_forward_now(data, TX_TIMEOUT_NSECS);
+ return HRTIMER_RESTART;
+ }
}
return HRTIMER_NORESTART;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 5.10.y 1/3] usb: gadget: f_ncm: remove timer_force_tx field
2026-11-25 11:35 FAILED: patch "[PATCH] usb: gadget: f_ncm: restart the TX timer if the TX freelist" failed to apply to 5.10-stable tree gregkh
@ 2026-11-26 15:31 ` Sasha Levin
2026-11-26 15:31 ` [PATCH 5.10.y 2/3] usb: gadget: f_ncm: remove spurious boolean timer_stopping Sasha Levin
2026-11-26 15:31 ` [PATCH 5.10.y 3/3] usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty Sasha Levin
0 siblings, 2 replies; 4+ messages in thread
From: Sasha Levin @ 2026-11-26 15:31 UTC (permalink / raw)
To: stable
Cc: Maciej Żenczykowski, Brooke Basile, Bryan O'Donoghue,
Felipe Balbi, Greg Kroah-Hartman, Lorenzo Colitti, Sasha Levin
From: Maciej Żenczykowski <maze@google.com>
[ Upstream commit dbaaca9aa5ce36c07a01a157d203071f6332a2af ]
It is simply not needed. This field is equivalent to skb being NULL.
Currently with the boolean set to true we call:
ncm->netdev->netdev_ops->ndo_start_xmit(NULL, ncm->netdev);
which calls u_ether's:
eth_start_xmit(NULL, ...)
which then calls:
skb = dev->wrap(dev->port_usb, NULL);
which calls back into f_ncm's:
ncm_wrap_ntb(..., NULL)
Cc: Brooke Basile <brookebasile@gmail.com>
Cc: "Bryan O'Donoghue" <bryan.odonoghue@linaro.org>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Link: https://lore.kernel.org/r/20210701114834.884597-1-zenczykowski@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 78585f90feb3 ("usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_ncm.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 609034f51fab4..558ecd0331a80 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -72,7 +72,6 @@ struct f_ncm {
struct sk_buff *skb_tx_data;
struct sk_buff *skb_tx_ndp;
u16 ndp_dgram_count;
- bool timer_force_tx;
struct hrtimer task_timer;
bool timer_stopping;
};
@@ -1128,8 +1127,11 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
dev_consume_skb_any(skb);
skb = NULL;
- } else if (ncm->skb_tx_data && ncm->timer_force_tx) {
- /* If the tx was requested because of a timeout then send */
+ } else if (ncm->skb_tx_data) {
+ /* If we get here ncm_wrap_ntb() was called with NULL skb,
+ * because eth_start_xmit() was called with NULL skb by
+ * ncm_tx_timeout() - hence, this is our signal to flush/send.
+ */
skb2 = package_for_tx(ncm);
if (!skb2)
goto err;
@@ -1160,8 +1162,6 @@ static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
/* Only send if data is available. */
if (!ncm->timer_stopping && ncm->skb_tx_data) {
- ncm->timer_force_tx = true;
-
/* XXX This allowance of a NULL skb argument to ndo_start_xmit
* XXX is not sane. The gadget layer should be redesigned so
* XXX that the dev->wrap() invocations to build SKBs is transparent
@@ -1169,8 +1169,6 @@ static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
* XXX interface.
*/
ncm->netdev->netdev_ops->ndo_start_xmit(NULL, ncm->netdev);
-
- ncm->timer_force_tx = false;
}
return HRTIMER_NORESTART;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 5.10.y 2/3] usb: gadget: f_ncm: remove spurious boolean timer_stopping
2026-11-26 15:31 ` [PATCH 5.10.y 1/3] usb: gadget: f_ncm: remove timer_force_tx field Sasha Levin
@ 2026-11-26 15:31 ` Sasha Levin
2026-11-26 15:31 ` [PATCH 5.10.y 3/3] usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-11-26 15:31 UTC (permalink / raw)
To: stable
Cc: Maciej Żenczykowski, Brooke Basile, Bryan O'Donoghue,
Felipe Balbi, Greg Kroah-Hartman, Lorenzo Colitti, Sasha Levin
From: Maciej Żenczykowski <maze@google.com>
[ Upstream commit cf4e2e880bde13af103d229be261e8f80c37921f ]
It is equivalent to ncm->netdev being NULL.
Cc: Brooke Basile <brookebasile@gmail.com>
Cc: "Bryan O'Donoghue" <bryan.odonoghue@linaro.org>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Link: https://lore.kernel.org/r/20210701114834.884597-2-zenczykowski@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 78585f90feb3 ("usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_ncm.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 558ecd0331a80..630b131422022 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -73,7 +73,6 @@ struct f_ncm {
struct sk_buff *skb_tx_ndp;
u16 ndp_dgram_count;
struct hrtimer task_timer;
- bool timer_stopping;
};
static inline struct f_ncm *func_to_ncm(struct usb_function *f)
@@ -891,7 +890,6 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
if (ncm->port.in_ep->enabled) {
DBG(cdev, "reset ncm\n");
- ncm->timer_stopping = true;
ncm->netdev = NULL;
gether_disconnect(&ncm->port);
ncm_reset_values(ncm);
@@ -929,7 +927,6 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
if (IS_ERR(net))
return PTR_ERR(net);
ncm->netdev = net;
- ncm->timer_stopping = false;
}
spin_lock(&ncm->lock);
@@ -1159,16 +1156,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
{
struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer);
+ struct net_device *netdev = READ_ONCE(ncm->netdev);
/* Only send if data is available. */
- if (!ncm->timer_stopping && ncm->skb_tx_data) {
+ if (netdev && ncm->skb_tx_data) {
/* XXX This allowance of a NULL skb argument to ndo_start_xmit
* XXX is not sane. The gadget layer should be redesigned so
* XXX that the dev->wrap() invocations to build SKBs is transparent
* XXX and performed in some way outside of the ndo_start_xmit
* XXX interface.
+ *
+ * This will call directly into u_ether's eth_start_xmit()
*/
- ncm->netdev->netdev_ops->ndo_start_xmit(NULL, ncm->netdev);
+ netdev->netdev_ops->ndo_start_xmit(NULL, netdev);
}
return HRTIMER_NORESTART;
}
@@ -1386,7 +1386,6 @@ static void ncm_disable(struct usb_function *f)
DBG(cdev, "ncm deactivated\n");
if (ncm->port.in_ep->enabled) {
- ncm->timer_stopping = true;
ncm->netdev = NULL;
gether_disconnect(&ncm->port);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 5.10.y 3/3] usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty
2026-11-26 15:31 ` [PATCH 5.10.y 1/3] usb: gadget: f_ncm: remove timer_force_tx field Sasha Levin
2026-11-26 15:31 ` [PATCH 5.10.y 2/3] usb: gadget: f_ncm: remove spurious boolean timer_stopping Sasha Levin
@ 2026-11-26 15:31 ` Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-11-26 15:31 UTC (permalink / raw)
To: stable
Cc: Cosmin Tanislav, stable, Vladyslav Tymoshchuk, Leonardo Costa,
Hiago De Franco, Greg Kroah-Hartman, Sasha Levin
From: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
[ Upstream commit 78585f90feb3bbaf3b1c642294c8c47e451dc3cf ]
ncm_wrap_ntb() aggregates datagrams into a pending NTB, which is sent
either when it becomes full, or after 300us since the NTB was started,
using ndo_start_xmit() (eth_start_xmit()).
ndo_start_xmit() returns NETDEV_TX_BUSY when the TX freelist is empty.
For regular packets this is fine since the networking core will requeue
them, but for timer-flushed packets there is no logic to handle this
situation, and HRTIMER_NORESTART is returned from ncm_tx_timeout()
without checking eth_start_xmit()'s return value.
Under sustained TX saturation the request freelist is empty most of the
time. Since the timer is never restarted, small packets keep getting
accumulated into the NTB, until either TX_MAX_NUM_DPE packets are stored
or NTB_DEFAULT_IN_SIZE is reached, which is an unknown amount of time.
Check the return value of ndo_start_xmit() and restart the timer after
another 300us.
Cc: stable <stable@kernel.org>
Fixes: 6d3865f9d41f ("usb: gadget: NCM: Add transmit multi-frame.")
Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Tested-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
Tested-by: Leonardo Costa <leonardo.costa@toradex.com>
Reported-by: Hiago De Franco <hiago.franco@toradex.com>
Closes: https://lore.kernel.org/all/20231204183751.64202-1-hiagofranco@gmail.com/
Link: https://patch.msgid.link/20260817192638.437798-1-cosmin-gabriel.tanislav.xa@renesas.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_ncm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 630b131422022..acdb6522dc2e7 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1157,6 +1157,7 @@ static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
{
struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer);
struct net_device *netdev = READ_ONCE(ncm->netdev);
+ netdev_tx_t ret;
/* Only send if data is available. */
if (netdev && ncm->skb_tx_data) {
@@ -1168,7 +1169,11 @@ static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
*
* This will call directly into u_ether's eth_start_xmit()
*/
- netdev->netdev_ops->ndo_start_xmit(NULL, netdev);
+ ret = netdev->netdev_ops->ndo_start_xmit(NULL, netdev);
+ if (ret == NETDEV_TX_BUSY) {
+ hrtimer_forward_now(data, TX_TIMEOUT_NSECS);
+ return HRTIMER_RESTART;
+ }
}
return HRTIMER_NORESTART;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 15:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 11:35 FAILED: patch "[PATCH] usb: gadget: f_ncm: restart the TX timer if the TX freelist" failed to apply to 5.10-stable tree gregkh
2026-11-26 15:31 ` [PATCH 5.10.y 1/3] usb: gadget: f_ncm: remove timer_force_tx field Sasha Levin
2026-11-26 15:31 ` [PATCH 5.10.y 2/3] usb: gadget: f_ncm: remove spurious boolean timer_stopping Sasha Levin
2026-11-26 15:31 ` [PATCH 5.10.y 3/3] usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox