Commit 0680e20a authored by Siddharth Vadapalli's avatar Siddharth Vadapalli Committed by Jakub Kicinski

net: ethernet: ti: am65-cpsw: Fix devlink port register sequence

Renaming interfaces using udevd depends on the interface being registered
before its netdev is registered. Otherwise, udevd reads an empty
phys_port_name value, resulting in the interface not being renamed.

Fix this by registering the interface before registering its netdev
by invoking am65_cpsw_nuss_register_devlink() before invoking
register_netdev() for the interface.

Move the function call to devlink_port_type_eth_set(), invoking it after
register_netdev() is invoked, to ensure that netlink notification for the
port state change is generated after the netdev is completely initialized.

Fixes: 58356eb3 ("net: ti: am65-cpsw-nuss: Add devlink support")
Signed-off-by: default avatarSiddharth Vadapalli <s-vadapalli@ti.com>
Link: https://lore.kernel.org/r/20220706070208.12207-1-s-vadapalli@ti.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 029c1c20
...@@ -2467,7 +2467,6 @@ static int am65_cpsw_nuss_register_devlink(struct am65_cpsw_common *common) ...@@ -2467,7 +2467,6 @@ static int am65_cpsw_nuss_register_devlink(struct am65_cpsw_common *common)
port->port_id, ret); port->port_id, ret);
goto dl_port_unreg; goto dl_port_unreg;
} }
devlink_port_type_eth_set(dl_port, port->ndev);
} }
devlink_register(common->devlink); devlink_register(common->devlink);
return ret; return ret;
...@@ -2511,6 +2510,7 @@ static void am65_cpsw_unregister_devlink(struct am65_cpsw_common *common) ...@@ -2511,6 +2510,7 @@ static void am65_cpsw_unregister_devlink(struct am65_cpsw_common *common)
static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
{ {
struct device *dev = common->dev; struct device *dev = common->dev;
struct devlink_port *dl_port;
struct am65_cpsw_port *port; struct am65_cpsw_port *port;
int ret = 0, i; int ret = 0, i;
...@@ -2527,6 +2527,10 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) ...@@ -2527,6 +2527,10 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
return ret; return ret;
} }
ret = am65_cpsw_nuss_register_devlink(common);
if (ret)
return ret;
for (i = 0; i < common->port_num; i++) { for (i = 0; i < common->port_num; i++) {
port = &common->ports[i]; port = &common->ports[i];
...@@ -2539,25 +2543,24 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) ...@@ -2539,25 +2543,24 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
i, ret); i, ret);
goto err_cleanup_ndev; goto err_cleanup_ndev;
} }
dl_port = &port->devlink_port;
devlink_port_type_eth_set(dl_port, port->ndev);
} }
ret = am65_cpsw_register_notifiers(common); ret = am65_cpsw_register_notifiers(common);
if (ret) if (ret)
goto err_cleanup_ndev; goto err_cleanup_ndev;
ret = am65_cpsw_nuss_register_devlink(common);
if (ret)
goto clean_unregister_notifiers;
/* can't auto unregister ndev using devm_add_action() due to /* can't auto unregister ndev using devm_add_action() due to
* devres release sequence in DD core for DMA * devres release sequence in DD core for DMA
*/ */
return 0; return 0;
clean_unregister_notifiers:
am65_cpsw_unregister_notifiers(common);
err_cleanup_ndev: err_cleanup_ndev:
am65_cpsw_nuss_cleanup_ndev(common); am65_cpsw_nuss_cleanup_ndev(common);
am65_cpsw_unregister_devlink(common);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment