From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>,
stable@vger.kernel.org, Jian Shen <shenjian15@huawei.com>,
Jijie Shao <shaojijie@huawei.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Zhangfei Gao <zhangfei.gao@linaro.org>
Subject: [PATCH net] net: hix5hd2_gmac: do not release the RX ring on interface close
Date: Sat, 21 Nov 2026 01:36:56 +0800 [thread overview]
Message-ID: <20261120173702.1551838-1-mmyangfl@gmail.com> (raw)
hix5hd2_net_close() frees the receive buffers while the free queue still
holds the descriptors the block has already fetched.
A port that keeps receiving then DMAs arrived frames into buffers the
slab has already taken back; on Hi3716cv200 the descriptors at the next
open all carried the previous session's stamps, and the frames received
then came up as slab garbage -- six parsed as LLC, the rest with an
unrecognized ethertype.
Do not release the receive buffers, their descriptors and the queue
pointers on the close, until the device goes away, so the block keeps
ownership of every address it prefetches.
The sibling hisi_femac has the same defect and resets the port before
freeing its ring, as in commit d54b21d82430 ("net: hisilicon:
hisi_femac: Stop the receiver before releasing the RX ring"); this one,
however, has no reset feature and has to keep them alive across a close.
Fixes: 57c5bc9ad7d7 ("net: hisilicon: add hix5hd2 mac driver")
Cc: stable@vger.kernel.org
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index 12a5657653f8..8c67a0670cbb 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -792,7 +792,7 @@ static netdev_tx_t hix5hd2_net_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}
-static void hix5hd2_free_dma_desc_rings(struct hix5hd2_priv *priv)
+static void hix5hd2_free_rx_buffers(struct hix5hd2_priv *priv)
{
struct hix5hd2_desc *desc;
dma_addr_t addr;
@@ -810,6 +810,13 @@ static void hix5hd2_free_dma_desc_rings(struct hix5hd2_priv *priv)
dev_kfree_skb_any(skb);
priv->rx_skb[i] = NULL;
}
+}
+
+static void hix5hd2_free_tx_buffers(struct hix5hd2_priv *priv)
+{
+ struct hix5hd2_desc *desc;
+ dma_addr_t addr;
+ int i;
for (i = 0; i < TX_DESC_NUM; i++) {
struct sk_buff *skb = priv->tx_skb[i];
@@ -873,7 +880,10 @@ static int hix5hd2_net_close(struct net_device *dev)
hix5hd2_irq_disable(priv);
napi_disable(&priv->napi);
netif_stop_queue(dev);
- hix5hd2_free_dma_desc_rings(priv);
+ /* free rx buffers when device goes away, not when interface closed;
+ * the hardware prefetches rx descriptors and cannot be expelled
+ */
+ hix5hd2_free_tx_buffers(priv);
if (dev->phydev) {
phy_stop(dev->phydev);
@@ -985,6 +995,8 @@ static void hix5hd2_destroy_hw_desc_queue(struct hix5hd2_priv *priv)
{
int i;
+ hix5hd2_free_rx_buffers(priv);
+
for (i = 0; i < QUEUE_NUMS; i++) {
if (priv->pool[i].desc) {
dma_free_coherent(priv->dev, priv->pool[i].size,
--
2.53.0
reply other threads:[~2026-11-20 17:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120173702.1551838-1-mmyangfl@gmail.com \
--to=mmyangfl@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=stable@vger.kernel.org \
--cc=zhangfei.gao@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox