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=1796387966; b=NjWelh0O4FTk2tw//iqeV/lNXonGrZBNcDCrgF6okXScTg2YGrOf4q52IXH82A+m8oe1 NNdUJSfqv6LUbC1e//l/vVIzRi+V68AbhVPXpkZA/wCjhtXRs7yYOcO7LOgEOIvYxsYD4 A7iZhUAdqAR8xUyBvX+wfzwLighW3y98A+/OghYetohpst9tH/PT3Wu1jkifui3QDfLKj QoutF4UAP4KM0+g6ZjqZLCL3qkfwe2rri/JrgCsnXIv3GeTa/nKMg69+g6avbgkiSkGfJ ydlkbDJ8dF3Q3essT9/Qtzi3+RGXpsHKO7G/MifxR7L/f9gp378PyWqNItc3wz9nS+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387966; 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=H/QM3FRN083iRLO70mtrQxCz4ehJUyBiPsB/P5pC/4g=; b=DwJy7GPDTi5SyCg9JujGdlAd3kv3rp14RKvV6VgeLIrlTMtOVKpe8vXNmcLYJyfAnhQg rdlUSWtPnuWx5s6Op9uujj06wrrQMFbMDbSEkuoDyvZ6I1lAFBO/ojpS5hrNoY1IkgVGK Q1gF3SKj+A3MHfjCswmN4Nw2oEb7Uz0yf+SDSZSmCtJ8q5XIGsC4d3jB87SycpdcPJROh PFQObIusJmleaddaL7NFaBPpgxE/W6N0TiVgy5FoeQCXF+MMX92HqIFFlt1BA9pzc1tpl KgeL9aWhE67xsazWzhAj7DoIVoE+G6CA+/yPgTMrvO2kcV7fKJT2C4GMbejF91mT3GQ== 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=ZccvNeQs; 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 2687F606A32C; Fri, 4 Dec 2026 12:39:25 +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=ZccvNeQs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 511A01F000C2; Fri, 4 Dec 2026 12:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387965; bh=H/QM3FRN083iRLO70mtrQxCz4ehJUyBiPsB/P5pC/4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZccvNeQs7ScEHNQcJ1pxBULtbMNsMVwzy2RoqfIhqMpYYt1zBomvucmzwOsi0T08l 4KNnWFm4wa39P8xDbt6iflqeRTkUdDYe9ZZcyF7QK0hzcMiqnPIsaBvhJe2/xOWPB8 utg7oedi+UZoJMf073+immlg6v19W2YF9KKtqCZA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ovidiu Panait , Maxime Chevallier , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0431/1059] net: stmmac: Track the TX DMA threshold per queue Date: Fri, 4 Dec 2026 18:59:22 +0900 Message-ID: <20261204100655.488367545@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ovidiu Panait [ Upstream commit 9dd53418781900f02897c805eed397555cf98417 ] Commit 3a6c12a0c6c3 ("net: stmmac: bump tc when get underflow error from DMA descriptor") made dwmac4 raise the DMA threshold of the queues that report TX underflows. This is done by incrementing a module global parameter 'tc' by 64 on each underflow. This leads to inconsistent TX DMA thresholds between queues and causes issues on platforms with multiple stmmac controllers, as 'tc' is shared by all of them. Once 'tc' goes over 256 the bumping stops, and queues that did not underflow before are left at the initial threshold. On the Renesas RZ/V2H platform, which has two dwmac4 controllers, we observed sporadic iperf3 TCP TX failures: iperf3 -c -t5 --bind-dev end1 ... [ 5] 0.00-5.00 sec 1.00 MBytes 1.68 Mbits/sec 87 sender [ 5] 0.00-5.00 sec 768 KBytes 1.26 Mbits/sec receiver This happens because the TX queues of end1 were underflowing on a large fraction of the packets, but the DMA TX threshold was never raised from the default of 64 bytes. The threshold was not raised because end0 had underflowed first and had already pushed 'tc' past 256. Which controller is affected depends on which one underflows first. To fix this, make the TX DMA threshold per queue instead of global. Each time an underflow happens on a queue, its TX DMA threshold gets incremented, without affecting other queues or controllers. With this change, 'tc' is only used as the initial value, and the RX threshold is no longer bumped together with the TX one, as TX underflows have nothing to do with the RX side. Fixes: 3a6c12a0c6c3 ("net: stmmac: bump tc when get underflow error from DMA descriptor") Signed-off-by: Ovidiu Panait Reviewed-by: Maxime Chevallier Link: https://patch.msgid.link/20261013114503.57487-2-ovidiu.panait.rb@renesas.com Signed-off-by: Jakub Kicinski [ sashal: Replaced per-queue context in the hunks for the TX threshold tracking; code changes are otherwise identical to upstream, with only surrounding context lines adjusted. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 33 +++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 7c7ed92094d11..103e5caca3c40 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -218,6 +218,7 @@ struct stmmac_priv { unsigned int rx_copybreak; u32 rx_riwt[MTL_MAX_TX_QUEUES]; + u32 tx_threshold[MTL_MAX_TX_QUEUES]; int hwts_rx_en; void __iomem *ioaddr; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c469a800fabb6..944779b0f511b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2376,7 +2376,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv) txfifosz /= tx_channels_count; if (priv->plat->force_thresh_dma_mode) { - txmode = tc; rxmode = tc; } else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) { /* @@ -2390,7 +2389,6 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv) rxmode = SF_DMA_MODE; priv->xstats.threshold = SF_DMA_MODE; } else { - txmode = tc; rxmode = SF_DMA_MODE; } @@ -2419,8 +2417,11 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv) for (chan = 0; chan < tx_channels_count; chan++) { qmode = priv->plat->tx_queues_cfg[chan].mode_to_use; - stmmac_dma_tx_mode(priv, priv->ioaddr, txmode, chan, - txfifosz, qmode); + if (txmode == SF_DMA_MODE) + priv->tx_threshold[chan] = SF_DMA_MODE; + + stmmac_dma_tx_mode(priv, priv->ioaddr, priv->tx_threshold[chan], + chan, txfifosz, qmode); } } @@ -2524,17 +2525,20 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) static void stmmac_bump_dma_threshold(struct stmmac_priv *priv, u32 chan) { - if (unlikely(priv->xstats.threshold != SF_DMA_MODE) && tc <= 256) { - tc += 64; + u32 thresh = priv->tx_threshold[chan]; - if (priv->plat->force_thresh_dma_mode) - stmmac_set_dma_operation_mode(priv, tc, tc, chan); - else - stmmac_set_dma_operation_mode(priv, tc, SF_DMA_MODE, - chan); + if (unlikely(thresh == SF_DMA_MODE) || thresh > 256) + return; - priv->xstats.threshold = tc; - } + thresh += 64; + + if (priv->plat->force_thresh_dma_mode) + stmmac_set_dma_operation_mode(priv, thresh, tc, chan); + else + stmmac_set_dma_operation_mode(priv, thresh, SF_DMA_MODE, chan); + + priv->tx_threshold[chan] = thresh; + priv->xstats.threshold = thresh; } /** @@ -7446,6 +7450,9 @@ int stmmac_dvr_probe(struct device *device, priv->xstats.threshold = tc; + for (i = 0; i < MTL_MAX_TX_QUEUES; i++) + priv->tx_threshold[i] = tc; + /* Initialize RSS */ rxq = priv->plat->rx_queues_to_use; netdev_rss_key_fill(priv->rss.key, sizeof(priv->rss.key)); -- 2.53.0