tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

problems with sysmon power



I've just tried to find out why my laptop just crashes if
the battery drains out instead of shutting down as intended.
(The shutdown should happen whether powerd runs or not
because there are both a kernel and a userland implementation.)

So to trigger this without ruining my battery I've modified the
sme_battery_critical() function in sysmon_envsys_events.c to
just return "true", controlled by a global variable.
With that variable set, the box shuts down. But it does so
even if an AC adapter is connected. So the sme_acadapter_check()
doesn't do it. That's a bug.

Not I've added a printf to tell the actual battery status
value read in sme_battery_critical(). This gives a "0".
But the enum this value is checked against starts with
"ENVSYS_BATTERY_CAPACITY_NORMAL = 1". So there is another bug.

It is also extremely confusing that the actual charge state
is called "capacity" throughout envsys, and that the bit
telling whether a battery is being charged is called "charge".
So we have code in eg acpi_bat.c which reads
        sc->sc_sensor[ACPIBAT_CHARGE_STATE].value_cur =
            ENVSYS_BATTERY_CAPACITY_NORMAL;
Perverted, isn't it?
I don't know where this originates from, byt perhaps it is
not too late to fix this before the next release.

And if I want to define my own upper or lower limits
where sysmon signals certain conditions (as a battery's
"critical-capacity" which should be "critical-charge"),
I need to count entries in proplist XML output,
see the envsys.conf(5) manpage for details.
This is not something a user should be forced to do.

So my rough impression is that this code needs a lot
of work before NetBSD-5.

best regards
Matthias




-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index