# Laptop Battery drains extremly fast!



## sk8harddiefast (Feb 10, 2015)

Hi. I know. Passed a lot of time from my last login. Sorry. I didn't forget you!
Here Is my problem.
I have a Lenovo Ideapad p400 touchscreen. Using Linux my battery was keeping at least 3 hours.
Now with FreeBSD almost 30 minutes! I follow this wiki: https://wiki.freebsd.org/TuningPowerConsumption
I made everything of them but still battery drains too fast! Is decreasing ~1% every 2 minutes! Before this was decreasing ~1% every minute!!! All this in idle state!!!
Writing this lines my battery went from 86% to 82%! Is insane!
How can I tweak my power management?


----------



## woodsb02 (Feb 11, 2015)

Just to confirm, have you enabled powerd(8) by adding `powerd_enable="YES"` to /etc/rc.conf?

Further discussion on the use of powerd(8) is here: Thread 172


----------



## sk8harddiefast (Feb 11, 2015)

Yes. Ok. Now My settings.

I use 10.1-RELEASE with default kernel for now.

On /boot/loader.conf


```
debug.cpufreq.lowest=600
hint.p4tcc.0.disabled="1"
hint.acpi_throttle.0.disabled="1"
```

On /etc/rc.conf


```
powerd_enable="YES"
powerd_flags="-a maximum -b adaptive -i 85 -r 60 -p 100"
```

My /etc/sysctl.conf


```
dev.cpu.0.cx_lowest=C5
dev.cpu.1.cx_lowest=C2
dev.cpu.2.cx_lowest=C5
dev.cpu.3.cx_lowest=C5
dev.cpu.4.cx_lowest=C5
dev.cpu.5.cx_lowest=C5
dev.cpu.6.cx_lowest=C5
dev.cpu.7.cx_lowest=C5
```

My battery still drops too fast! Almost 1% per minute! Using it like this in 6 months I will need a new battery!
PS. The only I want is a normal react of my laptop as all the laptops in the world. Full power on AC and on battery but do economy when is open and I don't use it.


----------



## nekoexmachina (Feb 11, 2015)

Hello!
Just a wild guess: this laptop has NVidia video card. Which driver do you use? Which NVidia profile (in settings) do you select?


----------



## sk8harddiefast (Feb 11, 2015)

Hi nekoexmachina! How are you?
Has Intel HD 4000. I am in a new fresh install. I didn't even fetched the ports.
I have no reason to go further if my battery cannot hold at least 2 hours of hard compiling on battery.


----------



## sk8harddiefast (Feb 11, 2015)

Ι used Manjaro Linux on laptop. I went back to FreeBSD because just I love FreeBSD. I want to make it work. On my desktop works perfect everywhere 4.5 years now.
On laptop I am disappointed. Wifi, brightness etc, will work. Now or in the near future. Some things will be hacked to do my job. Is not this the problem.
But power? On a laptop is the biggest problem! Imagine the reality.
Battery 100%

```
cd /usr/src
make buildkernel KERCONF=MYKERNEL
```
make installkernel KERNC.....bzzzzzz Battery 0%. Please connect charger on your laptop to install the kernel!!!

```
Sudo portsnap fecth update
portupgrade -a
```
Battery 0%. Please connect charger on your laptop to install the rest updates!!!

```
ssh ember@192.168.1.18
```
Battery 0%. Please connect charger on your laptop to connect to desktop!!!

Ok. I Finished my system after a month of hard tweaking.
Lets Power on.

Battery 0%.
Battery damaged.
Please change battery on your laptop to boot into FreeBSD!!!

As you understand this make the laptop unable to run FreeBSD.


----------



## adrian@ (Feb 11, 2015)

Please post the 'dmesg' output after boot so we can see what hardware is in the thing. Thanks!


----------



## sk8harddiefast (Feb 11, 2015)

Ok. Here it is

```
Copyright (c) 1992-2014 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
   The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 10.1-RELEASE-p5 #0: Tue Jan 27 08:55:07 UTC 2015
  root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
CPU: Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz (2195.06-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x306a9  Family = 0x6  Model = 0x3a  Stepping = 9
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x7fbae3bf<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  Structured Extended Features=0x281<FSGSBASE,SMEP,ERMS>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
  TSC: P-state invariant, performance statistics
real memory  = 8589934592 (8192 MB)
avail memory = 8120803328 (7744 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <LENOVO CB-01  >
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 SMT threads
cpu0 (BSP): APIC ID:  0
cpu1 (AP): APIC ID:  1
cpu2 (AP): APIC ID:  2
cpu3 (AP): APIC ID:  3
cpu4 (AP): APIC ID:  4
cpu5 (AP): APIC ID:  5
cpu6 (AP): APIC ID:  6
cpu7 (AP): APIC ID:  7
ioapic0 <Version 2.0> irqs 0-23 on motherboard
kbd1 at kbdmux0
random: <Software, Yarrow> initialized
acpi0: <LENOVO CB-01> on motherboard
acpi0: Power Button (fixed)
cpu0: <ACPI CPU> on acpi0
cpu1: <ACPI CPU> on acpi0
cpu2: <ACPI CPU> on acpi0
cpu3: <ACPI CPU> on acpi0
cpu4: <ACPI CPU> on acpi0
cpu5: <ACPI CPU> on acpi0
cpu6: <ACPI CPU> on acpi0
cpu7: <ACPI CPU> on acpi0
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 950
Event timer "HPET" frequency 14318180 Hz quality 550
atrtc0: <AT realtime clock> port 0x70-0x77 irq 8 on acpi0
atrtc0: Warning: Couldn't map I/O.
Event timer "RTC" frequency 32768 Hz quality 0
attimer0: <AT timer> port 0x40-0x43,0x50-0x53 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
acpi_ec0: <Embedded Controller: GPE 0x17> port 0x62,0x66 on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0x3000-0x303f mem 0xd0000000-0xd03fffff,0xc0000000-0xcfffffff irq 16 at device 2.0 on pci0
agp0: <IvyBridge mobile GT2 IG> on vgapci0
agp0: aperture size is 256M, detected 65532k stolen memory
vgapci0: Boot video device
xhci0: <Intel Panther Point USB 3.0 controller> mem 0xd0600000-0xd060ffff at device 20.0 on pci0
usbus0: waiting for BIOS to give up control
xhci0: 32 byte context size.
xhci0: Port routing mask set to 0xffffffff
usbus0 on xhci0
pci0: <simple comms> at device 22.0 (no driver attached)
ehci0: <Intel Panther Point USB 2.0 controller> mem 0xd0619000-0xd06193ff irq 16 at device 26.0 on pci0
usbus1: waiting for BIOS to give up control
usbus1: timed out waiting for BIOS
usbus1: EHCI version 1.0
usbus1 on ehci0
hdac0: <Intel Panther Point HDA Controller> mem 0xd0610000-0xd0613fff irq 22 at device 27.0 on pci0
pcib1: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0
pci1: <ACPI PCI bus> on pcib1
re0: <RealTek 810xE PCIe 10/100baseTX> port 0x2000-0x20ff mem 0xd0404000-0xd0404fff,0xd0400000-0xd0403fff irq 16 at device 0.0 on pci1
re0: Using 1 MSI-X message
re0: ASPM disabled
re0: Chip rev. 0x40800000
re0: MAC rev. 0x00400000
miibus0: <MII bus> on re0
rlphy0: <RTL8201E 10/100 media interface> PHY 1 on miibus0
rlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto, auto-flow
re0: Ethernet address: 20:89:84:36:3b:36
pcib2: <ACPI PCI-PCI bridge> irq 16 at device 28.1 on pci0
pci2: <ACPI PCI bus> on pcib2
iwn0: <Intel Centrino Wireless-N 2230> mem 0xd0500000-0xd0501fff irq 17 at device 0.0 on pci2
iwn0: adapter type 12 not supported
iwn0: could not attach device, error 45
device_attach: iwn0 attach returned 45
ehci1: <Intel Panther Point USB 2.0 controller> mem 0xd0618000-0xd06183ff irq 23 at device 29.0 on pci0
usbus2: waiting for BIOS to give up control
usbus2: timed out waiting for BIOS
usbus2: EHCI version 1.0
usbus2 on ehci1
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
ahci0: <Intel Panther Point AHCI SATA controller> port 0x3088-0x308f,0x3094-0x3097,0x3080-0x3087,0x3090-0x3093,0x3060-0x307f mem 0xd0617000-0xd06177ff irq 19 at device 31.2 on pci0
ahci0: AHCI v1.30 with 6 6Gbps ports, Port Multiplier not supported
ahcich1: <AHCI channel> at channel 1 on ahci0
ahcich2: <AHCI channel> at channel 2 on ahci0
ahciem0: <AHCI enclosure management bridge> on ahci0
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_tz0: <Thermal Zone> on acpi0
acpi_button0: <Power Button> on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Generic PS/2 mouse, device ID 0
battery0: <ACPI Control Method Battery> on acpi0
acpi_acad0: <AC Adapter> on acpi0
orm0: <ISA Option ROM> at iomem 0xc0000-0xcefff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
ppc0: cannot reserve I/O port range
est0: <Enhanced SpeedStep Frequency Control> on cpu0
est1: <Enhanced SpeedStep Frequency Control> on cpu1
est2: <Enhanced SpeedStep Frequency Control> on cpu2
est3: <Enhanced SpeedStep Frequency Control> on cpu3
est4: <Enhanced SpeedStep Frequency Control> on cpu4
est5: <Enhanced SpeedStep Frequency Control> on cpu5
est6: <Enhanced SpeedStep Frequency Control> on cpu6
est7: <Enhanced SpeedStep Frequency Control> on cpu7
random: unblocking device.
usbus0: 5.0Gbps Super Speed USB v3.0
Timecounters tick every 1.000 msec
hdacc0: <Realtek ALC269 HDA CODEC> at cad 0 on hdac0
hdaa0: <Realtek ALC269 Audio Function Group> at nid 1 on hdacc0
pcm0: <Realtek ALC269 (Analog 2.0+HP/2.0)> at nid 20,21 and 24 on hdaa0
pcm1: <Realtek ALC269 (Internal Analog Mic)> at nid 18 on hdaa0
hdacc1: <Intel Panther Point HDA CODEC> at cad 3 on hdac0
hdaa1: <Intel Panther Point Audio Function Group> at nid 1 on hdacc1
pcm2: <Intel Panther Point (HDMI/DP 8ch)> at nid 5 on hdaa1
usbus1: 480Mbps High Speed USB v2.0
usbus2: 480Mbps High Speed USB v2.0
ugen1.1: <Intel> at usbus1
uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen0.1: <0x8086> at usbus0
uhub1: <0x8086 XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
ugen2.1: <Intel> at usbus2
uhub2: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus2
ada0 at ahcich1 bus 0 scbus0 target 0 lun 0
ada0: <ADATA SP900 5.6.0> ATA-8 SATA 3.x device
ada0: Serial Number 7E3620002080
ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
ada0: Command Queueing enabled
ada0: 122104MB (250069680 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad4
ses0 at ahciem0 bus 0 scbus2 target 0 lun 0
ses0: <AHCI SGPIO Enclosure 1.00 0001> SEMB S-E-S 2.00 device
ses0: SEMB SES Device
cd0 at ahcich2 bus 0 scbus1 target 0 lun 0
cd0: <HL-DT-ST DVDRAM GU70N DE01> Removable CD-ROM SCSI-0 device
cd0: Serial Number M45CATB0842
cd0: 150.000MB/s transfers (SATA 1.x, UDMA6, ATAPI 12bytes, PIO 8192bytes)
cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed
SMP: AP CPU #1 Launched!
SMP: AP CPU #6 Launched!
SMP: AP CPU #4 Launched!
SMP: AP CPU #2 Launched!
SMP: AP CPU #7 Launched!
SMP: AP CPU #3 Launched!
SMP: AP CPU #5 Launched!
Timecounter "TSC-low" frequency 1097529900 Hz quality 1000
Root mount waiting for: usbus2 usbus1 usbus0
uhub1: 8 ports with 8 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub0: 2 ports with 2 removable, self powered
Root mount waiting for: usbus2 usbus1 usbus0
ugen1.2: <vendor 0x8087> at usbus1
uhub3: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2> on usbus1
ugen2.2: <vendor 0x8087> at usbus2
uhub4: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2> on usbus2
Root mount waiting for: usbus2 usbus1 usbus0
usbd_setup_device_desc: getting device descriptor at addr 1 failed, USB_ERR_TIMEOUT
uhub4: 6 ports with 6 removable, self powered
uhub3: 6 ports with 6 removable, self powered
ugen1.3: <vendor 0x8087> at usbus1
usb_alloc_device: Failure selecting configuration index 0:USB_ERR_IOERROR, port 2, addr 1 (ignored)
ugen0.2: <vendor 0x06cb> at usbus0
Root mount waiting for: usbus1 usbus0
ugen1.4: <Generic> at usbus1
ugen0.3: <Vimicro Corp.> at usbus0
Trying to mount root from ufs:/dev/gpt/ssdrootfs [rw]...
ubt0: <vendor 0x8087 product 0x07da, class 224/1, rev 2.00/78.69, addr 3> on usbus1
WARNING: attempt to domain_add(bluetooth) after domainfinalize()
WARNING: attempt to domain_add(netgraph) after domainfinalize()
```
Has an i7 4 Cores / 4 threads, 8GB ram, Intel Centrino Wifi, realtek Lan, Intel hd 4000 Graphics card and an Adata SSD.

This is my CPU: http://ark.intel.com/products/71670/Intel-Core-i7-3632QM-Processor-6M-Cache-up-to-3_20-GHz-BGA


----------



## adrian@ (Feb 11, 2015)

Right, ivy bridge.

So, do this:
`# pkg install intel-pcm`
`# kldload cpuctl`
`# pcm.x 1`

Run it for a few seconds, hit ctrl-C and paste the results here.

It's likely that the CPU isn't going fully into deep sleep states and your battery is being chewed.

Then put this in /boot/loader.conf, reboot, and try again:

```
drm.i915.enable_rc6=7
```


----------



## sk8harddiefast (Feb 11, 2015)

So to be late to answer. I went to get my girlfriend from the University.
This are the results:
http://pastebin.com/GUJQqtX6
I upload them to pastebin because forum cannot upload a big text
Also I add this line to /boot/loader.conf

```
drm.i915.enable_rc6=7
```


----------



## sk8harddiefast (Feb 13, 2015)

Here are the right configurations for Power Management.

1) According the developers we shouldn't have -i (idle%) higher than -r (run%).  The defaults are
-i 50 -r 75.

2) C-states:

In /etc/sysctl.conf, this is wrong:

```
dev.cpu.0.cx_lowest=C5
dev.cpu.1.cx_lowest=C2
dev.cpu.2.cx_lowest=C5
dev.cpu.3.cx_lowest=C5
dev.cpu.4.cx_lowest=C5
dev.cpu.5.cx_lowest=C5
dev.cpu.6.cx_lowest=C5
dev.cpu.7.cx_lowest=C5
```
Apart from the oddity of C2 on cpu1, setting these is NOT the way to do this, you have to set hw.acpi.cpu.cx_lowest instead, then cpufreq(4) uses that to set the individual cx_lowest per CPU (and all to the same state) which is usually and best accomplished by setting the below in rc.conf, as stated in https://wiki.freebsd.org/TuningPowerConsumption:

```
performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"
```


----------

