From: Matthew Dillon Date: Fri, 19 Mar 2004 06:30:08 +0000 (+0000) Subject: If XL cannot properly attach it tries to detach to clean up. Unfortunately, X-Git-Tag: v2.0.1~11741 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/069f2034bd244026824b6ee53900a4c92a97ccc6 If XL cannot properly attach it tries to detach to clean up. Unfortunately, the detach code expects it to have gotten most of the way through the attach and if it hasn't the system will crash. This commit adds a flag that tells the detach code whether the attach got far enough along for the detach to be able to reset the card (and do certain other things). --- diff --git a/sys/dev/netif/xl/if_xl.c b/sys/dev/netif/xl/if_xl.c index a593c94fb7..eac098fa6f 100644 --- a/sys/dev/netif/xl/if_xl.c +++ b/sys/dev/netif/xl/if_xl.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/pci/if_xl.c,v 1.72.2.28 2003/10/08 06:01:57 murray Exp $ - * $DragonFly: src/sys/dev/netif/xl/if_xl.c,v 1.9 2004/03/14 15:36:53 joerg Exp $ + * $DragonFly: src/sys/dev/netif/xl/if_xl.c,v 1.10 2004/03/19 06:30:08 dillon Exp $ */ /* @@ -1461,6 +1461,8 @@ xl_attach(dev) goto fail; } + sc->xl_flags |= XL_FLAG_ATTACH_MAPPED; + /* Reset the adapter. */ xl_reset(sc); @@ -1811,9 +1813,16 @@ xl_detach(dev) res = SYS_RES_IOPORT; } - xl_reset(sc); - xl_stop(sc); - ether_ifdetach(ifp); + /* + * Only try to communicate with the device if we were able to map + * the ports. This flag is set before ether_ifattach() so it also + * governs our call to ether_ifdetach(). + */ + if (sc->xl_flags & XL_FLAG_ATTACH_MAPPED) { + xl_reset(sc); + xl_stop(sc); + ether_ifdetach(ifp); + } if (sc->xl_miibus) device_delete_child(dev, sc->xl_miibus); diff --git a/sys/dev/netif/xl/if_xlreg.h b/sys/dev/netif/xl/if_xlreg.h index e2f4255313..1eb90cc50d 100644 --- a/sys/dev/netif/xl/if_xlreg.h +++ b/sys/dev/netif/xl/if_xlreg.h @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/pci/if_xlreg.h,v 1.25.2.8 2003/08/10 21:55:57 silby Exp $ - * $DragonFly: src/sys/dev/netif/xl/if_xlreg.h,v 1.3 2004/01/24 06:34:02 dillon Exp $ + * $DragonFly: src/sys/dev/netif/xl/if_xlreg.h,v 1.4 2004/03/19 06:30:08 dillon Exp $ */ #define XL_EE_READ 0x0080 /* read, 5 bit address */ @@ -576,6 +576,7 @@ struct xl_mii_frame { #define XL_FLAG_INVERT_MII_PWR 0x0040 #define XL_FLAG_NO_XCVR_PWR 0x0080 #define XL_FLAG_USE_MMIO 0x0100 +#define XL_FLAG_ATTACH_MAPPED 0x0200 /* set after ports mapped */ #define XL_NO_XCVR_PWR_MAGICBITS 0x0900