From: Nicolai Buchwitz <nb@tipi-net.de>
To: "Théo Lebrun" <theo.lebrun@bootlin.com>
Cc: Conor Dooley <conor.dooley@microchip.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Sean Anderson <sean.anderson@linux.dev>,
Antoine Tenart <atenart@kernel.org>,
Russell King <linux@armlinux.org.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>,
Gregory CLEMENT <gregory.clement@bootlin.com>,
Tawfik Bayouk <tawfik.bayouk@mobileye.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 1/3] net: macb: never give hardware a NULL RX buffer
Date: Mon, 21 Sep 2026 08:54:40 +0200 [thread overview]
Message-ID: <c431bd54f9e26158a10bdfd6a4d606b0@tipi-net.de> (raw)
In-Reply-To: <20260918-macb-close-v1-1-221d916b7961@bootlin.com>
On 18.9.2026 22:32, Théo Lebrun wrote:
> The refill logic is simple: iterate over all pending rx slots, allocate
> SKB (& DMA map) if needed and hand it off the to hardware by clearing
> the RX_USED flag.
>
> If the refill operation fails mid-way, it early returns leaving the
> following slots untouched. In the normal case that is fine, because all
> slots have been properly initialised (and might have been already used
> by HW meaning they won't be reused). When slots have not been
> initialised however, we are in trouble.
>
> After dma_alloc_coherent() of the rx ring buffer, all slots have NULL
> pointers and RX_USED cleared meaning HW will try using them. Ensure
> this does not happen by setting the RX_USED flag on all slots before
> calling refill at buffer alloc, in gem_init_rx_ring(). That way even if
> refill fails on an alloc/dma_map, the HW won't try using NULL pointers
> as buffers.
>
> Theoretical bugfix, never encountered in practice. To reproduce,
> introduce memory pressure (less than 512 SKBs of free memory) and open
> the interface.
>
> Note that this codepath also hits at resume, on HRESP errors and on
> set_ringparam (while interface is running).
>
> Fixes: 4df95131ea80 ("net/macb: change RX path for GEM")
> Cc: stable@vger.kernel.org
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c
> b/drivers/net/ethernet/cadence/macb_main.c
> index b8234ac4b602..751fa9e68099 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -2785,9 +2785,14 @@ static int macb_alloc(struct macb *bp)
>
> static void gem_init_rx_ring(struct macb_queue *queue)
> {
> + unsigned int i;
> +
> queue->rx_tail = 0;
> queue->rx_prepared_head = 0;
>
> + for (i = 0; i < queue->bp->rx_ring_size; i++)
> + macb_rx_desc(queue, i)->addr |= MACB_BIT(RX_USED);
> +
> gem_rx_refill(queue);
> }
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Regards
Nicolai
next prev parent reply other threads:[~2026-09-21 6:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 20:32 [PATCH 0/3] net: macb: fix close races (and RX refill error handling) Théo Lebrun
2026-09-18 20:32 ` [PATCH 1/3] net: macb: never give hardware a NULL RX buffer Théo Lebrun
2026-09-21 6:54 ` Nicolai Buchwitz [this message]
2026-09-18 20:32 ` [PATCH 2/3] net: macb: propagate RX ring refill errors Théo Lebrun
2026-09-21 7:05 ` Nicolai Buchwitz
2026-09-21 9:54 ` Théo Lebrun
2026-09-18 20:32 ` [PATCH 3/3] net: macb: quiesce IRQs and drain BH on interface close Théo Lebrun
2026-09-21 6:55 ` Nicolai Buchwitz
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=c431bd54f9e26158a10bdfd6a4d606b0@tipi-net.de \
--to=nb@tipi-net.de \
--cc=andrew+netdev@lunn.ch \
--cc=atenart@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.clement@bootlin.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=sean.anderson@linux.dev \
--cc=stable@vger.kernel.org \
--cc=tawfik.bayouk@mobileye.com \
--cc=theo.lebrun@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.kondratiev@mobileye.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
all inboxes | Powered by JetHome®