public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: pvalerio@redhat.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, nicolas.ferre@microchip.com,
	claudiu.beznea@tuxon.dev, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
	lorenzo@kernel.org, theo.lebrun@bootlin.com, nb@tipi-net.de
Subject: Re: [PATCH net-next v6 1/7] net: macb: move Rx buffers alloc from link up to open
Date: Sun, 29 Mar 2026 12:47:35 -0700	[thread overview]
Message-ID: <20260329194735.2781096-1-kuba@kernel.org> (raw)
In-Reply-To: <20260323221047.2749577-2-pvalerio@redhat.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: macb: move Rx buffers alloc from link up to open

This commit moves the Rx buffer allocation in the macb driver from link up
to open. It allows the initialization to fail early and loudly if the
Rx rings cannot be refilled, rather than initializing the device in a
broken state.

[ ... ]

> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 1cb49252abf5..38302cba05ad 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -1504,6 +1505,7 @@ static void gem_rx_refill(struct macb_queue *queue)
>  			if (unlikely(!skb)) {
>  				netdev_err(bp->dev,
>  					   "Unable to allocate sk_buff\n");
> +				err = -ENOMEM;
>  				break;
>  			}

If dma_map_single() fails shortly after this block, the code frees the
allocated skb and breaks out of the loop:

	paddr = dma_map_single(&bp->pdev->dev, skb->data,
			       bp->rx_buffer_size,
			       DMA_FROM_DEVICE);
	if (dma_mapping_error(&bp->pdev->dev, paddr)) {
		dev_kfree_skb(skb);
		break;
	}

Does this cause the function to return 0 (success) despite the DMA mapping
failure, bypassing the new fail-early design?

[ ... ]

> @@ -6108,12 +6127,20 @@ static int __maybe_unused macb_resume(struct device *dev)
>  	for (q = 0, queue = bp->queues; q < bp->num_queues;
>  	     ++q, ++queue) {
>  		if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC)) {
> -			if (macb_is_gem(bp))
> -				gem_init_rx_ring(queue);
> -			else
> +			if (macb_is_gem(bp)) {
> +				err = gem_init_rx_ring(queue);
> +				if (err) {
> +					dev_err(dev, "Unable to init RX ring: %d\n", err);
> +					return err;
> +				}
> +			} else {
>  				macb_init_rx_ring(queue);
> +			}
>  		}
> +	}
>  
> +	for (q = 0, queue = bp->queues; q < bp->num_queues;
> +	     ++q, ++queue) {
>  		napi_enable(&queue->napi_rx);
>  		napi_enable(&queue->napi_tx);
>  	}

If gem_init_rx_ring() fails and we return err early here, the subsequent
loop that calls napi_enable() is skipped.

Since NAPI was disabled during suspend, the NAPI context remains in a
disabled state. If the interface is later administratively brought down,
.ndo_stop (macb_close) will unconditionally call napi_disable().

Can calling napi_disable() on an already disabled NAPI context cause an
infinite loop and a hard kernel deadlock in this scenario?
-- 
pw-bot: cr

  reply	other threads:[~2026-03-29 19:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 22:10 [PATCH net-next v6 0/7] net: macb: Add XDP support and page pool integration Paolo Valerio
2026-03-23 22:10 ` [PATCH net-next v6 1/7] net: macb: move Rx buffers alloc from link up to open Paolo Valerio
2026-03-29 19:47   ` Jakub Kicinski [this message]
2026-03-23 22:10 ` [PATCH net-next v6 2/7] net: macb: rename rx_skbuff into rx_buff Paolo Valerio
2026-03-29 19:47   ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 3/7] net: macb: Add page pool support handle multi-descriptor frame rx Paolo Valerio
2026-03-25 17:45   ` Simon Horman
2026-03-29 19:47   ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 4/7] net: macb: make macb_tx_skb generic Paolo Valerio
2026-03-29 19:47   ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 5/7] net: macb: generalize tx buffer handling Paolo Valerio
2026-03-29 19:47   ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 6/7] net: macb: add XDP support for gem Paolo Valerio
2026-03-24  4:57   ` Mohsin Bashir
2026-03-29 19:47   ` Jakub Kicinski
2026-03-29 19:50   ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 7/7] net: macb: introduce ndo_xdp_xmit support Paolo Valerio
2026-03-29 19:47   ` Jakub Kicinski

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=20260329194735.2781096-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=lorenzo@kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pabeni@redhat.com \
    --cc=pvalerio@redhat.com \
    --cc=theo.lebrun@bootlin.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