MLK-14682 net: fec: avoid mac re-inited after system resume back
authorAndy Duan <fugang.duan@nxp.com>
Fri, 7 Apr 2017 03:16:09 +0000 (11:16 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:21:54 +0000 (15:21 -0500)
Function .fec_resume() had called .fec_restart() before phy resume to ensure
MAC mii bus can work, but the firth .adjust_link() call .fec_restart() to re-init
the MAC again that is not necessary since PHY duplex and speed have no change
during suspend status, so remove the unnecessary mac re-inited after resume back.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
drivers/net/ethernet/freescale/fec.h
drivers/net/ethernet/freescale/fec_main.c

index 158d80f..15dcf48 100644 (file)
@@ -550,6 +550,7 @@ struct fec_enet_private {
        struct device_node *phy_node;
        int     link;
        bool    fixed_link;
+       bool    require_init;
        int     full_duplex;
        int     speed;
        struct  completion mdio_done;
index c1698cc..ec49f16 100644 (file)
@@ -1774,11 +1774,13 @@ static void fec_enet_adjust_link(struct net_device *ndev)
 
                if (fep->full_duplex != phy_dev->duplex) {
                        fep->full_duplex = phy_dev->duplex;
+                       fep->require_init = true;
                        status_change = 1;
                }
 
                if (phy_dev->speed != fep->speed) {
                        fep->speed = phy_dev->speed;
+                       fep->require_init = true;
                        status_change = 1;
                }
 
@@ -1786,7 +1788,9 @@ static void fec_enet_adjust_link(struct net_device *ndev)
                if (status_change) {
                        napi_disable(&fep->napi);
                        netif_tx_lock_bh(ndev);
-                       fec_restart(ndev);
+                       /* avoid to re-init MAC after resume back */
+                       if (fep->require_init)
+                               fec_restart(ndev);
                        netif_wake_queue(ndev);
                        netif_tx_unlock_bh(ndev);
                        napi_enable(&fep->napi);
@@ -3799,6 +3803,7 @@ static int __maybe_unused fec_resume(struct device *dev)
                        pinctrl_pm_select_default_state(&fep->pdev->dev);
                }
                fec_restart(ndev);
+               fep->require_init = false;
                netif_tx_lock_bh(ndev);
                netif_device_attach(ndev);
                netif_tx_unlock_bh(ndev);