Subject: apm0 at acpi0 fails with LOCKDEBUG
To: None <current-users@netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: current-users
Date: 03/13/2007 22:39:47
Hi,
   with the following system:

NetBSD 4.99.12 (GENERIC_LAPTOP) #13: Tue Mar 13 19:48:01 GMT 2007

+DIAGNOSTIC+LOCKDEBUG

I see an unitialized lock when apm0 attaches to acpi0..

[..]
acpitz0 at acpi0: ACPI Thermal Zone
acpitz0: unable to get polling interval; using default of 30.0s
acpitz0: active cooling level 0: 96.0C
acpitz0: active cooling level 1: 96.0C
acpitz0: critical 97.0C passive 68.0C
apm0 at acpi0: Power Management spec V1.2

simple_lock: uninitialized lock
lock: 0xc0821000, currently at: /home/plunky/src/sys/kern/kern_lock.c:584
uvm_fault(0xc08359c0, 0, 1) -> 0xe

I did a bit of googling and found the same problem reported by Nicholas
Joly some time ago:
    http://mail-index.netbsd.org/current-users/2006/08/11/0009.html

the fix appears to be quite straightforward, just use the open call which
initializes the lock - the close does nothing  (I put it in for form), and
no arguments are used anyway (could pass FREAD as flags?)

--- sys/dev/acpi/acpi_apm.c.orig	2007-01-27 23:37:46.000000000 +0000
+++ sys/dev/acpi/acpi_apm.c	2007-03-13 21:37:26.000000000 +0000
@@ -226,6 +226,8 @@
 /*ARGSUSED*/
 acpiapm_disconnect(void *opaque)
 {
+
+	sysmonclose_envsys(0, 0, 0, NULL);
 	return;
 }

@@ -233,6 +235,8 @@
 /*ARGSUSED*/
 acpiapm_enable(void *opaque, int onoff)
 {
+
+	sysmonopen_envsys(0, 0, 0, NULL);
 	return;
 }


is ok to commit that?

iain