From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: Sandeep Haemoon <sandeeph@loljews.com>
Cc: netdev@vger.kernel.org, Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: mtk_eth_soc: allocate dummy netdev before registering netdevs
Date: Wed, 16 Sep 2026 15:32:20 +0200 [thread overview]
Message-ID: <aqqaY4wvRf6LUKjZ@lore-desk> (raw)
In-Reply-To: <patch-12c1a57b1d914b28b89455f24de55ee4@loljews.com>
[-- Attachment #1: Type: text/plain, Size: 4060 bytes --]
> From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
> From: Sandeep Haemoon <sandeeph@loljews.com>
> Date: Tue, 15 Sep 2026 22:00:00 +0300
> Subject: [PATCH] net: ethernet: mtk_eth_soc: allocate dummy netdev before registering netdevs
>
> The DMA ring and NAPI are shared between the multiple MAC netdevs and are
> carried by an internal "dummy" netdev (eth->dummy_dev). mtk_probe() creates
> that dummy device only after the MAC netdevs have been registered, so for a
> brief window the netdevs are visible to the network core while
> eth->dummy_dev is still NULL.
>
> If anything brings the first netdev up during that window (e.g. netifd
> opening the WAN link the instant the interface is registered), mtk_open()
> takes the first-open path and runs mtk_start_dma() -> mtk_dma_init() ->
> mtk_rx_alloc(), which calls __xdp_rxq_info_reg() with eth->dummy_dev ==
> NULL. That triggers
>
> WARNING: CPU: ... Missing net_device from driver
>
> in net/core/xdp.c and returns -ENODEV, so mtk_open() fails and the
> interface (e.g. the WAN port on MediaTek MT7988) stays down until it is
> manually brought up after probe has completed.
>
> Allocate the dummy netdev and add the shared tx/rx NAPI to it before
> registering the MAC netdevs, and free it from the probe error path instead
> of the now-unneeded err_unreg_netdev cleanup.
I think the Fix is right, but there is a preliminary bug to fix I guess.
Can you please rebase your patch on top of the following one? Thanks.
https://lore.kernel.org/netdev/20260916-mtk_eth_soc-netdev-fix-v1-1-5dac50eb65b1@oss.qualcomm.com/T/#u
Regards,
Lorenzo
>
> Signed-off-by: Sandeep Haemoon <sandeeph@loljews.com>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 31 ++++++++++++++--------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index fd7a49a..ae6a19b 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -5337,6 +5337,22 @@ static int mtk_probe(struct platform_device *pdev)
> }
> }
>
> + /* we run 2 devices on the same DMA ring so we need a dummy device
> + * for NAPI to work. Allocate it before registering the netdevs so a
> + * concurrent ndo_open (e.g. netifd bringing the first netdev up) never
> + * observes eth->dummy_dev == NULL, which would make mtk_rx_alloc() ->
> + * __xdp_rxq_info_reg() warn ("Missing net_device from driver",
> + * net/core/xdp.c) and leave the interface down on boot.
> + */
> + eth->dummy_dev = alloc_netdev_dummy(0);
> + if (!eth->dummy_dev) {
> + err = -ENOMEM;
> + dev_err(eth->dev, "failed to allocated dummy device\n");
> + goto err_deinit_ppe;
> + }
> + netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx);
> + netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx);
> +
> for (i = 0; i < MTK_MAX_DEVS; i++) {
> if (!eth->netdev[i])
> continue;
> @@ -5351,17 +5367,6 @@ static int mtk_probe(struct platform_device *pdev)
> eth->netdev[i]->base_addr, eth->irq[MTK_FE_IRQ_SHARED]);
> }
>
> - /* we run 2 devices on the same DMA ring so we need a dummy device
> - * for NAPI to work
> - */
> - eth->dummy_dev = alloc_netdev_dummy(0);
> - if (!eth->dummy_dev) {
> - err = -ENOMEM;
> - dev_err(eth->dev, "failed to allocated dummy device\n");
> - goto err_unreg_netdev;
> - }
> - netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx);
> - netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx);
>
> platform_set_drvdata(pdev, eth);
> schedule_delayed_work(ð->reset.monitor_work,
> @@ -5369,9 +5374,9 @@ static int mtk_probe(struct platform_device *pdev)
>
> return 0;
>
> -err_unreg_netdev:
> - mtk_unreg_dev(eth);
> err_deinit_ppe:
> + if (eth->dummy_dev)
> + free_netdev(eth->dummy_dev);
> mtk_ppe_deinit(eth);
> mtk_mdio_cleanup(eth);
> err_free_dev:
> --
> 2.39.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-09-16 13:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 18:55 [PATCH] net: ethernet: mtk_eth_soc: allocate dummy netdev before registering netdevs Sandeep Haemoon
2026-09-16 13:32 ` Lorenzo Bianconi [this message]
2026-09-19 1:52 ` netdev-bot+sashiko
2026-09-20 17:38 ` [PATCH net v2] " Sandeep Haemoon
2026-09-24 16:31 ` 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=aqqaY4wvRf6LUKjZ@lore-desk \
--to=lorenzo.bianconi@oss.qualcomm.com \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=sandeeph@loljews.com \
--cc=stable@vger.kernel.org \
/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