From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796554904; b=r0dH9t3anELb1Oh4HkwbrYn8kub2rE87Exz89ol79Xv1ddRfCLaglhnfNQ17FX3mdrfa bhPEfMbel2F7fZxrP3MndMjMWIikQtYyQo6iTmplSzTVDOhGcSd4MQsdXgjGzfueBpt6g 2jW80kKcVew003/+b87F4eaJQP1mxDqh9+TfiLyzen0hdR7Pe2FMInuTF3+wDP5NdgCYO v1HYDuKO9o2bC4whMg9LyWmA7olSYdl2roVBe53ancJGtbweLbLmnyVDfNoiypUvYddm4 GJ5FiXCHzqUOJnDhjB7vtlB9vNQXkGscjnlajJ0rXwTGBe/YZbEoHCIHQ33eix3NUGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796554904; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=cGV8/dNXLHd1UOhK5mQOvW1+DdglLVOFRITLOHVznIo=; b=yy9mbauHP7mNFK31Q9Iz2OWWoPHRTZ2fAepYKBNkxXhBuoiEupoF+N+sGWQ0iPCm2y6F 65nR2wlWIVsaxUECxESQDTAGMwZqu/mprQREeOZzcCY2NjHXVpHa1EDc5NBLlPyL2TCCm M+k5f2+yB4mFMbe6/nphDDCF2ICNvoxqjZuQMMXOcp+RbC8e2OUXDchIXXPFU5nohQB6U o4rZMlPSMLvMx6hSmduABP+Ojr+f0GoIfFDTQLIuwWyQhzVz26CRvX/GBjrFoElXgkl35 F5S5UVD5T2Y32diuSh+qgbV3gmAU8G3eaTvwcEGNzJPRDz8zeusZ5bwiGHt+GDXBMlQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="USd/N9gF"; arc=none smtp.remote-ip=209.85.216.44 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E17A606A322 for ; Sun, 6 Dec 2026 11:01:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8E17A606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=USd/N9gF Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-3b532dfb874so1637924a91.3 for ; Sun, 06 Dec 2026 03:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796554903; x=1797159703; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cGV8/dNXLHd1UOhK5mQOvW1+DdglLVOFRITLOHVznIo=; b=USd/N9gF5z8F/9BZtUTl8iwJAS+tY3k8y6Hg47u1J61xOp839ahyEVISuK8F9JtWvU aOyXsu/awh0yq23H6BZ4GEVJlo0ghlM/xavxsoiB1tVmM7hJYpWDcoJ1ltJnQIYjuvgK bsgZbRPjXxR2TJYWrDCupe1Gh4pS6w6E6+ksMZRFeCDHAnnM8R4JHAAghHk1kekguu+j MGwMakJ/bu/fiCZaLpr4l6wA8FSa2P99dQcBaE5NZQ7DT8uvfWtki5bxEQAzFabRUsS9 qt7Y7Y0tpgEzaMyz3GaNrgEUrr7h+Dbl0thZ2mOQcxIMIsjEJYHW1yBz97uQUr7p88m8 Fr3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796554903; x=1797159703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cGV8/dNXLHd1UOhK5mQOvW1+DdglLVOFRITLOHVznIo=; b=eWpwR8Kr96rLAyzK9cRJ7Q5U1yPzjl+A9s2Xj2Kn5gvs4Rm7wJBBmt+RaRKbgFGSFi Karz0TtC9kWp3pB3avyad5p8RBmZkiMi3CX2NEWkseAy3jR9PFnaDXpnoIO9dBe4+QwK fwSVEkySJWLYXQtc+zbsMTMvQ05e8CXU8Yyj28N24wLedQbtxenXZ4Uc/r+HS0mf4JMe BGG5J4vcpf3Erhwd6wTu4QcLPko0HsIMbi715MtEZ6vXBsb9CMdTPbvmFhAWfdBBqRdq dIAikSC4QlrRKZya0EP+tt0w0jD51Lp7hexPuZCh/d8UYRdtTwKnzGxOrctH9e5yKH8o Dmng== X-Gm-Message-State: AB4q+uF+GMO/tB2GP+Rp7Z8oCU8QQ1g02PHserLp0oA6od7UkKCVET37 3WmGX5sjMTgLXwnXtGEl4XDyW2YbxoXJMNXzxioCI4LZSMBUQth28fKJLhw3e4bD X-Gm-Gg: AZFdTZcNf6oIHvUgV32YgLw2ZTk6RBDdRTJm8/78X/vPcYbi2ZrqHcSEWp57PEr8BK1 TQ/iIyfgVrpwiT/2mmVmbAAtQ4Zcgm6CEeCLknHeadvxnPyIZRPEmAv5Fns32TJEehXlG6U2IMH ju6EKHCcoTrRPtgvZ/BrisMEJmpnte51Lzlzb81k9FCl2kcYlA8D4t7e3xFJPIkugFnMj6Dsuxn U920RztRsFStspfLWt3i/O5LeToZpsae6lh/P99B4IacbKPVuW+/ehxOTajN+IXUPytmfIPipP3 xSJN9EAdG3DnE48fZ1EjYzVzBjjrxVebHOl/quTATI9XC8/SiNUTkLHbd9TZaF6g4yV+q9Fr72K 9ByS7rY1SbL+uT3c4OlY/98i9YGgxW1aql30SNPzyezYHLL15GZHYku8PDl3BMPINyvCE8T/q6T V2G7qKRpv1E0JeSPL7aTidfz/ceFAZCfKrJdHJkBXP2jk/XlgvEpnxhwxyCFxzMyPty/oT9dpWX piopdPHsWnA2Jkm9KNrmAAD35j0uTevfurBvWtNAwSQQwevrJb7LB6kC8cCbZc6kUR1Vp4VwFNp LwwBtNIg8HuxrU26lfW2XHjWELc2BWF8Z/byFDa1zh5v2hhzpJsZVO8= X-Received: by 2002:a17:90b:570c:b0:3ac:ffb8:183b with SMTP id 98e67ed59e1d1-3b5e06a2a1fmr6618826a91.51.1796554903331; Sun, 06 Dec 2026 03:01:43 -0800 (PST) Received: from d.home.yangfl.dn42 ([2a09:bac1:76a0:d30::1d0:db]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddc37998sm12326040a91.10.2026.12.06.03.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 03:01:43 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Jian Shen , Jijie Shao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zhangfei Gao , Dongpo Li Subject: [PATCH net v2 4/4] net: hix5hd2_gmac: keep TX/RX queues alive across a close Date: Sun, 6 Dec 2026 19:00:32 +0800 Message-ID: <20261206110034.4094717-5-mmyangfl@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261206110034.4094717-1-mmyangfl@gmail.com> References: <20261206110034.4094717-1-mmyangfl@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hix5hd2_net_close() frees the buffers while the block still holds prefetched descriptors. On Hi3716cv200 the descriptors consumed at the next open carried the previous session's stamps and the received frames came up as slab garbage, indicating possible memory corruption. Do not release the buffers at close; keep them until the device goes away. The sibling hisi_femac had the same defect, and was fixed by commit d54b21d82430 ("net: hisilicon: hisi_femac: Stop the receiver before releasing the RX ring"), which resets the port before freeing its ring. This one, however, has no equivalent: the interface reset leaves the prefetched descriptors in place, and the reset that clears the queue state also resets the switch-fabric port the MAC feeds, so neither can serve to quiesce the block before a free. With buffers retained across a close, completions of pre-close sends reach BQL only after the reopen, so drop netdev_reset_queue() from the open; resetting there would report completions of bytes it never counted. hix5hd2_hw_init() wipes the pending interrupt status that would have announced completions stranded behind the close, and the BQL state now carries across the close as well, so schedule NAPI once after the reopen. The release reads the scatter-gather descriptors as well as the hardware ones, so the hardware queues are destroyed before the SG queue. Fixes: 57c5bc9ad7d7 ("net: hisilicon: add hix5hd2 mac driver") Signed-off-by: David Yang --- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c index 106356a1d264..850675fb3d13 100644 --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c @@ -860,13 +860,17 @@ static int hix5hd2_net_open(struct net_device *dev) hix5hd2_hw_init(priv); hix5hd2_rx_refill(priv); - netdev_reset_queue(dev); netif_start_queue(dev); napi_enable(&priv->napi); hix5hd2_port_enable(priv); hix5hd2_irq_enable(priv); + /* Buffers retained across a close, but hix5hd2_hw_init() discarded any + * pending interrupt status; process any outstanding packets now. + */ + napi_schedule(&priv->napi); + return 0; } @@ -878,7 +882,9 @@ 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); + /* The buffers stay owned across a close; release them with the rings on + * device removal. + */ if (dev->phydev) { phy_stop(dev->phydev); @@ -1003,6 +1009,8 @@ static void hix5hd2_destroy_hw_desc_queue(struct hix5hd2_priv *priv) { int i; + hix5hd2_free_dma_desc_rings(priv); + for (i = 0; i < QUEUE_NUMS; i++) { if (priv->pool[i].desc) { dma_free_coherent(priv->dev, priv->pool[i].size, @@ -1281,10 +1289,10 @@ static int hix5hd2_dev_probe(struct platform_device *pdev) return ret; out_destroy_queue: - if (HAS_CAP_TSO(priv->hw_cap)) - hix5hd2_destroy_sg_desc_queue(priv); netif_napi_del(&priv->napi); hix5hd2_destroy_hw_desc_queue(priv); + if (HAS_CAP_TSO(priv->hw_cap)) + hix5hd2_destroy_sg_desc_queue(priv); out_phy_node: of_node_put(priv->phy_node); err_mdiobus: @@ -1311,9 +1319,9 @@ static void hix5hd2_dev_remove(struct platform_device *pdev) mdiobus_unregister(priv->bus); mdiobus_free(priv->bus); + hix5hd2_destroy_hw_desc_queue(priv); if (HAS_CAP_TSO(priv->hw_cap)) hix5hd2_destroy_sg_desc_queue(priv); - hix5hd2_destroy_hw_desc_queue(priv); of_node_put(priv->phy_node); free_netdev(ndev); } -- 2.53.0