[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <42765b5f-2d94-4fd6-8cd9-977729220696@iscas.ac.cn>
Date: Tue, 27 Jan 2026 12:38:30 +0800
From: Vivian Wang <wangruikang@...as.ac.cn>
To: Tomas Hlavacek <tmshlvck@...il.com>, netdev@...r.kernel.org
Cc: linux-riscv@...ts.infradead.org, spacemit@...ts.linux.dev,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
"David S . Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>,
Yixun Lan <dlan@...nel.org>
Subject: Re: [PATCH net v2] net: spacemit: k1-emac: program frame size
registers for jumbo frames
Hi Tomas,
Thanks for the fix. Just a few more things...
Firstly, I believe it is preferred to send a new patch version in its
own thread with a link to the previous version. See
Documentation/process/maintainer-netdev.rst:
The new version of patches should be posted as a separate thread,
not as a reply to the previous posting. Change log should include a link
to the previous posting (see :ref:`Changes requested`).
You can do that for v3.
Secondly...
On 1/27/26 01:14, Tomas Hlavacek wrote:
> [...]
>
> diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
> index 220eb5ce7583..31b1bdb2827e 100644
> --- a/drivers/net/ethernet/spacemit/k1_emac.c
> +++ b/drivers/net/ethernet/spacemit/k1_emac.c
> @@ -228,6 +228,12 @@ static void emac_init_hw(struct emac_priv *priv)
> DEFAULT_TX_THRESHOLD);
> emac_wr(priv, MAC_RECEIVE_PACKET_START_THRESHOLD, DEFAULT_RX_THRESHOLD);
>
> + /* Set maximum frame size and jabber size based on configured buffer
> + * size.
> + */
> + emac_wr(priv, MAC_MAXIMUM_FRAME_SIZE, priv->dma_buf_sz);
> + emac_wr(priv, MAC_RECEIVE_JABBER_SIZE, priv->dma_buf_sz);
> +
I tested this (also setting MAC_TRANSMIT_JABBER_SIZE, as Yixun
described) and it appears that this has surfaced a latent bug in the code.
I found that the hardware can't actually handle 4096-byte buffers, since
the size field is only 12-bit. (It was my fault to assume that existing
code was right in this regard...) So MTU larger than ~2000 breaks the
hardware, and also triggers the WARN_ON_ONCE() in emac_rx_frame_good().
4095 works just fine.
Can you include this in v3 as well? Maybe also reword the commit
messages a bit. Thanks.
(Here's hoping Thunderbird hasn't destroyed the whitespace...)
diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
index 31b1bdb2827e..78306a06a329 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@ -38,7 +38,7 @@
#define EMAC_DEFAULT_BUFSIZE 1536
#define EMAC_RX_BUF_2K 2048
-#define EMAC_RX_BUF_4K 4096
+#define EMAC_RX_BUF_MAX FIELD_MAX(RX_DESC_1_BUFFER_SIZE_1_MASK)
/* Tuning parameters from SpacemiT */
#define EMAC_TX_FRAMES 64
@@ -937,7 +937,7 @@ static int emac_change_mtu(struct net_device *ndev, int mtu)
else if (frame_len <= EMAC_RX_BUF_2K)
priv->dma_buf_sz = EMAC_RX_BUF_2K;
else
- priv->dma_buf_sz = EMAC_RX_BUF_4K;
+ priv->dma_buf_sz = EMAC_RX_BUF_MAX;
ndev->mtu = mtu;
@@ -2011,7 +2011,7 @@ static int emac_probe(struct platform_device *pdev)
ndev->hw_features = NETIF_F_SG;
ndev->features |= ndev->hw_features;
- ndev->max_mtu = EMAC_RX_BUF_4K - (ETH_HLEN + ETH_FCS_LEN);
+ ndev->max_mtu = EMAC_RX_BUF_MAX - (ETH_HLEN + ETH_FCS_LEN);
ndev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
priv = netdev_priv(ndev);
Powered by blists - more mailing lists