From 395a636fb233e862bf7feafe81c539d9475ffc79 Mon Sep 17 00:00:00 2001 From: Semen Ustimenko Date: Mon, 13 Aug 2001 18:37:31 +0000 Subject: [PATCH] Fix an bug in FreeBSD attach routine - attaching MII interfaces before doing common_attach is wrong as common attach initialize some fileds used by mediainit routine. This was hard to notify because loading driver as kld lead to mediainit routine being called after common_attach, though probe_phy is called before. MFC after: 1 week --- sys/dev/tx/if_tx.c | 16 +++++++--------- sys/pci/if_tx.c | 16 +++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index f7610c713a4..707355dbd01 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -523,12 +523,9 @@ epic_freebsd_attach(dev) /* Workaround for Application Note 7-15 */ for (i=0; i<16; i++) CSR_WRITE_4(sc, TEST1, TEST1_CLOCK_TEST); - /* - * Do ifmedia setup. - */ - if (mii_phy_probe(dev, &sc->miibus, - epic_ifmedia_upd, epic_ifmedia_sts)) { - device_printf(dev, "MII without any PHY!?\n"); + /* Do OS independent part, including chip wakeup and reset */ + if (epic_common_attach(sc)) { + device_printf(dev, "memory distribution error\n"); bus_teardown_intr(dev, sc->irq, sc->sc_ih); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); bus_release_resource(dev, EPIC_RES, EPIC_RID, sc->res); @@ -536,9 +533,10 @@ epic_freebsd_attach(dev) goto fail; } - /* Do OS independent part, including chip wakeup and reset */ - if (epic_common_attach(sc)) { - device_printf(dev, "memory distribution error\n"); + /* Do ifmedia setup */ + if (mii_phy_probe(dev, &sc->miibus, + epic_ifmedia_upd, epic_ifmedia_sts)) { + device_printf(dev, "MII without any PHY!?\n"); bus_teardown_intr(dev, sc->irq, sc->sc_ih); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); bus_release_resource(dev, EPIC_RES, EPIC_RID, sc->res); diff --git a/sys/pci/if_tx.c b/sys/pci/if_tx.c index f7610c713a4..707355dbd01 100644 --- a/sys/pci/if_tx.c +++ b/sys/pci/if_tx.c @@ -523,12 +523,9 @@ epic_freebsd_attach(dev) /* Workaround for Application Note 7-15 */ for (i=0; i<16; i++) CSR_WRITE_4(sc, TEST1, TEST1_CLOCK_TEST); - /* - * Do ifmedia setup. - */ - if (mii_phy_probe(dev, &sc->miibus, - epic_ifmedia_upd, epic_ifmedia_sts)) { - device_printf(dev, "MII without any PHY!?\n"); + /* Do OS independent part, including chip wakeup and reset */ + if (epic_common_attach(sc)) { + device_printf(dev, "memory distribution error\n"); bus_teardown_intr(dev, sc->irq, sc->sc_ih); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); bus_release_resource(dev, EPIC_RES, EPIC_RID, sc->res); @@ -536,9 +533,10 @@ epic_freebsd_attach(dev) goto fail; } - /* Do OS independent part, including chip wakeup and reset */ - if (epic_common_attach(sc)) { - device_printf(dev, "memory distribution error\n"); + /* Do ifmedia setup */ + if (mii_phy_probe(dev, &sc->miibus, + epic_ifmedia_upd, epic_ifmedia_sts)) { + device_printf(dev, "MII without any PHY!?\n"); bus_teardown_intr(dev, sc->irq, sc->sc_ih); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); bus_release_resource(dev, EPIC_RES, EPIC_RID, sc->res);