[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230313224237.28757-11-Sergey.Semin@baikalelectronics.ru>
Date: Tue, 14 Mar 2023 01:42:34 +0300
From: Serge Semin <Sergey.Semin@...kalelectronics.ru>
To: Giuseppe Cavallaro <peppe.cavallaro@...com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Russell King <linux@...linux.org.uk>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>
CC: Serge Semin <Sergey.Semin@...kalelectronics.ru>,
Serge Semin <fancer.lancer@...il.com>,
Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>,
Pavel Parkhomenko <Pavel.Parkhomenko@...kalelectronics.ru>,
Christian Marangi <ansuelsmth@...il.com>,
Biao Huang <biao.huang@...iatek.com>,
Yang Yingliang <yangyingliang@...wei.com>,
<netdev@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH net 10/13] net: stmmac: Make buf_sz module parameter useful
Since the first day of the driver been added to the kernel the Rx
DMA-buffer size module parameter hasn't been utilized for something
more-or-less useful. The STMMAC main code used to initialize the actual Rx
DMA-buffer size (priv->dma_buf_sz) with it by default, but then overwrote
it anyway in accordance with Network device MTU or with default
DMA_BUFFER_SIZE/DEFAULT_BUFSIZE macro. Moreover in the both older and
modern versions of the STMMAC driver the buf_sz module parameter was
overwritten on each Net-dev open procedure with a value calculated in
accordance with MTU and allowed maximum buffer size. Needless to say that
even though it doesn't affect the driver functionality much, setting the
generic parameter with a value specific to a private device is wrong,
seeing each DW MAC may have different maximum buffer size on the same
platform.
In order to finally make the buf_sz (Rx DMA buffer size) parameter really
useful let's stop setting it up with a value specific to a particular
controller and use it to calculate the Rx DMA-buffer size instead of MTU
if one is greater than the later. Thus we'll be able to tune the buffer
size up when it's necessary.
Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.")
Signed-off-by: Serge Semin <Sergey.Semin@...kalelectronics.ru>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index e5cb4edc4e23..12de84b7e90d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -100,10 +100,10 @@ static int tc = TC_DEFAULT;
module_param(tc, int, 0644);
MODULE_PARM_DESC(tc, "DMA threshold control value");
-#define DEFAULT_BUFSIZE 1536
-static int buf_sz = DEFAULT_BUFSIZE;
-module_param(buf_sz, int, 0644);
-MODULE_PARM_DESC(buf_sz, "DMA buffer size");
+#define DEFAULT_BUFSIZE 1536U
+static unsigned int buf_sz = DEFAULT_BUFSIZE;
+module_param(buf_sz, uint, 0644);
+MODULE_PARM_DESC(buf_sz, "Rx DMA buffer size");
#define STMMAC_RX_COPYBREAK 256
@@ -3730,7 +3730,7 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu)
bfsize = 0;
if (bfsize < BUF_SIZE_16KiB)
- bfsize = stmmac_set_bfsize(mtu, 0);
+ bfsize = stmmac_set_bfsize(max(buf_sz, mtu), 0);
dma_conf->dma_buf_sz = bfsize;
/* Chose the tx/rx size from the already defined one in the
@@ -3817,7 +3817,6 @@ static int __stmmac_open(struct net_device *dev,
priv->rx_copybreak = STMMAC_RX_COPYBREAK;
- buf_sz = dma_conf->dma_buf_sz;
memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));
stmmac_reset_queues_param(priv);
--
2.39.2
Powered by blists - more mailing lists