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 v3 5/5] net: hix5hd2_gmac: Support fixed-link
Date: Wed, 25 Nov 2026 00:28:20 +0000	[thread overview]
Message-ID: <179556650026.3135.16586116032189589789@kernel.org> (raw)
In-Reply-To: <20261124002442.19414-6-mmyangfl@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] hix5hd2_dev_probe()
  (drivers/net/ethernet/hisilicon/hix5hd2_gmac.c) now uses…
- [Low] The series' binding text (hisilicon,hisi-gmac-v1.yaml, `mdio`
  description) says: "With a fixed link, the MDIO bus is not registered…

--

net: hix5hd2_gmac: Support fixed-link

When the MAC node has no phy-handle but of_phy_is_fixed_link() returns
true, this commit registers a fixed PHY from the MAC DT node. For a fixed
link, MDIO bus registration is skipped unless an mdio child node is
present. phy-handle takes precedence over managed = "in-band-status".

> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index a176870079e96..b787b7777e924 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> @@ -1176,37 +1176,52 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
>  		hix5hd2_phy_reset(priv);
>  	}
>  
> -	bus = devm_mdiobus_alloc(dev);
> -	if (bus == NULL) {
> -		ret = -ENOMEM;
> +	priv->phy_node = of_parse_phandle(node, "phy-handle", 0);
> +
> +	/* In the case of a fixed PHY, the DT node associated
> +	 * to the PHY is the Ethernet MAC DT node.
> +	 */
> +	if (!priv->phy_node && of_phy_is_fixed_link(node)) {
> +		ret = of_phy_register_fixed_link(node);
> +		if (ret < 0)
> +			goto out_disable_clk;
> +		priv->phy_node = of_node_get(node);
> +	} else if (!priv->phy_node) {
> +		netdev_err(ndev, "not find phy-handle\n");
> +		ret = -EINVAL;
>  		goto out_disable_clk;
>  	}

[Severity: Low]
Is this condition broader than intended? of_phy_is_fixed_link() also
returns true for any managed value other than "auto":

drivers/net/mdio/of_mdio.c:of_phy_is_fixed_link() {
    ...
	err = of_property_read_string(np, "managed", &managed);
	if (err == 0 && strcmp(managed, "auto") != 0)
		return true;
    ...
}

Before this patch, a MAC node with managed = "in-band-status" and no
phy-handle failed probe with "not find phy-handle". Now it probes and goes
through of_phy_register_fixed_link(), which checks in-band-status first:

drivers/net/mdio/of_mdio.c:of_phy_register_fixed_link() {
    ...
	if (of_property_read_string(np, "managed", &managed) == 0 &&
	    strcmp(managed, "in-band-status") == 0) {
		/* status is zeroed, namely its .link member */
		goto register_phy;
	}
    ...
}

That registers a fixed PHY with link=0. It also skips any fixed-link
subnode, so the speed and duplex given there are ignored.

hix5hd2 is a plain phylib MAC. It connects with of_phy_connect() in
hix5hd2_net_open(), and hix5hd2_adjust_link() is the only place that
programs port speed and duplex. The driver has no in-band status reader
and never calls fixed_phy_set_link_update() or fixed_phy_change_carrier().
Would the link ever come up for such a node?

The binding in this series only exempts fixed-link from the phy-handle
requirement. The commit message only says phy-handle takes precedence
over in-band-status.

Should managed = "in-band-status" without a phy-handle be rejected here?
Another option is to check for a fixed-link description explicitly.

[ ... ]

>  	mdio_np = of_get_child_by_name(node, "mdio");
> -	ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
> +	if (mdio_np || priv->phy_node != node) {
> +		bus = devm_mdiobus_alloc(dev);

[ ... ]

> +		ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
> +		if (ret) {
> +			of_node_put(mdio_np);
> +			goto out_phy_node;
> +		}
> +	}

[Severity: Low]
What happens with a MAC node that has both a phy-handle and a fixed-link
subnode, but no mdio child?

phy-handle takes precedence, so priv->phy_node points at the PHY node and
priv->phy_node != node is true. The bus is then registered on the MAC
node itself. __of_mdiobus_register() finds the fixed-link child, which has
no reg, and scans every address:

drivers/net/mdio/of_mdio.c:__of_mdiobus_register() {
    ...
			/* be noisy to encourage people to set reg property */
			dev_info(&mdio->dev, "scan phy %pOFn at address %i\n",
				 child, addr);
    ...
}

The fixed-link node has no compatible, so it counts as a PHY, and
of_mdiobus_register_phy() is tried on it at each free address. This
produces the "scan phy fixed-link at address X" output that the commit
message says this change avoids.

The binding text in this series says:

    With a fixed link, the MDIO bus is not registered unless this node is
    present.

The binding does not forbid combining phy-handle with fixed-link. Should
the binding description or this condition be changed so they agree for
this case?

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

      reply	other threads:[~2026-11-25  0:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  0:24 [PATCH net-next v3 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-24  0:24 ` [PATCH net-next v3 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus David Yang
2026-11-25  0:28   ` netdev-bot+sashiko
2026-11-24  0:24 ` [PATCH net-next v3 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node David Yang
2026-11-24  0:24 ` [PATCH net-next v3 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists David Yang
2026-11-25  0:28   ` netdev-bot+sashiko
2026-11-24  0:24 ` [PATCH net-next v3 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link David Yang
2026-11-25  0:28   ` netdev-bot+sashiko
2026-11-24  0:24 ` [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link David Yang
2026-11-25  0:28   ` 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=179556650026.3135.16586116032189589789@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