Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2658487pxj; Mon, 14 Jun 2021 04:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx34JumPPYYAk/UG7cWKlb+89xfSn4E8hETWvevaz99sZiUgMWtxUAEkgB2ZctAsYCAD61I X-Received: by 2002:a17:906:2510:: with SMTP id i16mr14388108ejb.218.1623669249199; Mon, 14 Jun 2021 04:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669249; cv=none; d=google.com; s=arc-20160816; b=w296tgqENZWbmn9djt9rQbO45OR6pdK0oGZxY3uQByeMOVmPHwqoz9cmqfq7bpSu4w JOu33Mu4RMq+DR1o4JdRRyO9xwOHxZz+NrAzE8aEVROP8xS4zuA2Be2Gz0a/ceC1195M TVaJWwsNIpRDSx+UY7QAYyNBMe/DPpXHXfKRPXan+qQtSueP7O1sTWJigYUugNAA+ZEE 1xeGCQ0srNqrRcCGkJxPMVYtSpBji8UKlloLisM0yPeQirnZ7PHVYK/dXhRF+d7VhnUQ AjqDsrIejrsAvQ6Qp9ilnkVIR56zg4UeGcFKOeXJg19Fs4Exed+gg+ghOe9ZJIkZbN9D 7BDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cPOLbogx7HHu3LnDJztTum2SQt1zsNHnj5anekeNHVM=; b=YlNEZdH6udWndsPdvyTsJFDlqiKHWFJDnHSx7yxEPgigH3ozgzuFZUi6pulSFapOAv 9u/4+d19hspm77DcEUfo7z2yNf7o7nkPQcqb/AE2hMRrEeFId8Y2DReTyBvexRBxMtEY rzVQitGMopJ/wer9Lg3LJu1Av/paFNCt1RpnOrVD/e46cM5QUvxECHmGfggW9sjHJpyn eqoAvGngVDZNCgWB6rOwV467CduxsJiQxaJrPL7MiKy/Nym5lHnXTYyNkDzLnnonvjNv yEDnRHgbbU1ewdUmYYWoGSzYkxhzH8P7QBkGfkvhGFF1qSjS/edTc0JfBp6oSty+8PYg Y9nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FwL+H3Up; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 13si10989356ejh.524.2021.06.14.04.13.46; Mon, 14 Jun 2021 04:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FwL+H3Up; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233190AbhFNLO7 (ORCPT + 99 others); Mon, 14 Jun 2021 07:14:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:39058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234685AbhFNLCu (ORCPT ); Mon, 14 Jun 2021 07:02:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB32F61878; Mon, 14 Jun 2021 10:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667431; bh=J5V1QVOgXXFiFt0IqM+CYK36Ta3RwIHNPWq3G/S5GvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwL+H3UpeTGVHRcFAuFbjhjiLmwADwz678Rd/V8xNd1lIZOHmWi9AQ+RACARLgsKV FrZJSAfoQ9MRjGmY+bbxzYaZAteFUDq2qSfLQX5vgrukwE4E5iaj3w3KrP+BqYEUeI Pw9tLSk3pgoOTujin7kQwrvH5Mu1QHbc0/hYfM78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brooke Basile , Bryan ODonoghue , Felipe Balbi , Lorenzo Colitti , =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Subject: [PATCH 5.10 068/131] usb: f_ncm: only first packet of aggregate needs to start timer Date: Mon, 14 Jun 2021 12:27:09 +0200 Message-Id: <20210614102655.341281623@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maciej Żenczykowski 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 Cc: Bryan O'Donoghue Cc: Felipe Balbi Cc: Lorenzo Colitti Signed-off-by: Maciej Żenczykowski Link: https://lore.kernel.org/r/20210608085438.813960-1-zenczykowski@gmail.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- 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);