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 v2 2/2] net: hix5hd2_gmac: support fixed-link and mdio child
Date: Mon, 23 Nov 2026 23:02:54 +0000	[thread overview]
Message-ID: <179547497461.3135.10844552053295953627@kernel.org> (raw)
In-Reply-To: <20261122230134.3366017-3-mmyangfl@gmail.com>

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 hix5hd2_dev_probe()
  (drivers/net/ethernet/hisilicon/hix5hd2_gmac.c), the MDIO bus is now…
- [Low] hix5hd2_dev_probe() now uses of_phy_is_fixed_link(node) to choose
  between the fixed-link path and the phy-handle path, and also to…

--

net: hix5hd2_gmac: support fixed-link and mdio child

This commit adds fixed-link support to hix5hd2_gmac. With it, the MAC can
probe when it is wired directly to another MAC with no PHY. It also
registers the MDIO bus on an "mdio" child node when one is present. When
the MAC node has a fixed-link and no mdio child, it skips the MDIO bus
entirely.

> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index 12a5657653f85..9a2a3fa1455fb 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c

[ ... ]

> @@ -1175,23 +1176,35 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
>  		hix5hd2_phy_reset(priv);
>  	}
>  

[ ... ]

> +	bus = NULL;
> +	mdio_np = of_get_child_by_name(node, "mdio");
> +	if (mdio_np || !of_phy_is_fixed_link(node)) {
> +		bus = mdiobus_alloc();
> +		if (!bus) {
> +			ret = -ENOMEM;
> +			of_node_put(mdio_np);
> +			goto out_disable_clk;
> +		}

[Severity: Medium]
In hix5hd2_dev_probe(), if the MAC node has a fixed-link but no "mdio"
child, this condition is false. mdiobus_alloc() and of_mdiobus_register()
are never called, and bus and priv->bus stay NULL.

Are MDIO devices described as direct children of the MAC node then
silently ignored?

The binding from the preceding patch ("dt-bindings: net:
hisilicon,hisi-gmac-v1: allow fixed-link and mdio child") still says this
for the mdio property:

    Node containing PHY children. If this node is not present, then PHYs
    will be direct children.

The binding also still references mdio.yaml at the MAC node level. So a
fixed-link node with direct <name>@<addr> MDIO children looks
binding-valid. Examples would be a PHY used by another MAC, or a switch
managed over this GMAC's MDIO lines. In that case nothing is probed and
no warning is printed.

Separately, the commit message says:

    Register the bus based on if the PHY attached to a given interface is
    described in the device tree or not, like commit ef8a2e27289e ("net:
    macb: fix probing of PHY not described in the dt").

Is that accurate? macb_mdiobus_register() always registers the bus. It
only chooses between DT-based and scan-based registration:

drivers/net/ethernet/cadence/macb_main.c:macb_mdiobus_register() {
    ...
	for_each_available_child_of_node(np, child)
		if (of_mdiobus_child_is_phy(child)) {
			of_node_put(child);
			return of_mdiobus_register(bp->mii_bus, np);
		}

	return mdiobus_register(bp->mii_bus);
}

Also, of_mdiobus_child_is_phy() returns true for any child that has no
compatible property:

drivers/net/mdio/of_mdio.c:of_mdiobus_child_is_phy() {
    ...
	if (!of_property_present(child, "compatible"))
		return true;
    ...
}

Under the macb logic, the fixed-link subnode would therefore still count
as a PHY. of_mdiobus_register(np) would still run and print the "scan phy
fixed-link at address X" messages.

The code here takes a different approach: it registers no bus at all for
fixed-link. Could the commit message describe what the code does instead?

The commit message also doesn't mention that an "mdio" child is now used
as the bus node. Before this patch it was scanned as a reg-less PHY
candidate of the MAC node.

[ ... ]

> @@ -1199,11 +1212,18 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
>  		goto err_mdiobus;
>  	}
>  
> -	priv->phy_node = of_parse_phandle(node, "phy-handle", 0);
> -	if (!priv->phy_node) {
> -		netdev_err(ndev, "not find phy-handle\n");
> -		ret = -EINVAL;
> -		goto err_mdiobus;
> +	if (of_phy_is_fixed_link(node)) {
> +		ret = of_phy_register_fixed_link(node);
> +		if (ret < 0)
> +			goto err_mdiobus;
> +		priv->phy_node = of_node_get(node);
> +	} else {
> +		priv->phy_node = of_parse_phandle(node, "phy-handle", 0);

[Severity: Low]
of_phy_is_fixed_link() also returns true when the node sets managed to
anything other than "auto". This happens even with no fixed-link property
or subnode:

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;
    ...
}

What happens to a node with managed = "in-band-status", a phy-handle and
no mdio child? Before this patch the driver ignored managed and connected
the real PHY through phy-handle.

After this patch:

- no MDIO bus is registered, because of the bus condition above
- phy-handle is never parsed
- of_phy_register_fixed_link() takes the in-band-status path:

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;
	}
    ...
}

hix5hd2 has no PCS or in-band status handling, so nothing ever sets the
fixed PHY's link. Would the interface stay link-down permanently?

The binding from this series only drops the phy-handle requirement when
fixed-link is present:

  - if:
      not:
        required:
          - fixed-link
    then:
      required:
        - phy-handle

So the binding still treats such a node as a phy-handle configuration.

No in-tree hix5hd2 DTS uses managed, and of_phy_get_and_connect() uses the
same precedence. The commit message doesn't mention this behaviour change,
though.

[ ... ]

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

      parent reply	other threads:[~2026-11-23 23:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 23:01 [PATCH net-next v2 0/2] net: hix5hd2_gmac: support fixed-link David Yang
2026-11-22 23:01 ` [PATCH net-next v2 1/2] dt-bindings: net: hisilicon,hisi-gmac-v1: allow fixed-link and mdio child David Yang
2026-11-22 23:01 ` [PATCH net-next v2 2/2] net: hix5hd2_gmac: support " David Yang
2026-11-23 19:57   ` Andrew Lunn
2026-11-23 23:02   ` 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=179547497461.3135.10844552053295953627@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