diff mbox series

[RFC,2/2] net: dsa: probe master device

Message ID 20210223161906.9177-3-michael@walle.cc
State Superseded
Delegated to: Priyanka Jain
Headers show
Series net: dsa: various fixes | expand

Commit Message

Michael Walle Feb. 23, 2021, 4:19 p.m. UTC
DSA needs to have the master device probed first for MAC inheritance.
Until now, it only works by chance because the only user (LS1028A SoC)
will probe the master device first. The probe order is given by the PCI
device ordering, thus it works because the master device has a "smaller"
BDF then the switch device.

Explicitly probe the master device in dsa_port_probe().

Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
Signed-off-by: Michael Walle <michael@walle.cc>
---
 net/dsa-uclass.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Vladimir Oltean Feb. 23, 2021, 4:34 p.m. UTC | #1
On Tue, Feb 23, 2021 at 05:19:06PM +0100, Michael Walle wrote:
> DSA needs to have the master device probed first for MAC inheritance.
> Until now, it only works by chance because the only user (LS1028A SoC)
> will probe the master device first. The probe order is given by the PCI
> device ordering, thus it works because the master device has a "smaller"
> BDF then the switch device.
> 
> Explicitly probe the master device in dsa_port_probe().
> 
> Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

By the way we had this in the old driver that marinated too much and
never got merged, I am not sure why we removed it during the second
submission process:

https://github.com/openil/u-boot/commit/2544ed8051d3dce55b12e13b6c2b476733d19c05
Michael Walle Feb. 23, 2021, 7:56 p.m. UTC | #2
Am 2021-02-23 17:19, schrieb Michael Walle:
> DSA needs to have the master device probed first for MAC inheritance.
> Until now, it only works by chance because the only user (LS1028A SoC)
> will probe the master device first. The probe order is given by the PCI
> device ordering, thus it works because the master device has a 
> "smaller"
> BDF then the switch device.
> 
> Explicitly probe the master device in dsa_port_probe().
> 
> Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>  net/dsa-uclass.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index 88a8ea9352..242e2be035 100644
> --- a/net/dsa-uclass.c
> +++ b/net/dsa-uclass.c
> @@ -284,6 +284,14 @@ static int dsa_port_probe(struct udevice *pdev)
>  	if (!master)
>  		return -ENODEV;
> 
> +	/*
> +	 * Probe the master device. We depend on the master device for proper
> +	 * operation and we also need it for MAC inheritance below.
> +	 */
> +	ret = device_probe(master);

btw, there is a "int ret" missing above. Will be fixed in the non-RFC
version.

> +	if (ret)
> +		return ret;
> +
>  	/*
>  	 * Inherit port's hwaddr from the DSA master, unless the port already
>  	 * has a unique MAC address specified in the environment.
diff mbox series

Patch

diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
index 88a8ea9352..242e2be035 100644
--- a/net/dsa-uclass.c
+++ b/net/dsa-uclass.c
@@ -284,6 +284,14 @@  static int dsa_port_probe(struct udevice *pdev)
 	if (!master)
 		return -ENODEV;
 
+	/*
+	 * Probe the master device. We depend on the master device for proper
+	 * operation and we also need it for MAC inheritance below.
+	 */
+	ret = device_probe(master);
+	if (ret)
+		return ret;
+
 	/*
 	 * Inherit port's hwaddr from the DSA master, unless the port already
 	 * has a unique MAC address specified in the environment.