From owner-cvs-src@FreeBSD.ORG Sat Feb 14 12:57:33 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2B8C916A4CE; Sat, 14 Feb 2004 12:57:33 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2708D43D1F; Sat, 14 Feb 2004 12:57:33 -0800 (PST) (envelope-from wpaul@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i1EKvXGe017585; Sat, 14 Feb 2004 12:57:33 -0800 (PST) (envelope-from wpaul@repoman.freebsd.org) Received: (from wpaul@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i1EKvW6w017584; Sat, 14 Feb 2004 12:57:32 -0800 (PST) (envelope-from wpaul) Message-Id: <200402142057.i1EKvW6w017584@repoman.freebsd.org> From: Bill Paul Date: Sat, 14 Feb 2004 12:57:32 -0800 (PST) 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 ndis_var.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2004 20:57:33 -0000 wpaul 2004/02/14 12:57:32 PST FreeBSD src repository Modified files: sys/compat/ndis kern_ndis.c ndis_var.h Log: Fix a problem with the way we schedule work on the NDIS worker threads. The Am1771 driver will sometimes do the following: - Some thread-> NdisScheduleWorkItem(some work) - Worker thread -> do some work, KeWaitForSingleObject(some event) - Some other thread -> NdisScheduleWorkItem(some other work) When the second call to NdisScheduleWorkItem() occurs, the NDIS worker thread (in our case ndis taskqueue) is suspended in KeWaitForSingleObject() and waiting for an event to be signaled. This is different from when the worker thread is idle and waiting on NdisScheduleWorkItem() to send it more jobs. However, the ndis_sched() function in kern_ndis.c always calls kthread_resume() when queueing a new job. Normally this would be ok, but here this causes KeWaitForSingleObject() to return prematurely, which is not what we want. To fix this, the NDIS threads created by kern_ndis.c maintain a state variable to indicate whether they are running (scanning the job list and executing jobs) or sleeping (blocked on kthread_suspend() in ndis_runq()), and ndis_sched() will only call kthread_resume() if the thread is in the sleeping state. Note that we can't just check to see if the thread is on the run queue: in both cases, the thread is sleeping, but it's sleeping for different reasons. This stops the Am1771 driver from emitting various "NDIS ERROR" messages and fixes some cases where it crashes. Revision Changes Path 1.39 +19 -2 src/sys/compat/ndis/kern_ndis.c 1.21 +3 -0 src/sys/compat/ndis/ndis_var.h