From owner-svn-src-all@freebsd.org Thu May 12 17:47:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE255B38AD0; Thu, 12 May 2016 17:47:31 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8DBCB102B; Thu, 12 May 2016 17:47:31 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4CHlUBC094188; Thu, 12 May 2016 17:47:30 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4CHlUWt094185; Thu, 12 May 2016 17:47:30 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201605121747.u4CHlUWt094185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Thu, 12 May 2016 17:47:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299544 - head/sys/dev/an X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2016 17:47:31 -0000 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);