powerd by default tries to use "best" method of battery state discovery. On my machine it tries to use "devd", which is running ok, but my battery uses CMBAT method, so "power on" event is not distinguished from "battery on" event report: kstep@knote:p2/var/log% sudo devd -Dd Parsing /etc/devd.conf setting scsi-controller-regex=(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)[0-9]+ Parsing files in /etc/devd Parsing files in /usr/local/etc/devd ### Here is pulled my power cable out ### Processing event '!system=ACPI subsystem=CMBAT type=\_SB_.PCI0.LPCB.BAT1 notify=0x80' Pushing table setting system=ACPI setting subsystem=CMBAT setting type=\_SB_.PCI0.LPCB.BAT1 setting notify=0x80 Processing notify event Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^ACAD Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^Thermal Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^Suspend Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^Resume Testing system=ACPI against ^IFNET Testing system=ACPI against ^IFNET Testing system=ACPI against ^IFNET Testing system=ACPI against ^IFNET Popping table ### Here I inserted my power cable back ### Processing event '!system=ACPI subsystem=CMBAT type=\_SB_.PCI0.LPCB.BAT1 notify=0x80' Pushing table setting system=ACPI setting subsystem=CMBAT setting type=\_SB_.PCI0.LPCB.BAT1 setting notify=0x80 Processing notify event Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^ACAD Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^Thermal Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ZFS Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^Suspend Testing system=ACPI against ^ACPI Testing subsystem=CMBAT against ^Resume Testing system=ACPI against ^IFNET Testing system=ACPI against ^IFNET Testing system=ACPI against ^IFNET Testing system=ACPI against ^IFNET Popping table Summary: "battery on" event gives message: Processing event '!system=ACPI subsystem=CMBAT type=\_SB_.PCI0.LPCB.BAT1 "power on" event gives message: Processing event '!system=ACPI subsystem=CMBAT type=\_SB_.PCI0.LPCB.BAT1 So there's no way on my notebook to distinguish turning power on or off via devd daemon, as powerd tries and ends up in either state constantly: *** power is on *** kstep@knote:p1~% sudo powerd -b adaptive -n adaptive -a maximum -v powerd: using sysctl for AC line status powerd: using devd for AC line status *** pulled power cable off => adaptive mode *** idle time > 90%, decreasing clock speed from 1600 MHz to 1400 MHz idle time > 90%, decreasing clock speed from 1400 MHz to 1333 MHz idle time > 90%, decreasing clock speed from 1333 MHz to 1166 MHz idle time > 90%, decreasing clock speed from 1166 MHz to 1067 MHz idle time < 65%, increasing clock speed from 1067 MHz to 1333 MHz idle time > 90%, decreasing clock speed from 1333 MHz to 1166 MHz idle time > 90%, decreasing clock speed from 1166 MHz to 1067 MHz idle time < 65%, increasing clock speed from 1067 MHz to 1333 MHz idle time < 65%, increasing clock speed from 1333 MHz to 1600 MHz idle time > 90%, decreasing clock speed from 1600 MHz to 1400 MHz idle time > 90%, decreasing clock speed from 1400 MHz to 1333 MHz idle time > 90%, decreasing clock speed from 1333 MHz to 1166 MHz idle time > 90%, decreasing clock speed from 1166 MHz to 1067 MHz idle time > 90%, decreasing clock speed from 1067 MHz to 933 MHz idle time > 90%, decreasing clock speed from 933 MHz to 800 MHz idle time < 65%, increasing clock speed from 800 MHz to 1067 MHz *** turned back power cable => should be back to "maximum" mode *** idle time > 90%, decreasing clock speed from 1067 MHz to 933 MHz idle time > 90%, decreasing clock speed from 933 MHz to 800 MHz idle time > 90%, decreasing clock speed from 800 MHz to 700 MHz idle time > 90%, decreasing clock speed from 700 MHz to 600 MHz idle time < 65%, increasing clock speed from 600 MHz to 800 MHz idle time > 90%, decreasing clock speed from 800 MHz to 700 MHz idle time > 90%, decreasing clock speed from 700 MHz to 600 MHz To solve the problem, I created a patch to add new parameter to force method of power mode discovery (see "Fix to the problem if known" part. Fix: I created a patch to add "-f <mode>" parameter, so I can run % sudo powerd -b adaptive -n adaptive -a maximum -f sysctl and powerd will use "sysctl" method to distinguish which power mode my notebook is, and this works correctly, switching modes from "maximum" to "adaptive" and back again depending of power source in use. My patch is attached to this form. Patch attached with submission follows: How-To-Repeat: 0. You should have some kind of PC (notebook) with CM battery and devd daemon running. 1. Run "powerd -b adaptive -n adaptive -a maximum -v" while power is on. PC's CPU should run at maximum frequency. 2. Turn off power, so PC begin to use battery. powerd should go to "adaptive" mode, CPU's frequency will begin to "jump" up & down depending of PC load. 3. Turn power on again, so PC begin to use external power source. powerd will not turn back to "maximum" mode, CPU's frequency will be still "jumping"...
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
Man page update should be added, but the patch by itself looks fine.
A commit references this bug: Author: avos Date: Sun Jan 6 02:39:04 UTC 2019 New revision: 342810 URL: https://svnweb.freebsd.org/changeset/base/342810 Log: powerd(8): allow to force a method of battery state query This change allows to determine power source via sysctl or /dev/apm when devd(8) is running (used by default). Based on patch from PR; other changes on top of it: - '-f' (force) -> '-s' (source) parameter renaming; - allow 'apm' -> 'devd' transition when '-s devd' is set (if APM is enabled); - man page update. Checked on amd64 with -s devd / sysctl and apm (an extra build with forced USE_APM define set was done) PR: 125707 Submitted by: Konstantin Stepanov <milezv@yandex.ru> Reviewed by: bcr, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D18742 Changes: head/usr.sbin/powerd/powerd.8 head/usr.sbin/powerd/powerd.c
A commit references this bug: Author: avos Date: Sun Jan 13 02:19:01 UTC 2019 New revision: 342981 URL: https://svnweb.freebsd.org/changeset/base/342981 Log: MFC r342810: powerd(8): allow to force a method of battery state query This change allows to determine power source via sysctl or /dev/apm when devd(8) is running (used by default). Based on patch from PR; other changes on top of it: - '-f' (force) -> '-s' (source) parameter renaming; - allow 'apm' -> 'devd' transition when '-s devd' is set (if APM is enabled); - man page update. PR: 125707 Submitted by: Konstantin Stepanov <milezv@yandex.ru> Reviewed by: bcr, imp Differential Revision: https://reviews.freebsd.org/D18742 Changes: _U stable/12/ stable/12/usr.sbin/powerd/powerd.8 stable/12/usr.sbin/powerd/powerd.c
A commit references this bug: Author: avos Date: Sun Jan 13 02:23:19 UTC 2019 New revision: 342982 URL: https://svnweb.freebsd.org/changeset/base/342982 Log: MFC r342810: powerd(8): allow to force a method of battery state query This change allows to determine power source via sysctl or /dev/apm when devd(8) is running (used by default). Based on patch from PR; other changes on top of it: - '-f' (force) -> '-s' (source) parameter renaming; - allow 'apm' -> 'devd' transition when '-s devd' is set (if APM is enabled); - man page update. PR: 125707 Submitted by: Konstantin Stepanov <milezv@yandex.ru> Reviewed by: bcr, imp Differential Revision: https://reviews.freebsd.org/D18742 Changes: _U stable/11/ stable/11/usr.sbin/powerd/powerd.8 stable/11/usr.sbin/powerd/powerd.c
A commit references this bug: Author: avos Date: Sun Jan 13 02:27:11 UTC 2019 New revision: 342983 URL: https://svnweb.freebsd.org/changeset/base/342983 Log: MFC r342810: powerd(8): allow to force a method of battery state query This change allows to determine power source via sysctl or /dev/apm when devd(8) is running (used by default). Based on patch from PR; other changes on top of it: - '-f' (force) -> '-s' (source) parameter renaming; - allow 'apm' -> 'devd' transition when '-s devd' is set (if APM is enabled); - man page update. PR: 125707 Submitted by: Konstantin Stepanov <milezv@yandex.ru> Reviewed by: bcr, imp Differential Revision: https://reviews.freebsd.org/D18742 Changes: _U stable/10/ stable/10/usr.sbin/powerd/powerd.8 stable/10/usr.sbin/powerd/powerd.c