From owner-cvs-all@FreeBSD.ORG Fri Jan 14 22:39:44 2005 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7CD7316A4CE; Fri, 14 Jan 2005 22:39:44 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 46D0B43D31; Fri, 14 Jan 2005 22:39:44 +0000 (GMT) (envelope-from wpaul@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j0EMdirx013685; Fri, 14 Jan 2005 22:39:44 GMT (envelope-from wpaul@repoman.freebsd.org) Received: (from wpaul@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j0EMdidD013684; Fri, 14 Jan 2005 22:39:44 GMT (envelope-from wpaul) Message-Id: <200501142239.j0EMdidD013684@repoman.freebsd.org> From: Bill Paul Date: Fri, 14 Jan 2005 22:39:44 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/compat/ndis kern_ndis.c ntoskrnl_var.h subr_ndis.c subr_ntoskrnl.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2005 22:39:44 -0000 wpaul 2005-01-14 22:39:44 UTC FreeBSD src repository Modified files: sys/compat/ndis kern_ndis.c ntoskrnl_var.h subr_ndis.c subr_ntoskrnl.c Log: Fix a problem reported by Pierre Beyssac. Sometinmes when ndis_get_info() calls MiniportQueryInformation(), it will return NDIS_STATUS_PENDING. When this happens, ndis_get_info() will sleep waiting for a completion event. If two threads call ndis_get_info() and both end up having to sleep, they will both end up waiting on the same wait channel, which can cause a panic in sleepq_add() if INVARIANTS are turned on. Fix this by having ndis_get_info() use a common mutex rather than using the process mutex with PROC_LOCK(). Also do the same for ndis_set_info(). Note that Pierre's original patch also made ndis_thsuspend() use the new mutex, but ndis_thsuspend() shouldn't need this since it will make each thread that calls it sleep on a unique wait channel. Also, it occured to me that we probably don't want to enter MiniportQueryInformation() or MiniportSetInformation() from more than one thread at any given time, so now we acquire a Windows spinlock before calling either of them. The Microsoft documentation says that MiniportQueryInformation() and MiniportSetInformation() are called at DISPATCH_LEVEL, and previously we would call KeRaiseIrql() to set the IRQL to DISPATCH_LEVEL before entering either routine, but this only guarantees mutual exclusion on uniprocessor machines. To make it SMP safe, we need to use a real spinlock. For now, I'm abusing the spinlock embedded in the NDIS_MINIPORT_BLOCK structure for this purpose. (This may need to be applied to some of the other routines in kern_ndis.c at a later date.) Export ntoskrnl_init_lock() (KeInitializeSpinlock()) from subr_ntoskrnl.c since we need to use in in kern_ndis.c, and since it's technically part of the Windows kernel DDK API along with the other spinlock routines. Use it in subr_ndis.c too rather than frobbing the spinlock directly. Revision Changes Path 1.62 +19 -14 src/sys/compat/ndis/kern_ndis.c 1.19 +1 -0 src/sys/compat/ndis/ntoskrnl_var.h 1.70 +2 -2 src/sys/compat/ndis/subr_ndis.c 1.46 +1 -2 src/sys/compat/ndis/subr_ntoskrnl.c