Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upEnhancement: battery charging thresholds on thinkpads #3851
Comments
andrewdavidwong
added
enhancement
C: kernel
labels
Apr 25, 2018
andrewdavidwong
added this to the Release 4.1 milestone
Apr 25, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rustybird
Apr 25, 2018
ectool from the coreboot project could be an alternative, it talks directly to the embedded controller and doesn't need any kernel patch. Theoretically, this should work for stock BIOS too?
You have to look up the right command line arguments for your notebook model, e.g. for an x230.
rustybird
commented
Apr 25, 2018
|
ectool from the coreboot project could be an alternative, it talks directly to the embedded controller and doesn't need any kernel patch. Theoretically, this should work for stock BIOS too? You have to look up the right command line arguments for your notebook model, e.g. for an x230. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
taradiddles
Apr 25, 2018
I didn't know about ectool - just compiled it, it seems to work. Thanks a lot !
I'll play with it a bit more and I'll write a doc in the Qubes-Community project since it's not really specific to Qubes.
Closing the issue then ...
taradiddles
commented
Apr 25, 2018
|
I didn't know about ectool - just compiled it, it seems to work. Thanks a lot ! I'll play with it a bit more and I'll write a doc in the Qubes-Community project since it's not really specific to Qubes. Closing the issue then ... |
taradiddles
closed this
Apr 25, 2018
andrewdavidwong
added
resolved
and removed
enhancement
labels
Apr 26, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jharveyb
May 25, 2018
@taradiddles Which machine did it work on for you? I have a T460 here & the X230 positions have no effect - could not find documentation for the correct locations in EC RAM. tp_smapi also doesn't support T430's and newer so curious as to your setup.
jharveyb
commented
May 25, 2018
|
@taradiddles Which machine did it work on for you? I have a T460 here & the X230 positions have no effect - could not find documentation for the correct locations in EC RAM. tp_smapi also doesn't support T430's and newer so curious as to your setup. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
taradiddles
May 25, 2018
I have a T450s with 2 batteries: an integrated one and a removable one.
Here's the output of ectool for the 0xb0 - 0xbf addresses
b0: 28 50 28 50 00 00 00 00 00 00 2d 05 00 96 01 00
The first four values are the battery charing thresholds for the 2 batteries:
b0: start charge for bat1 0x28 = 40 (%)b1: stop charge for bat1 0x50 = 80 (%)b2: start charge for bat2b3: stop charge for bat2
No idea if those addresses are the same for a T460 though :(
I too tried to find the EC documentation but it seems that a bit of reverse engineering is needed (the only thing I found was the chipset low-level doc). You'll likely have to dump the EC registers with ectool, set the charging threshold to different values with tlp and the acpi_call module, dump the EC registers again and then compare/diff with the first dump.
[edit: updated comment after hitting "comment" by mistake]
taradiddles
commented
May 25, 2018
•
|
I have a T450s with 2 batteries: an integrated one and a removable one. Here's the output of
The first four values are the battery charing thresholds for the 2 batteries:
No idea if those addresses are the same for a T460 though :( [edit: updated comment after hitting "comment" by mistake] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jharveyb
May 26, 2018
Those same addresses seem to work for me!
I only had b0 & b1 written before, started testing with the internal battery above start threshold and AC attached; no charging, as expected.
After adding an external battery without writing to b2 or b3, it began charging. Writing the same thresholds to b2 & b3 and reintroducing AC didn't cause either battery to charge (though upower and the xfce-power-manager still thought they were).
Discharging the internal battery below its start threshold and reintroducing AC caused it to charge up to the stop threshold - tl;dr it works perfectly, thank you for the help!
jharveyb
commented
May 26, 2018
|
Those same addresses seem to work for me! I only had b0 & b1 written before, started testing with the internal battery above start threshold and AC attached; no charging, as expected. |
taradiddles commentedApr 24, 2018
•
edited
Edited 2 times
-
taradiddles
edited Apr 24, 2018 (most recent)
-
taradiddles
edited Apr 24, 2018
Qubes OS version:
up to 4.0
Enhancement
Rationale: When properly set, battery charging thresholds can significantly extend battery life. Unfortunately Qubes OS doesn't ship the acpi_call kernel module required to use such feature on Thinkpads, which are popular laptops amongst qubes users. People who want to use that functionality have to boot a customized live distro (eg. Fedora on USB with persistent storage with the required kernel module + user space scripts) in order to set the thresholds. That's cumbersome and not secure.
Proposal: include the acpi_call module in dom0's kernel (maybe shipped by default or as a rpm add-on). On other distros TLP is usually used to set thresholds from user-space but it should be easy to extract the threshold functionality from TLP's bash scripts (I could do that if this enhancement is accepted). I don't think including and using the module would increase dom0's attack surface, but I'm not a security expert. For info the acpi_call module is only 332 sloc.
Related hardware: Thinkpads with Sandy Bridge and newer models (X220/T420, X230/T430 et al.)
edit: I posted this idea some time ago on qubes-devel but didn't get a reply except a +1 from another user