* [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-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, 0 replies; 6+ 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] 6+ 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; 6+ 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] 6+ 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-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, 0 replies; 6+ 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] 6+ 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-24 0:24 ` [PATCH net-next v3 5/5] net: hix5hd2_gmac: Support fixed-link David Yang
4 siblings, 0 replies; 6+ 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] 6+ 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
4 siblings, 0 replies; 6+ 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] 6+ messages in thread