Skip to content

Commit 1958ff5

Browse files
zenczykowskigregkh
authored andcommitted
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 <[email protected]> Cc: Bryan O'Donoghue <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Lorenzo Colitti <[email protected]> Signed-off-by: Maciej Żenczykowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3370139 commit 1958ff5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/usb/gadget/function/f_ncm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,11 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
11011101
ncm->ndp_dgram_count = 1;
11021102

11031103
/* Note: we skip opts->next_ndp_index */
1104-
}
11051104

1106-
/* Delay the timer. */
1107-
hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS,
1108-
HRTIMER_MODE_REL_SOFT);
1105+
/* Start the timer. */
1106+
hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS,
1107+
HRTIMER_MODE_REL_SOFT);
1108+
}
11091109

11101110
/* Add the datagram position entries */
11111111
ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len);

0 commit comments

Comments
 (0)