NetBSD Problem Report #46415

From mlelstv@henery.1st.de  Sat May  5 07:34:02 2012
Return-Path: <mlelstv@henery.1st.de>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 25DD563B915
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  5 May 2012 07:34:02 +0000 (UTC)
Message-Id: <20120505073357.9B76C28168@henery.1st.de>
Date: Sat,  5 May 2012 09:33:57 +0200 (CEST)
From: mlelstv@serpens.de
Reply-To: mlelstv@serpens.de
To: gnats-bugs@gnats.NetBSD.org
Subject: sensor_battery gets unsupported power events
X-Send-Pr-Version: 3.95

>Number:         46415
>Category:       kern
>Synopsis:       sensor_battery gets unsupported power events
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 05 07:35:00 +0000 2012
>Originator:     Michael van Elst
>Release:        NetBSD 6.99.6
>Organization:
-- 
                                Michael van Elst
Internet: mlelstv@serpens.de
                                "A potential Snark may lurk in every tree."
>Environment:


System: NetBSD tazz 6.99.6 NetBSD 6.99.6 (TAZZ) #0: Sat May 5 02:17:23 CEST 2012
 mlelstv@henery:/home/netbsd-current/obj.amd64/home/netbsd-current/src/sys/arch/
amd64/compile/TAZZ amd64
Architecture: x86_64
Machine: amd64
>Description:
When the laptop battery reaches a warning level, an event is passed to
powerd which runs the sensor_battery script, but which fails.

May  5 07:52:54 tazz root: /etc/powerd/scripts/sensor_battery: unsupported event warning-under on device acpibat0

warning-under is not a specified event for the battery sensor.

acpibat0 has two sensors: ACPIBAT_CAPACITY and ACPIBAT_CHARGING_STATE.
When the capacity falls below a warning threshold,
- ACPIBAT_CAPACITY changes state to ENVSYS_SWARNUNDER and
- ACPIBAT_CHARGE_STATE is set to the value ENVSYS_BATTERY_CAPACITY_WARNING.

Events are finally delivered to powerd with sme_deliver_event().
For a capacity event it tries to translate the sensor state
(ENVSYS_S*) into a sysmon event (PENVSYS_EVENT_*). The ENVSYS_SWARNUNDER
state corresponds to PENVSYS_EVENT_WARNUNDER which is delivered
by powerd as "warning-under" to the script.

For some reason the translation table also contains battery sensor
_values_ that never appear as state but that are translated into
battery events (PENVSYS_EVENT_BATT_*). Apparently there was a
mixup between sensor state and value.


>How-To-Repeat:
Use a system with the acpibat driver that generates battery charging
events and watch the sensor_battery script fail.

>Fix:
The sensors do not know about capacity-based limits. If sysmon
wants to differentiate between value-based limits and capacity-based
limits, there needs to be a translation of the sensor state according
to the sensor type.

As an alternative you could just drop the special capacity events and use
the generic events instead. This mainly requires a correction in the
sensor_battery script and the documentation.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.