Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmyangfl@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, shenjian15@huawei.com, shaojijie@huawei.com,
	devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link
Date: Fri, 27 Nov 2026 01:43:18 +0000	[thread overview]
Message-ID: <179574379856.3135.451399791466560621@kernel.org> (raw)
In-Reply-To: <20261126005524.4156940-6-mmyangfl@gmail.com>

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

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

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).

- [High] hix5hd2_dev_remove() in
  drivers/net/ethernet/hisilicon/hix5hd2_gmac.c still calls…
- [Medium] The commit message says phy-handle takes precedence over
  of_phy_is_fixed_link() (for managed = "in-band-status").

--

net: hix5hd2_gmac: Support fixed-link

This patch adds fixed-link support to hix5hd2_gmac. When the node has no
phy-handle, the driver now registers a fixed PHY from the MAC node. It
also skips MDIO bus registration for a fixed link unless an "mdio" child
node is present.

> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index b3b2aa1b76988..eeb7221c0cde8 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c

[ ... ]

> +	bus = NULL;
>  	mdio_np = of_get_available_child_by_name(node, "mdio");
> -	ret = of_mdiobus_register(bus, mdio_np ?: node);
> +	if (mdio_np || (priv->phy_node != node &&
> +			!of_phy_is_fixed_link(node))) {

[Severity: Medium]
The commit message says:

    of_phy_is_fixed_link() also returns true for managed = "in-band-status";
    give phy-handle precedence over it, like fec and gianfar.

Does this condition keep that precedence for bus registration?

priv->phy_node == node only happens when the fixed-link branch ran, and
of_phy_is_fixed_link(node) is already true there. So the test reduces to
"mdio_np || !of_phy_is_fixed_link(node)".

of_phy_is_fixed_link() in drivers/net/mdio/of_mdio.c returns true for any
managed value other than "auto":

	err = of_property_read_string(np, "managed", &managed);
	if (err == 0 && strcmp(managed, "auto") != 0)
		return true;

Consider a node with phy-handle, managed = "in-band-status", and the PHY
as a direct child of the MAC node with no "mdio" subnode. The
hisilicon,hisi-gmac-v1.yaml binding only forbids direct PHY children
when fixed-link is present, so this layout is allowed.

For that node of_mdiobus_register() is never called, so the PHY is never
created. hix5hd2_net_open() then fails here:

	phy = of_phy_connect(dev, priv->phy_node,
			     &hix5hd2_adjust_link, 0, priv->phy_mode);
	if (!phy) {
		...
		return -ENODEV;

Before this patch the bus was always registered on mdio_np ?: node, and
this layout worked. This configuration also leaves priv->bus NULL, which
leads to the remove issue below.

Would "mdio_np || priv->phy_node != node" be the intended test here?

> +		bus = devm_mdiobus_alloc(dev);
> +		if (!bus) {
> +			ret = -ENOMEM;
> +			of_node_put(mdio_np);
> +			goto out_phy_node;
> +		}
> +
> +		bus->priv = priv;
> +		bus->name = "hix5hd2_mii_bus";
> +		bus->read = hix5hd2_mdio_read;
> +		bus->write = hix5hd2_mdio_write;
> +		bus->parent = &pdev->dev;
> +		snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii",
> +			 dev_name(&pdev->dev));
> +		priv->bus = bus;

[ ... ]

> @@ -1294,6 +1314,8 @@ static void hix5hd2_dev_remove(struct platform_device *pdev)
>  	if (HAS_CAP_TSO(priv->hw_cap))
>  		hix5hd2_destroy_sg_desc_queue(priv);
>  	hix5hd2_destroy_hw_desc_queue(priv);
> +	if (priv->phy_node == pdev->dev.of_node)
> +		of_phy_deregister_fixed_link(pdev->dev.of_node);
>  	of_node_put(priv->phy_node);
>  }

[Severity: High]
Can hix5hd2_dev_remove() dereference a NULL priv->bus now?

Just above this hunk, remove still does:

	unregister_netdev(ndev);
	cancel_work_sync(&priv->tx_timeout_task);
	mdiobus_unregister(priv->bus);

With this patch, hix5hd2_dev_probe() only allocates the bus and sets
priv->bus inside the new conditional block. Take the fixed-link case
this patch adds support for, with no phy-handle and no "mdio" child.
Probe succeeds and priv->bus stays NULL, because the private area from
devm_alloc_etherdev() is zeroed.

On unbind or rmmod, mdiobus_unregister() dereferences bus right away:

	if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED))
		return;

The probe error path gained an "if (bus)" check. Does remove need the
same check on priv->bus?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126005524.4156940-1-mmyangfl%40gmail.com

      reply	other threads:[~2026-11-27  1:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  0:55 [PATCH net-next v4 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-26  0:55 ` [PATCH net-next v4 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus David Yang
2026-11-26  0:55 ` [PATCH net-next v4 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node David Yang
2026-11-27  1:43   ` netdev-bot+sashiko
2026-11-26  0:55 ` [PATCH net-next v4 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists David Yang
2026-11-26  0:55 ` [PATCH net-next v4 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link David Yang
2026-11-26  0:55 ` [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-27  1:43   ` netdev-bot+sashiko [this message]

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=179574379856.3135.451399791466560621@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.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