From owner-svn-src-head@freebsd.org Thu May 12 19:13:47 2016 Return-Path: Delivered-To: svn-src-head@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 8F09CB38B9F; Thu, 12 May 2016 19:13:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70F3F1AC8; Thu, 12 May 2016 19:13:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 566E3B93C; Thu, 12 May 2016 15:13:46 -0400 (EDT) From: John Baldwin To: Scott Long Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r299544 - head/sys/dev/an Date: Thu, 12 May 2016 12:11:08 -0700 Message-ID: <1887870.BCG0T4KVbU@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <201605121747.u4CHlUWt094185@repo.freebsd.org> References: <201605121747.u4CHlUWt094185@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 12 May 2016 15:13:46 -0400 (EDT) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2016 19:13:47 -0000 On Thursday, May 12, 2016 05:47:30 PM Scott Long wrote: > 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. Except that if they return 0 (which most shouldn't) it is guaranteed. an_probe() used to return 0, but it was changed to return BUS_PROBE_DEFAULT without fixing this. (Oops) an_probe() could just be fixed to destroy the lock and the lock init could then be moved into an_attach(). > 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)); This wasn't necessary before. > 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)); This isn't necessary now (softc's are pre-zeroed by new-bus). > 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; > -- John Baldwin