From owner-p4-projects@FreeBSD.ORG Sat Sep 13 17:17:04 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 98793106567A; Sat, 13 Sep 2008 17:17:04 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CA5B1065678 for ; Sat, 13 Sep 2008 17:17:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 42D648FC0A for ; Sat, 13 Sep 2008 17:17:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m8DHH4Tu039205 for ; Sat, 13 Sep 2008 17:17:04 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m8DHH4Dl039197 for perforce@freebsd.org; Sat, 13 Sep 2008 17:17:04 GMT (envelope-from hselasky@FreeBSD.org) Date: Sat, 13 Sep 2008 17:17:04 GMT Message-Id: <200809131717.m8DHH4Dl039197@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 149717 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: Sat, 13 Sep 2008 17:17:04 -0000 http://perforce.freebsd.org/chv.cgi?CH=149717 Change 149717 by hselasky@hselasky_laptop001 on 2008/09/13 17:16:08 Integrate some files because the problems I've tried to fix have been fixed. And the fixes are not inter compatible. That means you will get a panic with the P4 USB kernel unless you have this change included, after my last IFC. Affected files ... .. //depot/projects/usb/src/sys/kern/kern_condvar.c#9 integrate .. //depot/projects/usb/src/sys/kern/kern_synch.c#12 integrate .. //depot/projects/usb/src/sys/kern/subr_bus.c#12 integrate .. //depot/projects/usb/src/sys/sys/mutex.h#9 integrate Differences ... ==== //depot/projects/usb/src/sys/kern/kern_condvar.c#9 (text+ko) ==== @@ -124,7 +124,7 @@ sleepq_lock(cvp); cvp->cv_waiters++; - DROP_GIANT(lock); + DROP_GIANT(); sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0); if (lock != &Giant.lock_object) { @@ -183,7 +183,7 @@ sleepq_lock(cvp); cvp->cv_waiters++; - DROP_GIANT(lock); + DROP_GIANT(); sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0); if (class->lc_flags & LC_SLEEPABLE) @@ -241,7 +241,7 @@ sleepq_lock(cvp); cvp->cv_waiters++; - DROP_GIANT(lock); + DROP_GIANT(); sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR | SLEEPQ_INTERRUPTIBLE, 0); @@ -306,7 +306,7 @@ sleepq_lock(cvp); cvp->cv_waiters++; - DROP_GIANT(lock); + DROP_GIANT(); sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0); sleepq_set_timeout(cvp, timo); @@ -374,7 +374,7 @@ sleepq_lock(cvp); cvp->cv_waiters++; - DROP_GIANT(lock); + DROP_GIANT(); sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR | SLEEPQ_INTERRUPTIBLE, 0); ==== //depot/projects/usb/src/sys/kern/kern_synch.c#12 (text+ko) ==== @@ -181,7 +181,7 @@ CTR5(KTR_PROC, "sleep: thread %ld (pid %ld, %s) on %s (%p)", td->td_tid, p->p_pid, td->td_name, wmesg, ident); - DROP_GIANT(lock); + DROP_GIANT(); if (lock != NULL && lock != &Giant.lock_object && !(class->lc_flags & LC_SLEEPABLE)) { WITNESS_SAVE(lock, lock_witness); ==== //depot/projects/usb/src/sys/kern/subr_bus.c#12 (text+ko) ==== ==== //depot/projects/usb/src/sys/sys/mutex.h#9 (text+ko) ==== @@ -366,44 +366,17 @@ * * Note that DROP_GIANT*() needs to be paired with PICKUP_GIANT() * The #ifndef is to allow lint-like tools to redefine DROP_GIANT. - * - * Note that by default DROP_GIANT takes no argument. Optionally you - * can specify an argument which explicitly has the name "lock" and - * type "struct lock_object *". If this "lock" pointer is equal to - * "&Giant", the DROP_GIANT macro will not do the final drop on the - * Giant mutex, but expects the calling code to do so. This feature is - * used by condition variables to allow sleeping on Giant. The - * condition variable code will then do the final drop! */ #ifndef DROP_GIANT -#define DROP_GIANT(arg) DROP_GIANT_SUB_##arg(arg) -#define DROP_GIANT_SUB_lock(arg) DROP_GIANT_SUB(arg) /* "lock" argument */ -#define DROP_GIANT_SUB_(arg) DROP_GIANT_SUB(NULL) /* no argument */ -#define DROP_GIANT_SUB(lock) \ +#define DROP_GIANT() \ do { \ - unsigned int _giantcnt; \ + int _giantcnt = 0; \ WITNESS_SAVE_DECL(Giant); \ \ if (mtx_owned(&Giant)) { \ - unsigned int _giantn; \ - if (((void *)(lock)) == ((void *)&Giant)) { \ - /* special case */ \ - _giantn = Giant.mtx_recurse; \ - } else { \ - /* default case */ \ - _giantn = Giant.mtx_recurse + 1; \ - } \ - if (_giantn != 0) { \ - WITNESS_SAVE(&Giant.lock_object, Giant); \ - _giantcnt = _giantn; \ - do { \ - mtx_unlock(&Giant); \ - } while (--_giantn); \ - } else { \ - _giantcnt = 0; \ - } \ - } else { \ - _giantcnt = 0; \ + WITNESS_SAVE(&Giant.lock_object, Giant); \ + for (_giantcnt = 0; mtx_owned(&Giant); _giantcnt++) \ + mtx_unlock(&Giant); \ } #define PICKUP_GIANT() \