* [PATCH net-next v3 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus
2026-11-24 0:24 [PATCH net-next v3 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
@ 2026-11-24 0:24 ` 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
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: David Yang @ 2026-11-24 0:24 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jian Shen, Jijie Shao, devicetree
Let devres manage the netdev and the MDIO bus, so that neither needs
to be released by hand in the error path and on remove.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 29 +++++++------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index 12a5657653f8..d129aeceb641 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -1106,7 +1106,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
struct mii_bus *bus;
int ret;
- ndev = alloc_etherdev(sizeof(struct hix5hd2_priv));
+ ndev = devm_alloc_etherdev(dev, sizeof(struct hix5hd2_priv));
if (!ndev)
return -ENOMEM;
@@ -1121,26 +1121,26 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base);
- goto out_free_netdev;
+ return ret;
}
priv->ctrl_base = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(priv->ctrl_base)) {
ret = PTR_ERR(priv->ctrl_base);
- goto out_free_netdev;
+ return ret;
}
priv->mac_core_clk = devm_clk_get(&pdev->dev, "mac_core");
if (IS_ERR(priv->mac_core_clk)) {
netdev_err(ndev, "failed to get mac core clk\n");
ret = -ENODEV;
- goto out_free_netdev;
+ return ret;
}
ret = clk_prepare_enable(priv->mac_core_clk);
if (ret < 0) {
netdev_err(ndev, "failed to enable mac core clk %d\n", ret);
- goto out_free_netdev;
+ return ret;
}
priv->mac_ifc_clk = devm_clk_get(&pdev->dev, "mac_ifc");
@@ -1175,7 +1175,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
hix5hd2_phy_reset(priv);
}
- bus = mdiobus_alloc();
+ bus = devm_mdiobus_alloc(dev);
if (bus == NULL) {
ret = -ENOMEM;
goto out_disable_clk;
@@ -1189,21 +1189,21 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
priv->bus = bus;
- ret = of_mdiobus_register(bus, node);
+ ret = devm_of_mdiobus_register(dev, bus, node);
if (ret)
- goto err_free_mdio;
+ goto out_disable_clk;
ret = of_get_phy_mode(node, &priv->phy_mode);
if (ret) {
netdev_err(ndev, "not find phy-mode\n");
- goto err_mdiobus;
+ goto out_disable_clk;
}
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;
+ goto out_disable_clk;
}
ndev->irq = platform_get_irq(pdev, 0);
@@ -1269,16 +1269,10 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
hix5hd2_destroy_hw_desc_queue(priv);
out_phy_node:
of_node_put(priv->phy_node);
-err_mdiobus:
- mdiobus_unregister(bus);
-err_free_mdio:
- mdiobus_free(bus);
out_disable_clk:
clk_disable_unprepare(priv->mac_ifc_clk);
out_disable_mac_core_clk:
clk_disable_unprepare(priv->mac_core_clk);
-out_free_netdev:
- free_netdev(ndev);
return ret;
}
@@ -1290,14 +1284,11 @@ static void hix5hd2_dev_remove(struct platform_device *pdev)
unregister_netdev(ndev);
cancel_work_sync(&priv->tx_timeout_task);
- mdiobus_unregister(priv->bus);
- mdiobus_free(priv->bus);
if (HAS_CAP_TSO(priv->hw_cap))
hix5hd2_destroy_sg_desc_queue(priv);
hix5hd2_destroy_hw_desc_queue(priv);
of_node_put(priv->phy_node);
- free_netdev(ndev);
}
static const struct of_device_id hix5hd2_of_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v3 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 0:28 UTC (permalink / raw)
To: mmyangfl
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
krzk+dt, conor+dt, shenjian15, shaojijie, devicetree
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] On a probe failure, the MDIO bus is now torn down after the MAC
clocks are already off.
--
net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus
This commit switches hix5hd2_gmac to devm_alloc_etherdev(),
devm_mdiobus_alloc() and devm_of_mdiobus_register(). It drops the
manual free_netdev() and mdiobus_unregister()/mdiobus_free() calls from
the probe error path and from hix5hd2_dev_remove().
> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index 12a5657653f85..d129aeceb641e 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
[ ... ]
> @@ -1189,21 +1189,21 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
> snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
> priv->bus = bus;
>
> - ret = of_mdiobus_register(bus, node);
> + ret = devm_of_mdiobus_register(dev, bus, node);
> if (ret)
> - goto err_free_mdio;
> + goto out_disable_clk;
[ ... ]
> @@ -1269,16 +1269,10 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
> hix5hd2_destroy_hw_desc_queue(priv);
> out_phy_node:
> of_node_put(priv->phy_node);
> -err_mdiobus:
> - mdiobus_unregister(bus);
> -err_free_mdio:
> - mdiobus_free(bus);
> out_disable_clk:
> clk_disable_unprepare(priv->mac_ifc_clk);
> out_disable_mac_core_clk:
> clk_disable_unprepare(priv->mac_core_clk);
> -out_free_netdev:
> - free_netdev(ndev);
>
> return ret;
> }
[Severity: Low]
Does this change when the MDIO bus is torn down, relative to the clocks,
if hix5hd2_dev_probe() fails?
Before this patch, a failure after of_mdiobus_register() ran
mdiobus_unregister() while mac_ifc_clk and mac_core_clk were still
enabled. Now the error path disables both clocks and returns. Devres then
runs devm_mdiobus_unregister() -> mdiobus_unregister() with the clocks
off.
These failures take that path:
- missing phy-mode or phy-handle
- platform_get_irq() errors, including -EPROBE_DEFER
- devm_request_irq() failure
- descriptor queue allocation failure
- register_netdev() failure
If the bus scan found a PHY and bound it to a driver, mdiobus_unregister()
calls phy_remove() through device_del(). phy_remove() can do MDIO I/O:
phy_remove()
phy_leds_unregister()
led_classdev_unregister()
led_set_brightness(LED_OFF)
phydev->drv->remove()
The LED_OFF write happens unless the DT sets retain-state-shutdown.
Those accesses go through hix5hd2_mdio_read() and hix5hd2_mdio_write().
Both poll the MAC register window in priv->base:
hix5hd2_mdio_wait_ready() {
...
for (i = 0; readl_relaxed(base + MDIO_SINGLE_CMD) & MDIO_START; i++) {
if (i == timeout)
return -ETIMEDOUT;
usleep_range(10, 20);
}
...
}
With the MAC block unclocked, could these accesses time out (up to 10000
iterations per access)? Could they read a stale ready value and lose the
write, or stall the bus on some SoCs?
Before this patch, hix5hd2_dev_remove() already called
mdiobus_unregister() with the clocks off, because probe and ndo_stop
both disable them. The new ordering only affects the unwind after a
failed probe.
The same ordering is still there after the later patch in this series,
"net: hix5hd2_gmac: Support fixed-link". Its out_phy_node and
out_disable_clk labels disable the clocks while devres still holds the
registered bus.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124002442.19414-1-mmyangfl%40gmail.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v3 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node
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-24 0:24 ` 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
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: David Yang @ 2026-11-24 0:24 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jian Shen, Jijie Shao, devicetree
This adds an optional mdio bus child node. If present, the mac will
look for PHYs there instead of directly under the top-level node. This
eliminates any ambiguity about whether child nodes are PHYs, and allows
the MDIO bus to contain non-PHY devices.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
.../devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
index 89ed6ab1905e..a71529825955 100644
--- a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
+++ b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
@@ -53,6 +53,13 @@ properties:
- const: mac_ifc
- const: phy
+ mdio:
+ $ref: mdio.yaml#
+ unevaluatedProperties: false
+ description:
+ Node containing PHY children. If this node is not present, then PHYs will
+ be direct children.
+
hisilicon,phy-reset-delays-us:
description: Triplet of PHY reset delays in microseconds.
items:
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH net-next v3 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists
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-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 ` 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-24 0:24 ` [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link David Yang
4 siblings, 1 reply; 10+ messages in thread
From: David Yang @ 2026-11-24 0:24 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jian Shen, Jijie Shao, devicetree
This allows explicitly specifying which children are present on the mdio
bus, like commit 4d98bb0d7ec2 ("net: macb: Use mdio child node for MDIO
bus if it exists").
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index d129aeceb641..a176870079e9 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -1101,6 +1101,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
+ struct device_node *mdio_np;
struct net_device *ndev;
struct hix5hd2_priv *priv;
struct mii_bus *bus;
@@ -1189,7 +1190,9 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
priv->bus = bus;
- ret = devm_of_mdiobus_register(dev, bus, node);
+ mdio_np = of_get_child_by_name(node, "mdio");
+ ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
+ of_node_put(mdio_np);
if (ret)
goto out_disable_clk;
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v3 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 0:28 UTC (permalink / raw)
To: mmyangfl
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
krzk+dt, conor+dt, shenjian15, shaojijie, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · 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).
- [Medium] In hix5hd2_dev_probe()
(drivers/net/ethernet/hisilicon/hix5hd2_gmac.c), the patch finds the…
--
net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists
This commit makes hix5hd2_dev_probe() look for an "mdio" child of the MAC
node. If one exists, the MDIO bus is registered against that child instead
of the MAC node itself, following the earlier macb change.
> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index d129aeceb641e..a176870079e96 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
[ ... ]
> @@ -1189,7 +1190,9 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
> snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
> priv->bus = bus;
>
> - ret = devm_of_mdiobus_register(dev, bus, node);
> + mdio_np = of_get_child_by_name(node, "mdio");
> + ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
> + of_node_put(mdio_np);
> if (ret)
> goto out_disable_clk;
[Severity: Medium]
What happens here when the mdio child exists but has status = "disabled"?
of_get_child_by_name() ignores the status property. In that case mdio_np
is non-NULL and the disabled node is passed to devm_of_mdiobus_register().
__of_mdiobus_register() then rejects it:
drivers/net/mdio/of_mdio.c:__of_mdiobus_register() {
...
/* Do not continue if the node is disabled */
if (!of_device_is_available(np))
return -ENODEV;
...
}
The -ENODEV goes back through the goto out_disable_clk path, and the whole
Ethernet device fails to probe.
Before this patch the MAC node was always passed in. Its child scan uses
for_each_available_child_of_node(), so a disabled child was just skipped.
The same lookup is still there at the end of the series. After "net:
hix5hd2_gmac: Support fixed-link", any non-NULL mdio_np forces bus
registration:
mdio_np = of_get_child_by_name(node, "mdio");
if (mdio_np || priv->phy_node != node) {
So a fixed-link MAC with a disabled mdio child would also fail probe with
-ENODEV. That doesn't match the binding text "With a fixed link, the MDIO
bus is not registered unless this node is present."
Would of_get_available_child_by_name() work better here? Other net drivers
such as rzn1_a5psw, owl-emac, ibm emac and mtk_star_emac use it for the
same lookup, and it would treat a disabled mdio child as absent.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124002442.19414-1-mmyangfl%40gmail.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v3 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link
2026-11-24 0:24 [PATCH net-next v3 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
` (2 preceding siblings ...)
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-24 0:24 ` 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
4 siblings, 1 reply; 10+ messages in thread
From: David Yang @ 2026-11-24 0:24 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jian Shen, Jijie Shao, devicetree
With a fixed link there is no phy-handle, make phy-handle required only
when no fixed-link is declared.
A fixed link without an "mdio" child node gets no MDIO bus, so devices
attached to the controller's MDIO lines must be described under the
"mdio" child node.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
.../bindings/net/hisilicon,hisi-gmac-v1.yaml | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
index a71529825955..c283c1b6ac72 100644
--- a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
+++ b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
@@ -13,6 +13,13 @@ maintainers:
allOf:
- $ref: /schemas/net/ethernet-controller.yaml#
- $ref: /schemas/net/mdio.yaml#
+ - if:
+ not:
+ required:
+ - fixed-link
+ then:
+ required:
+ - phy-handle
properties:
compatible:
@@ -58,7 +65,8 @@ properties:
unevaluatedProperties: false
description:
Node containing PHY children. If this node is not present, then PHYs will
- be direct children.
+ be direct children. With a fixed link, the MDIO bus is not registered
+ unless this node is present.
hisilicon,phy-reset-delays-us:
description: Triplet of PHY reset delays in microseconds.
@@ -74,7 +82,6 @@ required:
- clocks
- clock-names
- phy-mode
- - phy-handle
unevaluatedProperties: false
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v3 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 0:28 UTC (permalink / raw)
To: mmyangfl
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
krzk+dt, conor+dt, shenjian15, shaojijie, devicetree
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] In Documentation/devicetree/bindings/net/hisilicon,hisi-
gmac-v1.yaml, this patch states a rule only in the free-text…
--
dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link
This patch makes phy-handle required only when no fixed-link is present.
It also adds a sentence to the mdio property description saying that, with
a fixed link, the MDIO bus is only registered when an mdio child node is
present.
> diff --git a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
> index a715298259552..c283c1b6ac723 100644
> --- a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
> +++ b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
> @@ -13,6 +13,13 @@ maintainers:
> allOf:
> - $ref: /schemas/net/ethernet-controller.yaml#
> - $ref: /schemas/net/mdio.yaml#
> + - if:
> + not:
> + required:
> + - fixed-link
> + then:
> + required:
> + - phy-handle
>
> properties:
> compatible:
[ ... ]
> @@ -58,7 +65,8 @@ properties:
> unevaluatedProperties: false
> description:
> Node containing PHY children. If this node is not present, then PHYs will
> - be direct children.
> + be direct children. With a fixed link, the MDIO bus is not registered
> + unless this node is present.
[Severity: Low]
Should this rule be enforced by the schema, rather than stated only in the
description?
The top-level allOf still includes mdio.yaml. Its '@[0-9a-f]+$'
patternProperties allows MDIO device nodes directly under the ethernet
node. The new if/then block only decides whether phy-handle is required.
That means a node with fixed-link and direct children such as
ethernet-phy@N or switch@N, but no mdio subnode, still passes
dt_binding_check.
Later in the series, "net: hix5hd2_gmac: Support fixed-link" makes
hix5hd2_dev_probe() skip MDIO bus registration in that case:
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c:hix5hd2_dev_probe() {
...
if (mdio_np || priv->phy_node != node) {
...
}
The driver then ignores those direct children without any warning.
Would an "if: required: [fixed-link]" / "then:" block work here, one that
disallows '@[0-9a-f]+$' children directly on the ethernet node?
Also, the new sentence describes Linux driver behaviour ("the MDIO bus is
not registered") rather than the hardware. The GMAC's MDIO controller and
lines exist whether or not the MAC link is fixed.
Could the text be reworded as a description rule instead? For example: with
fixed-link, MDIO devices must be placed under the mdio node.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124002442.19414-1-mmyangfl%40gmail.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link
2026-11-24 0:24 [PATCH net-next v3 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
` (3 preceding siblings ...)
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-24 0:24 ` David Yang
2026-11-25 0:28 ` netdev-bot+sashiko
4 siblings, 1 reply; 10+ messages in thread
From: David Yang @ 2026-11-24 0:24 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jian Shen, Jijie Shao, devicetree
On Hi3716cv200 hix5hd2_gmac is found directly linked to another MAC
without PHY. The driver didn't take fixed-link into account and failed
probe when the node has no phy-handle. Register a fixed PHY from the
node in that case.
With a fixed link declared on the MAC node, of_mdiobus_register() treats
the reg-less fixed-link child as a PHY candidate and walks all 32 bus
addresses, printing "scan phy fixed-link at address X" for each address.
Skip the MDIO bus registration for a fixed link, unless devices are
described under an "mdio" child node, like
commit d0c3601f2c4e ("net: macb: Avoid 20s boot delay by skipping MDIO
bus registration for fixed-link PHY").
of_phy_is_fixed_link() also returns true for managed = "in-band-status";
give phy-handle precedence over it, like fec and gianfar, so nodes with
a phy-handle keep MDIO management.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 63 ++++++++++++-------
1 file changed, 41 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index a176870079e9..b787b7777e92 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;
}
- 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;
-
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);
+ 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;
+
+ ret = devm_of_mdiobus_register(dev, bus, mdio_np ?: node);
+ if (ret) {
+ of_node_put(mdio_np);
+ goto out_phy_node;
+ }
+ }
of_node_put(mdio_np);
- if (ret)
- goto out_disable_clk;
ret = of_get_phy_mode(node, &priv->phy_mode);
if (ret) {
netdev_err(ndev, "not find phy-mode\n");
- goto out_disable_clk;
- }
-
- 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 out_disable_clk;
+ goto out_phy_node;
}
ndev->irq = platform_get_irq(pdev, 0);
@@ -1271,6 +1286,8 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
netif_napi_del(&priv->napi);
hix5hd2_destroy_hw_desc_queue(priv);
out_phy_node:
+ if (priv->phy_node == node)
+ of_phy_deregister_fixed_link(node);
of_node_put(priv->phy_node);
out_disable_clk:
clk_disable_unprepare(priv->mac_ifc_clk);
@@ -1291,6 +1308,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);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 0:28 UTC (permalink / raw)
To: mmyangfl
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, robh,
krzk+dt, conor+dt, shenjian15, shaojijie, devicetree
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
^ permalink raw reply [flat|nested] 10+ messages in thread