net: eqos: connect and config PHY from probe stage instead of starting EQOS
PATCH 1/1 net: eqos: connect and config PHY from probe stage instead of starting EQOS
For EQOS ethernet, it will do phy_connect() and phy_config() when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.
phy_config()
-> board_phy_config()
-> phydev->drv->config() // i.MX8MP/DXL use realtek PHY
-> rtl8211f_config()
-> genphy_config_aneg()
-> genphy_restart_aneg() // restart auto-nego, then need seconds to completeTo avoid wasting time, we can move PHY connection and configuration from eqos_start() to eqos_probe(). This patch also moves clock setting from eqos_start() to eqos_probe() as MDIO access need CSR clock, there is no function change.
Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (313 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254 After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
--- drivers/net/dwc_eth_qos.c | 132 +++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 65 deletions(-)
drivers/net/dwc_eth_qos.c +67 -65
@@ -1045,20 +1045,6 @@ static int eqos_start(struct udevice *dev) eqos->tx_desc_idx =0 ; eqos->rx_desc_idx =0 ; - ret = eqos->config->ops->eqos_start_clks (dev); -if (ret <0 ) { -pr_err ("eqos_start_clks() failed: %d" , ret); - goto err; - } - - ret = eqos->config->ops->eqos_start_resets (dev); -if (ret <0 ) { -pr_err ("eqos_start_resets() failed: %d" , ret); - goto err_stop_clks; - } - -udelay (10 ); - eqos->reg_access_ok = true; ret = wait_for_bit_le32(&eqos->dma_regs->mode,
@@ -1066,68 +1052,34 @@ static int eqos_start(struct udevice *dev) eqos->config->swr_wait, false);if (ret) {pr_err ("EQOS_DMA_MODE_SWR stuck" ); - goto err_stop_resets; + goto err; } ret = eqos->config->ops->eqos_calibrate_pads (dev);if (ret <0 ) {pr_err ("eqos_calibrate_pads() failed: %d" , ret); - goto err_stop_resets; + goto err; } rate = eqos->config->ops->eqos_get_tick_clk_rate (dev); val = (rate /1000000 ) -1 ;writel (val, &eqos->mac_regs->us_tic_counter); -/* -* if PHY was already connected and configured, -* don't need to reconnect/reconfigure again -*/ -if (!eqos->phy) { -int addr =-1 ; -#ifdef CONFIG_DM_ETH_PHY - addr =eth_phy_get_addr (dev); -#endif -#ifdef DWC_NET_PHYADDR - addr =DWC_NET_PHYADDR ; -#endif - eqos->phy =phy_connect (eqos->mii, addr, dev, - eqos->config->interface (dev)); -if (!eqos->phy) { -pr_err ("phy_connect() failed" ); - goto err_stop_resets; - } - -if (eqos->max_speed) { - ret =phy_set_supported (eqos->phy, eqos->max_speed); -if (ret) { -pr_err ("phy_set_supported() failed: %d" , ret); - goto err_shutdown_phy; - } - } - - ret =phy_config (eqos->phy); -if (ret <0 ) { -pr_err ("phy_config() failed: %d" , ret); - goto err_shutdown_phy; - } - } - ret =phy_startup (eqos->phy);if (ret <0 ) {pr_err ("phy_startup() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }if (!eqos->phy->link) {pr_err ("No link" ); - goto err_shutdown_phy; + goto err; } ret =eqos_adjust_link (dev);if (ret <0 ) {pr_err ("eqos_adjust_link() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }/* Configure MTL */
@@ -1356,12 +1308,6 @@ static int eqos_start(struct udevice *dev)debug ("%s: OK\n" , __func__);return 0 ; -err_shutdown_phy: -phy_shutdown (eqos->phy); -err_stop_resets: - eqos->config->ops->eqos_stop_resets (dev); -err_stop_clks: - eqos->config->ops->eqos_stop_clks (dev); err:pr_err ("FAILED: %d" , ret);return ret;
@@ -1412,12 +1358,6 @@ static void eqos_stop(struct udevice *dev)clrbits_le32 (&eqos->dma_regs->ch0_rx_control,EQOS_DMA_CH0_RX_CONTROL_SR ); -if (eqos->phy) { -phy_shutdown (eqos->phy); - } - eqos->config->ops->eqos_stop_resets (dev); - eqos->config->ops->eqos_stop_clks (dev); -debug ("%s: OK\n" , __func__); }
@@ -1888,9 +1828,65 @@ static int eqos_probe(struct udevice *dev)eth_phy_set_mdio_bus (dev, eqos->mii);#endif + ret = eqos->config->ops->eqos_start_clks (dev); +if (ret <0 ) { +pr_err ("eqos_start_clks() failed: %d" , ret); + goto err_unregister_mdio; + } + + ret = eqos->config->ops->eqos_start_resets (dev); +if (ret <0 ) { +pr_err ("eqos_start_resets() failed: %d" , ret); + goto err_stop_clks; + } + +udelay (10 ); + +/* +* if PHY was already connected and configured, +* don't need to reconnect/reconfigure again +*/ +if (!eqos->phy) { +int addr =-1 ; +#ifdef CONFIG_DM_ETH_PHY + addr =eth_phy_get_addr (dev); +#endif +#ifdef DWC_NET_PHYADDR + addr =DWC_NET_PHYADDR ; +#endif + eqos->phy =phy_connect (eqos->mii, addr, dev, + eqos->config->interface (dev)); +if (!eqos->phy) { +pr_err ("phy_connect() failed" ); + goto err_stop_resets; + } + +if (eqos->max_speed) { + ret =phy_set_supported (eqos->phy, eqos->max_speed); +if (ret) { +pr_err ("phy_set_supported() failed: %d" , ret); + goto err_shutdown_phy; + } + } + + ret =phy_config (eqos->phy); +if (ret <0 ) { +pr_err ("phy_config() failed: %d" , ret); + goto err_shutdown_phy; + } + } +debug ("%s: OK\n" , __func__);return 0 ; +err_shutdown_phy: +phy_shutdown (eqos->phy); +err_stop_resets: + eqos->config->ops->eqos_stop_resets (dev); +err_stop_clks: + eqos->config->ops->eqos_stop_clks (dev); +err_unregister_mdio: +mdio_unregister (eqos->mii); err_free_mdio:mdio_free (eqos->mii); err_remove_resources_tegra:
@@ -1908,6 +1904,12 @@ static int eqos_remove(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev); +if (eqos->phy) { +phy_shutdown (eqos->phy); + } + eqos->config->ops->eqos_stop_resets (dev); + eqos->config->ops->eqos_stop_clks (dev); +mdio_unregister (eqos->mii);mdio_free (eqos->mii); eqos->config->ops->eqos_remove_resources (dev);
Signature · 1 line
2.17.1
Hi,
Quoted 2 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation
s/eqos_srart()/eqos_start()/
Quoted 49 lines
to complete when do tftp boot.
phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL use realtek PHY -> rtl8211f_config() -> genphy_config_aneg() -> genphy_restart_aneg() // restart auto-nego, then need seconds to completeTo avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (313 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254 After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Signed-off-by Joakim Zhang <[email protected]>--- drivers/net/dwc_eth_qos.c | 132 +++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 65 deletions(-)drivers/net/dwc_eth_qos.c +0
-5@@ -1045,20 +1045,6 @@ static int eqos_start(struct udevice *dev) eqos->tx_desc_idx =0 ; eqos->rx_desc_idx =0 ; - ret = eqos->config->ops->eqos_start_clks (dev); -if (ret <0 ) { -pr_err ("eqos_start_clks() failed: %d" , ret); - goto err; - }
drivers/net/dwc_eth_qos.c static int eqos_start(struct udevice *dev) · line 1048
Quoted 10 lines
drivers/net/dwc_eth_qos.c +0
-9- - ret = eqos->config->ops->eqos_start_resets (dev); -if (ret <0 ) { -pr_err ("eqos_start_resets() failed: %d" , ret); - goto err_stop_clks; - } - -udelay (10 ); - eqos->reg_access_ok = true;
=> as clock is moved in probe...
the line
eqos->reg_access_ok = true
should be also moved I think
or reg_access_ok can be removed, as reg_access_ok is always one when eqos_write_hwaddr is called
Quoted 115 lines
drivers/net/dwc_eth_qos.c +14
-51ret = wait_for_bit_le32(&eqos->dma_regs->mode,@@ -1066,68 +1052,34 @@ static int eqos_start(struct udevice *dev) eqos->config->swr_wait, false);if (ret) {pr_err ("EQOS_DMA_MODE_SWR stuck" ); - goto err_stop_resets; + goto err; } ret = eqos->config->ops->eqos_calibrate_pads (dev);if (ret <0 ) {pr_err ("eqos_calibrate_pads() failed: %d" , ret); - goto err_stop_resets; + goto err; } rate = eqos->config->ops->eqos_get_tick_clk_rate (dev); val = (rate /1000000 ) -1 ;writel (val, &eqos->mac_regs->us_tic_counter); -/* -* if PHY was already connected and configured, -* don't need to reconnect/reconfigure again -*/ -if (!eqos->phy) { -int addr =-1 ; -#ifdef CONFIG_DM_ETH_PHY - addr =eth_phy_get_addr (dev); -#endif -#ifdef DWC_NET_PHYADDR - addr =DWC_NET_PHYADDR ; -#endif - eqos->phy =phy_connect (eqos->mii, addr, dev, - eqos->config->interface (dev)); -if (!eqos->phy) { -pr_err ("phy_connect() failed" ); - goto err_stop_resets; - } - -if (eqos->max_speed) { - ret =phy_set_supported (eqos->phy, eqos->max_speed); -if (ret) { -pr_err ("phy_set_supported() failed: %d" , ret); - goto err_shutdown_phy; - } - } - - ret =phy_config (eqos->phy); -if (ret <0 ) { -pr_err ("phy_config() failed: %d" , ret); - goto err_shutdown_phy; - } - } - ret =phy_startup (eqos->phy);if (ret <0 ) {pr_err ("phy_startup() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }if (!eqos->phy->link) {pr_err ("No link" ); - goto err_shutdown_phy; + goto err; } ret =eqos_adjust_link (dev);if (ret <0 ) {pr_err ("eqos_adjust_link() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }/* Configure MTL */ @@ -1356,12 +1308,6 @@ static int eqos_start(struct udevice *dev)debug ("%s: OK\n" , __func__);return 0 ; -err_shutdown_phy: -phy_shutdown (eqos->phy); -err_stop_resets: - eqos->config->ops->eqos_stop_resets (dev); -err_stop_clks: - eqos->config->ops->eqos_stop_clks (dev); err:pr_err ("FAILED: %d" , ret);return ret;@@ -1412,12 +1358,6 @@ static void eqos_stop(struct udevice *dev)clrbits_le32 (&eqos->dma_regs->ch0_rx_control,EQOS_DMA_CH0_RX_CONTROL_SR ); -if (eqos->phy) { -phy_shutdown (eqos->phy); - } - eqos->config->ops->eqos_stop_resets (dev); - eqos->config->ops->eqos_stop_clks (dev); -debug ("%s: OK\n" , __func__); }@@ -1888,9 +1828,65 @@ static int eqos_probe(struct udevice *dev)eth_phy_set_mdio_bus (dev, eqos->mii);#endif + ret = eqos->config->ops->eqos_start_clks (dev); +if (ret <0 ) { +pr_err ("eqos_start_clks() failed: %d" , ret); + goto err_unregister_mdio; + } + + ret = eqos->config->ops->eqos_start_resets (dev); +if (ret <0 ) { +pr_err ("eqos_start_resets() failed: %d" , ret);
drivers/net/dwc_eth_qos.c static int eqos_probe(struct udevice *dev) · line 1849
Quoted 10 lines
drivers/net/dwc_eth_qos.c +10
-0+ goto err_stop_clks; + } + +udelay (10 ); + +/* +* if PHY was already connected and configured, +* don't need to reconnect/reconfigure again +*/ +if (!eqos->phy) {
this test can be remove I think
because we have always eqos->phy = NULL in probe,
PHY was can't be configured before probe
and it should be done again after a remove...
Quoted 46 lines
drivers/net/dwc_eth_qos.c +37
-0+int addr =-1 ; +#ifdef CONFIG_DM_ETH_PHY + addr =eth_phy_get_addr (dev); +#endif +#ifdef DWC_NET_PHYADDR + addr =DWC_NET_PHYADDR ; +#endif + eqos->phy =phy_connect (eqos->mii, addr, dev, + eqos->config->interface (dev)); +if (!eqos->phy) { +pr_err ("phy_connect() failed" ); + goto err_stop_resets; + } + +if (eqos->max_speed) { + ret =phy_set_supported (eqos->phy, eqos->max_speed); +if (ret) { +pr_err ("phy_set_supported() failed: %d" , ret); + goto err_shutdown_phy; + } + } + + ret =phy_config (eqos->phy); +if (ret <0 ) { +pr_err ("phy_config() failed: %d" , ret); + goto err_shutdown_phy; + } + } +debug ("%s: OK\n" , __func__);return 0 ; +err_shutdown_phy: +phy_shutdown (eqos->phy); +err_stop_resets: + eqos->config->ops->eqos_stop_resets (dev); +err_stop_clks: + eqos->config->ops->eqos_stop_clks (dev); +err_unregister_mdio: +mdio_unregister (eqos->mii); err_free_mdio:mdio_free (eqos->mii); err_remove_resources_tegra:@@ -1908,6 +1904,12 @@ static int eqos_remove(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev);
drivers/net/dwc_eth_qos.c static int eqos_remove(struct udevice *dev) · line 1915
Quoted 10 lines
drivers/net/dwc_eth_qos.c +6
-0+if (eqos->phy) { +phy_shutdown (eqos->phy); + } + eqos->config->ops->eqos_stop_resets (dev); + eqos->config->ops->eqos_stop_clks (dev); +mdio_unregister (eqos->mii);mdio_free (eqos->mii); eqos->config->ops->eqos_remove_resources (dev);
Regards
Patrick
Hi All
For information
Another patch from Marek will collide with this one => https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Patrice
Quoted 261 lines · Patrick DELAUNAY
Hi,
Quoted 2 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiations/eqos_srart()/eqos_start()/
Quoted 48 lines
to complete when do tftp boot.
phy_config()
->board_phy_config()
->phydev->drv->config()// i.MX8MP/DXL use realtek PHY
->rtl8211f_config()
->genphy_config_aneg()
->genphy_restart_aneg()// restart auto-nego, then need seconds to completeTo avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (313 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254 After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Signed-off-by Joakim Zhang <[email protected]>---
drivers/net/dwc_eth_qos.c| 132 +++++++++++++++++++-------------------1 file changed, 67 insertions(+), 65 deletions(-)drivers/net/dwc_eth_qos.c +0
-4@@ -1045,20 +1045,6 @@ static int eqos_start(struct udevice *dev) eqos->tx_desc_idx = 0; eqos->rx_desc_idx = 0; - ret = eqos->config->ops->eqos_start_clks(dev); - if (ret < 0) { - pr_err("eqos_start_clks() failed: %d", ret); - goto err; - }drivers/net/dwc_eth_qos.c static int eqos_start(struct udevice *dev) · line 1048
Quoted 10 lines
drivers/net/dwc_eth_qos.c +0
-9- - ret = eqos->config->ops->eqos_start_resets(dev); - if (ret < 0) { - pr_err("eqos_start_resets() failed: %d", ret); - goto err_stop_clks; - } - - udelay(10); - eqos->reg_access_ok = true;=> as clock is moved in probe...
the line
eqos->reg_access_ok= true
should be also moved I thinkor
reg_access_okcan be removed, asreg_access_okis always one wheneqos_write_hwaddris calledQuoted 104 lines
drivers/net/dwc_eth_qos.c +2
-2ret = wait_for_bit_le32(&eqos->dma_regs->mode,@@ -1066,68 +1052,34 @@ static int eqos_start(struct udevice *dev) eqos->config->swr_wait, false); if (ret) { pr_err("EQOS_DMA_MODE_SWR stuck"); - goto err_stop_resets; + goto err; } ret = eqos->config->ops->eqos_calibrate_pads(dev); if (ret < 0) { pr_err("eqos_calibrate_pads() failed: %d", ret); - goto err_stop_resets; + goto err; } rate = eqos->config->ops->eqos_get_tick_clk_rate(dev); val = (rate / 1000000) - 1; writel(val, &eqos->mac_regs->us_tic_counter);- /*
- * if PHY was already connected and configured, - * don't need to reconnect/reconfigure again - */
- if (!eqos->phy) {
- int addr = -1;drivers/net/dwc_eth_qos.c +0
-28-#ifdef CONFIG_DM_ETH_PHY - addr = eth_phy_get_addr(dev); -#endif -#ifdef DWC_NET_PHYADDR - addr = DWC_NET_PHYADDR; -#endif - eqos->phy = phy_connect(eqos->mii, addr, dev, - eqos->config->interface(dev)); - if (!eqos->phy) { - pr_err("phy_connect() failed"); - goto err_stop_resets; - } - - if (eqos->max_speed) { - ret = phy_set_supported(eqos->phy, eqos->max_speed); - if (ret) { - pr_err("phy_set_supported() failed: %d", ret); - goto err_shutdown_phy; - } - } - - ret = phy_config(eqos->phy); - if (ret < 0) { - pr_err("phy_config() failed: %d", ret); - goto err_shutdown_phy; - } - } -ret =
phy_startup(eqos->phy);
if (ret < 0) {
pr_err("phy_startup() failed: %d", ret); - gotoerr_shutdown_phy;
+ goto err;
}
if (!eqos->phy->link) {
pr_err("No link");
- gotoerr_shutdown_phy;
+ goto err;
}
ret =eqos_adjust_link(dev);
if (ret < 0) {pr_err("eqos_adjust_link() failed: %d", ret); - gotoerr_shutdown_phy;
+ goto err;
}
/* Configure MTL */drivers/net/dwc_eth_qos.c +0
-0@@ -1356,12 +1308,6 @@ static int eqos_start(struct udevice *dev) debug("%s: OK\n", __func__); return 0;-err_shutdown_phy:
-phy_shutdown(eqos->phy);drivers/net/dwc_eth_qos.c +0
-4-err_stop_resets: - eqos->config->ops->eqos_stop_resets(dev); -err_stop_clks: - eqos->config->ops->eqos_stop_clks(dev);err:
pr_err("FAILED: %d", ret);
return ret;drivers/net/dwc_eth_qos.c +0
-5@@ -1412,12 +1358,6 @@ static void eqos_stop(struct udevice *dev) clrbits_le32(&eqos->dma_regs->ch0_rx_control, EQOS_DMA_CH0_RX_CONTROL_SR); - if (eqos->phy) { - phy_shutdown(eqos->phy); - } - eqos->config->ops->eqos_stop_resets(dev); - eqos->config->ops->eqos_stop_clks(dev); - debug("%s: OK\n", __func__); } @@ -1888,9 +1828,65 @@ static int eqos_probe(struct udevice *dev)
eth_phy_set_mdio_bus(dev, eqos->mii); #endif
+ ret =eqos->config->ops->eqos_start_clks(dev); + if (ret < 0) {
+pr_err("eqos_start_clks() failed: %d", ret); + gotoerr_unregister_mdio;
+ }drivers/net/dwc_eth_qos.c +4
-0+ + ret = eqos->config->ops->eqos_start_resets(dev); + if (ret < 0) { + pr_err("eqos_start_resets() failed: %d", ret);drivers/net/dwc_eth_qos.c static int eqos_probe(struct udevice *dev) · line 1849
Quoted 10 lines
drivers/net/dwc_eth_qos.c +10
-0+ goto err_stop_clks; + } + + udelay(10); + + /* + * if PHY was already connected and configured, + * don't need to reconnect/reconfigure again + */ + if (!eqos->phy) {this test can be remove I think
because we have always
eqos->phy= NULL in probe,PHY was can't be configured before probe
and it should be done again after a remove...
Quoted 43 lines
+ int addr = -1;
drivers/net/dwc_eth_qos.c +28
-0+#ifdef CONFIG_DM_ETH_PHY + addr = eth_phy_get_addr(dev); +#endif +#ifdef DWC_NET_PHYADDR + addr = DWC_NET_PHYADDR; +#endif + eqos->phy = phy_connect(eqos->mii, addr, dev, + eqos->config->interface(dev)); + if (!eqos->phy) { + pr_err("phy_connect() failed"); + goto err_stop_resets; + } + + if (eqos->max_speed) { + ret = phy_set_supported(eqos->phy, eqos->max_speed); + if (ret) { + pr_err("phy_set_supported() failed: %d", ret); + goto err_shutdown_phy; + } + } + + ret = phy_config(eqos->phy); + if (ret < 0) { + pr_err("phy_config() failed: %d", ret); + goto err_shutdown_phy; + } + } +
debug("%s: OK\n", __func__);
return 0;
+err_shutdown_phy:
+phy_shutdown(eqos->phy);drivers/net/dwc_eth_qos.c +6
-0+err_stop_resets: + eqos->config->ops->eqos_stop_resets(dev); +err_stop_clks: + eqos->config->ops->eqos_stop_clks(dev); +err_unregister_mdio: + mdio_unregister(eqos->mii);
err_free_mdio:
mdio_free(eqos->mii);
err_remove_resources_tegra:drivers/net/dwc_eth_qos.c static int eqos_remove(struct udevice *dev) · line 1913
Quoted 10 lines
drivers/net/dwc_eth_qos.c +5
-0@@ -1908,6 +1904,12 @@ static int eqos_remove(struct udevice *dev) debug("%s(dev=%p):\n", __func__, dev); + if (eqos->phy) { + phy_shutdown(eqos->phy); + } + eqos->config->ops->eqos_stop_resets(dev); + eqos->config->ops->eqos_stop_clks(dev); + mdio_unregister(eqos->mii); mdio_free(eqos->mii); eqos->config->ops->eqos_remove_resources(dev);Regards
Patrick
Hi Patrick,
Quoted 88 lines
-----Original Message-----
From: Patrick DELAUNAY <[email protected]>
Sent: 2021年11月15日 18:42
To: Joakim Zhang <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Ye Li <[email protected]>; [email protected]; [email protected]; Christophe ROULLIER <[email protected]>; Marek Vasut <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSHi,
Quoted 3 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiations/eqos_srart()/eqos_start()/
Quoted 4 lines
to complete when do tftp boot.
phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL userealtek PHY
Quoted 3 lines
-> rtl8211f_config() -> genphy_config_aneg() ->
genphy_restart_aneg()Quoted 26 lines
// restart auto-nego, then need seconds to complete
To avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1 DHCP client bound to address 10.193.102.192 (313 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Quoted 3 lines
Signed-off-by Joakim Zhang <[email protected]>--- drivers/net/dwc_eth_qos.c | 132+++++++++++++++++++-------------------
Quoted 15 lines
1 file changed, 67 insertions(+), 65 deletions(-)drivers/net/dwc_eth_qos.c +0
-5@@ -1045,20 +1045,6 @@ static int eqos_start(struct udevice *dev) eqos->tx_desc_idx =0 ; eqos->rx_desc_idx =0 ; - ret = eqos->config->ops->eqos_start_clks (dev); -if (ret <0 ) { -pr_err ("eqos_start_clks() failed: %d" , ret); - goto err; - }drivers/net/dwc_eth_qos.c static int eqos_start(struct udevice *dev) · line 1048
Quoted 10 lines
drivers/net/dwc_eth_qos.c +0
-9- - ret = eqos->config->ops->eqos_start_resets (dev); -if (ret <0 ) { -pr_err ("eqos_start_resets() failed: %d" , ret); - goto err_stop_clks; - } - -udelay (10 ); - eqos->reg_access_ok = true;=> as clock is moved in probe...
Quoted 6 lines
the line
eqos->reg_access_ok = trueshould be also moved I think
or
reg_access_okcan be removed, asreg_access_okis always one wheneqos_write_hwaddris called
Why? I saw this variable "reg_access_ok " doesn't have initialize value. If remove this line, I think it will break the logic in eqos_write_hwaddr(), so I agree also move it into probe().
Quoted 129 lines
Quoted 115 lines
drivers/net/dwc_eth_qos.c +14
-51ret = wait_for_bit_le32(&eqos->dma_regs->mode,@@ -1066,68 +1052,34 @@ static int eqos_start(struct udevice *dev) eqos->config->swr_wait, false);if (ret) {pr_err ("EQOS_DMA_MODE_SWR stuck" ); - goto err_stop_resets; + goto err; } ret = eqos->config->ops->eqos_calibrate_pads (dev);if (ret <0 ) {pr_err ("eqos_calibrate_pads() failed: %d" , ret); - goto err_stop_resets; + goto err; } rate = eqos->config->ops->eqos_get_tick_clk_rate (dev); val = (rate /1000000 ) -1 ;writel (val, &eqos->mac_regs->us_tic_counter); -/* -* if PHY was already connected and configured, -* don't need to reconnect/reconfigure again -*/ -if (!eqos->phy) { -int addr =-1 ; -#ifdef CONFIG_DM_ETH_PHY - addr =eth_phy_get_addr (dev); -#endif -#ifdef DWC_NET_PHYADDR - addr =DWC_NET_PHYADDR ; -#endif - eqos->phy =phy_connect (eqos->mii, addr, dev, - eqos->config->interface (dev)); -if (!eqos->phy) { -pr_err ("phy_connect() failed" ); - goto err_stop_resets; - } - -if (eqos->max_speed) { - ret =phy_set_supported (eqos->phy, eqos->max_speed); -if (ret) { -pr_err ("phy_set_supported() failed: %d" , ret); - goto err_shutdown_phy; - } - } - - ret =phy_config (eqos->phy); -if (ret <0 ) { -pr_err ("phy_config() failed: %d" , ret); - goto err_shutdown_phy; - } - } - ret =phy_startup (eqos->phy);if (ret <0 ) {pr_err ("phy_startup() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }if (!eqos->phy->link) {pr_err ("No link" ); - goto err_shutdown_phy; + goto err; } ret =eqos_adjust_link (dev);if (ret <0 ) {pr_err ("eqos_adjust_link() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }/* Configure MTL */ @@ -1356,12 +1308,6 @@ static int eqos_start(struct udevice *dev)debug ("%s: OK\n" , __func__);return 0 ; -err_shutdown_phy: -phy_shutdown (eqos->phy); -err_stop_resets: - eqos->config->ops->eqos_stop_resets (dev); -err_stop_clks: - eqos->config->ops->eqos_stop_clks (dev); err:pr_err ("FAILED: %d" , ret);return ret;@@ -1412,12 +1358,6 @@ static void eqos_stop(struct udevice *dev)clrbits_le32 (&eqos->dma_regs->ch0_rx_control,EQOS_DMA_CH0_RX_CONTROL_SR ); -if (eqos->phy) { -phy_shutdown (eqos->phy); - } - eqos->config->ops->eqos_stop_resets (dev); - eqos->config->ops->eqos_stop_clks (dev); -debug ("%s: OK\n" , __func__); }@@ -1888,9 +1828,65 @@ static int eqos_probe(struct udevice *dev)eth_phy_set_mdio_bus (dev, eqos->mii);#endif + ret = eqos->config->ops->eqos_start_clks (dev); +if (ret <0 ) { +pr_err ("eqos_start_clks() failed: %d" , ret); + goto err_unregister_mdio; + } + + ret = eqos->config->ops->eqos_start_resets (dev); +if (ret <0 ) { +pr_err ("eqos_start_resets() failed: %d" , ret);drivers/net/dwc_eth_qos.c static int eqos_probe(struct udevice *dev) · line 1849
Quoted 10 lines
drivers/net/dwc_eth_qos.c +10
-0+ goto err_stop_clks; + } + +udelay (10 ); + +/* +* if PHY was already connected and configured, +* don't need to reconnect/reconfigure again +*/ +if (!eqos->phy) {this test can be remove I think
Quoted 5 lines
because we have always
eqos->phy= NULL in probe,PHY was can't be configured before probe
and it should be done again after a remove...
Agree, I will remove this check.
Best Regards,
Joakim Zhang
Quoted 63 lines
Quoted 47 lines
drivers/net/dwc_eth_qos.c +37
-0+int addr =-1 ; +#ifdef CONFIG_DM_ETH_PHY + addr =eth_phy_get_addr (dev); +#endif +#ifdef DWC_NET_PHYADDR + addr =DWC_NET_PHYADDR ; +#endif + eqos->phy =phy_connect (eqos->mii, addr, dev, + eqos->config->interface (dev)); +if (!eqos->phy) { +pr_err ("phy_connect() failed" ); + goto err_stop_resets; + } + +if (eqos->max_speed) { + ret =phy_set_supported (eqos->phy, eqos->max_speed); +if (ret) { +pr_err ("phy_set_supported() failed: %d" , ret); + goto err_shutdown_phy; + } + } + + ret =phy_config (eqos->phy); +if (ret <0 ) { +pr_err ("phy_config() failed: %d" , ret); + goto err_shutdown_phy; + } + } +debug ("%s: OK\n" , __func__);return 0 ; +err_shutdown_phy: +phy_shutdown (eqos->phy); +err_stop_resets: + eqos->config->ops->eqos_stop_resets (dev); +err_stop_clks: + eqos->config->ops->eqos_stop_clks (dev); +err_unregister_mdio: +mdio_unregister (eqos->mii); err_free_mdio:mdio_free (eqos->mii); err_remove_resources_tegra:@@ -1908,6 +1904,12 @@ static int eqos_remove(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev);drivers/net/dwc_eth_qos.c static int eqos_remove(struct udevice *dev) · line 1915
Quoted 10 lines
drivers/net/dwc_eth_qos.c +6
-0+if (eqos->phy) { +phy_shutdown (eqos->phy); + } + eqos->config->ops->eqos_stop_resets (dev); + eqos->config->ops->eqos_stop_clks (dev); +mdio_unregister (eqos->mii);mdio_free (eqos->mii); eqos->config->ops->eqos_remove_resources (dev);Regards
Patrick
Quoted 18 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL use realtek PHY -> rtl8211f_config() -> genphy_config_aneg() -> genphy_restart_aneg() // restart auto-nego, then need seconds to completeTo avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Quoted 16 lines
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (313 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254 After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms)
Using ethernet@30bf0000 device
TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
How much time do you save exactly, Is it the ~140ms you show here at the commit log ?
Quoted 212 lines
Signed-off-by Joakim Zhang <[email protected]>--- drivers/net/dwc_eth_qos.c | 132 +++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 65 deletions(-)drivers/net/dwc_eth_qos.c +67
-66@@ -1045,20 +1045,6 @@ static int eqos_start(struct udevice *dev) eqos->tx_desc_idx =0 ; eqos->rx_desc_idx =0 ; - ret = eqos->config->ops->eqos_start_clks (dev); -if (ret <0 ) { -pr_err ("eqos_start_clks() failed: %d" , ret); - goto err; - } - - ret = eqos->config->ops->eqos_start_resets (dev); -if (ret <0 ) { -pr_err ("eqos_start_resets() failed: %d" , ret); - goto err_stop_clks; - } - -udelay (10 ); - eqos->reg_access_ok = true; ret = wait_for_bit_le32(&eqos->dma_regs->mode,@@ -1066,68 +1052,34 @@ static int eqos_start(struct udevice *dev) eqos->config->swr_wait, false);if (ret) {pr_err ("EQOS_DMA_MODE_SWR stuck" ); - goto err_stop_resets; + goto err; } ret = eqos->config->ops->eqos_calibrate_pads (dev);if (ret <0 ) {pr_err ("eqos_calibrate_pads() failed: %d" , ret); - goto err_stop_resets; + goto err; } rate = eqos->config->ops->eqos_get_tick_clk_rate (dev); val = (rate /1000000 ) -1 ;writel (val, &eqos->mac_regs->us_tic_counter); -/* -* if PHY was already connected and configured, -* don't need to reconnect/reconfigure again -*/ -if (!eqos->phy) { -int addr =-1 ; -#ifdef CONFIG_DM_ETH_PHY - addr =eth_phy_get_addr (dev); -#endif -#ifdef DWC_NET_PHYADDR - addr =DWC_NET_PHYADDR ; -#endif - eqos->phy =phy_connect (eqos->mii, addr, dev, - eqos->config->interface (dev)); -if (!eqos->phy) { -pr_err ("phy_connect() failed" ); - goto err_stop_resets; - } - -if (eqos->max_speed) { - ret =phy_set_supported (eqos->phy, eqos->max_speed); -if (ret) { -pr_err ("phy_set_supported() failed: %d" , ret); - goto err_shutdown_phy; - } - } - - ret =phy_config (eqos->phy); -if (ret <0 ) { -pr_err ("phy_config() failed: %d" , ret); - goto err_shutdown_phy; - } - } - ret =phy_startup (eqos->phy);if (ret <0 ) {pr_err ("phy_startup() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }if (!eqos->phy->link) {pr_err ("No link" ); - goto err_shutdown_phy; + goto err; } ret =eqos_adjust_link (dev);if (ret <0 ) {pr_err ("eqos_adjust_link() failed: %d" , ret); - goto err_shutdown_phy; + goto err; }/* Configure MTL */ @@ -1356,12 +1308,6 @@ static int eqos_start(struct udevice *dev)debug ("%s: OK\n" , __func__);return 0 ; -err_shutdown_phy: -phy_shutdown (eqos->phy); -err_stop_resets: - eqos->config->ops->eqos_stop_resets (dev); -err_stop_clks: - eqos->config->ops->eqos_stop_clks (dev); err:pr_err ("FAILED: %d" , ret);return ret;@@ -1412,12 +1358,6 @@ static void eqos_stop(struct udevice *dev)clrbits_le32 (&eqos->dma_regs->ch0_rx_control,EQOS_DMA_CH0_RX_CONTROL_SR ); -if (eqos->phy) { -phy_shutdown (eqos->phy); - } - eqos->config->ops->eqos_stop_resets (dev); - eqos->config->ops->eqos_stop_clks (dev); -debug ("%s: OK\n" , __func__); }@@ -1888,9 +1828,65 @@ static int eqos_probe(struct udevice *dev)eth_phy_set_mdio_bus (dev, eqos->mii);#endif + ret = eqos->config->ops->eqos_start_clks (dev); +if (ret <0 ) { +pr_err ("eqos_start_clks() failed: %d" , ret); + goto err_unregister_mdio; + } + + ret = eqos->config->ops->eqos_start_resets (dev); +if (ret <0 ) { +pr_err ("eqos_start_resets() failed: %d" , ret); + goto err_stop_clks; + } + +udelay (10 ); + +/* +* if PHY was already connected and configured, +* don't need to reconnect/reconfigure again +*/ +if (!eqos->phy) { +int addr =-1 ; +#ifdef CONFIG_DM_ETH_PHY + addr =eth_phy_get_addr (dev); +#endif +#ifdef DWC_NET_PHYADDR + addr =DWC_NET_PHYADDR ; +#endif + eqos->phy =phy_connect (eqos->mii, addr, dev, + eqos->config->interface (dev)); +if (!eqos->phy) { +pr_err ("phy_connect() failed" ); + goto err_stop_resets; + } + +if (eqos->max_speed) { + ret =phy_set_supported (eqos->phy, eqos->max_speed); +if (ret) { +pr_err ("phy_set_supported() failed: %d" , ret); + goto err_shutdown_phy; + } + } + + ret =phy_config (eqos->phy); +if (ret <0 ) { +pr_err ("phy_config() failed: %d" , ret); + goto err_shutdown_phy; + } + } +debug ("%s: OK\n" , __func__);return 0 ; +err_shutdown_phy: +phy_shutdown (eqos->phy); +err_stop_resets: + eqos->config->ops->eqos_stop_resets (dev); +err_stop_clks: + eqos->config->ops->eqos_stop_clks (dev); +err_unregister_mdio: +mdio_unregister (eqos->mii); err_free_mdio:mdio_free (eqos->mii); err_remove_resources_tegra:@@ -1908,6 +1904,12 @@ static int eqos_remove(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev); +if (eqos->phy) { +phy_shutdown (eqos->phy); + } + eqos->config->ops->eqos_stop_resets (dev); + eqos->config->ops->eqos_stop_clks (dev); +mdio_unregister (eqos->mii);mdio_free (eqos->mii); eqos->config->ops->eqos_remove_resources (dev); --2.17.1
Hi Ramon,
Quoted 51 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 13:57
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 7 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL userealtek PHY
Quoted 3 lines
-> rtl8211f_config() -> genphy_config_aneg() ->
genphy_restart_aneg()Quoted 10 lines
// restart auto-nego, then need seconds to complete
To avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Quoted 16 lines
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1 DHCP client bound to address 10.193.102.192 (313 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
Quoted 2 lines
How much time do you save exactly, Is it the ~140ms you show here at the commit log ?
Exactly not. This time points to DHCP client bound to address, not the time this patch saves.
How can we evaluate the time we save? Please see the log:
Before:
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1
After:
Booting from net ...
BOOTP broadcast 1
And you need to check the related code:drivers/net/dwc_eth_qos.c: phy_startup ->...->drivers/net/phy/phy.c: genphy_update_link()
https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/phy/phy.c#L225
while (!(mii_reg & BMSR_ANEGCOMPLETE)) {
/*
* Timeout reached ?
*/
if (i > (PHY_ANEG_TIMEOUT / 50)) {
printf(" TIMEOUT !\n");
phydev->link = 0;
return -ETIMEDOUT;
}
if (ctrlc()) {
puts("user interrupt!\n");
phydev->link = 0;
return -EINTR;
}
if ((i++ % 10) == 0)
printf(".");
mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
mdelay(50); /* 50 ms */
}We can see that one "." is about 500ms, so from the log, we save about 500*7=3500ms=3.5s, this also means that PHY needs about 3.5s to complete auto-nego.
I also described this in the commit message, "users need wait seconds for PHY auto negotiation to complete when do tftp boot", may not quite clear, I will improve it.
Best Regards,
Joakim Zhang
Ramon Fried
NAKQuoted 99 lines · Joakim Zhang
Hi Ramon,
Quoted 51 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 13:57
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 7 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL userealtek PHY
Quoted 3 lines
-> rtl8211f_config() -> genphy_config_aneg() ->
genphy_restart_aneg()Quoted 10 lines
// restart auto-nego, then need seconds to complete
To avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Quoted 16 lines
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1 DHCP client bound to address 10.193.102.192 (313 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Quoted 2 lines
How much time do you save exactly, Is it the ~140ms you show here at the commit log ?
Exactly not. This time points to DHCP client bound to address, not the time this patch saves.
How can we evaluate the time we save? Please see the log:
Before:
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1
After:
Booting from net ...
BOOTP broadcast 1And you need to check the related code:
drivers/net/dwc_eth_qos.c:phy_startup->...->drivers/net/phy/phy.c:genphy_update_link()https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/phy/phy.c#L225
while (!(mii_reg & BMSR_ANEGCOMPLETE)) { /* * Timeout reached ? */ if (i > (PHY_ANEG_TIMEOUT / 50)) { printf(" TIMEOUT !\n"); phydev->link = 0; return -ETIMEDOUT; } if (ctrlc()) { puts("user interrupt!\n"); phydev->link = 0; return -EINTR; } if ((i++ % 10) == 0) printf("."); mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR); mdelay(50); /* 50 ms */ }
Quoted 6 lines
We can see that one "." is about 500ms, so from the log, we save about 500*7=3500ms=3.5s, this also means that PHY needs about 3.5s to complete auto-nego.
I also described this in the commit message, "users need wait seconds for PHY auto negotiation to complete when do tftp boot", may not quite clear, I will improve it.
Best Regards,
Joakim Zhang
NACK.
Hi Joakim.
It's currently working like that for all network drivers, it's not specific What you're currently suggesting is that the link will be brought up automatically for all users, even if they're not interested in network booting.
That won't work.
Thanks,
Ramon
Quoted 145 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 18:45
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 57 lines · Joakim Zhang
Hi Ramon,
Quoted 53 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 13:57
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 7 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL userealtek PHY
Quoted 3 lines
-> rtl8211f_config() -> genphy_config_aneg() ->
genphy_restart_aneg()Quoted 27 lines
// restart auto-nego, then need seconds to complete
To avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1 DHCP client bound to address 10.193.102.192 (313 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Quoted 4 lines
Quoted 2 lines
How much time do you save exactly, Is it the ~140ms you show here at the commit log ?
Exactly not. This time points to DHCP client bound to address, not the time
this patch saves.
Quoted 6 lines
How can we evaluate the time we save? Please see the log:
Before:
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete.......done
Quoted 10 lines
BOOTP broadcast 1
After:
Booting from net ...
BOOTP broadcast 1And you need to check the related code:
drivers/net/dwc_eth_qos.c:phy_startup->...->drivers/net/phy/phy.c:genphy_update_link()https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsour
Quoted 1 line
ce.denx.de%2Fu-boot%2Fu-boot%2F-%2Fblob%2Fmaster%2Fdrivers%2Fnet %2Fphy
Quoted 1 line
%2Fphy.c%23L225&data=04%7C01%7Cqiangqing.zhang%40nxp.com%
7C59322db
Quoted 1 line
193a54788a09308d9a8ee2cfc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0% 7C0%7
Quoted 1 line
C637726563178464522%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIj
Quoted 1 line
oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=usRIR7L exBnk
Quoted 14 lines
dnDO3U8hHYtMAIWT8bJ0Q7wgTElUjHs%3D&reserved=0
while (!(mii_reg & BMSR_ANEGCOMPLETE)) { /* * Timeout reached ? */ if (i > (PHY_ANEG_TIMEOUT / 50)) { printf(" TIMEOUT !\n"); phydev->link = 0; return -ETIMEDOUT; } if (ctrlc()) { puts("user interrupt!\n");Quoted 8 lines
phydev->link = 0; return -EINTR; } if ((i++ % 10) == 0) printf("."); mii_reg = phy_read(phydev,
MDIO_DEVAD_NONE,MII_BMSR);Quoted 4 lines
mdelay(50); /* 50 ms */ }We can see that one "." is about 500ms, so from the log, we save about
500*7=3500ms=3.5s, this also means that PHY needs about 3.5s to complete auto-nego.
Quoted 2 lines
I also described this in the commit message, "users need wait seconds for
PHY auto negotiation to complete when do tftp boot", may not quite clear, I will improve it.
Quoted 3 lines
Best Regards,
Joakim Zhang
Quoted 6 lines
NACK.
Hi Joakim.
It's currently working like that for all network drivers, it's not specific What you're currently suggesting is that the link will be brought up automatically for all users, even if they're not interested in network booting. That won't work.
Hi Ramon,
I am not quite understand you mean, I only connect and config the PHY in the MAC probe stage, yes, the link should be brought up, but startup PHY still in MAC open operation, just attaching PHY to MAC in MAC probe, seems not a problem. Is there any side effect?
We did the same thing in FEC driver: https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fec_mxc.c#L1522
Best Regards,
Joakim Zhang
Quoted 2 lines
Thanks,
Ramon
Quoted 153 lines · Joakim Zhang
Quoted 146 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 18:45
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 57 lines · Joakim Zhang
Hi Ramon,
Quoted 53 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 13:57
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 7 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXL userealtek PHY
Quoted 3 lines
-> rtl8211f_config() -> genphy_config_aneg() ->
genphy_restart_aneg()Quoted 27 lines
// restart auto-nego, then need seconds to complete
To avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete....... done BOOTP broadcast 1 DHCP client bound to address 10.193.102.192 (313 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254
After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Quoted 4 lines
Quoted 2 lines
How much time do you save exactly, Is it the ~140ms you show here at the commit log ?
Exactly not. This time points to DHCP client bound to address, not the time
this patch saves.
Quoted 6 lines
How can we evaluate the time we save? Please see the log:
Before:
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation to complete.......done
Quoted 10 lines
BOOTP broadcast 1
After:
Booting from net ...
BOOTP broadcast 1And you need to check the related code:
drivers/net/dwc_eth_qos.c:phy_startup->...->drivers/net/phy/phy.c:genphy_update_link()https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsour
Quoted 1 line
ce.denx.de%2Fu-boot%2Fu-boot%2F-%2Fblob%2Fmaster%2Fdrivers%2Fnet %2Fphy
Quoted 1 line
%2Fphy.c%23L225&data=04%7C01%7Cqiangqing.zhang%40nxp.com%
7C59322db
Quoted 1 line
193a54788a09308d9a8ee2cfc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0% 7C0%7
Quoted 1 line
C637726563178464522%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIj
Quoted 1 line
oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=usRIR7L exBnk
Quoted 14 lines
dnDO3U8hHYtMAIWT8bJ0Q7wgTElUjHs%3D&reserved=0
while (!(mii_reg & BMSR_ANEGCOMPLETE)) { /* * Timeout reached ? */ if (i > (PHY_ANEG_TIMEOUT / 50)) { printf(" TIMEOUT !\n"); phydev->link = 0; return -ETIMEDOUT; } if (ctrlc()) { puts("user interrupt!\n");Quoted 8 lines
phydev->link = 0; return -EINTR; } if ((i++ % 10) == 0) printf("."); mii_reg = phy_read(phydev,
MDIO_DEVAD_NONE,MII_BMSR);Quoted 4 lines
mdelay(50); /* 50 ms */ }We can see that one "." is about 500ms, so from the log, we save about
500*7=3500ms=3.5s, this also means that PHY needs about 3.5s to complete auto-nego.
Quoted 2 lines
I also described this in the commit message, "users need wait seconds for
PHY auto negotiation to complete when do tftp boot", may not quite clear, I will improve it.
Quoted 3 lines
Best Regards,
Joakim ZhangQuoted 6 lines
NACK.
Hi Joakim.
It's currently working like that for all network drivers, it's not specific What you're currently suggesting is that the link will be brought up automatically for all users, even if they're not interested in network booting. That won't work.
Quoted 4 lines
Hi Ramon,
I am not quite understand you mean, I only connect and config the PHY in the MAC probe stage, yes, the link should be brought up, but startup PHY still in MAC open operation, just attaching PHY to MAC in MAC probe, seems not a problem. Is there any side effect?
The link up is a side effect, the U-Boot device model works in lazy loading mode, where stuff is initialized only when needed. This works the same for all phys in all places.
Additionally, I'm not following how much time can you actually save, how much time passes between the probe() function and start() function in your setup ? how could it be seconds ?
Quoted 2 lines
We did the same thing in FEC driver: https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fec_mxc.c#L1522
True, that's an example that contradicts what I just said, but it's wrong.
Quoted 5 lines
Best Regards,
Joakim ZhangQuoted 2 lines
Thanks,
Ramon
Hi Ramon,
Quoted 185 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月17日 12:20
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 56 lines · Joakim Zhang
Quoted 56 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 18:45
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 40 lines · Joakim Zhang
Hi Ramon,
Quoted 36 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: 2021年11月16日 13:57
To: Joakim Zhang <[email protected]>
Cc: Joe Hershberger <[email protected]>; U-Boot Mailing List <[email protected]>; Ye Li <[email protected]>; Patrick Delaunay <[email protected]>; Daniil Stas <[email protected]>; Stephen Warren <[email protected]>
Subject: Re: [PATCH] net: eqos: connect and config PHY from probe stage instead of starting EQOSQuoted 8 lines · Joakim Zhang
For EQOS ethernet, it will do
phy_connect()andphy_config()when start the ethernet (eqos_srart()), users need wait seconds for PHY auto negotiation to complete when do tftp boot.phy_config() -> board_phy_config() -> phydev->drv->config() // i.MX8MP/DXLuse
realtek PHY
Quoted 3 lines
-> rtl8211f_config() -> genphy_config_aneg() ->
genphy_restart_aneg()Quoted 9 lines
// restart auto-nego, then need seconds to complete
To avoid wasting time, we can move PHY connection and configuration from
eqos_start()toeqos_probe(). This patch also moves clock setting fromeqos_start()toeqos_probe()as MDIO access need CSR clock, there is no function change.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Tested-on: i.MX8MP & i.MX8DXL
Before:
u-boot=> run netboot
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation tocomplete.......
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 14 lines
Quoted 5 lines
done BOOTP broadcast 1 DHCP client bound to address 10.193.102.192
(313 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Quoted 9 lines
After:
u-boot=> run netboot
Booting from net ...
BOOTP broadcast 1
DHCP client bound to address 10.193.102.192 (454 ms) Using ethernet@30bf0000 device TFTP from server 10.193.108.176; our IP address is 10.193.102.192; sending through gateway 10.193.102.254Quoted 2 lines
How much time do you save exactly, Is it the ~140ms you show here at the commit log ?
Exactly not. This time points to DHCP client bound to address, not the time
Quoted 7 lines
Quoted 7 lines
this patch saves.
Quoted 6 lines
How can we evaluate the time we save? Please see the log:
Before:
Booting from net ...
ethernet@30bf0000 Waiting for PHY auto negotiation tocomplete.......
Quoted 6 lines
Quoted 6 lines
done
Quoted 5 lines
BOOTP broadcast 1
After:
Booting from net ...
BOOTP broadcast 1Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
And you need to check the related code:
drivers/net/dwc_eth_qos.c:phy_startup->...->drivers/net/phy/phy.c:genphy_update_link()https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fso
Quoted 3 lines
Quoted 3 lines
ur
Quoted 1 line
ce.denx.de%2Fu-boot%2Fu-boot%2F-%2Fblob%2Fmaster%2Fdrivers%2Fnet
Quoted 2 lines
Quoted 2 lines
%2Fphy
Quoted 1 line
%2Fphy.c%23L225&data=04%7C01%7Cqiangqing.zhang%40nxp.co
m%
Quoted 3 lines
Quoted 3 lines
7C59322db
Quoted 1 line
193a54788a09308d9a8ee2cfc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%
Quoted 3 lines
Quoted 3 lines
7C0%7
Quoted 1 line
C637726563178464522%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
Quoted 3 lines
Quoted 3 lines
MDAiLCJQIj
Quoted 1 line
oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=usRIR7L
Quoted 37 lines
Quoted 37 lines
exBnk
Quoted 14 lines
dnDO3U8hHYtMAIWT8bJ0Q7wgTElUjHs%3D&reserved=0
while (!(mii_reg & BMSR_ANEGCOMPLETE)) { /* * Timeout reached ? */ if (i > (PHY_ANEG_TIMEOUT / 50)) { printf(" TIMEOUT !\n"); phydev->link = 0; return -ETIMEDOUT; } if (ctrlc()) { puts("user interrupt!\n");Quoted 8 lines
phydev->link = 0; return -EINTR; } if ((i++ % 10) == 0) printf("."); mii_reg = phy_read(phydev,
MDIO_DEVAD_NONE,MII_BMSR);Quoted 5 lines
mdelay(50); /* 50 ms */ }We can see that one "." is about 500ms, so from the log, we save about
500*7=3500ms=3.5s, this also means that PHY needs about 3.5s to complete auto-nego.
Quoted 3 lines
I also described this in the commit message, "users need wait seconds for
PHY auto negotiation to complete when do tftp boot", may not quite clear, I will improve it.
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Best Regards,
Joakim ZhangNACK.
Hi Joakim.
It's currently working like that for all network drivers, it's not specific What you're currently suggesting is that the link will be brought up automatically for all users, even if they're not interested innetwork booting.
Quoted 4 lines
Quoted 1 line
That won't work.
Hi Ramon,
Quoted 7 lines
Quoted 2 lines
I am not quite understand you mean, I only connect and config the PHY in the MAC probe stage, yes, the link should be brought up, but startup
PHY still in MAC open operation, just attaching PHY to MAC in MAC probe, seems not a problem. Is there any side effect?
The link up is a side effect, the U-Boot device model works in lazy loading mode, where stuff is initialized only when needed. This works the same for all phys in all places.
Understand, thanks.
Quoted 3 lines
Additionally, I'm not following how much time can you actually save, how much time passes between the
probe()function andstart()function in your setup ? how could it be seconds ?
Actually, Realtek PHY(RTL8211FDI) at my side, it needs about 3.5s to complete auto-negotiation. If we connect and config PHY in probe(), it _may_ complete auto-nego when user start network (start()), as you said, yes, if we start network quickly, we also need some time to wait it to complete. However, at least, we can save some time compared to connect and config PHY in start(), where we need wait about 3.5s to complete auto-nego.
Quoted 14 lines
Quoted 3 lines
We did the same thing in FEC driver:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsour
Quoted 1 line
ce.denx.de%2Fu-boot%2Fu-boot%2F-%2Fblob%2Fmaster%2Fdrivers%2Fnet %2Ffec
Quoted 1 line
_mxc.c%23L1522&data=04%7C01%7Cqiangqing.zhang%40nxp.com%7C4 3be042d
Quoted 1 line
7b6f427f406708d9a98188f8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C
Quoted 1 line
Quoted 7 lines
637727196088131120%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM DAiLCJQIjo
Quoted 1 line
iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=bElnoO13 uq0kg
Quoted 1 line
t7yzIFwiMJpVH3L49SNF5dssplt%2Fjw%3D&reserved=0
True, that's an example that contradicts what I just said, but it's wrong.
OK.
Best Regards,
Joakim Zhang
Quoted 4 lines
Quoted 4 lines
Best Regards,
Joakim ZhangQuoted 2 lines
Thanks,
Ramon