Article View: linux.kernel.netdev
Article #10082Re:Re: [PATCH net v5 2/2] net: stmmac: restore RX descriptor buffer addresses on resume
From: Ding Hui
Date: Tue, 03 Nov 2026 06:00
Date: Tue, 03 Nov 2026 06:00
99 lines
13032 bytes
13032 bytes
Hi Thomas,
Thank you for reproducing the issue on the STM32MP215-DK and for
backporting and testing the series. It is helpful to have confirmation
on another platform. I understand that the backport required changes,
so I will not describe this as testing the series as-is.
>Overall, I’m okay with your patch, I have a few suggestions:
>
> > + stmmac_legacy_serdes_power_down(priv);
> > + mutex_unlock(&priv->lock);
> > + rtnl_unlock();
> > + return ret;
>replace these 4 lines with: `goto error_unlock;`
>
Regarding the error path, agreed. I have replaced the duplicated cleanup
with "goto error_unlock" in my local revision.
> > @@ -8503,6 +8577,18 @@ int stmmac_resume(struct device *dev)
> > stmmac_free_tx_skbufs(priv);
> > stmmac_clear_descriptors(priv, &priv->dma_conf);
> >
> > + for (queue = 0; queue < priv->plat->rx_queues_to_use; queue++) {
> > + ret = stmmac_reinit_rx_descriptors(priv, &priv->dma_conf, queue);
> > + if (ret) {
> > + netdev_err(ndev, "Failed to restore RX queue %u: %d\n",
> > + queue, ret);
> > + stmmac_legacy_serdes_power_down(priv);
> > + mutex_unlock(&priv->lock);
> > + rtnl_unlock();
> > + return ret;
> > + }
> > + }
> > +
> > ret = stmmac_hw_setup(ndev);
> > if (ret < 0) {
> > netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
>
>You could move the calls to `stmmac_free_tx_skbufs()`,
>`stmmac_clear_descriptors()`, and your loop into a dedicated function,
>perhaps something like `stmmac_resume_descriptors()`.
>
>In my PR, I also factorized the loops so there is one for TX and one for
>RX, instead of one loop for TX and RX in `stmmac_clear_descriptors()`,
>one loop for TX in `stmmac_free_tx_skbufs()`, and one loop for RX to
>rebuild them.
>By doing this, I managed to remove the `stmmac_free_tx_skbufs()`
>function. It changes the PM sequence a bit, but I think it is okay. I’ll
>let you decide whether you want to do it or not.
>
Extracting a stmmac_resume_descriptors() helper also makes sense. I will
look at organizing the work per TX and RX queue.
> > + /* GMAC4/XGMAC secondary address writes overwrite the OWN bit. */
> > + dma_wmb();
> > + for (i = 0; i < dma_conf->dma_rx_size; i++) {
> > + buf = &rx_q->buf_pool[i];
> > + if (rx_q->xsk_pool && !buf->xdp)
> > + continue;
> > +
> > + p = stmmac_get_rx_desc(priv, rx_q, i);
> > + stmmac_set_rx_owner(priv, p, false);
> > + }
>
>Since on GMAC4/XGMAC we need to set the owner bit after writing the
>secondary address, why do we need to call `stmmac_clear_descriptors()`
>before reinitializing the RX descriptors?
>Since `stmmac_clear_descriptors()` is a loop that calls
>`stmmac_init_rx_desc()`, and I verified that all `.init_rx_desc` ops set
>the OWN bit to 1, could we call `stmmac_clear_descriptors()` after
>rebuilding the RX descriptors instead and remove this loop ?
>
Regarding moving stmmac_clear_descriptors() after restoring the buffer
addresses, you are right that the GMAC4/XGMAC init_rx_desc callbacks do
not overwrite those addresses. For a fully populated RX ring, doing the
initialization afterwards could replace the separate re-arm pass.
The complication is the partially populated AF_XDP ring. In v5,
stmmac_clear_descriptors() unconditionally sets OWN on every RX
descriptor. Moving that call after buffer restoration would therefore
also give descriptors without an XSK buffer to DMA.
The v5 ordering was intended to leave those slots CPU-owned afterwards,
but further review exposed problems with that approach: the legacy
clear callbacks do not clear OWN, and the unfilled slots also need to
be represented correctly in the software refill state.
I am addressing those issues in the next revision. I agree that the
better ordering is to restore addresses and chain pointers first, then
initialize/re-arm only the valid descriptors, while preserving the
legacy descriptor control fields and the existing RX watchdog policy.
Unfilled XSK descriptors must remain CPU-owned and available for a
later refill.
Thanks again for the suggestions and the testing feedback.
Best regards,
Ding Hui
Technical Details
Message-ID:
<20261103060052.2226087-1-dinghui1111@163.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355238-linux-kernel-netdev=dewy.ruReferences:
<872a93b8-4bd9-4718-89e2-019fd3c5b8ac@foss.st.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355238-linux-kernel-netdev=dewy.ru From: dinghui1111@163.com (Ding Hui) Newsgroups: linux.kernel.netdev Subject: Re:Re: [PATCH net v5 2/2] net: stmmac: restore RX descriptor buffer addresses on resume Date: Tue, 3 Nov 2026 14:00:52 +0800 Organization: Usenet Network Message-ID: <20261103060052.2226087-1-dinghui1111@163.com> References: <872a93b8-4bd9-4718-89e2-019fd3c5b8ac@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3105519"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:l8+f9X+x23WMlnB1SX3mlpiSZVA= sha256:nKjZkN9LrRvgl5I6rSnmxHdqMMsmWIyya4Nl1QTN8n0= sha1:jxVZaqJx69uLLIEI3EBa9a3j5eQ= sha256:n9qzZZxiPM4HFSZNiyMvKw62vyzrOGOX53okWBX2ehw= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 23B99112745; Tue, 3 Nov 2026 09:03:21 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.148 X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lb3se-D8W5qx; Tue, 3 Nov 2026 09:03:18 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355238-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 7C1AE112718; Tue, 3 Nov 2026 09:03:08 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 700B66013EC; Tue, 3 Nov 2026 06:03:07 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793685786; b=Y9XFQr8OcLJqwv8pzroY7k56rLsEFymX46QjvOkeFx//s7+HEInH9sW6QtBoR5j/IWI/ AqiciqJ3tJty7/ECERwNMYx+j23b/7/Tp2UA/nPXsVA/t9vjOClxh21JRE+d8a2KhtfsA aQo2rBSkCp3sToGR8XcblmzkV8DuKYF1CmJ7BsEXWXXGVXOYvaszVQilFtHC0FsplHVZ4 wYijmVe3CkWN2HpdMLGzz5L2Xp/rlYl0hMNLFzdmImtzLpAUnuJKaBjjTr7h7i8mkvx3C r5l7uD0HyAJgx3UQLHIJc34YhMNyFWTZ1/aItHtGgdET16BW1dSH/vhSjzRTuEKjwTA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793685786; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=OQG3Rpe6sTxKeQSDXn4PTSV6RnWCQvYTk9rhHTjrvog=; b=R1bmb65X1Qb4Zx5ECt/DMqL/TC3TiGxZgwgR/diBIjX+wX3A8VDJvZxRUXNCe6Vr6Eg8 fZ7rmsB/bKl0w8nKYgKeWlNep9Mke+nuSgpfHnxTymSmdw8+kq8tW5iE3drQNkcUAQaL3 yHrGTYWnGJPennZkBwdT8r5e2owVEWoIURvTL+t0PfMNrt2bFMPDgPdvEXN5SpWn+b30J ZCoMqwrZz1f2ih+5F49xDbBRaaTece3EzJlnjbhF7A2LAV0zFudDERUjHo3PRTSXqJ7lI F3zhM7Cr0VEaulbecp2FekWCjvSpo6ur5sTeGl2mP9JVHeEXpCky+N/MK3+qXgRRMDA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b="mZ/0YRCX"; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B74F7606A32E; Tue, 3 Nov 2026 06:03:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=mZ/0YRCX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.5 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793685775; b=QboYZ5r3IQshE4sOW0NrOUuXGuFaB2uAJLrZ8KzTDcLJF6OAXmwVJVqjfRrdauzuIqRc jasjLzllo90Dzq2ySm4kjT8D944+NWxHgW2myoQ+D3ZzwAQS9ewlXa5CsZ8Jm/tk6VgP0 CgdUGWuXveklTIcC2IaA+IOoha3bqlIvj/0h+FCd8XDt8kTZ2dcP+LAVFiFKJ7UnCTAE/ Fr8eINb7u7Zk0xzPJybaq5k2YMoo1Dbw42gg0CnkZUlTGa1DhoWkQDjtAxn9UiGHUJlQZ CJ7yNaI8Yaz7+tbKvHIfmROQ57KKJBWFROdhkY2Eqq0Q+C5Kw6xyj5s/+Z0bzAP7+DQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793685775; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=OQG3Rpe6sTxKeQSDXn4PTSV6RnWCQvYTk9rhHTjrvog=; b=J/T3+Dd/m6CYW2yBow1DOsEc83a22c4ghYPFPg4YR92oa5buLrIShZGt+wHQi429q7VA dI0oVCF8ErW9/o4xNCaIzxND2YOycg+A3Ti6NT/QHrKf83se4TcWZQGmgJmPOb2RVz0qm sr2S51VDAlinff/RoFEostaSDhahrsXz59LbCKaHiohSa+klFd2iJW/Fn2FsUg0NNAm0Z C9dDdzjduZX+5AyCfhytK4v6ITKSWKmuPZjBUaGTVtWXmaMqwfTABLM5WOP0X702gPIvn wLKor7HfK2xyDgA5ppwLGXMHZDCTcNGwdDwCgDLeNwCOegFGY/9SysOP8OPikQyt3XQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b="mZ/0YRCX"; arc=none smtp.remote-ip=117.135.210.5 X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 172E3606A324; Tue, 3 Nov 2026 06:02:51 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 172E3606A324 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version: Content-Type; bh=OQG3Rpe6sTxKeQSDXn4PTSV6RnWCQvYTk9rhHTjrvog=; b=mZ/0YRCXPreDbWsTT2WI0GF1zW4Z7NZ25mxEHLaWuDJKTi+xeh+5HDnj+kOl1+ gElUeb7xSjDPliWGtY3T3iCEBiUd5edBGj/3S8yawz+ZgCbCdF8gDD+PJQS20RBd 0IExIPjFoeX5BFXhr603vdY/QBUmH5SUr1CGnSixKTQRs= X-Received: from 4CV529F122.company.local (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wD3vy2UeOlqvBZcFA--.42044S2; Tue, 03 Nov 2026 14:01:03 +0800 (CST) X-Cc: alexandre.torgue@foss.st.com, andrew+netdev@lunn.ch, davem@davemloft.net, dinghui1111@163.com, dinghui@lixiang.com, edumazet@kernel.org, fujiahui@lixiang.com, kuba@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, liuxuanjun@lixiang.com, maxime.chevallier@bootlin.com, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org, pabeni@redhat.com, xiasanbo@lixiang.com, yangchen11@lixiang.com, zhoujing3@lixiang.com X-Mailer: git-send-email 2.34.1 X-In-Reply-To: <872a93b8-4bd9-4718-89e2-019fd3c5b8ac@foss.st.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: _____wD3vy2UeOlqvBZcFA--.42044S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAw4ktr17GFW8ur17ZF4UXFb_yoWrWw1rp3 yay39rtrykJr4xCr48Xw4xWFy2vFs8Xa15Gw1rJw1qy390krnavFy3KrWYya4xGFZ3Xw1F vF4UZ39xCF4DCrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEna93UUUUU= X-CM-SenderInfo: pglqwx1xlriiqr6rljoofrz/xtbC0h9ahmrpeJ9hkwAA3H