* [PATCH net-next 0/2] net: ethernet: ti: am65-cpsw: Fix MAC address fetching
@ 2025-04-11 12:09 Michael Walle
2025-04-11 12:09 ` [PATCH net-next 1/2] net: ethernet: ti: am65-cpsw: set fwnode for ports Michael Walle
2025-04-11 12:09 ` [PATCH net-next 2/2] net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER Michael Walle
0 siblings, 2 replies; 4+ messages in thread
From: Michael Walle @ 2025-04-11 12:09 UTC (permalink / raw)
To: Saravana Kannan, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Michael Walle
MAC addresses can be fetched from a NVMEM device. of_get_mac_address()
will return EPROBE_DEFER if that device is not available yet. That
isn't handled correctly by the driver and it will always fall back
to either a random MAC address or it's own "fetch by fuse" method.
Also, if the ethernet (sub)node has a link to the nvmem device,
it will fail to create a device link as the fwnode parameter isn't
populated. That's fixed in the first patch.
Michael Walle (2):
net: ethernet: ti: am65-cpsw: set fwnode for ports
net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 27 +++++++++++++-----------
1 file changed, 15 insertions(+), 12 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 1/2] net: ethernet: ti: am65-cpsw: set fwnode for ports
2025-04-11 12:09 [PATCH net-next 0/2] net: ethernet: ti: am65-cpsw: Fix MAC address fetching Michael Walle
@ 2025-04-11 12:09 ` Michael Walle
2025-04-11 20:17 ` Saravana Kannan
2025-04-11 12:09 ` [PATCH net-next 2/2] net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER Michael Walle
1 sibling, 1 reply; 4+ messages in thread
From: Michael Walle @ 2025-04-11 12:09 UTC (permalink / raw)
To: Saravana Kannan, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Michael Walle
fwnode needs to be set for a device for fw_devlink to be able to
track/enforce its dependencies correctly. Without this, you'll see error
messages like this when the supplier has probed and tries to make sure
all its fwnode consumers are linked to it using device links:
am65-cpsw-nuss 8000000.ethernet: Failed to create device link (0x180) with supplier ..
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index c9fd34787c99..af7d0f761597 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2749,7 +2749,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
mutex_init(&ndev_priv->mm_lock);
port->qos.link_speed = SPEED_UNKNOWN;
SET_NETDEV_DEV(port->ndev, dev);
- port->ndev->dev.of_node = port->slave.port_np;
+ device_set_node(&port->ndev->dev,
+ of_fwnode_handle(of_node_get(port->slave.port_np)));
eth_hw_addr_set(port->ndev, port->slave.mac_addr);
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER
2025-04-11 12:09 [PATCH net-next 0/2] net: ethernet: ti: am65-cpsw: Fix MAC address fetching Michael Walle
2025-04-11 12:09 ` [PATCH net-next 1/2] net: ethernet: ti: am65-cpsw: set fwnode for ports Michael Walle
@ 2025-04-11 12:09 ` Michael Walle
1 sibling, 0 replies; 4+ messages in thread
From: Michael Walle @ 2025-04-11 12:09 UTC (permalink / raw)
To: Saravana Kannan, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Michael Walle
of_get_mac_address() might fetch the MAC address from NVMEM and that
driver might not have been loaded. In that case, -EPROBE_DEFER is
returned. Right now, this will trigger an immediate fallback to
am65_cpsw_am654_get_efuse_macid() possibly resulting in a random MAC
address although the MAC address is stored in the referenced NVMEM.
Fix it by handling the -EPROBE_DEFER return code correctly. This also
means that the creation of the MDIO device has to be moved to a later
stage as -EPROBE_DEFER must not be returned after child devices are
created.
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index af7d0f761597..0bf877e180bd 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2679,7 +2679,9 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
goto of_node_put;
ret = of_get_mac_address(port_np, port->slave.mac_addr);
- if (ret) {
+ if (ret == -EPROBE_DEFER) {
+ goto of_node_put;
+ } else if (ret) {
am65_cpsw_am654_get_efuse_macid(port_np,
port->port_id,
port->slave.mac_addr);
@@ -3551,6 +3553,16 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
return ret;
}
+ am65_cpsw_nuss_get_ver(common);
+
+ ret = am65_cpsw_nuss_init_host_p(common);
+ if (ret)
+ goto err_pm_clear;
+
+ ret = am65_cpsw_nuss_init_slave_ports(common);
+ if (ret)
+ goto err_pm_clear;
+
node = of_get_child_by_name(dev->of_node, "mdio");
if (!node) {
dev_warn(dev, "MDIO node not found\n");
@@ -3567,16 +3579,6 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
}
of_node_put(node);
- am65_cpsw_nuss_get_ver(common);
-
- ret = am65_cpsw_nuss_init_host_p(common);
- if (ret)
- goto err_of_clear;
-
- ret = am65_cpsw_nuss_init_slave_ports(common);
- if (ret)
- goto err_of_clear;
-
/* init common data */
ale_params.dev = dev;
ale_params.ale_ageout = AM65_CPSW_ALE_AGEOUT_DEFAULT;
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/2] net: ethernet: ti: am65-cpsw: set fwnode for ports
2025-04-11 12:09 ` [PATCH net-next 1/2] net: ethernet: ti: am65-cpsw: set fwnode for ports Michael Walle
@ 2025-04-11 20:17 ` Saravana Kannan
0 siblings, 0 replies; 4+ messages in thread
From: Saravana Kannan @ 2025-04-11 20:17 UTC (permalink / raw)
To: Michael Walle
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, linux-kernel
On Fri, Apr 11, 2025 at 5:09 AM Michael Walle <mwalle@kernel.org> wrote:
>
> fwnode needs to be set for a device for fw_devlink to be able to
> track/enforce its dependencies correctly. Without this, you'll see error
> messages like this when the supplier has probed and tries to make sure
> all its fwnode consumers are linked to it using device links:
>
> am65-cpsw-nuss 8000000.ethernet: Failed to create device link (0x180) with supplier ..
>
> Signed-off-by: Michael Walle <mwalle@kernel.org>
> ---
> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index c9fd34787c99..af7d0f761597 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2749,7 +2749,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
> mutex_init(&ndev_priv->mm_lock);
> port->qos.link_speed = SPEED_UNKNOWN;
> SET_NETDEV_DEV(port->ndev, dev);
> - port->ndev->dev.of_node = port->slave.port_np;
> + device_set_node(&port->ndev->dev,
> + of_fwnode_handle(of_node_get(port->slave.port_np)));
Why are you doing of_node_get()? If that's a bug fix, can you do that
as a separate patch?
After you address that:
Reviewed-by: Saravana Kannan <saravanak@google.com>
-Saravana
>
> eth_hw_addr_set(port->ndev, port->slave.mac_addr);
>
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-11 20:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11 12:09 [PATCH net-next 0/2] net: ethernet: ti: am65-cpsw: Fix MAC address fetching Michael Walle
2025-04-11 12:09 ` [PATCH net-next 1/2] net: ethernet: ti: am65-cpsw: set fwnode for ports Michael Walle
2025-04-11 20:17 ` Saravana Kannan
2025-04-11 12:09 ` [PATCH net-next 2/2] net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER Michael Walle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®