From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385683; b=HwYx52/amquzJBJUob9ZwQaMX1r8NkX2HhuZPR7y4sRZ04E1hdzq6i3cK4oEDsU5R/53 3g377dD1vFZ3nG0H9vbChqXGZ7M2Vzdq4ZOsF2ln8DuWjIMb2wU1px783ugg4yKmle9Em omKv3wTIIxdYilAXOajsd4E8odVAdev4jpCFWriTrUDwnaVXUQH9cmPKx4uDjeEDVS8Fn EkIUbk5swK5Ti/cosMPTQvMvj26UnB9Y2DL4jwnZHsl41iIAvw9zTgahzFgVso2EogsNB ZCtRZP/nqqY28edGnqXA9fh6U1QpvunAGtiz/Vmxg/7MvdeSgEogt+7trxxaesGKa9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385683; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=AMyZ6XdQbsD+cBPZ4SuEk9jReiYwHH0CtuAdB24eySQ=; b=zSlnuag+0G9L95BCko6lLA+5N2xe+XFJBUkah5dvldIU/8Bcvx24KdQwjvA8AMQ6K9AW UlvSeb+9s9+oV/QgTWHd+Nugr/7wbwc7OcXJ6hJVvQQJbjyuWsoAffBbLElsTnKCdVGpP pPVcjkH/lGoI8BA7mwyADmKadBP4TNZoC88PnMBGLsRNpsQjiTRLue0Ws38ltS9lRi9WQ EVvZCIw7BD0sJIZhSRS2UYAaB2DpyA0pDC+KK0z25J0CwfE+WoDyqj+r4d/Pw5l4+jWI8 GITr/wHk4sfy2YGjbSUOlzvcGwyBtmCBD9tzhQNJ1sHV8G+qZ9H45OTAcSyjR1wjoZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Lw9J0mX3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6FD2606A322; Fri, 4 Dec 2026 12:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Lw9J0mX3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 630E11F000C2; Fri, 4 Dec 2026 12:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385682; bh=AMyZ6XdQbsD+cBPZ4SuEk9jReiYwHH0CtuAdB24eySQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lw9J0mX3lFVbUQvF6jkVE5I0G65pgFrRBvT/DmBwmxyyrQz3dGSqmT+8m8l3TuDaZ qy5z/Ho8uXFBdchvN2d2wjUeWtdbkm68DBVO1Pq/K3hSPsncmHID5M8gMjF0XlANlE RooltVuYw+lHi/QpjzhbxA4EVI/47wjQt49k26IQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Cosmin Tanislav , Vladyslav Tymoshchuk , Leonardo Costa , Hiago De Franco Subject: [PATCH 6.6 0650/1167] usb: gadget: f_ncm: restart the TX timer if the TX freelist is empty Date: Fri, 4 Dec 2026 19:01:17 +0900 Message-ID: <20261204100718.987170097@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cosmin Tanislav commit 78585f90feb3bbaf3b1c642294c8c47e451dc3cf upstream. 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 Fixes: 6d3865f9d41f ("usb: gadget: NCM: Add transmit multi-frame.") Signed-off-by: Cosmin Tanislav Tested-by: Vladyslav Tymoshchuk Tested-by: Leonardo Costa Reported-by: Hiago De Franco 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 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_ncm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -1138,6 +1138,7 @@ static enum hrtimer_restart ncm_tx_timeo { 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 @@ -1148,7 +1149,11 @@ static enum hrtimer_restart ncm_tx_timeo * * 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; }