From owner-svn-src-all@FreeBSD.ORG Thu Apr 11 17:50:51 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 21897C24; Thu, 11 Apr 2013 17:50:51 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 14A78E96; Thu, 11 Apr 2013 17:50:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3BHooQX055612; Thu, 11 Apr 2013 17:50:50 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3BHoorN055611; Thu, 11 Apr 2013 17:50:50 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201304111750.r3BHoorN055611@svn.freebsd.org> From: Navdeep Parhar Date: Thu, 11 Apr 2013 17:50:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249370 - head/sys/dev/cxgbe 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.14 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, 11 Apr 2013 17:50:51 -0000 Author: np Date: Thu Apr 11 17:50:50 2013 New Revision: 249370 URL: http://svnweb.freebsd.org/changeset/base/249370 Log: cxgbe(4): Ensure that the MOD_LOAD handler runs before either t4nex or t5nex attach to their devices. MFC after: 3 days Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Thu Apr 11 17:16:08 2013 (r249369) +++ head/sys/dev/cxgbe/t4_main.c Thu Apr 11 17:50:50 2013 (r249370) @@ -418,7 +418,7 @@ static int read_i2c(struct adapter *, st #ifdef TCP_OFFLOAD static int toe_capability(struct port_info *, int); #endif -static int t4_mod_event(module_t, int, void *); +static int mod_event(module_t, int, void *); struct { uint16_t device; @@ -6997,12 +6997,15 @@ tweak_tunables(void) } static int -t4_mod_event(module_t mod, int cmd, void *arg) +mod_event(module_t mod, int cmd, void *arg) { int rc = 0; + static int loaded = 0; switch (cmd) { case MOD_LOAD: + if (atomic_fetchadd_int(&loaded, 1)) + break; t4_sge_modload(); mtx_init(&t4_list_lock, "T4 adapters", 0, MTX_DEF); SLIST_INIT(&t4_list); @@ -7014,6 +7017,8 @@ t4_mod_event(module_t mod, int cmd, void break; case MOD_UNLOAD: + if (atomic_fetchadd_int(&loaded, -1) > 1) + break; #ifdef TCP_OFFLOAD mtx_lock(&t4_uld_list_lock); if (!SLIST_EMPTY(&t4_uld_list)) { @@ -7041,10 +7046,10 @@ t4_mod_event(module_t mod, int cmd, void static devclass_t t4_devclass, t5_devclass; static devclass_t cxgbe_devclass, cxl_devclass; -DRIVER_MODULE(t4nex, pci, t4_driver, t4_devclass, t4_mod_event, 0); +DRIVER_MODULE(t4nex, pci, t4_driver, t4_devclass, mod_event, 0); MODULE_VERSION(t4nex, 1); -DRIVER_MODULE(t5nex, pci, t5_driver, t5_devclass, 0, 0); +DRIVER_MODULE(t5nex, pci, t5_driver, t5_devclass, mod_event, 0); MODULE_VERSION(t5nex, 1); DRIVER_MODULE(cxgbe, t4nex, cxgbe_driver, cxgbe_devclass, 0, 0);