* [PATCH net-next v4 0/5] net: hix5hd2_gmac: Support fixed-link
@ 2026-11-26 0:55 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
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: David Yang @ 2026-11-26 0:55 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
Support MAC-to-MAC link on hix5hd2_gmac. Also add and support mdio child
node to suppress warnings when fixed linked, as in macb.
v4:
- reword in dt bindings
- register MDIO bus manually
- skip disabled mdio child
v3: https://lore.kernel.org/r/20261124002442.19414-1-mmyangfl@gmail.com
- use devm_*
- split mdio child node and fixed-link
v2: https://lore.kernel.org/r/20261122230134.3366017-1-mmyangfl@gmail.com
- add mdio bus child node
v1: https://lore.kernel.org/r/20261120031026.1371052-1-mmyangfl@gmail.com
David Yang (5):
net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus
dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node
net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists
dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link
net: hix5hd2_gmac: Support fixed-link
.../bindings/net/hisilicon,hisi-gmac-v1.yaml | 25 +++++-
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 87 +++++++++++--------
2 files changed, 77 insertions(+), 35 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v4 1/5] net: hix5hd2_gmac: Use devm_ managed netdev and MDIO bus
2026-11-26 0:55 [PATCH net-next v4 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
@ 2026-11-26 0:55 ` 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
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: David Yang @ 2026-11-26 0:55 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 allocation, so that
neither needs to be freed by hand in the error path and on remove.
The MDIO bus itself is still registered and unregistered by hand, so
that it is torn down before the MAC clocks are disabled on the probe
error path.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 20 +++++++------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index 12a5657653f8..44b05d41cb95 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;
@@ -1191,7 +1191,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
ret = of_mdiobus_register(bus, node);
if (ret)
- goto err_free_mdio;
+ goto out_disable_clk;
ret = of_get_phy_mode(node, &priv->phy_mode);
if (ret) {
@@ -1271,14 +1271,10 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
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;
}
@@ -1291,13 +1287,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] 8+ messages in thread
* [PATCH net-next v4 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node
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 ` 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
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: David Yang @ 2026-11-26 0:55 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] 8+ messages in thread
* [PATCH net-next v4 3/5] net: hix5hd2_gmac: Use mdio child node for MDIO bus if it exists
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-26 0:55 ` 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
4 siblings, 0 replies; 8+ messages in thread
From: David Yang @ 2026-11-26 0:55 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 44b05d41cb95..b3b2aa1b7698 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 = of_mdiobus_register(bus, node);
+ mdio_np = of_get_available_child_by_name(node, "mdio");
+ ret = of_mdiobus_register(bus, mdio_np ?: node);
+ of_node_put(mdio_np);
if (ret)
goto out_disable_clk;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v4 4/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Allow fixed-link
2026-11-26 0:55 [PATCH net-next v4 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
` (2 preceding siblings ...)
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 ` David Yang
2026-11-26 0:55 ` [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link David Yang
4 siblings, 0 replies; 8+ messages in thread
From: David Yang @ 2026-11-26 0:55 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 fixed-link there is no phy-handle, make phy-handle required only
when no fixed-link is declared.
A fixed link gets no MDIO bus by default. In such case, MDIO devices
must be placed under the mdio node, and PHY nodes directly under the
ethernet node are rejected.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
.../bindings/net/hisilicon,hisi-gmac-v1.yaml | 20 +++++++++++++++++--
1 file changed, 18 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..2f1c0e0afb88 100644
--- a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
+++ b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
@@ -13,6 +13,22 @@ maintainers:
allOf:
- $ref: /schemas/net/ethernet-controller.yaml#
- $ref: /schemas/net/mdio.yaml#
+ - if:
+ not:
+ required:
+ - fixed-link
+ then:
+ required:
+ - phy-handle
+ - if:
+ required:
+ - fixed-link
+ then:
+ not:
+ required:
+ - phy-handle
+ patternProperties:
+ '@[0-9a-f]+$': false
properties:
compatible:
@@ -58,7 +74,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 fixed-link, MDIO devices must be placed under the
+ mdio node.
hisilicon,phy-reset-delays-us:
description: Triplet of PHY reset delays in microseconds.
@@ -74,7 +91,6 @@ required:
- clocks
- clock-names
- phy-mode
- - phy-handle
unevaluatedProperties: false
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link
2026-11-26 0:55 [PATCH net-next v4 0/5] net: hix5hd2_gmac: Support fixed-link David Yang
` (3 preceding siblings ...)
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 ` David Yang
2026-11-27 1:43 ` netdev-bot+sashiko
4 siblings, 1 reply; 8+ messages in thread
From: David Yang @ 2026-11-26 0:55 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.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 70 ++++++++++++-------
1 file changed, 46 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index b3b2aa1b7698..eeb7221c0cde 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -1176,37 +1176,55 @@ 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;
-
+ 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))) {
+ 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 = of_mdiobus_register(bus, mdio_np ?: node);
+ if (ret) {
+ of_node_put(mdio_np);
+ bus = NULL;
+ 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 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;
+ goto out_phy_node;
}
ndev->irq = platform_get_irq(pdev, 0);
@@ -1271,9 +1289,11 @@ 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);
-err_mdiobus:
- mdiobus_unregister(bus);
+ if (bus)
+ mdiobus_unregister(bus);
out_disable_clk:
clk_disable_unprepare(priv->mac_ifc_clk);
out_disable_mac_core_clk:
@@ -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);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v4 2/5] dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node
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
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 1:43 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 this commit the binding hisilicon,hisi-gmac-v1.yaml adds an
optional `mdio` child node and says that PHYs sit under it when it is…
--
dt-bindings: net: hisilicon,hisi-gmac-v1: Add mdio bus child node
This adds an optional mdio child node to the hisi-gmac-v1 binding. When
the node is present, the MAC looks for PHYs under it instead of directly
under the top-level node.
> diff --git a/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml b/Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml
> index 89ed6ab1905e1..a715298259552 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.
[Severity: Low]
With only this commit applied, does the driver honour the new mdio child?
hix5hd2_dev_probe() in drivers/net/ethernet/hisilicon/hix5hd2_gmac.c still
registers the MDIO bus on the top-level MAC node:
hix5hd2_dev_probe() {
...
ret = of_mdiobus_register(bus, node);
...
}
The binding now accepts PHYs placed under mdio { }. A DT using that layout
would leave the PHY unregistered at this point in the series.
of_phy_connect() in hix5hd2_net_open() would then fail to find a
phy_device for the phy-handle.
The next patch in the series, "net: hix5hd2_gmac: Use mdio child node for
MDIO bus if it exists", looks up the child with
of_get_available_child_by_name(node, "mdio"). It then calls
of_mdiobus_register(bus, mdio_np ?: node), which closes the gap.
This is the usual dt-bindings-first order for a series, so this is likely
fine as is. It is noted here only for completeness.
>
> hisilicon,phy-reset-delays-us:
> description: Triplet of PHY reset delays in microseconds.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126005524.4156940-1-mmyangfl%40gmail.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v4 5/5] net: hix5hd2_gmac: Support fixed-link
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
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 1:43 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 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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-27 1:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox