From owner-p4-projects@FreeBSD.ORG Mon Jun 12 20:33:06 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F414416A41F; Mon, 12 Jun 2006 20:33:05 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D190A16A418 for ; Mon, 12 Jun 2006 20:33:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BFC043D49 for ; Mon, 12 Jun 2006 20:33:05 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5CKUnS9007845 for ; Mon, 12 Jun 2006 20:30:49 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5CKUnZE007842 for perforce@freebsd.org; Mon, 12 Jun 2006 20:30:49 GMT (envelope-from jhb@freebsd.org) Date: Mon, 12 Jun 2006 20:30:49 GMT Message-Id: <200606122030.k5CKUnZE007842@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 99078 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jun 2006 20:33:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=99078 Change 99078 by jhb@jhb_mutex on 2006/06/12 20:30:28 Style fixes and close a race. Affected files ... .. //depot/projects/smpng/sys/kern/subr_firmware.c#9 edit Differences ... ==== //depot/projects/smpng/sys/kern/subr_firmware.c#9 (text+ko) ==== @@ -96,11 +96,6 @@ return frp; } -/* - * Note that for a module loaded via kldload before it was asked for by - * a consumer, fp->file will be NULL, so we won't try to unload the - * module when the last reference is dropped. - */ static void clearentry(struct firmware *fp) { @@ -226,8 +221,7 @@ if (fp == NULL) break; file = fp->file; - /* No longer explicitly loaded. */ - fp->file = NULL; + clearentry(fp); mtx_unlock(&firmware_mtx); linker_release_module(NULL, NULL, file); @@ -251,6 +245,8 @@ if (fp->refcnt == 0) { if ((flags & FIRMWARE_UNLOAD) == 0) fp->flags |= FIRMWAREFLAG_KEEPKLDREF; + else if (fp->file) + taskqueue_enqueue(taskqueue_thread, &firmware_task); } mtx_unlock(&firmware_mtx); } @@ -261,6 +257,7 @@ static int firmware_modevent(module_t mod, int type, void *unused) { + struct firmware *fp; int i; switch (type) { @@ -269,7 +266,7 @@ return 0; case MOD_UNLOAD: for (i = 0; i < FIRMWARE_MAX; i++) { - struct firmware *fp = &firmware_table[i]; + fp = &firmware_table[i]; fp->flags &= ~FIRMWAREFLAG_KEEPKLDREF; } taskqueue_enqueue(taskqueue_thread, &firmware_task);