Fix broken link on Xilinx's AXI Ethernet in SGMII mode
Subsystems (5)
v5 cover Fix broken link on Xilinx's AXI Ethernet in SGMII mode
The Ethernet driver use phy-handle to reference the PCS/PMA PHY. This could be a problem if one wants to configure an external PHY via phylink, since it use the same phandle to get the PHY. To fix this, introduce a dedicated pcs-handle to point to the PCS/PMA PHY and deprecate the use of pointing it with phy-handle. A similar use case of pcs-handle can be seen on dpaa2 as well.
The v4 patch was wrongly based on net-next tree. 1,2,4 parts of v5 patch was generated after re-applying the v4 patch then resolving conflicts on the net tree. 3/5 also describes the pcs-handle more globally at the ethernet-controller device tree binding document.
Andy Chiu (4):
net: axienet: setup mdio unconditionally
net: axienet: factor out phy_node in struct axienet_local
dt-bindings: net: add pcs-handle attribute
net: axiemac: use a phandle to reference pcs_phy
.../bindings/net/ethernet-controller.yaml | 6 ++++ .../bindings/net/xilinx_axienet.txt | 8 ++++- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 -- .../net/ethernet/xilinx/xilinx_axienet_main.c | 33 ++++++++++--------- 4 files changed, 31 insertions(+), 18 deletions(-)
Signature · 1 line
2.34.1
PATCH v5 1/4 net: axienet: setup mdio unconditionally
The call to axienet_mdio_setup should not depend on whether "phy-node" pressents on the DT. Besides, since lp->phy_node is used if PHY is in SGMII or 100Base-X modes, move it into the if statement. And the next patch will remove lp->phy_node from driver's private structure and do an of_node_put on it right away after use since it is not used elsewhere.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6 -7
@@ -2060,15 +2060,14 @@ static int axienet_probe(struct platform_device *pdev)if (ret) goto cleanup_clk; - lp->phy_node =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); -if (lp->phy_node) { - ret =axienet_mdio_setup (lp); -if (ret) -dev_warn (&pdev->dev, -"error registering MDIO bus: %d\n" , ret); - } + ret =axienet_mdio_setup (lp); +if (ret) +dev_warn (&pdev->dev, +"error registering MDIO bus: %d\n" , ret); +if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { + lp->phy_node =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 );if (!lp->phy_node) {dev_err (&pdev->dev,"phy-handle required for 1000BaseX/SGMII\n" ); ret = -EINVAL ;
Signature · 1 line
2.34.1
PATCH v5 2/4 net: axienet: factor out phy_node in struct axienet_local
In reply to Andy Chiuthe struct member phy_node of struct axienet_local is not used by the driver anymore after initialization. It might be a remnent of old code and could be removed.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 -- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +++++-------- 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +0 -2
@@ -428,8 +428,6 @@ struct axienet_local {struct net_device *ndev;struct device *dev; -struct device_node *phy_node; -struct phylink *phylink;struct phylink_config phylink_config;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5 -8
@@ -2067,18 +2067,20 @@ static int axienet_probe(struct platform_device *pdev)if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { - lp->phy_node =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); -if (!lp->phy_node) { + np =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); +if (!np) {dev_err (&pdev->dev,"phy-handle required for 1000BaseX/SGMII\n" ); ret = -EINVAL ; goto cleanup_mdio; } - lp->pcs_phy =of_mdio_find_device (lp->phy_node); + lp->pcs_phy =of_mdio_find_device (np);if (!lp->pcs_phy) { ret = -EPROBE_DEFER ; +of_node_put (np); goto cleanup_mdio; } lp->phylink_config.pcs_poll = true; +of_node_put (np); } lp->phylink_config.dev = &ndev->dev;
@@ -2120,8 +2122,6 @@ static int axienet_probe(struct platform_device *pdev)put_device (&lp->pcs_phy->dev);if (lp->mii_bus)axienet_mdio_teardown (lp); -of_node_put (lp->phy_node); - cleanup_clk:clk_bulk_disable_unprepare (XAE_NUM_MISC_CLOCKS , lp->misc_clks);clk_disable_unprepare (lp->axi_clk);
@@ -2150,9 +2150,6 @@ static int axienet_remove(struct platform_device *pdev)clk_bulk_disable_unprepare (XAE_NUM_MISC_CLOCKS , lp->misc_clks);clk_disable_unprepare (lp->axi_clk); -of_node_put (lp->phy_node); - lp->phy_node =NULL ; -free_netdev (ndev);return 0 ;
Signature · 1 line
2.34.1
PATCH v5 3/4 dt-bindings: net: add pcs-handle attribute
In reply to Andy ChiuDocument the new pcs-handle attribute to support connecting to an external PHY. For Xilinx's AXI Ethernet, this is used when the core operates in SGMII or 1000Base-X modes and links through the internal PCS/PMA PHY.
--- .../devicetree/bindings/net/ethernet-controller.yaml | 6 ++++++ Documentation/devicetree/bindings/net/xilinx_axienet.txt | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +6 -0
@@ -102,6 +102,12 @@ properties: phy-mode: $ref: "#/properties/phy-connection-type" + pcs-handle: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Specifies a reference to a node representing a PCS PHY device on a MDIO + bus to link with an external PHY (phy-handle) if exists. + phy-handle: $ref: /schemas/types.yaml#/definitions/phandle description:
Documentation/devicetree/bindings/net/xilinx_axienet.txt +7 -1
@@ -26,7 +26,8 @@ Required properties: specified, the TX/RX DMA interrupts should be on that node instead, and only the Ethernet core interrupt is optionally specified here. -- phy-handle : Should point to the external phy device. +- phy-handle : Should point to the external phy device if exists. Pointing + this to the PCS/PMA PHY is deprecated and should be avoided. See ethernet.txt file in the same directory. - xlnx,rxmem : Set to allocated memory buffer for Rx/Tx in the hardware
@@ -68,6 +69,11 @@ Optional properties: required through the core's MDIO interface (i.e. always, unless the PHY is accessed through a different bus). + - pcs-handle: Phandle to the internal PCS/PMA PHY in SGMII or 1000Base-X + modes, where "pcs-handle" should be preferably used to point + to the PCS/PMA PHY, and "phy-handle" should point to an + external PHY if exists. + Example: axi_ethernet_eth: ethernet@40c00000 { compatible = "xlnx,axi-ethernet-1.00.a";
Signature · 1 line
2.34.1
Re: [PATCH v5 net 3/4] dt-bindings: net: add pcs-handle attribute
Documentation/devicetree/bindings/net/xilinx_axienet.txt Optional properties: · line 75
Quoted 4 lines
+ - pcs-handle: Phandle to the internal PCS/PMA PHY in SGMII or 1000Base-X
Documentation/devicetree/bindings/net/xilinx_axienet.txt +3
-0+ modes, where "pcs-handle" should be preferably used to point + to the PCS/PMA PHY, and "phy-handle" should point to an + external PHY if exists.
Since this is a new property, you don't have any backwards compatibility to worry about, don't use 'preferably'. It should point to the PCS/PCA PHY and anything else is wrong for this new property.
Andrew
Re: [PATCH v5 net 3/4] dt-bindings: net: add pcs-handle attribute
Thanks for the suggestion. I have included this in the v6 patch.
Andy
Quoted 11 lines · Andrew Lunn
Documentation/devicetree/bindings/net/xilinx_axienet.txt Optional properties: · line 75
Quoted 5 lines
+ - pcs-handle: Phandle to the internal PCS/PMA PHY in SGMII or 1000Base-X
Documentation/devicetree/bindings/net/xilinx_axienet.txt +3
-0+ modes, where "pcs-handle" should be preferably used to point + to the PCS/PMA PHY, and "phy-handle" should point to an + external PHY if exists.Since this is a new property, you don't have any backwards compatibility to worry about, don't use 'preferably'. It should point to the PCS/PCA PHY and anything else is wrong for this new property.
Andrew
PATCH v5 4/4 net: axiemac: use a phandle to reference pcs_phy
In reply to Andy ChiuIn some SGMII use cases where both a fixed link external PHY and the internal PCS/PMA PHY need to be configured, we should explicitly use a phandle "pcs-phy" to get the reference to the PCS/PMA PHY. Otherwise, the driver would use "phy-handle" in the DT as the reference to both the external and the internal PCS/PMA PHY.
In other cases where the core is connected to a SFP cage, we could still point phy-handle to the intenal PCS/PMA PHY, and let the driver connect to the SFP module, if exist, via phylink.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9 -2
@@ -2067,9 +2067,16 @@ static int axienet_probe(struct platform_device *pdev)if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { - np =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); + np =of_parse_phandle (pdev->dev.of_node,"pcs-handle" ,0 );if (!np) { -dev_err (&pdev->dev,"phy-handle required for 1000BaseX/SGMII\n" ); +/* Deprecated: Always use "pcs-handle" for pcs_phy. +* Falling back to "phy-handle" here is only for +* backward compatibility with old device trees. +*/ + np =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); + } +if (!np) { +dev_err (&pdev->dev,"pcs-handle (preferred) or phy-handle required for 1000BaseX/SGMII\n" ); ret = -EINVAL ; goto cleanup_mdio; }
Signature · 1 line
2.34.1