Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: hix5hd2_gmac: do not release the RX ring on interface close
@ 2026-11-20 17:36 David Yang
  0 siblings, 0 replies; only message in thread
From: David Yang @ 2026-11-20 17:36 UTC (permalink / raw)
  To: netdev
  Cc: David Yang, stable, Jian Shen, Jijie Shao, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Zhangfei Gao

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20 17:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 17:36 [PATCH net] net: hix5hd2_gmac: do not release the RX ring on interface close David Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox