[net-next] net: gemini: Try to register phy before netdev

Message ID 20200905104530.29998-1-linus.walleij@linaro.org
State New
Headers show
Series
  • [net-next] net: gemini: Try to register phy before netdev
Related show

Commit Message

Linus Walleij Sept. 5, 2020, 10:45 a.m.
It's nice if the phy is online before we register the netdev
so try to do that first.

Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/net/ethernet/cortina/gemini.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

-- 
2.26.2

Comments

Andrew Lunn Sept. 5, 2020, 3:50 p.m. | #1
On Sat, Sep 05, 2020 at 12:45:30PM +0200, Linus Walleij wrote:
> It's nice if the phy is online before we register the netdev

> so try to do that first.


Hi Linus

The PHY handling in this driver is all a bit odd.

gmac_open() will also try to connect the PHY if it has not already
been found. gmac_stop() does not seem to have a symmetrical
phy_disconnect. However, gmac_uninit does?

I do wonder if more cleanup should be done while you are at it?

    Andrew
Linus Walleij Sept. 5, 2020, 8:41 p.m. | #2
On Sat, Sep 5, 2020 at 5:50 PM Andrew Lunn <andrew@lunn.ch> wrote:

> The PHY handling in this driver is all a bit odd.

>

> gmac_open() will also try to connect the PHY if it has not already

> been found. gmac_stop() does not seem to have a symmetrical

> phy_disconnect. However, gmac_uninit does?

>

> I do wonder if more cleanup should be done while you are at it?


OK I send a new more invasive version :)

Thanks,
Linus Walleij

Patch

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index ffec0f3dd957..cf4dc6345f0d 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2505,6 +2505,11 @@  static int gemini_ethernet_port_probe(struct platform_device *pdev)
 	if (ret)
 		goto unprepare;
 
+	ret = gmac_setup_phy(netdev);
+	if (ret)
+		netdev_info(netdev,
+			    "PHY init failed, deferring to ifup time\n");
+
 	ret = register_netdev(netdev);
 	if (ret)
 		goto unprepare;
@@ -2513,10 +2518,6 @@  static int gemini_ethernet_port_probe(struct platform_device *pdev)
 		    "irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
 		    port->irq, &dmares->start,
 		    &gmacres->start);
-	ret = gmac_setup_phy(netdev);
-	if (ret)
-		netdev_info(netdev,
-			    "PHY init failed, deferring to ifup time\n");
 	return 0;
 
 unprepare: