netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next 0/2] ravb: Support describing the MDIO bus
@ 2024-03-09 15:53 Niklas Söderlund
  2024-03-09 15:53 ` [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node Niklas Söderlund
  2024-03-09 15:53 ` [net-next 2/2] ravb: Add support for an optional MDIO mode Niklas Söderlund
  0 siblings, 2 replies; 12+ messages in thread
From: Niklas Söderlund @ 2024-03-09 15:53 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree
  Cc: linux-renesas-soc, Niklas Söderlund

Hello,

This series adds support to the binding and driver of the Renesas 
Ethernet AVB to described the MDIO bus. Currently the driver uses the OF 
node of the device itself when registering the MDIO bus. This forces any 
MDIO bus properties the MDIO core should react on to be set on the 
device OF node. This is confusing and non of the MDIO bus properties are 
described in the Ethernet AVB bindings.

Patch 1/2 extends the bindings with an optional mdio child-node to the 
device that can be used to contain the MDIO bus settings. While patch 
2/2 changes the driver to use this node (if present) when registering 
the MDIO bus.

If the new optional mdio child-node is not present the driver fallback
to the old behavior and uses the device OF node like before. This change 
is fully backward compatible with existing usage of the bindings.

Niklas Söderlunn (2):
  dt-bindings: net: renesas,etheravb: Add optional MDIO bus node
  ravb: Add support for an optional MDIO mode

 .../bindings/net/renesas,etheravb.yaml          |  4 ++++
 drivers/net/ethernet/renesas/ravb_main.c        | 17 +++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

-- 
2.44.0


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

* [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node
  2024-03-09 15:53 [net-next 0/2] ravb: Support describing the MDIO bus Niklas Söderlund
@ 2024-03-09 15:53 ` Niklas Söderlund
  2024-03-09 19:22   ` Sergey Shtylyov
  2024-03-10  8:44   ` Krzysztof Kozlowski
  2024-03-09 15:53 ` [net-next 2/2] ravb: Add support for an optional MDIO mode Niklas Söderlund
  1 sibling, 2 replies; 12+ messages in thread
From: Niklas Söderlund @ 2024-03-09 15:53 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree
  Cc: linux-renesas-soc, Niklas Söderlund

The Renesas Ethernet AVB bindings do not allow the MDIO bus to be
described. This has not been needed as only a single PHY is
supported and no MDIO bus properties have been needed.

Add an optional mdio node to the binding which allows the MDIO bus to be
described and allow bus properties to be set.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 Documentation/devicetree/bindings/net/renesas,etheravb.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
index de7ba7f345a9..5345ad8e1be4 100644
--- a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
+++ b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
@@ -93,6 +93,10 @@ properties:
     description: Number of size cells on the MDIO bus.
     const: 0
 
+  mdio:
+    $ref: /schemas/net/mdio.yaml#
+    unevaluatedProperties: false
+
   renesas,no-ether-link:
     type: boolean
     description:
-- 
2.44.0


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

* [net-next 2/2] ravb: Add support for an optional MDIO mode
  2024-03-09 15:53 [net-next 0/2] ravb: Support describing the MDIO bus Niklas Söderlund
  2024-03-09 15:53 ` [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node Niklas Söderlund
@ 2024-03-09 15:53 ` Niklas Söderlund
  2024-03-09 19:28   ` Sergey Shtylyov
  2024-03-11  9:32   ` Geert Uytterhoeven
  1 sibling, 2 replies; 12+ messages in thread
From: Niklas Söderlund @ 2024-03-09 15:53 UTC (permalink / raw)
  To: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree
  Cc: linux-renesas-soc, Niklas Söderlund

The driver used the OF node of the device itself when registering the
MDIO bus. While this works it creates a problem, it forces any MDIO bus
properties to also be set on the devices OF node. This mixes the
properties of two distinctly different things and is confusing.

This change adds support for an optional mdio node to be defined as a
child to the device OF node. The child node can then be used to describe
MDIO bus properties that the MDIO core can act on when registering the
bus.

If no mdio child node is found the driver fallback to the old behavior
and register the MDIO bus using the device OF node. This change is
backward compatible with old bindings in use.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/net/ethernet/renesas/ravb_main.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index fa48ff4aba2d..b62f765ce066 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2564,6 +2564,7 @@ static int ravb_mdio_init(struct ravb_private *priv)
 {
 	struct platform_device *pdev = priv->pdev;
 	struct device *dev = &pdev->dev;
+	struct device_node *mdio_node;
 	struct phy_device *phydev;
 	struct device_node *pn;
 	int error;
@@ -2582,8 +2583,20 @@ static int ravb_mdio_init(struct ravb_private *priv)
 	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
 		 pdev->name, pdev->id);
 
-	/* Register MDIO bus */
-	error = of_mdiobus_register(priv->mii_bus, dev->of_node);
+	/* Register MDIO bus
+	 *
+	 * Look for a mdio child node, if it exist use it when registering the
+	 * MDIO bus. If no node is found fallback to old behavior and use the
+	 * device OF node. This is used to be able to describe MDIO bus
+	 * properties that are consumed when registering the MDIO bus.
+	 */
+	mdio_node = of_get_child_by_name(dev->of_node, "mdio");
+	if (mdio_node) {
+		error = of_mdiobus_register(priv->mii_bus, mdio_node);
+		of_node_put(mdio_node);
+	} else {
+		error = of_mdiobus_register(priv->mii_bus, dev->of_node);
+	}
 	if (error)
 		goto out_free_bus;
 
-- 
2.44.0


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

* Re: [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node
  2024-03-09 15:53 ` [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node Niklas Söderlund
@ 2024-03-09 19:22   ` Sergey Shtylyov
  2024-03-10  8:44   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 12+ messages in thread
From: Sergey Shtylyov @ 2024-03-09 19:22 UTC (permalink / raw)
  To: Niklas Söderlund, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Geert Uytterhoeven, Claudiu Beznea,
	Yoshihiro Shimoda, Biju Das, netdev, devicetree
  Cc: linux-renesas-soc

On 3/9/24 6:53 PM, Niklas Söderlund wrote:

> The Renesas Ethernet AVB bindings do not allow the MDIO bus to be
> described. This has not been needed as only a single PHY is
> supported and no MDIO bus properties have been needed.
> 
> Add an optional mdio node to the binding which allows the MDIO bus to be
> described and allow bus properties to be set.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey


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

* Re: [net-next 2/2] ravb: Add support for an optional MDIO mode
  2024-03-09 15:53 ` [net-next 2/2] ravb: Add support for an optional MDIO mode Niklas Söderlund
@ 2024-03-09 19:28   ` Sergey Shtylyov
  2024-03-09 20:44     ` Niklas Söderlund
  2024-03-11  9:32   ` Geert Uytterhoeven
  1 sibling, 1 reply; 12+ messages in thread
From: Sergey Shtylyov @ 2024-03-09 19:28 UTC (permalink / raw)
  To: Niklas Söderlund, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Geert Uytterhoeven, Claudiu Beznea,
	Yoshihiro Shimoda, Biju Das, netdev, devicetree
  Cc: linux-renesas-soc

On 3/9/24 6:53 PM, Niklas Söderlund wrote:

> The driver used the OF node of the device itself when registering the

   s/OF/DT/, perhaps?

> MDIO bus. While this works it creates a problem, it forces any MDIO bus

   While this works, it creates a problem: it forces any MDIO bus...

> properties to also be set on the devices OF node. This mixes the

  Again, DT node?

> properties of two distinctly different things and is confusing.
> 
> This change adds support for an optional mdio node to be defined as a
> child to the device OF node. The child node can then be used to describe
> MDIO bus properties that the MDIO core can act on when registering the
> bus.
> 
> If no mdio child node is found the driver fallback to the old behavior
> and register the MDIO bus using the device OF node. This change is
> backward compatible with old bindings in use.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

MBR, Sergey

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

* Re: [net-next 2/2] ravb: Add support for an optional MDIO mode
  2024-03-09 19:28   ` Sergey Shtylyov
@ 2024-03-09 20:44     ` Niklas Söderlund
  2024-03-11  9:24       ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Niklas Söderlund @ 2024-03-09 20:44 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree, linux-renesas-soc

Hi Sergey,

Thanks for your review.

On 2024-03-09 22:28:47 +0300, Sergey Shtylyov wrote:
> On 3/9/24 6:53 PM, Niklas Söderlund wrote:
> 
> > The driver used the OF node of the device itself when registering the
> 
>    s/OF/DT/, perhaps?

I thought we referred to it as DT node when talking about .dts{i,o} 
files and OF node when it was used inside the kernel? The infrastructure 
around its called of_get_child_by_name() and of_node_put() for example.  
And I believe OF is an abbreviation for Open Firmware (?). IIRC this is 
because ACPI might also be in the mix somewhere and DT != ACPI :-)

I'm happy to change this if I understood it wrong, if not I like to keep 
it as is.

> 
> > MDIO bus. While this works it creates a problem, it forces any MDIO bus
> 
>    While this works, it creates a problem: it forces any MDIO bus...

Thanks will fix.

> 
> > properties to also be set on the devices OF node. This mixes the
> 
>   Again, DT node?
> 
> > properties of two distinctly different things and is confusing.
> > 
> > This change adds support for an optional mdio node to be defined as a
> > child to the device OF node. The child node can then be used to describe
> > MDIO bus properties that the MDIO core can act on when registering the
> > bus.
> > 
> > If no mdio child node is found the driver fallback to the old behavior
> > and register the MDIO bus using the device OF node. This change is
> > backward compatible with old bindings in use.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> [...]
> 
> MBR, Sergey

-- 
Kind Regards,
Niklas Söderlund

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

* Re: [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node
  2024-03-09 15:53 ` [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node Niklas Söderlund
  2024-03-09 19:22   ` Sergey Shtylyov
@ 2024-03-10  8:44   ` Krzysztof Kozlowski
  2024-03-10 13:46     ` Niklas Söderlund
  1 sibling, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-10  8:44 UTC (permalink / raw)
  To: Niklas Söderlund, Sergey Shtylyov, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven,
	Claudiu Beznea, Yoshihiro Shimoda, Biju Das, netdev, devicetree
  Cc: linux-renesas-soc

On 09/03/2024 16:53, Niklas Söderlund wrote:
> The Renesas Ethernet AVB bindings do not allow the MDIO bus to be
> described. This has not been needed as only a single PHY is
> supported and no MDIO bus properties have been needed.
> 
> Add an optional mdio node to the binding which allows the MDIO bus to be
> described and allow bus properties to be set.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---

I believe this is v2. Mark your patchsets clearly (git format-patch -v2
or use b4) and provide changelog under --- or in the cover letter.


>  Documentation/devicetree/bindings/net/renesas,etheravb.yaml | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
> index de7ba7f345a9..5345ad8e1be4 100644
> --- a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
> +++ b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
> @@ -93,6 +93,10 @@ properties:
>      description: Number of size cells on the MDIO bus.
>      const: 0
>  
> +  mdio:
> +    $ref: /schemas/net/mdio.yaml#
> +    unevaluatedProperties: false
> +

Please fixup the phy pattern, so it will be obvious it is for
ethernet-phy and probably deprecate it. The phy goes to mdio bus, right?


Best regards,
Krzysztof


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

* Re: [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node
  2024-03-10  8:44   ` Krzysztof Kozlowski
@ 2024-03-10 13:46     ` Niklas Söderlund
  2024-03-12 12:07       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 12+ messages in thread
From: Niklas Söderlund @ 2024-03-10 13:46 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree, linux-renesas-soc

Hi Krzysztof,

Thanks for your comments.

On 2024-03-10 09:44:45 +0100, Krzysztof Kozlowski wrote:
> On 09/03/2024 16:53, Niklas Söderlund wrote:
> > The Renesas Ethernet AVB bindings do not allow the MDIO bus to be
> > described. This has not been needed as only a single PHY is
> > supported and no MDIO bus properties have been needed.
> > 
> > Add an optional mdio node to the binding which allows the MDIO bus to be
> > described and allow bus properties to be set.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> 
> I believe this is v2. Mark your patchsets clearly (git format-patch -v2
> or use b4) and provide changelog under --- or in the cover letter.
> 
> 
> >  Documentation/devicetree/bindings/net/renesas,etheravb.yaml | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
> > index de7ba7f345a9..5345ad8e1be4 100644
> > --- a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
> > +++ b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
> > @@ -93,6 +93,10 @@ properties:
> >      description: Number of size cells on the MDIO bus.
> >      const: 0
> >  
> > +  mdio:
> > +    $ref: /schemas/net/mdio.yaml#
> > +    unevaluatedProperties: false
> > +
> 
> Please fixup the phy pattern, so it will be obvious it is for
> ethernet-phy and probably deprecate it. The phy goes to mdio bus, right?

Yes the PHY goes on the MDIO bus and the pattern is only needed for 
backward compatibility.

The pattern was specific to ethernet-phy in the past, but Rob removed it 
in commit ac8fe40c3628 ("dt-bindings: net: renesas: Drop ethernet-phy 
node schema"). Have something changed and I should revert that as part 
of this patch?

I agree it should be listed as deprecated, would this diff work for you?

+# In older bindings there where no mdio child-node to describe the MDIO bus
+# and the PHY. To not fail older bindings accept any node with an address. New
+# users should describe the PHY inside the mdio child-node.
 patternProperties:
   "@[0-9a-f]$":
     type: object
+    deprecated: true

Depending on if Rob's patch should be reverted in whole or in part I 
could also try to revert the pattern to "^ethernet-phy@[0-9a-f]$" if you 
wish. Please let me know what looks best to you.

> 
> 
> Best regards,
> Krzysztof
> 

-- 
Kind Regards,
Niklas Söderlund

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

* Re: [net-next 2/2] ravb: Add support for an optional MDIO mode
  2024-03-09 20:44     ` Niklas Söderlund
@ 2024-03-11  9:24       ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2024-03-11  9:24 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree, linux-renesas-soc

Hi Niklas,

On Sat, Mar 9, 2024 at 9:44 PM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> On 2024-03-09 22:28:47 +0300, Sergey Shtylyov wrote:
> > On 3/9/24 6:53 PM, Niklas Söderlund wrote:
> >
> > > The driver used the OF node of the device itself when registering the
> >
> >    s/OF/DT/, perhaps?
>
> I thought we referred to it as DT node when talking about .dts{i,o}
> files and OF node when it was used inside the kernel? The infrastructure
> around its called of_get_child_by_name() and of_node_put() for example.
> And I believe OF is an abbreviation for Open Firmware (?). IIRC this is
> because ACPI might also be in the mix somewhere and DT != ACPI :-)

OF is indeed an abbreviation for Open Firmware...
Originally, the of_*() code was written to interact with device trees
provided by Open Firmware.  Later, it was extended to work with
flattened device trees (FDT) provided by something other than Open
Firmware.

> I'm happy to change this if I understood it wrong, if not I like to keep
> it as is.

... but no real Open Firmware is involved on Renesas ARM platforms,
so DT is more appropriate here.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [net-next 2/2] ravb: Add support for an optional MDIO mode
  2024-03-09 15:53 ` [net-next 2/2] ravb: Add support for an optional MDIO mode Niklas Söderlund
  2024-03-09 19:28   ` Sergey Shtylyov
@ 2024-03-11  9:32   ` Geert Uytterhoeven
  2024-03-11 11:03     ` Niklas Söderlund
  1 sibling, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2024-03-11  9:32 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree, linux-renesas-soc

Hi Niklas,

On Sat, Mar 9, 2024 at 4:55 PM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> The driver used the OF node of the device itself when registering the
> MDIO bus. While this works it creates a problem, it forces any MDIO bus
> properties to also be set on the devices OF node. This mixes the
> properties of two distinctly different things and is confusing.
>
> This change adds support for an optional mdio node to be defined as a
> child to the device OF node. The child node can then be used to describe
> MDIO bus properties that the MDIO core can act on when registering the
> bus.
>
> If no mdio child node is found the driver fallback to the old behavior
> and register the MDIO bus using the device OF node. This change is
> backward compatible with old bindings in use.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Thanks for your patch!

> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2582,8 +2583,20 @@ static int ravb_mdio_init(struct ravb_private *priv)
>         snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
>                  pdev->name, pdev->id);
>
> -       /* Register MDIO bus */
> -       error = of_mdiobus_register(priv->mii_bus, dev->of_node);
> +       /* Register MDIO bus
> +        *
> +        * Look for a mdio child node, if it exist use it when registering the
> +        * MDIO bus. If no node is found fallback to old behavior and use the
> +        * device OF node. This is used to be able to describe MDIO bus
> +        * properties that are consumed when registering the MDIO bus.
> +        */
> +       mdio_node = of_get_child_by_name(dev->of_node, "mdio");
> +       if (mdio_node) {
> +               error = of_mdiobus_register(priv->mii_bus, mdio_node);
> +               of_node_put(mdio_node);
> +       } else {
> +               error = of_mdiobus_register(priv->mii_bus, dev->of_node);
> +       }
>         if (error)
>                 goto out_free_bus;
>

Perhaps the code should be streamlined for the modern case?

        mdio_node = of_get_child_by_name(dev->of_node, "mdio");
        if (!mdio_node) {
                /* backwards compatibility for DT lacking mdio subnode */
                mdio_node = of_node_get(dev->of_node);
        }

        error = of_mdiobus_register(priv->mii_bus, mdio_node);
        of_node_put(mdio_node);

When deemed necessary, you can easily replace the backwards
compatibility handling by error handling later.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [net-next 2/2] ravb: Add support for an optional MDIO mode
  2024-03-11  9:32   ` Geert Uytterhoeven
@ 2024-03-11 11:03     ` Niklas Söderlund
  0 siblings, 0 replies; 12+ messages in thread
From: Niklas Söderlund @ 2024-03-11 11:03 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree, linux-renesas-soc

Hi Geert,

Thanks for your suggestion.

On 2024-03-11 10:32:35 +0100, Geert Uytterhoeven wrote:
> Hi Niklas,
> 
> On Sat, Mar 9, 2024 at 4:55 PM Niklas Söderlund
> <niklas.soderlund+renesas@ragnatech.se> wrote:
> > The driver used the OF node of the device itself when registering the
> > MDIO bus. While this works it creates a problem, it forces any MDIO bus
> > properties to also be set on the devices OF node. This mixes the
> > properties of two distinctly different things and is confusing.
> >
> > This change adds support for an optional mdio node to be defined as a
> > child to the device OF node. The child node can then be used to describe
> > MDIO bus properties that the MDIO core can act on when registering the
> > bus.
> >
> > If no mdio child node is found the driver fallback to the old behavior
> > and register the MDIO bus using the device OF node. This change is
> > backward compatible with old bindings in use.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> 
> Thanks for your patch!
> 
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -2582,8 +2583,20 @@ static int ravb_mdio_init(struct ravb_private *priv)
> >         snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
> >                  pdev->name, pdev->id);
> >
> > -       /* Register MDIO bus */
> > -       error = of_mdiobus_register(priv->mii_bus, dev->of_node);
> > +       /* Register MDIO bus
> > +        *
> > +        * Look for a mdio child node, if it exist use it when registering the
> > +        * MDIO bus. If no node is found fallback to old behavior and use the
> > +        * device OF node. This is used to be able to describe MDIO bus
> > +        * properties that are consumed when registering the MDIO bus.
> > +        */
> > +       mdio_node = of_get_child_by_name(dev->of_node, "mdio");
> > +       if (mdio_node) {
> > +               error = of_mdiobus_register(priv->mii_bus, mdio_node);
> > +               of_node_put(mdio_node);
> > +       } else {
> > +               error = of_mdiobus_register(priv->mii_bus, dev->of_node);
> > +       }
> >         if (error)
> >                 goto out_free_bus;
> >
> 
> Perhaps the code should be streamlined for the modern case?
> 
>         mdio_node = of_get_child_by_name(dev->of_node, "mdio");
>         if (!mdio_node) {
>                 /* backwards compatibility for DT lacking mdio subnode */
>                 mdio_node = of_node_get(dev->of_node);
>         }
> 
>         error = of_mdiobus_register(priv->mii_bus, mdio_node);
>         of_node_put(mdio_node);
> 
> When deemed necessary, you can easily replace the backwards
> compatibility handling by error handling later.

This looks much better, will do so as well as s/OF/DT/ in the commit 
message for next version.

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> -- 
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

-- 
Kind Regards,
Niklas Söderlund

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

* Re: [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node
  2024-03-10 13:46     ` Niklas Söderlund
@ 2024-03-12 12:07       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-12 12:07 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Sergey Shtylyov, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Claudiu Beznea, Yoshihiro Shimoda, Biju Das,
	netdev, devicetree, linux-renesas-soc

On 10/03/2024 14:46, Niklas Söderlund wrote:
> Hi Krzysztof,
> 
> Thanks for your comments.
> 
> On 2024-03-10 09:44:45 +0100, Krzysztof Kozlowski wrote:
>> On 09/03/2024 16:53, Niklas Söderlund wrote:
>>> The Renesas Ethernet AVB bindings do not allow the MDIO bus to be
>>> described. This has not been needed as only a single PHY is
>>> supported and no MDIO bus properties have been needed.
>>>
>>> Add an optional mdio node to the binding which allows the MDIO bus to be
>>> described and allow bus properties to be set.
>>>
>>> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>>> ---
>>
>> I believe this is v2. Mark your patchsets clearly (git format-patch -v2
>> or use b4) and provide changelog under --- or in the cover letter.
>>
>>
>>>  Documentation/devicetree/bindings/net/renesas,etheravb.yaml | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
>>> index de7ba7f345a9..5345ad8e1be4 100644
>>> --- a/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
>>> +++ b/Documentation/devicetree/bindings/net/renesas,etheravb.yaml
>>> @@ -93,6 +93,10 @@ properties:
>>>      description: Number of size cells on the MDIO bus.
>>>      const: 0
>>>  
>>> +  mdio:
>>> +    $ref: /schemas/net/mdio.yaml#
>>> +    unevaluatedProperties: false
>>> +
>>
>> Please fixup the phy pattern, so it will be obvious it is for
>> ethernet-phy and probably deprecate it. The phy goes to mdio bus, right?
> 
> Yes the PHY goes on the MDIO bus and the pattern is only needed for 
> backward compatibility.
> 
> The pattern was specific to ethernet-phy in the past, but Rob removed it 
> in commit ac8fe40c3628 ("dt-bindings: net: renesas: Drop ethernet-phy 
> node schema"). Have something changed and I should revert that as part 
> of this patch?

Ah, indeed. Let it stay as is. I thought there would be conflict with
mdio, but pattern still looks for unit address, so it's fine to have
both: existing @[0-9a-f] and mdio.

> 
> I agree it should be listed as deprecated, would this diff work for you?
> 
> +# In older bindings there where no mdio child-node to describe the MDIO bus
> +# and the PHY. To not fail older bindings accept any node with an address. New
> +# users should describe the PHY inside the mdio child-node.
>  patternProperties:
>    "@[0-9a-f]$":
>      type: object
> +    deprecated: true

Looks fine.

> 
> Depending on if Rob's patch should be reverted in whole or in part I 
> could also try to revert the pattern to "^ethernet-phy@[0-9a-f]$" if you 
> wish. Please let me know what looks best to you.
> 

Best regards,
Krzysztof


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

end of thread, other threads:[~2024-03-12 12:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-09 15:53 [net-next 0/2] ravb: Support describing the MDIO bus Niklas Söderlund
2024-03-09 15:53 ` [net-next 1/2] dt-bindings: net: renesas,etheravb: Add optional MDIO bus node Niklas Söderlund
2024-03-09 19:22   ` Sergey Shtylyov
2024-03-10  8:44   ` Krzysztof Kozlowski
2024-03-10 13:46     ` Niklas Söderlund
2024-03-12 12:07       ` Krzysztof Kozlowski
2024-03-09 15:53 ` [net-next 2/2] ravb: Add support for an optional MDIO mode Niklas Söderlund
2024-03-09 19:28   ` Sergey Shtylyov
2024-03-09 20:44     ` Niklas Söderlund
2024-03-11  9:24       ` Geert Uytterhoeven
2024-03-11  9:32   ` Geert Uytterhoeven
2024-03-11 11:03     ` Niklas Söderlund

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