Skip to contentSkip to conversation

net/stmmac: Fixes for maximum TX/RX queues to use by driver

PATCH Applied Jakub Raczynski 3 participants 5 messages Jun 11 – Jun 13 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20260611113403eucas1p1f4b61896c875f1f6833d6ca136472af8@eucas1p1.samsung.com

#1 lore raw

cover net/stmmac: Fixes for maximum TX/RX queues to use by driver

When contributing other changes preparing functions for new XGMAC hardware
https://lore.kernel.org/netdev/[email protected]/
there have been reports by Sashiko AI review about pre-existing issues in the code. These problems are non-insignificant and are 'net' material fixes, rather than net-next features.
One issue in this patchset was reported by Sashiko AI, while other technically part of new patchset, but is reasonable related fix. All of issues are wrong DTS configuration, but kernel needs to handle it.

Jakub Raczynski (2):
net/stmmac: Apply TBS config only to used queues net/stmmac: Apply MTL_MAX queue limit if config missing

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
#2 lore raw

PATCH 1/2 net/stmmac: Apply TBS config only to used queues

While opening stmmac driver, there is enabling of TBS (Time-Based Scheduling) option in dma config. Currently this is executed for all possible TX queues via MTL_MAX_TX_QUEUES macro, but actual number of queues used might differ. While setting this is generally harmless, since memory for MTL_MAX_TX_QUEUES is allocated, it is incorrect, because it prepares config for unused queues.

Change this to apply tbs config only to tx_queues_to_use.

Fixes 4896bb7c0b31a ("net: stmmac: do not clear TBS enable bit on link up/down")
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
index 3591755ea30b..5917bf47c7de 100644
@@ -4140,7 +4140,7 @@ static int __stmmac_open(struct net_device *dev,
 	u8 chan;
 	int ret;
 
-	for (int i = 0; i < MTL_MAX_TX_QUEUES; i++)
+	for (int i = 0; i < priv->plat->tx_queues_to_use; i++)
 		if (priv->dma_conf.tx_queue[i].tbs & STMMAC_TBS_EN)
 			dma_conf->tx_queue[i].tbs = priv->dma_conf.tx_queue[i].tbs;
 	memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));
Signature · 1 line
2.34.1
#3 lore raw

PATCH 2/2 net/stmmac: Apply MTL_MAX queue limit if config missing

In reply to Jakub Raczynski

When "snps,rx-queues-to-use" or "tx-queues-to-use" config in DTS is provided current code will apply U8_MAX value for queues_to_use if there is input of higher value. But actual maximum number of supported queues is set via macro MTL_MAX_RX_QUEUES and MTL_MAX_TX_QUEUES, which currently have value of 8.

This value of U8_MAX will be capped to value provided by core in DMA capabilities (dma_conf), but it does so only if core provides it. This is true for XGMAC (dwxgmac2) and some GMAC (dwmac4),
but not for (dwmac1000). This capping is at later stage in stmmac_hw_init(), and during stmmac_mtl_setup() we might parse fields outside allocated memory if queues_to_use is over defines MTL_MAX_ values,
for example following rx_queues_cfg is array of size of MTL_MAX_RX_QUEUES.

Fix this by capping value to MTL_MAX during config parsing.

Fixes 94808793fed71 ("net: stmmac: use u8 for ?x_queues_to_use and number_?x_queues")
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4 -4
index 5cae2aa72906..dc5f951a311d 100644
@@ -156,8 +156,8 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
 
 	/* Processing RX queues common config */
 	if (!of_property_read_u32(rx_node, "snps,rx-queues-to-use", &value)) {
-		if (value > U8_MAX)
-			value = U8_MAX;
+		if (value > MTL_MAX_RX_QUEUES)
+			value = MTL_MAX_RX_QUEUES;
 		plat->rx_queues_to_use = value;
 	}
 
@@ -210,8 +210,8 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
 
 	/* Processing TX queues common config */
 	if (!of_property_read_u32(tx_node, "snps,tx-queues-to-use", &value)) {
-		if (value > U8_MAX)
-			value = U8_MAX;
+		if (value > MTL_MAX_TX_QUEUES)
+			value = MTL_MAX_TX_QUEUES;
 		plat->tx_queues_to_use = value;
 	}
 
Signature · 1 line
2.34.1
reviewer Reviewed-by on the v1 series
#4 lore raw
In reply to Jakub Raczynski
Quoted 9 lines · Jakub Raczynski

When contributing other changes preparing functions for new XGMAC hardware
https://lore.kernel.org/netdev/[email protected]/
there have been reports by Sashiko AI review about pre-existing issues in the code. These problems are non-insignificant and are 'net' material fixes, rather than net-next features.
One issue in this patchset was reported by Sashiko AI, while other technically part of new patchset, but is reasonable related fix. All of issues are wrong DTS configuration, but kernel needs to handle it.

Quoted 3 lines

Jakub Raczynski (2):
net/stmmac: Apply TBS config only to used queues net/stmmac: Apply MTL_MAX queue limit if config missing

For the series;

FTR, there is AI-generated review of this patch-set available on sashiko.dev However I believe that feedback can be viewed in the context of possible follow-up and should not impede the progress of this patchset.

#5 lore raw
In reply to Jakub Raczynski
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 11 Jun 2026 13:33:56 +0200 you wrote:

When contributing other changes preparing functions for new XGMAC hardware
https://lore.kernel.org/netdev/[email protected]/
there have been reports by Sashiko AI review about pre-existing issues in the code. These problems are non-insignificant and are 'net' material fixes, rather than net-next features.
One issue in this patchset was reported by Sashiko AI, while other technically part of new patchset, but is reasonable related fix. All of issues are wrong DTS configuration, but kernel needs to handle it.

[...]

Here is the summary with links:
- [net,1/2] net/stmmac: Apply TBS config only to used queues

    https://git.kernel.org/netdev/net-next/c/8b10877d9d6c
  - [net,2/2] net/stmmac: Apply MTL_MAX queue limit if config missing
    https://git.kernel.org/netdev/net-next/c/8a7bca6de6de

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html