From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Ding Hui <dinghui1111@163.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>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
"open list:STMMAC ETHERNET DRIVER" <netdev@vger.kernel.org>,
"moderated list:ARM/STM32 ARCHITECTURE"
<linux-stm32@st-md-mailman.stormreply.com>,
"moderated list:ARM/STM32 ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
open list <linux-kernel@vger.kernel.org>
Cc: tommaso.merciai.xr@bp.renesas.com, dinghui@lixiang.com,
xiasanbo@lixiang.com, yangchen11@lixiang.com,
liuxuanjun@lixiang.com
Subject: Re: [PATCH net v7 2/4] net: stmmac: track unfilled XSK RX descriptors explicitly
Date: Tue, 17 Nov 2026 14:21:29 +0100 [thread overview]
Message-ID: <73d6b341-3553-4243-83aa-ea8bb223cef9@bootlin.com> (raw)
In-Reply-To: <92136a2c509f26f7a02053380a0b3c0fa426df48.1794646293.git.dinghui@lixiang.com>
Hi,
On 11/14/26 10:21, Ding Hui wrote:
> From: Ding Hui <dinghui@lixiang.com>
>
> An XSK fill ring may supply fewer buffers than the RX ring needs. Those
> unfilled descriptors must remain CPU-owned, including on legacy cores
> whose clear callback only clears the buffer address. Add an ownership
> operation that preserves descriptor size and ring/chain control fields.
>
> Track the number of descriptors awaiting refill independently of the
> ring indices, so an entirely empty ring can be distinguished from one
> with no pending refills. Initialize the pending region after the allocated
> prefix and stop consumption before entering it. Retry pending refills
> on each poll, including userspace wakeups with fewer than a batch of
> buffers, and retain batching during packet processing.
>
> Update the tail after successful refills and kick legacy RX DMA. Use the
> end-of-ring tail address for a refill ending at index zero, including a
> completely empty ring populated before DMA has advanced from the base.
> Select the receive buffer size from the XSK pool even if no buffers were
> available at initialization.
>
> Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy")
> Signed-off-by: Ding Hui <dinghui@lixiang.com>
> ---
> .../ethernet/stmicro/stmmac/dwmac4_descs.c | 6 +++
> .../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 6 +++
> .../net/ethernet/stmicro/stmmac/enh_desc.c | 6 +++
> drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 ++
> .../net/ethernet/stmicro/stmmac/norm_desc.c | 6 +++
> drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +
> .../net/ethernet/stmicro/stmmac/stmmac_main.c | 49 +++++++++++++------
> 7 files changed, 63 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index c6a8f8d73501..307bbd63dbcb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -176,6 +176,11 @@ static void dwmac4_set_tx_owner(struct dma_desc *p)
> p->des3 |= cpu_to_le32(TDES3_OWN);
> }
>
> +static void dwmac4_clear_rx_owner(struct dma_desc *p)
> +{
> + p->des3 &= cpu_to_le32(~RDES3_OWN);
> +}
> +
> static void dwmac4_set_rx_owner(struct dma_desc *p, int disable_rx_ic)
> {
> u32 flags = (RDES3_OWN | RDES3_BUFFER1_VALID_ADDR);
> @@ -539,6 +544,7 @@ const struct stmmac_desc_ops dwmac4_desc_ops = {
> .rx_status = dwmac4_wrback_get_rx_status,
> .set_tx_owner = dwmac4_set_tx_owner,
> .set_rx_owner = dwmac4_set_rx_owner,
> + .clear_rx_owner = dwmac4_clear_rx_owner,
> .get_rx_vlan_tci = dwmac4_wrback_get_rx_vlan_tci,
> .get_rx_vlan_valid = dwmac4_wrback_get_rx_vlan_valid,
> .get_rx_frame_len = dwmac4_wrback_get_rx_frame_len,
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> index 6719ac6e395b..ad377c76ed4e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
> @@ -51,6 +51,11 @@ static void dwxgmac2_set_tx_owner(struct dma_desc *p)
> p->des3 |= cpu_to_le32(XGMAC_TDES3_OWN);
> }
>
> +static void dwxgmac2_clear_rx_owner(struct dma_desc *p)
> +{
> + p->des3 &= cpu_to_le32(~XGMAC_RDES3_OWN);
sparse says :
+../drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:181:20: warning: cast truncates bits from constant value (ffffffff7fffffff becomes 7fffffff)
+../drivers/net/ethernet/stmicro/stmmac/norm_desc.c:146:20: warning: cast truncates bits from constant value (ffffffff7fffffff becomes 7fffffff)
+../drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c:56:20: warning: cast truncates bits from constant value (ffffffff7fffffff becomes 7fffffff)
+../drivers/net/ethernet/stmicro/stmmac/enh_desc.c:304:20: warning: cast truncates bits from constant value (ffffffff7fffffff becomes 7fffffff)
Not too big of a deal, but let's not add new sparse warnings.
We've seen that before, you can maybe use some trickery like here :
https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/net/ethernet/stmicro/stmmac/descs.h#L73
The rests of the series starts to look fairly solid, I've quickly tested
it and it does seem to work, I'll properly review the next iteration,
Thank you,
Maxime
next prev parent reply other threads:[~2026-11-17 13:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 9:21 [PATCH net v7 0/4] net: stmmac: fix RX descriptors and XSK TX on resume Ding Hui
2026-11-14 9:21 ` [PATCH net v7 1/4] net: stmmac: honor allocation flags when initializing RX buffers Ding Hui
2026-11-14 9:21 ` [PATCH net v7 2/4] net: stmmac: track unfilled XSK RX descriptors explicitly Ding Hui
2026-11-17 13:21 ` Maxime Chevallier [this message]
2026-11-14 9:21 ` [PATCH net v7 3/4] net: stmmac: restore RX descriptor buffer addresses on resume Ding Hui
2026-11-14 9:21 ` [PATCH net v7 4/4] net: stmmac: restore the XSK TX pool " Ding Hui
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=73d6b341-3553-4243-83aa-ea8bb223cef9@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dinghui1111@163.com \
--cc=dinghui@lixiang.com \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=liuxuanjun@lixiang.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tommaso.merciai.xr@bp.renesas.com \
--cc=xiasanbo@lixiang.com \
--cc=yangchen11@lixiang.com \
/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