devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode
@ 2022-04-05  9:19 Andy Chiu
  2022-04-05  9:19 ` [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally Andy Chiu
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Andy Chiu @ 2022-04-05  9:19 UTC (permalink / raw)
  To: davem, michal.simek, radhey.shyam.pandey
  Cc: andrew, kuba, pabeni, robh+dt, krzk+dt, linux, netdev, devicetree,
	Andy Chiu

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.

--- patch v5 ---
 - Re-apply the v4 patch on the net tree.
 - Describe the pcs-handle DT binding at ethernet-controller level.
--- patch v6 ---
 - Remove "preferrably" to clearify usage of pcs_handle.
--- patch v7 ---
 - Rebase the patch on latest net/master
--- patch v8 ---
 - Rebase the patch on net-next/master
 - Add "reviewed-by" tag in PATCH 3/4: dt-bindings: net: add pcs-handle
   attribute
 - Remove "fix" tag in last commit message since this is not a critical
   bug and will not be back ported to stable.

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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally
  2022-04-05  9:19 [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode Andy Chiu
@ 2022-04-05  9:19 ` Andy Chiu
  2022-04-05 12:00   ` Radhey Shyam Pandey
  2022-04-05 12:16   ` Andrew Lunn
  2022-04-05  9:19 ` [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local Andy Chiu
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: Andy Chiu @ 2022-04-05  9:19 UTC (permalink / raw)
  To: davem, michal.simek, radhey.shyam.pandey
  Cc: andrew, kuba, pabeni, robh+dt, krzk+dt, linux, netdev, devicetree,
	Andy Chiu, Greentime Hu, Robert Hancock

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.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Robert Hancock <robert.hancock@calian.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index c7eb05e4a6bf..78a991bbbcf9 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -2064,15 +2064,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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local
  2022-04-05  9:19 [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode Andy Chiu
  2022-04-05  9:19 ` [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally Andy Chiu
@ 2022-04-05  9:19 ` Andy Chiu
  2022-04-05 12:09   ` Radhey Shyam Pandey
  2022-04-05 12:17   ` Andrew Lunn
  2022-04-05  9:19 ` [PATCH v8 net-next 3/4] dt-bindings: net: add pcs-handle attribute Andy Chiu
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: Andy Chiu @ 2022-04-05  9:19 UTC (permalink / raw)
  To: davem, michal.simek, radhey.shyam.pandey
  Cc: andrew, kuba, pabeni, robh+dt, krzk+dt, linux, netdev, devicetree,
	Andy Chiu, Greentime Hu, Robert Hancock

the 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.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Robert Hancock <robert.hancock@calian.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet.h      |  2 --
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 0f9c88dd1a4a..d5c1e5c4a508 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -433,8 +433,6 @@ struct axienet_local {
 	struct net_device *ndev;
 	struct device *dev;
 
-	struct device_node *phy_node;
-
 	struct phylink *phylink;
 	struct phylink_config phylink_config;
 
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 78a991bbbcf9..3daef64a85bd 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -2071,17 +2071,19 @@ 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;
 		}
+		of_node_put(np);
 		lp->pcs.ops = &axienet_pcs_ops;
 		lp->pcs.poll = true;
 	}
@@ -2124,8 +2126,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);
@@ -2154,9 +2154,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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v8 net-next 3/4] dt-bindings: net: add pcs-handle attribute
  2022-04-05  9:19 [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode Andy Chiu
  2022-04-05  9:19 ` [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally Andy Chiu
  2022-04-05  9:19 ` [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local Andy Chiu
@ 2022-04-05  9:19 ` Andy Chiu
  2022-04-05 12:18   ` Andrew Lunn
  2022-04-05  9:19 ` [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy Andy Chiu
  2022-04-06 13:10 ` [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode patchwork-bot+netdevbpf
  4 siblings, 1 reply; 13+ messages in thread
From: Andy Chiu @ 2022-04-05  9:19 UTC (permalink / raw)
  To: davem, michal.simek, radhey.shyam.pandey
  Cc: andrew, kuba, pabeni, robh+dt, krzk+dt, linux, netdev, devicetree,
	Andy Chiu, Greentime Hu, Rob Herring

Document 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.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/net/ethernet-controller.yaml      | 6 ++++++
 Documentation/devicetree/bindings/net/xilinx_axienet.txt  | 8 +++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index 817794e56227..4f15463611f8 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -106,6 +106,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:
diff --git a/Documentation/devicetree/bindings/net/xilinx_axienet.txt b/Documentation/devicetree/bindings/net/xilinx_axienet.txt
index b8e4894bc634..1aa4c6006cd0 100644
--- a/Documentation/devicetree/bindings/net/xilinx_axienet.txt
+++ b/Documentation/devicetree/bindings/net/xilinx_axienet.txt
@@ -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 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";
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy
  2022-04-05  9:19 [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode Andy Chiu
                   ` (2 preceding siblings ...)
  2022-04-05  9:19 ` [PATCH v8 net-next 3/4] dt-bindings: net: add pcs-handle attribute Andy Chiu
@ 2022-04-05  9:19 ` Andy Chiu
  2022-04-05 12:18   ` Andrew Lunn
  2022-04-05 12:23   ` Radhey Shyam Pandey
  2022-04-06 13:10 ` [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode patchwork-bot+netdevbpf
  4 siblings, 2 replies; 13+ messages in thread
From: Andy Chiu @ 2022-04-05  9:19 UTC (permalink / raw)
  To: davem, michal.simek, radhey.shyam.pandey
  Cc: andrew, kuba, pabeni, robh+dt, krzk+dt, linux, netdev, devicetree,
	Andy Chiu, Greentime Hu, Robert Hancock

In 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.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Robert Hancock <robert.hancock@calian.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 3daef64a85bd..d6fc3f7acdf0 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -2071,9 +2071,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;
 		}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* RE: [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally
  2022-04-05  9:19 ` [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally Andy Chiu
@ 2022-04-05 12:00   ` Radhey Shyam Pandey
  2022-04-05 12:16   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Radhey Shyam Pandey @ 2022-04-05 12:00 UTC (permalink / raw)
  To: Andy Chiu, davem@davemloft.net, Michal Simek
  Cc: andrew@lunn.ch, kuba@kernel.org, pabeni@redhat.com,
	robh+dt@kernel.org, krzk+dt@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, devicetree@vger.kernel.org, Greentime Hu,
	Robert Hancock

> -----Original Message-----
> From: Andy Chiu <andy.chiu@sifive.com>
> Sent: Tuesday, April 5, 2022 2:49 PM
> To: davem@davemloft.net; Michal Simek <michals@xilinx.com>; Radhey
> Shyam Pandey <radheys@xilinx.com>
> Cc: andrew@lunn.ch; kuba@kernel.org; pabeni@redhat.com;
> robh+dt@kernel.org; krzk+dt@kernel.org; linux@armlinux.org.uk;
> netdev@vger.kernel.org; devicetree@vger.kernel.org; Andy Chiu
> <andy.chiu@sifive.com>; Greentime Hu <greentime.hu@sifive.com>; Robert
> Hancock <robert.hancock@calian.com>
> Subject: [PATCH v8 net-next 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
:s/pressents/present

> 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.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Robert Hancock <robert.hancock@calian.com>

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
> ---
>  drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index c7eb05e4a6bf..78a991bbbcf9 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -2064,15 +2064,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;
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local
  2022-04-05  9:19 ` [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local Andy Chiu
@ 2022-04-05 12:09   ` Radhey Shyam Pandey
  2022-04-05 12:17   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Radhey Shyam Pandey @ 2022-04-05 12:09 UTC (permalink / raw)
  To: Andy Chiu, davem@davemloft.net, Michal Simek
  Cc: andrew@lunn.ch, kuba@kernel.org, pabeni@redhat.com,
	robh+dt@kernel.org, krzk+dt@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, devicetree@vger.kernel.org, Greentime Hu,
	Robert Hancock

> -----Original Message-----
> From: Andy Chiu <andy.chiu@sifive.com>
> Sent: Tuesday, April 5, 2022 2:49 PM
> To: davem@davemloft.net; Michal Simek <michals@xilinx.com>; Radhey
> Shyam Pandey <radheys@xilinx.com>
> Cc: andrew@lunn.ch; kuba@kernel.org; pabeni@redhat.com;
> robh+dt@kernel.org; krzk+dt@kernel.org; linux@armlinux.org.uk;
> netdev@vger.kernel.org; devicetree@vger.kernel.org; Andy Chiu
> <andy.chiu@sifive.com>; Greentime Hu <greentime.hu@sifive.com>; Robert
> Hancock <robert.hancock@calian.com>
> Subject: [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct
> axienet_local
> 
> the 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.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Robert Hancock <robert.hancock@calian.com>

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>

> ---
>  drivers/net/ethernet/xilinx/xilinx_axienet.h      |  2 --
>  drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +++++--------
>  2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h
> b/drivers/net/ethernet/xilinx/xilinx_axienet.h
> index 0f9c88dd1a4a..d5c1e5c4a508 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
> @@ -433,8 +433,6 @@ struct axienet_local {
>  	struct net_device *ndev;
>  	struct device *dev;
> 
> -	struct device_node *phy_node;
> -
>  	struct phylink *phylink;
>  	struct phylink_config phylink_config;
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 78a991bbbcf9..3daef64a85bd 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -2071,17 +2071,19 @@ 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;
>  		}
> +		of_node_put(np);
>  		lp->pcs.ops = &axienet_pcs_ops;
>  		lp->pcs.poll = true;
>  	}
> @@ -2124,8 +2126,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);
> @@ -2154,9 +2154,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;
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally
  2022-04-05  9:19 ` [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally Andy Chiu
  2022-04-05 12:00   ` Radhey Shyam Pandey
@ 2022-04-05 12:16   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2022-04-05 12:16 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, michal.simek, radhey.shyam.pandey, kuba, pabeni, robh+dt,
	krzk+dt, linux, netdev, devicetree, Greentime Hu, Robert Hancock

On Tue, Apr 05, 2022 at 05:19:26PM +0800, Andy Chiu wrote:
> 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.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Robert Hancock <robert.hancock@calian.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local
  2022-04-05  9:19 ` [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local Andy Chiu
  2022-04-05 12:09   ` Radhey Shyam Pandey
@ 2022-04-05 12:17   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2022-04-05 12:17 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, michal.simek, radhey.shyam.pandey, kuba, pabeni, robh+dt,
	krzk+dt, linux, netdev, devicetree, Greentime Hu, Robert Hancock

On Tue, Apr 05, 2022 at 05:19:27PM +0800, Andy Chiu wrote:
> the 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.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Robert Hancock <robert.hancock@calian.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v8 net-next 3/4] dt-bindings: net: add pcs-handle attribute
  2022-04-05  9:19 ` [PATCH v8 net-next 3/4] dt-bindings: net: add pcs-handle attribute Andy Chiu
@ 2022-04-05 12:18   ` Andrew Lunn
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2022-04-05 12:18 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, michal.simek, radhey.shyam.pandey, kuba, pabeni, robh+dt,
	krzk+dt, linux, netdev, devicetree, Greentime Hu, Rob Herring

On Tue, Apr 05, 2022 at 05:19:28PM +0800, Andy Chiu wrote:
> Document 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.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Rob Herring <robh@kernel.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy
  2022-04-05  9:19 ` [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy Andy Chiu
@ 2022-04-05 12:18   ` Andrew Lunn
  2022-04-05 12:23   ` Radhey Shyam Pandey
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2022-04-05 12:18 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, michal.simek, radhey.shyam.pandey, kuba, pabeni, robh+dt,
	krzk+dt, linux, netdev, devicetree, Greentime Hu, Robert Hancock

On Tue, Apr 05, 2022 at 05:19:29PM +0800, Andy Chiu wrote:
> In 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.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Robert Hancock <robert.hancock@calian.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy
  2022-04-05  9:19 ` [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy Andy Chiu
  2022-04-05 12:18   ` Andrew Lunn
@ 2022-04-05 12:23   ` Radhey Shyam Pandey
  1 sibling, 0 replies; 13+ messages in thread
From: Radhey Shyam Pandey @ 2022-04-05 12:23 UTC (permalink / raw)
  To: Andy Chiu, davem@davemloft.net, Michal Simek
  Cc: andrew@lunn.ch, kuba@kernel.org, pabeni@redhat.com,
	robh+dt@kernel.org, krzk+dt@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, devicetree@vger.kernel.org, Greentime Hu,
	Robert Hancock

> -----Original Message-----
> From: Andy Chiu <andy.chiu@sifive.com>
> Sent: Tuesday, April 5, 2022 2:49 PM
> To: davem@davemloft.net; Michal Simek <michals@xilinx.com>; Radhey
> Shyam Pandey <radheys@xilinx.com>
> Cc: andrew@lunn.ch; kuba@kernel.org; pabeni@redhat.com;
> robh+dt@kernel.org; krzk+dt@kernel.org; linux@armlinux.org.uk;
> netdev@vger.kernel.org; devicetree@vger.kernel.org; Andy Chiu
> <andy.chiu@sifive.com>; Greentime Hu <greentime.hu@sifive.com>; Robert
> Hancock <robert.hancock@calian.com>
> Subject: [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference
> pcs_phy
> 
> In 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

Internal

> module, if exist, via phylink.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Robert Hancock <robert.hancock@calian.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>

> ---
>  drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 3daef64a85bd..d6fc3f7acdf0 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -2071,9 +2071,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;
>  		}
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode
  2022-04-05  9:19 [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode Andy Chiu
                   ` (3 preceding siblings ...)
  2022-04-05  9:19 ` [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy Andy Chiu
@ 2022-04-06 13:10 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-06 13:10 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, michal.simek, radhey.shyam.pandey, andrew, kuba, pabeni,
	robh+dt, krzk+dt, linux, netdev, devicetree

Hello:

This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue,  5 Apr 2022 17:19:25 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [v8,net-next,1/4] net: axienet: setup mdio unconditionally
    https://git.kernel.org/netdev/net/c/d1c4f93e3f0a
  - [v8,net-next,2/4] net: axienet: factor out phy_node in struct axienet_local
    https://git.kernel.org/netdev/net/c/ab3a5d4c6081
  - [v8,net-next,3/4] dt-bindings: net: add pcs-handle attribute
    https://git.kernel.org/netdev/net/c/dc48f04fd656
  - [v8,net-next,4/4] net: axiemac: use a phandle to reference pcs_phy
    https://git.kernel.org/netdev/net/c/19c7a43912c6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-04-06 15:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-05  9:19 [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode Andy Chiu
2022-04-05  9:19 ` [PATCH v8 net-next 1/4] net: axienet: setup mdio unconditionally Andy Chiu
2022-04-05 12:00   ` Radhey Shyam Pandey
2022-04-05 12:16   ` Andrew Lunn
2022-04-05  9:19 ` [PATCH v8 net-next 2/4] net: axienet: factor out phy_node in struct axienet_local Andy Chiu
2022-04-05 12:09   ` Radhey Shyam Pandey
2022-04-05 12:17   ` Andrew Lunn
2022-04-05  9:19 ` [PATCH v8 net-next 3/4] dt-bindings: net: add pcs-handle attribute Andy Chiu
2022-04-05 12:18   ` Andrew Lunn
2022-04-05  9:19 ` [PATCH v8 net-next 4/4] net: axiemac: use a phandle to reference pcs_phy Andy Chiu
2022-04-05 12:18   ` Andrew Lunn
2022-04-05 12:23   ` Radhey Shyam Pandey
2022-04-06 13:10 ` [PATCH v8 net-next 0/4] Fix broken link on Xilinx's AXI Ethernet in SGMII mode patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).