cvs commit: src/sys/compat/ndis kern_ndis.c ndis_var.h
wpaul at FreeBSD.org
Sat Feb 14 12:57:33 PST 2004
wpaul 2004/02/14 12:57:32 PST
FreeBSD src repository
sys/compat/ndis kern_ndis.c ndis_var.h
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
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
More information about the cvs-src