path: root/drivers/usb
diff options
authorMaciej ┼╗enczykowski <>2021-06-08 01:54:38 -0700
committerGreg Kroah-Hartman <>2021-06-09 10:34:18 +0200
commit1958ff5ad2d4908b44a72bcf564dfe67c981e7fe (patch)
tree7f006b805b421effb2193d265de444969a103e8b /drivers/usb
parent3370139745853f7826895293e8ac3aec1430508e (diff)
usb: f_ncm: only first packet of aggregate needs to start timer
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 <> Cc: Bryan O'Donoghue <> Cc: Felipe Balbi <> Cc: Lorenzo Colitti <> Signed-off-by: Maciej ┼╗enczykowski <> Link: Cc: stable <> Signed-off-by: Greg Kroah-Hartman <>
Diffstat (limited to 'drivers/usb')
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 0d23c6c11a13..855127249f24 100644
--- 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(struct gether *port,
ncm->ndp_dgram_count = 1;
/* Note: we skip opts->next_ndp_index */
- }
- /* Delay the timer. */
- hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS,
+ /* Start the timer. */
+ hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS,
+ }
/* Add the datagram position entries */
ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len);