Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: linusw@kernel.org
Cc: ulli.kroll@googlemail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	mirq-linux@rere.qmqm.pl, mhun512@gmail.com, edumazet@kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v9 02/14] net: ethernet: cortina: Keep ports bound for shared IRQ
Date: Tue, 24 Nov 2026 18:29:48 +0000	[thread overview]
Message-ID: <179554498899.3135.2703515763788273993@kernel.org> (raw)
In-Reply-To: <20261120-gemini-ethernet-fixes-3-v9-2-298671d799d5@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In the commit "net: ethernet: cortina: Keep ports bound for
  shared IRQ", gmac_setup_phy()…
- [Low] The commit "net: ethernet: cortina: Keep ports bound for shared
  IRQ" fixes user-visible bugs on in-tree boards but has no Fixes: tag…

--

net: ethernet: cortina: Keep ports bound for shared IRQ

This patch keeps Gemini ethernet child ports bound as IRQ-only ports when
no PHY is described or PHY setup fails. That keeps the shared free queue
interrupt routed through port 1 available. Probe is deferred until
referenced PHYs register, and ports are published to the parent under
RTNL only once their setup is complete.

> The software free queue interrupt is routed through port 1 even on
> boards which only connect a PHY to port 0. Since PHY setup was moved
> into probe, the PHY-less port fails to bind and releases the threaded
> handler needed by the shared queue.
>
> Publishing the port before PHY setup also leaves a dangling parent pointer
> when probe fails and devres frees the netdev private data. Opening the
> sibling can then dereference freed memory.

[Severity: Low]
This describes a use-after-free and a lost SWFQ interrupt handler. Both
can happen on in-tree boards such as gemini-verbatim-s08v1901-d1.dts,
where ethernet-port@1 has no phy-mode and no phy-handle.

Before this patch, gemini_ethernet_port_probe() set geth->port1 before
gmac_setup_phy() failed with -ENODEV. Devres then freed the port, and
opening eth0 dereferenced the stale pointer in geth_resize_freeq():

    other_netdev = geth->port1->netdev;

Should this have a Fixes: tag and Cc: stable so stable backporters pick
it up?

The change behind "Since PHY setup was moved into probe" looks like
3e813d61401a ("net: gemini: Clean up phy registration"). The ordering
that leaves the dangling pointer goes back to 4d5ae32f5e1e ("net:
ethernet: Add a driver for Gemini gigabit ethernet").

> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index f198e535f1a00..4f27a48908b1a 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c

[ ... ]

> @@ -359,18 +361,51 @@ static void gmac_adjust_link(struct net_device *netdev)

[ ... ]

> +	} else {
> +		phy_np = of_parse_phandle(dev->of_node, "phy-handle", 0);
> +		if (!phy_np)
> +			return -ENODEV;
> +	}
> +
> +	phy = of_phy_find_device(phy_np);
> +	of_node_put(phy_np);
>  	if (!phy)
> -		return -ENODEV;
> +		return -EPROBE_DEFER;

[Severity: Medium]
Can this defer forever when the phy-handle target never gets a
phy_device? of_phy_find_device() returns NULL both for a PHY that is
slow to appear and for one that never will. Some examples of the second
case:

  - the PHY node referenced by phy-handle has status = "disabled", and
    of_mdiobus_register() only walks available children
  - the PHY does not answer at its address, so of_mdiobus_register()
    logs "MDIO device at address %d is missing." and skips it
  - the MDIO bus driver (such as mdio-gpio) is not built

In gemini_ethernet_port_probe(), a deferral skips the IRQ-only fallback:

	ret = gmac_setup_phy(netdev);
	if (ret) {
		dev_err_probe(dev, ret, "PHY init failed\n");
		if (ret == -EPROBE_DEFER)
			goto unprepare;
		goto irq_only;
	}

so gemini_port_publish() never runs for this port. fw_devlink does not
parse phy-handle, and the deferred probe timeout does not override a
driver's own -EPROBE_DEFER. The port is therefore retried indefinitely.

Opening the sibling then fails every time:

gmac_open()
  geth_resize_freeq()
    if (!geth->initialized || !geth->port0 || !geth->port1)
        return -ENODEV;

gmac_open() treats this as fatal ("could not resize freeq", goto
err_stop_phy), so the sibling interface never comes up.

The commit message says ports stay bound when PHY setup "fails
permanently, so an unusable interface does not disable its sibling".
Isn't a PHY that never registers that kind of permanent failure? In
this case the unusable port still disables its sibling.

Could something like driver_deferred_probe_check_state(), or a fallback
to irq_only after the deferred probe timeout, handle the permanent case
here? The behaviour looks the same at the end of the series:
gmac_setup_phy() still returns -EPROBE_DEFER and the probe still takes
goto unprepare.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5%40kernel.org

  reply	other threads:[~2026-11-24 18:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:29 [PATCH net-next v9 00/14] net: ethernet: cortina: Fix Gemini RX buffer management Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 01/14] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 02/14] net: ethernet: cortina: Keep ports bound for shared IRQ Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko [this message]
2026-11-20 17:29 ` [PATCH net-next v9 03/14] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 04/14] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 05/14] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 06/14] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 07/14] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 08/14] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 09/14] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 10/14] net: ethernet: cortina: Separate RX buffer capacity from free queue size Linus Walleij
2026-11-20 17:29 ` [PATCH net-next v9 11/14] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 12/14] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 13/14] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-11-24 18:29   ` netdev-bot+sashiko
2026-11-20 17:29 ` [PATCH net-next v9 14/14] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij

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=179554498899.3135.2703515763788273993@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=mhun512@gmail.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ulli.kroll@googlemail.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