Re: ampd(8) -Z option

2019-08-11 Thread Walter Alejandro Iglesias
Jan Stary wrote:
> Eventualy it does suspend, but much later than
> when the battery life goes below the specified value.

Doing more testing I noticed the same.  For example, with these options:

 # apmd -d -t 60 -z 

It took *5* minutes to suspend the machine.  In my first tests I passed
bigger values to -t (120 seconds) what made me think -Z was ignored.

Not a dev here but I try to learn when I have time.  I took a look to
/src/usr.sbin/apmd/ampd.c, I see there is a loop (line 507) where the
limit passed to -t is checked, then if AC is not connected the
autoaction is executed.  Time seems to be handled with a system call
(kevent), that's beyond my basic C knowledge. :-)  Perhaps some other
checking in this loop add delays, just guessing.


Walter



Re: ampd(8) -Z option

2019-08-09 Thread Jan Stary
On Aug 04 17:33:41, w...@roquesor.com wrote:
> Now I gave a try to the apmd(8) -Z option but, so far, I couldn't make
> it work in a reliable way.  I added to rc.conf.local:
> 
>  apmd_flags="-A -Z 20"
> 
> But, after doing some tests, sometimes it works, other it seems like
> it's totally ignored.

Similar here (Dell Latitude E5570, dmesg below).
Eventualy it does suspend, but much later than
when the battery life goes below the specified value.

dell# pgrep -fl apmd
13368 /usr/sbin/apmd -A -z 93 -t 60
77336 man -m /home/hans/man apmd

dell# apm
Battery state: high, 90% remaining, 217 minutes life estimate
A/C adapter state: not connected
Performance adjustment mode: auto (800 MHz)

This should suspend already, right? Eventualy,

Aug  9 18:05:22 dell apmd: estimated battery life 89%, autoaction limit set to 
93% .
Aug  9 18:05:22 dell apmd: system suspending

> Curious because power management seems to work fine in my T410.  It
> sleeps, resumes and hibernates perfectly.

Yes, manual standby/suspend/hibernate and resume
works perfectly on this machine too.

On Aug 04 11:43:19, ed...@pettijohn-web.com wrote:
> Is your laptop plugged in during the tests? 

No.

On Aug 04 14:23:46, ed...@pettijohn-web.com wrote:
> Probably has a lot to do with the quality of the battery.

This is a brand new original Dell battery.
acpibat0 at acpi0: BAT0 model "DELL 7V69Y53" serial 2106 type LiP oem "SMP"

Jan


OpenBSD 6.5-current (GENERIC.MP) #0: Thu Aug  8 12:10:50 CEST 2019
h...@dell.stare.cz:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 16810340352 (16031MB)
avail mem = 16290713600 (15536MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xeac10 (107 entries)
bios0: vendor Dell Inc. version "1.5.0" date 04/22/2016
bios0: Dell Inc. Latitude E5570
acpi0 at bios0: ACPI 5.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT FIDT MCFG HPET SSDT LPIT SSDT SSDT SSDT DBGP 
DBG2 SSDT UEFI SSDT SSDT SLIC ASF!
acpi0: wakeup devices PEG0(S4) PEGP(S4) PEG1(S4) PEGP(S4) PEG2(S4) PEGP(S4) 
RP09(S4) PXSX(S4) RP10(S4) PXSX(S4) RP11(S4) PXSX(S4) RP12(S4) PXSX(S4) 
RP13(S4) PXSX(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz, 2295.29 MHz, 06-5e-03
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 24MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz, 2294.66 MHz, 06-5e-03
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz, 2294.66 MHz, 06-5e-03
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz, 2294.66 MHz, 06-5e-03
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSG

Re: ampd(8) -Z option

2019-08-04 Thread Edgar Pettijohn


On Aug 4, 2019 12:10 PM, Walter Alejandro Iglesias  wrote:
>
> Hi Edgar,
>
> On Sun, Aug 04, 2019 at 11:43:19AM -0500, Edgar Pettijohn wrote:
> > On Sun, Aug 04, 2019 at 05:33:41PM +0200, Walter Alejandro Iglesias wrote:
> > > Hello,
> > > 
> > > Since years I've been using a shell script of mine to shutdown my laptop
> > > when battery is critical.  Convenient because I made it portable among
> > > unix-like systems.  In the case of OpenBSD the script asks battery and
> > > AC status to apm(4).
> > > 
> > > Now I gave a try to the apmd(8) -Z option but, so far, I couldn't make
> > > it work in a reliable way.  I added to rc.conf.local:
> > > 
> > >  apmd_flags="-A -Z 20"
> > > 
> > > But, after doing some tests, sometimes it works, other it seems like
> > > it's totally ignored.
> > 
> > Is your laptop plugged in during the tests? 
>
> First of all, thank you for answering. :-)
>
> The cable is plugged to a multiple socket that has and interrupter.  I
> cut the energy from there while doing the tests, mainly because I'm
> interested it work in that way.
>
> I'm not an electricity expert but I think I understand why you're asking
> that question.  If the AC cable is connected to the laptop, even when in
> the other end it's not connected to the source, since the converter
> holds some residual voltage could make the laptop think it's still
> connected to the main source, right?  But when the source is cut (in the
> way I explained above,) apm(4) correctly says the AC power is
> "disconnected," that's why I assumed apmd(8) should not be tricked by
> the converter.
>

Sounds good. I also have to add -t 60 for it to work on my laptop. Probably has 
a lot to do with the quality of the battery.

Edgar
> > 
> > Edgar
> > 
> > > 
> > > Curious because power management seems to work fine in my T410.  It
> > > sleeps, resumes and hibernates perfectly.  /var/log/messages and 'apmd
> > > -d' don't show significant errors.  Do I need to set something else, add
> > > some -t value to ampd command or some script to /etc/apm?
> > > 
> > > 
> > > Walter
> > > 
>



Re: ampd(8) -Z option

2019-08-04 Thread Walter Alejandro Iglesias
Hi Edgar,

On Sun, Aug 04, 2019 at 11:43:19AM -0500, Edgar Pettijohn wrote:
> On Sun, Aug 04, 2019 at 05:33:41PM +0200, Walter Alejandro Iglesias wrote:
> > Hello,
> > 
> > Since years I've been using a shell script of mine to shutdown my laptop
> > when battery is critical.  Convenient because I made it portable among
> > unix-like systems.  In the case of OpenBSD the script asks battery and
> > AC status to apm(4).
> > 
> > Now I gave a try to the apmd(8) -Z option but, so far, I couldn't make
> > it work in a reliable way.  I added to rc.conf.local:
> > 
> >  apmd_flags="-A -Z 20"
> > 
> > But, after doing some tests, sometimes it works, other it seems like
> > it's totally ignored.
> 
> Is your laptop plugged in during the tests? 

First of all, thank you for answering. :-)

The cable is plugged to a multiple socket that has and interrupter.  I
cut the energy from there while doing the tests, mainly because I'm
interested it work in that way.

I'm not an electricity expert but I think I understand why you're asking
that question.  If the AC cable is connected to the laptop, even when in
the other end it's not connected to the source, since the converter
holds some residual voltage could make the laptop think it's still
connected to the main source, right?  But when the source is cut (in the
way I explained above,) apm(4) correctly says the AC power is
"disconnected," that's why I assumed apmd(8) should not be tricked by
the converter.

> 
> Edgar
> 
> > 
> > Curious because power management seems to work fine in my T410.  It
> > sleeps, resumes and hibernates perfectly.  /var/log/messages and 'apmd
> > -d' don't show significant errors.  Do I need to set something else, add
> > some -t value to ampd command or some script to /etc/apm?
> > 
> > 
> > Walter
> > 



Re: ampd(8) -Z option

2019-08-04 Thread Bryan Wright
   I’ve also wrestled with this same issue and am eager to hear the responses.
   I did have much better results after adding -t 60  to my flags.  I suspect 
my not exactly new x220’s battery was going from my given percentage to zero in 
less time than the default polling time of 10mins.   I’m not sure mine is 
completely sorted out. I do find a dead laptop from time to time.
~Bryan



Re: ampd(8) -Z option

2019-08-04 Thread Edgar Pettijohn
On Sun, Aug 04, 2019 at 05:33:41PM +0200, Walter Alejandro Iglesias wrote:
> Hello,
> 
> Since years I've been using a shell script of mine to shutdown my laptop
> when battery is critical.  Convenient because I made it portable among
> unix-like systems.  In the case of OpenBSD the script asks battery and
> AC status to apm(4).
> 
> Now I gave a try to the apmd(8) -Z option but, so far, I couldn't make
> it work in a reliable way.  I added to rc.conf.local:
> 
>  apmd_flags="-A -Z 20"
> 
> But, after doing some tests, sometimes it works, other it seems like
> it's totally ignored.

Is your laptop plugged in during the tests? 

Edgar

> 
> Curious because power management seems to work fine in my T410.  It
> sleeps, resumes and hibernates perfectly.  /var/log/messages and 'apmd
> -d' don't show significant errors.  Do I need to set something else, add
> some -t value to ampd command or some script to /etc/apm?
> 
> 
>   Walter
> 



ampd(8) -Z option

2019-08-04 Thread Walter Alejandro Iglesias
Hello,

Since years I've been using a shell script of mine to shutdown my laptop
when battery is critical.  Convenient because I made it portable among
unix-like systems.  In the case of OpenBSD the script asks battery and
AC status to apm(4).

Now I gave a try to the apmd(8) -Z option but, so far, I couldn't make
it work in a reliable way.  I added to rc.conf.local:

 apmd_flags="-A -Z 20"

But, after doing some tests, sometimes it works, other it seems like
it's totally ignored.

Curious because power management seems to work fine in my T410.  It
sleeps, resumes and hibernates perfectly.  /var/log/messages and 'apmd
-d' don't show significant errors.  Do I need to set something else, add
some -t value to ampd command or some script to /etc/apm?


Walter