Subject: callout(9), IPL_NONE and IPL_SOFTCLOCK
To: None <tech-kern@netbsd.org>
From: Juan RP <juan@xtrarom.org>
List: tech-kern
Date: 05/12/2007 06:29:39
Hey, while I was developping envsys2 I discovered an interesting
things (probably I'm missing something).

I have code that runs a function with callout(9) and uses
the sme_gtredata callback to fetch current values from device,
the device I'm using is aiboost(4). It's a wrapper that uses
ACPI as backend to fetch sensor values/descriptions, etc.

Well, here starts the good thing. I'm protecting the operations
in the callout function with a mutex (MUTEX_DRIVER, IPL_NONE)
and after booting a kernel with LOCKDEBUG/DIAGNOSTIC it paniced
with an assertion from kern_mutex.c "curthread != 0".

The backtrace showed the callout tick function and softclock(),
amongst others. So I changed the mutex that protects the code
in the callout function to IPL_SOFTCLOCK and it still paniced
but with a different backtrace.

This time the backtrace was different: AcpiOsWaitSemaphore,
AcpiOsAcquireMutex, etc.

I looked at the OsdSynch.c file and I saw that it uses an adaptive
mutex with IPL_NONE, so I changed it to IPL_SOFTCLOCK... and voila,
there are no panics nor more assertions.

Andrew (or someone else), do you know what is it? I mean, why do
I have to change all mutexes inside of the callout to IPL_SOFTCLOCK?

-- 
http://plog.xtrarom.org/
Juan RP's blog - NetBSD/pkgsrc news in Spanish