This is a note to let you know that I've just added the patch titled usb: f_ncm: only first packet of aggregate needs to start timer to the 5.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: usb-f_ncm-only-first-packet-of-aggregate-needs-to-start-timer.patch and it can be found in the queue-5.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 1958ff5ad2d4908b44a72bcf564dfe67c981e7fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= <maze@xxxxxxxxxx> Date: Tue, 8 Jun 2021 01:54:38 -0700 Subject: usb: f_ncm: only first packet of aggregate needs to start timer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Maciej Żenczykowski <maze@xxxxxxxxxx> commit 1958ff5ad2d4908b44a72bcf564dfe67c981e7fe upstream. The reasoning for this change is that if we already had a packet pending, then we also already had a pending timer, and as such there is no need to reschedule it. This also prevents packets getting delayed 60 ms worst case under a tiny packet every 290us transmit load, by keeping the timeout always relative to the first queued up packet. (300us delay * 16KB max aggregation / 80 byte packet =~ 60 ms) As such the first packet is now at most delayed by 300us. Under low transmit load, this will simply result in us sending a shorter aggregate, as originally intended. This patch has the benefit of greatly reducing (by ~10 factor with 1500 byte frames aggregated into 16 kiB) the number of (potentially pretty costly) updates to the hrtimer. Cc: Brooke Basile <brookebasile@xxxxxxxxx> Cc: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx> Cc: Felipe Balbi <balbi@xxxxxxxxxx> Cc: Lorenzo Colitti <lorenzo@xxxxxxxxxx> Signed-off-by: Maciej Żenczykowski <maze@xxxxxxxxxx> Link: https://lore.kernel.org/r/20210608085438.813960-1-zenczykowski@xxxxxxxxx Cc: stable <stable@xxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/usb/gadget/function/f_ncm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -1101,11 +1101,11 @@ static struct sk_buff *ncm_wrap_ntb(stru ncm->ndp_dgram_count = 1; /* Note: we skip opts->next_ndp_index */ - } - /* Delay the timer. */ - hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, - HRTIMER_MODE_REL_SOFT); + /* Start the timer. */ + hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, + HRTIMER_MODE_REL_SOFT); + } /* Add the datagram position entries */ ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len); Patches currently in stable-queue which might be from maze@xxxxxxxxxx are queue-5.12/usb-f_ncm-ncm_bitrate-speed-is-unsigned.patch queue-5.12/usb-fix-various-gadget-panics-on-10gbps-cabling.patch queue-5.12/usb-f_ncm-only-first-packet-of-aggregate-needs-to-start-timer.patch queue-5.12/usb-fix-various-gadgets-null-ptr-deref-on-10gbps-cabling.patch