net: hix5hd2_gmac: support fixed-link
Subsystems (3)
PATCH 1/1 net: hix5hd2_gmac: support fixed-link
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.
Add support for fixed-link. A fixed link has no PHY address, yet of_mdiobus_register() walks all 32 addresses and prints a warning line for every address. Suppress the warning by masking out all PHY address.
--- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +22 -6
@@ -1189,7 +1189,12 @@ 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); +if (of_phy_is_fixed_link (node)) { + bus->phy_mask = ~0 ; + ret =mdiobus_register (bus); + }else { + ret =of_mdiobus_register (bus, node); + }if (ret) goto err_free_mdio;
@@ -1199,11 +1204,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 ); +if (!priv->phy_node) { +netdev_err (ndev,"not find phy-handle\n" ); + ret = -EINVAL ; + goto err_mdiobus; + } } ndev->irq =platform_get_irq (pdev,0 );
@@ -1268,6 +1280,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 (of_phy_is_fixed_link (node)) +of_phy_deregister_fixed_link (node);of_node_put (priv->phy_node); err_mdiobus:mdiobus_unregister (bus);
@@ -1296,6 +1310,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 (of_phy_is_fixed_link (pdev->dev.of_node)) +of_phy_deregister_fixed_link (pdev->dev.of_node);of_node_put (priv->phy_node);free_netdev (ndev); }
Signature · 1 line
2.53.0
Quoted 7 lines · David Yang
On Hi3716cv200
hix5hd2_gmacis 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.Add support for fixed-link. A fixed link has no PHY address, yet
of_mdiobus_register()walks all 32 addresses and prints a warning line for every address.
What warning does it give?
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c static int hix5hd2_dev_probe(struct platform_device *pdev) · line 1197
Quoted 11 lines
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +6
-1@@ -1189,7 +1189,12 @@ 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); +if (of_phy_is_fixed_link (node)) { + bus->phy_mask = ~0 ; + ret =mdiobus_register (bus); + }else { + ret =of_mdiobus_register (bus, node); + }
This seems wrong. The MDIO bus has nothing to do with a fixed link. There is nothing to stop you having devices on the bus, e.g. an Ethernet switch, while the MAC uses a fixed link.
Andrew
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
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:1192-1197), the fixed-…
- [Low] After this patch, hix5hd2_dev_probe() accepts a node that has 'fixed-link' and no 'phy-handle'…
--
net: hix5hd2_gmac: support fixed-link
This commit adds fixed-link support to hix5hd2_gmac for Hi3716cv200, where the MAC is wired directly to another MAC with no PHY. When fixed-link is present, the MDIO bus is registered with mdiobus_register() and all addresses masked, and the fixed-link PHY is registered in place of the phy-handle lookup.
Quoted 5 lines
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +0
-0
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c static int hix5hd2_dev_probe(struct platform_device *pdev) · line 1197
Quoted 10 lines
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +6
-1@@ -1189,7 +1189,12 @@ 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); +if (of_phy_is_fixed_link (node)) { + bus->phy_mask = ~0 ; + ret =mdiobus_register (bus); + }else { + ret =of_mdiobus_register (bus, node); + }
[Severity: Medium]
Does the commit message match what this hunk does? The message says:
Suppress the warning by masking out all PHY address.
__of_mdiobus_register() in drivers/net/mdio/of_mdio.c already masks every address before it registers the bus:
/* Mask out all PHYs from auto probing. Instead the PHYs listed in
* the device tree are populated after the bus has been registered */
mdio->phy_mask = ~0;So setting bus->phy_mask = ~0 is not what stops the 32 lines of output.
The output seems to come from the fixed-link child node. It has no reg property, so __of_mdiobus_parse_phys() sets scanphys. It also has no compatible property, so of_mdiobus_child_is_phy() treats it as a PHY:
if (!of_property_present(child, "compatible"))
return true;
The auto-scan loop in __of_mdiobus_register() then prints this for every address:
dev_info(&mdio->dev, "scan phy %pOFn at address %i\n",
child, addr);What actually removes the output is skipping OF registration altogether.
That has a side effect when fixed-link is present. The bus gets no fwnode, so DT children of the MAC node are never populated and of_mdio_find_bus() cannot find this bus.
The hisilicon,hisi-gmac-v1.yaml binding includes mdio.yaml, which describes the MAC node as an MDIO bus with optional children. Take a switch whose CPU port is on a fixed link and which is managed over this GMAC's MDIO lines. Can that setup still be described, or is the registered mii_bus left with nothing able to use it?
Fixed-link nodes failed probe before this patch, so this is not a regression of existing behaviour. Could the commit message at least state this limitation and describe the mechanism accurately?
Quoted 15 lines
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +3
-5if (ret) goto err_free_mdio;@@ -1199,11 +1204,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 )
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c static int hix5hd2_dev_probe(struct platform_device *pdev) · line 1219
Quoted 10 lines
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +9
-0+ goto err_mdiobus; + priv->phy_node =of_node_get (node); + }else { + 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; + } }
[Severity: Low]
Does the DT binding need updating along with this? hix5hd2_dev_probe() now accepts a node with fixed-link and no phy-handle. However, Documentation/devicetree/bindings/net/hisilicon,hisi-gmac-v1.yaml still requires phy-handle unconditionally:
required:
- compatible
- reg
- interrupts
- clocks
- clock-names
- phy-mode
- phy-handle
The fixed-link property itself passes through the ethernet-controller.yaml $ref. The required phy-handle rule does not, so a Hi3716cv200 DTS that uses fixed-link alone would fail dtbs_check.
Would a oneOf or if/then that accepts fixed-link instead of phy-handle fit here?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120031026.1371052-1-mmyangfl%40gmail.com