msk(4): If link is down, don't disable RX/TX MACs if they are not enabled
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 31 Jul 2011 06:53:23 +0000 (14:53 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 31 Jul 2011 06:58:06 +0000 (14:58 +0800)
Obtained-from: FreeBSD 192727

sys/dev/netif/msk/if_msk.c

index 8ab15a0..0b16cb0 100644 (file)
@@ -494,10 +494,12 @@ msk_miibus_statchg(device_t dev)
                msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0);
                /* Disable Rx/Tx MAC. */
                gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
-               gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
-               GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac);
-               /* Read again to ensure writing. */
-               GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
+               if (gmac & (GM_GPCR_RX_ENA | GM_GPCR_TX_ENA)) {
+                       gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
+                       GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac);
+                       /* Read again to ensure writing. */
+                       GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
+               }
        }
 }