Author: scottl Date: Thu May 12 17:47:30 2016 New Revision: 299544 URL: https://svnweb.freebsd.org/changeset/base/299544
Log: Move mutex initialization from PCI probe to PCI attach. Drivers are not allowed to create any persistent state in their probe routine because it's not guaranteed that they'll win the election and be allowed to attach. Submitted by: Matthew Macy MFC after: 3 days Modified: head/sys/dev/an/if_an.c head/sys/dev/an/if_an_pci.c head/sys/dev/an/if_anreg.h Modified: head/sys/dev/an/if_an.c ============================================================================== --- head/sys/dev/an/if_an.c Thu May 12 16:34:59 2016 (r299543) +++ head/sys/dev/an/if_an.c Thu May 12 17:47:30 2016 (r299544) @@ -304,23 +304,6 @@ SYSCTL_PROC(_hw_an, OID_AUTO, an_cache_m 0, sizeof(an_conf_cache), sysctl_an_cache_mode, "A", ""); /* - * Setup the lock for PCI attachment since it skips the an_probe - * function. We need to setup the lock in an_probe since some - * operations need the lock. So we might as well create the - * lock in the probe. - */ -int -an_pci_probe(device_t dev) -{ - struct an_softc *sc = device_get_softc(dev); - - mtx_init(&sc->an_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, - MTX_DEF); - - return(0); -} - -/* * We probe for an Aironet 4500/4800 card by attempting to * read the default SSID list. On reset, the first entry in * the SSID list will contain the name "tsunami." If we don't Modified: head/sys/dev/an/if_an_pci.c ============================================================================== --- head/sys/dev/an/if_an_pci.c Thu May 12 16:34:59 2016 (r299543) +++ head/sys/dev/an/if_an_pci.c Thu May 12 17:47:30 2016 (r299544) @@ -119,16 +119,16 @@ static int an_probe_pci(device_t dev) { struct an_type *t; - struct an_softc *sc = device_get_softc(dev); + uint16_t vid, did; - bzero(sc, sizeof(struct an_softc)); t = an_devs; + vid = pci_get_vendor(dev); + did = pci_get_device(dev); while (t->an_name != NULL) { - if (pci_get_vendor(dev) == t->an_vid && - pci_get_device(dev) == t->an_did) { + if (vid == t->an_vid && + did == t->an_did) { device_set_desc(dev, t->an_name); - an_pci_probe(dev); return(BUS_PROBE_DEFAULT); } t++; @@ -145,8 +145,16 @@ an_attach_pci(dev) int flags, error = 0; sc = device_get_softc(dev); + bzero(sc, sizeof(struct an_softc)); flags = device_get_flags(dev); + /* + * Setup the lock in PCI attachment since it skips the an_probe + * function. + */ + mtx_init(&sc->an_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, + MTX_DEF); + if (pci_get_vendor(dev) == AIRONET_VENDORID && pci_get_device(dev) == AIRONET_DEVICEID_MPI350) { sc->mpi350 = 1; Modified: head/sys/dev/an/if_anreg.h ============================================================================== --- head/sys/dev/an/if_anreg.h Thu May 12 16:34:59 2016 (r299543) +++ head/sys/dev/an/if_anreg.h Thu May 12 17:47:30 2016 (r299544) @@ -500,7 +500,6 @@ int an_alloc_port (device_t, int, int); int an_alloc_memory (device_t, int, int); int an_alloc_aux_memory (device_t, int, int); int an_alloc_irq (device_t, int, int); -int an_pci_probe (device_t); int an_probe (device_t); int an_shutdown (device_t); void an_resume (device_t); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"